Skip to content
  • totten's avatar
    joomla#26 - Fix path derivation when CMS is rooted in a subdir · d0cda11f
    totten authored
    Overview
    --------
    
    CiviCRM is deployed inside a CMS. The CMS is usually deployed at the HTTP root (`http://example.org`),
    but it is sometimes deployed in a subdirectory (`http://example.org/my-cms`).
    
    Some asset URLs are computed using the variables `[civicrm.bower]`, `[civicrm.packages]`, and `[civicrm.vendor]`, which
    are derived from the value of `[civicrm.root]`.  However, if the site is deployed in a subdirectory, and if using v5.23,
    then the computation of `[civicrm.bower]` (etc) can misbehave.
    
    Before
    ------
    
    When the URL for `[civicrm.bower]` (or similar) is derived, it goes through multiple filters - first, from absolute to
    relative, and then later from relative back to absolute.  In the process, the base is inadvertently changed.
    
    After
    -----
    
    When the URL is derived, it is computed in absolute format - and simply kept that way.
    
    Comments
    --------
    
    Regarding test coverage, there are two relevant unit-tests. This PR only updates one.
    
    * `E2E\Core\PathUrlTest`: This is a more concrete smoke test which demonstrates functional problems with variables like
      `[civicrm.bower]`.  It should already catch problems like joomla#26...  but only if you run the E2E suite on a system
      where the CMS was deployed to a subdirectory.  `civibuild` doesn't currently include such a build-type.
    * `Civi\Core\PathsTest`: This is a more abstract, headless test to examine edge-cases in `Civi\Core\Paths`. It does not
      specifically check for `[civicrm.bower]` or similar variables (b/c the URL routing is ill-defined in a headless context).
      However, I've updated it to compare/contrast the working and non-working ways to derive variables.
    d0cda11f