Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-52754

Hooks bug: When a Struts action has been overridden, the overridden action can be invoked by incorrect Struts action paths


    • Type: Bug
    • Status: Closed
    • Resolution: Duplicate
    • Affects Version/s: 6.2.1 CE GA2
    • Fix Version/s: None
    • Component/s: Legacy, Legacy > API
    • Labels:
    • Fix Priority:


      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


          Issue Links



              support-lep@liferay.com SE Support
              jesse.rao Jesse Rao
              Participants of an Issue:
              Recent user:
              Marta Elicegui
              0 Vote for this issue
              0 Start watching this issue


                Days since last comment:
                5 years, 35 weeks, 2 days ago


                  Version Package