Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken logic in CRM_Utils_System_DrupalBase::formatResourceUrl() #13400

Merged
merged 1 commit into from
Mar 3, 2019

Conversation

mfb
Copy link
Contributor

@mfb mfb commented Jan 4, 2019

CRM_Utils_System_DrupalBase::formatResourceUrl() formats CSS or JS URLs to be passed to the CMS for aggregation.

It works fine for the most part, but has some broken logic when an absolute URL containing the $base_url is passed in (for example, from shoreditch extension).

Before

The URL path is checked via file_exists() to see if it's an internal file. Query string is stripped off later in the function. However, this check will always fail unless the query string is stripped off first. In addition, the path being checked is missing a slash between DRUPAL_ROOT and the path, so again the check will always fail. This results in the resource not being aggregated even though it could.

After

Strip off the query string and add the missing slash. If file is found, we set the $url reference. Resource aggregation works.

Comments

You might be wondering why there is a query string passed, which is then stripped off. This is because CRM_Core_Resources::addCacheCode() adds a cache-busting query string. It gets stripped off in favor of doing CSS/JS aggregation.

@civibot
Copy link

civibot bot commented Jan 4, 2019

(Standard links)

@civibot civibot bot added the master label Jan 4, 2019
@seamuslee001
Copy link
Contributor

Jenkins re test this please

Copy link
Contributor

@MegaphoneJon MegaphoneJon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replicated this bug, then ran this code and reviewed the code to ensure it does what's expected. Everything looks good.

In theory this could have a test, but it relies on the DRUPAL_ROOT constant. I'm not sure if it's kosher to assume the test suite is running on Drupal.

@seamuslee001
Copy link
Contributor

I'm going to merge this based on Jon's testing

@seamuslee001 seamuslee001 merged commit 128dcbe into civicrm:master Mar 3, 2019
@eileenmcnaughton
Copy link
Contributor

@mfb @MegaphoneJon we are seeing reports of " "Incorrect Resource URLs" after upgrading to 5.13.5 (we skipped 5.13.4)."

I think it's to do with changing the presence or otherwise of the trailing slash & then the comparison not picking that up

@eileenmcnaughton
Copy link
Contributor

Changed my mind - git blame lies elsewhere - it's the guzzle timeout being too aggressive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants