-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Add system check for clean URL configuration #24477
Conversation
(Standard links)
|
public static function checkWpCleanurls() { | ||
$config = CRM_Core_Config::singleton(); | ||
//Right now this config issue largely affects Wordpress only. This check could be applied to other CMS' but for now it's just WP | ||
if ($config->userFramework != 'WordPress') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test fail is a style issue where it doesn't like the indentation on line 96, but regarding cms-specific, a preferred way would be:
- Put all of the code below in this function here instead into CRM_Utils_System_Wordpress in a function called checkCleanurls()
- In CRM_Utils_System_Base, make a function checkCleanurls() that just returns
[]
- And then here this becomes a one-line function which will automatically do the right thing for all cmses, and is easy to update independently for other cmses by making overrides in their own CRM_Utils_System_XXX.
public static function checkCleanurls() {
return CRM_Core_Config::singleton()->userSystem->checkCleanurls();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I just followed CRM_Utils_Check_Component_Cms but this makes sense as a way to organize it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that one could probably be cleaned up too someday (grin).
private static function checkCleanPage($slug, $id, $config) { | ||
$client = new GuzzleHttp\Client(); | ||
$res = $client->head($config->userFrameworkBaseURL . $config->wpBasePage . $slug . $id); | ||
$httpCode = $res->getStatusCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be some situations where guzzle throws an exception. Can wrap this in a try/catch just so that system checks don't fail in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Will do if this gets used. Not even sure if it's workable yet. Currently any implementation of guzzle here, or cURL, appears to break the whole system status page with no logs of a sort I can find. Not sure if that's because it's an angular page and I don't know angular or what yet :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it needs a backslash in front of GuzzleHttp, or add a use
statement at the top of the file and then just put Client
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay cool i'll try that when I get back to this later. I thought it was set properly because I can see it hitting the url in my access log but the system page then fails to load so obviously something was wrong.
04ecc66
to
5fddb9a
Compare
@demeritcowboy thanks for all the feedback! I believe this is working now and has integrated all of your feedback and been rebased/squashed so I am removing the [WIP]. |
5fddb9a
to
d04cf40
Compare
Thanks. Overall it looks ok to me but some missing ts's, and some other comments.
|
Re: [r-doc] This is technically still true, the old URLs will work... but nowadays you'll start running into session issues i.e. "cannot find valid value for id" which is confusing and frustrating to end-users trying to pay for an event etc. An admin would also need to remember to update any hard-coded URLs on the front-end of their site, which is perhaps what could be added to the docs but might be out of scope for that page. Re: [r-tech] Thanks for the comments. Never heard of docurl2 before that's quite useful although the name is quite confusing and I keep getting it mixed up xD. Added some ts(). Re: [r-code]
|
Thanks for the explanations. |
The catch there is just if Guzzle fails for whatever reason we "couldn't load a page". Perhaps it should be more explicit about what's going on. I think the second check there under Edit: Sorry - I see where the "refresh cache" text is duplicated now and I am making a change. |
Ok I think we're almost there. Sorry I'm being so picky but it's What I Do(™).
|
@demeritcowboy no worries at all! It's good to get me back into the swing of things, making a lot of small mistakes.
|
I've also given this an I do think we should update the docs and at least say that as of 5.55 we strongly recommend that CleanURLs be enabled as we have seen session errors when they are not enabled. I am struggling with how to word this, but I do think we need to clarify and push people to Clean URLs. |
If you're feeling good at this point I can squash this down again. Thanks for all the review time! |
Move per demerit's feedback Add action button, link to WordPress Permalinks page. resolve style warnings
70290f8
to
cbcea42
Compare
Overview
https://lab.civicrm.org/dev/core/-/issues/3839
Before
Clean URL settings are often not updated by unsuspecting admins as older sites are upgraded to versions of CiviCRM where they should be required.
After
System check warning appears for Wordpress users if civicrm.settings.php does not include up-to-date clean URL settings.
Technical Details
[WIP] because I am having trouble with both
$civicrm_settings['CIVICRM_CLEANURL']
not updating properly each time in my testing when swapping betweendefine('CIVICRM_CLEANURL', 0);
anddefine('CIVICRM_CLEANURL', 1);
... and because I cannot manage to cURL or GuzzleHttpClient() without breaking the system status page, and i'm really not quite sure why yet... but I need to stop here and spend some time on other things today.Any thoughts welcome!