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 false negatives in checkResourceUrl() #12460

Merged
merged 1 commit into from
Jul 16, 2018

Conversation

freephile
Copy link
Contributor

@freephile freephile commented Jul 12, 2018

Overview

Without this proposed fix, I'm receiving false errors about the CiviCRM Resource URL not being set correctly.

Before

I can access http://coastaltrails.org/wp-content/plugins/civicrm/civicrm/packages/jquery/css/images/arrow.png But WITHOUT the fix, I get an error

The Resource URL is not set correctly. Please set the CiviCRM Resource URL.

I have CiviCRM Resource URL set to [civicrm.root]/

My URL Variables are calculated as:

[cms.root]	http://coastaltrails.org/
[civicrm.root]	http://coastaltrails.org/wp-content/plugins/civicrm/civicrm/
[civicrm.files]	http://coastaltrails.org/wp-content/uploads/civicrm/
These variables are computed automatically using civicrm.settings.php and its options, such as CIVICRM_TEMPLATE_COMPILEDIR.

After

No Error on CiviCRM System Status page. Footer 'system status' is not Red

Technical Details

The stripos() function will return '0' if the needle string is the first thing found in the haystack. Thus, you must use equivalence rather than a true/false test where "position zero" evaluates to false.

Comments

Tested on Civi 5.3.0 on WordPress 4.9.7

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@civibot
Copy link

civibot bot commented Jul 12, 2018

(Standard links)

@freephile freephile changed the title Fix false positives in checkResourceUrl() Fix false negatives in checkResourceUrl() Jul 12, 2018
@MegaphoneJon
Copy link
Contributor

This check was my bad idea, so I'll review this. Also could someone with permissions add Greg to the whitelist? This is his first commit to core (thank you Greg!) but is a long-time contributor in CiviCRM chat.

@seamuslee001
Copy link
Contributor

Jenkins add to whitelist

@seamuslee001
Copy link
Contributor

@eileenmcnaughton
Copy link
Contributor

(style issue will be that drupal coding standards -which we follow - require upper case FALSE )

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'm a bit mystified - The string being checked isn't the resource URL, but the HTTP response, which should be "HTTP/1.1 200 OK". It sounds like yours just returns "200 OK" - but when I load the URL myself, I see the response as "HTTP/1.1 200 OK".

Regardless, I agree that this change is safe and expresses the original intent more accurately, so I'm giving this "merge-on-pass".

@eileenmcnaughton
Copy link
Contributor

I've added merge-on-pass per @MegaphoneJon review - however, it won't pass until the style warning is fixed

Without this proposed fix, I'm receiving false errors about the CiviCRM Resource URL not being set correctly.

The stripos() function will return '0' if the needle string is the first thing found in the haystack. Thus, you must use equivalence rather than a true/false test where "position zero" evaluates to false.

Tested on Civi 5.3.0 on WordPress 4.9.7

I can access http://coastaltrails.org/wp-content/plugins/civicrm/civicrm/packages/jquery/css/images/arrow.png But WITHOUT the fix, I get an error
```
The Resource URL is not set correctly. Please set the CiviCRM Resource URL.
```
I have CiviCRM Resource URL set to `[civicrm.root]/`

My URL Variables are calculated as:
```
[cms.root]	http://coastaltrails.org/
[civicrm.root]	http://coastaltrails.org/wp-content/plugins/civicrm/civicrm/
[civicrm.files]	http://coastaltrails.org/wp-content/uploads/civicrm/
These variables are computed automatically using civicrm.settings.php and its options, such as CIVICRM_TEMPLATE_COMPILEDIR.
```
@colemanw
Copy link
Member

I've updated this PR to fix the style issue. Can be merged when tests complete.

@eileenmcnaughton eileenmcnaughton merged commit 3a09ea8 into civicrm:master Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants