Hooks bug: When a Struts action has been overridden, the overridden action can be invoked by incorrect Struts action paths.
Reported by JL Gonzalez on this documentation page: https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/lp-6-1-dgen06-overriding-and-adding-struts-actions-0
If you override a Struts path that 'contains' in its string the path of another one, your overridden action will be called not only when your action is called but also when any other Struts path that 'contains' it is called. Consider the following example:
Suppose we create a hook to override the following Struts path: /document_library/edit_file_entry
To do so, we create a hook and add this to the lifery-hook.xml:
When we execute this, it works perfectly. But try to edit a File Entry Type or try to add a comment to a file.
Those actions have the following Struts paths:
Notice that both 'contain' the string of our modified Struts path:
All of these action paths invoke ModifiedEditFileEntryAction. This is not the intended behavior. Only '/document_library/edit_file_entry' should do invoke ModifiedEditFileEntryAction.
If you call originalStrutsPortletAction.processAction inside the Action it will work properly, redirecting to the right '/document_library/edit_file_entry_discussion' or 'document_library/edit_file_entry_type' or 'document_library/edit_file_entry'.
The only way to avoid this is checking if your Struts path is not 'contained' in any other Struts path of the struts-config.xml and if it is, create a <struts-action> for each one in your liferay-hook, redirecting to a dummy XXXXXAction that will only override the processAction, render and serveResource with a call to the original ones with originalStrutsPortletAction.processAction,originalStrutsPortletAction.render or originalStrutsPortletAction.serveResource