-
-
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 to ensure WP base page exists #17698
Conversation
(Standard links)
|
@kcristiano @christianwach are there any non-standard WP configs that could potentially get tripped up in this? |
Jenkins retest this please |
@christianwach what do you think about Multi-Site? That could be an issue. @agh1 I am a bit concerned about this, we already have the problem of: This appears on most installs, it's marked critical and all testing I've done shows it's a false positive, but I can't figure out a reliable fix for that and I just have to tell people to ignore. I'd like to avoid that here. |
Jenkins re test this please |
@kcristiano the difference here is that it looks up via civicrm-core/CRM/Utils/Check/Component/Cms.php Lines 32 to 39 in 2586fbb
Potentially the handy link could be wrong in some circumstances, but I can't think of when. I do think that it would make sense to revisit that resource URL check, because it seems to trip up on the placeholders on nearly everyone, but that's outside the scope of this PR. Separately, the test failures seem really weirdly unrelated unless I'm missing something. |
@agh1 Good points and forgive my rants. I am revisiting the other issue. I'll test this, but I do think we should restrict to single site to start. I see too many issues with WP Multi-Site. Is CiviCRM Network Activated? Is it activated just on a single site? Are we sharing Databases? I can go on, but this all affects what base page gets used and how we'd use it. |
For the resource url see https://lab.civicrm.org/dev/core/-/issues/1647 and https://lab.civicrm.org/dev/drupal/-/issues/114 which are the same problem. |
@kcristiano if you're accessing CiviCRM within a WP multi-site, would it make a difference how to call |
I agree with @kcristiano that this check should only apply to single site instances of WordPress. There are just too many possible configurations when using WordPress Multisite and WordPress Multi-Network for this to be reliable. |
@agh1 Can I please please ask that there be no notice in multisite? Anyone using multisite should be able to get their luggage off the carousel. This seems like unnecessary (and, most likely, misleading) clutter. |
Ok due to popular demand I've toned it down to a |
@christianwach I was just writing my most recent comment when yours came in--are you saying please please not even a |
@agh1 Yes. It's not that the |
@agh1 The issue is we have so many possibilities:
In short WP Multi-Site is as standard as a standard CiviEvent setup. Everyone does it differently. And yes get_posts() will look to the site you are logged into -- BUT CiviCRM may be set to only show on site id 1. I have tested and I had a number of false positives - in my case all 'Good" when no base pages exist. I do think that this check may be helpful - but more to us - Developers and Partners. I'd limit to Single site only and not even run on Multi-Site. If this goes in, it's another system status I have to unhook in our repos and I really don't want to do that. I see the value in Single Site I see too many potential 'unexpected outcomes' in Multi-Site. |
@christianwach @kcristiano sounds fine with me. I've updated it to completely skip the check for multisite. I do worry that this system check may be the least concern in the contexts where the check would have a false positive. In other words, if you're accessing the backend of CiviCRM via site 2 and CiviCRM is only expected to work on site 1, with no base page on site 2, all of the frontend links from the backend of CiviCRM should be bad, right? |
In my testing it will take all front end pages to the main site - at least native CiviCRM links. Any site that tries to get a native CiviCRM page on site 2 would fail and in this case it'd be correct. I agree with @christianwach that if someone is installing MS it's on them. I am just concerned that the noise generated by system checks has passed the point where they mean anything. I know I have been adamant here, but I don't see the value on this check on MS. I am still trying to work through civicrm/civicrm-wordpress#205 But the issue here is that the way I set up MS it failed. If I set it up a different way it works - yet all it should do is create a page on the blog_id I am logged into with CiviCRM - yet my standard config was different. Once we get past that PR(and I think we will but we must update the docs as to the install procedure as well) then could we add a MS check? _ Maybe_ |
Your last comment @kcristiano got me wondering how CRM_Utils_System_WordPress::url() handles things for frontend links, and it turns out that it builds on the civicrm-core/CRM/Utils/System/WordPress.php Line 398 in 1611013
which is populated by looking up the page on the current site corresponding to the civicrm-core/CRM/Utils/System/WordPress.php Lines 77 to 83 in 1611013
If nothing else, it's better to use a method for the check that's consistent with the method for building the URLs, so I changed how to do the lookup here. It also lets me provide better information in the situation of someone unpublishing the page. |
I've added OK-without-test as we don't have a way to test wp-specific stuff. @kcristiano @christianwach I assume one of you will merge when you are happy with this |
@eileenmcnaughton @agh1 We will meet to discuss this and take action tomorrow. |
Thanks @christianwach - as always you & @kcristiano are on top of things! |
Here are a few points that emerged from our discussion:
tl;dr We're still ambivalent about the value of this check. |
@christianwach I can see how point 3 might be relevant and possible to implement. In principle it seems like an edge case, but it would certainly be easy to add that one line letting plugins modify the value before looking it up. However, points 2, 4, and 5 seem to argue against offering a system status page at all. We check for all kinds of things that don't affect some users. Refusing to add a check that is sensitive and specific won't stop the system from yelling at people that their database is unprepared for the chance that some future version of CiviCRM will allow emoji. Point 5 gets to the real purpose of this check and the real problem with a lot of checks. Most system checks should not show on a fresh install of CiviCRM. If CiviCRM can find a problem, it should be able to prevent it or at least tell you during install. This system check is for the specific, shockingly common situation of someone deciding to clean out their site and delete the "CiviCRM" base page. (I know the page itself says not to delete it, but I suppose people think it's just programmed to say that as a fail-safe measure.) It's also helpful if someone moves CiviCRM from one site to another and the destination either lacks the page or doesn't have the custom base page that the source site did. Unlike checks that warn about theoretical future problems or newly-introduced requirements, this watches out for something that actually breaks sites when it happens and has been an issue ever since the base page feature was introduced. Incidentally, if you're interested in ways to avoid "the impression that CiviCRM is broken software", I think @seamuslee001 and @eileenmcnaughton were at least discussing a way to display system checks for a more specific permission than Adminster CiviCRM. |
Actually, I take that back about point 3. The Since this check looks at that setting, the situation of a plugin modifying the default base page slug is already handled. I can see arguments both ways as to whether the "default" is CiviCRM's default or whatever the plugins have modified it to be. |
@agh1 I just did a test where I changed the base page on install using an mu-plugin function tc_change_slug( ) {
$tc_slug = 'crmbasepage';
return $tc_slug;
}
add_filter( 'civicrm_basepage_slug', 'tc_change_slug' ); This does change the base page on install and store it in civicrm_settings. @christianwach is there another use of the filter I am missing that should be looked at?
I do get this. I've had times where odd things broke (Mosaico) due to lack of a base page. At the very least I think the severity needs to be dampened down and we need to improve the worjding for users. Let me add this to my 5.28 RC testing sites and see if I encounter any issues. |
@kcristiano Nope, that's the one. The result was presumably that the check reported the wrong value for the default base page slug on this install (i.e. |
That makes sense that in an environment where the default base page has been modified via |
Sorry I'm getting backed up on comments--I was addressing the language suggestions. I'll respond to levels @kcristiano in just a sec. |
@kcristiano in determining levels for the system check we've been trying to stick to how they're described in PSR-3: https://www.php-fig.org/psr/psr-3/#3-psrlogloggerinterface
By this measure, the basepage being missing is certainly more severe than "normal but significant events", and probably more severe than "undesirable things that are not necessarily wrong". It's short of "action must be taken immediately", and while this will make an "application component unavailable"--namely all contribution pages, events, Mosaico, and more--I wanted to lean against alarmism, so I chose "error". Moving away from the framework to more practical considerations, a "notice" will not appear to the admin like anything is wrong. To me, all of these warnings about upcoming PHP versions and UTF8MB4 should be classic notices: nothing is wrong right now, but you ought to be aware. In contrast, a missing basepage is going to cause serious problems for most people, and more specifically, those problems won't be easy for someone to trace back to the missing page. There's no way to promise that all messages will be applicable to everyone, but that is why you can hush the message either through the UI or the API. My feeling is that someone who has gone out of their way to delete the base page or modify the setting to a page that doesn't exist is someone who can go out of their way to click the button to hide the message. In contrast, if someone less sophisticated has a standard site and sees that message, it's almost always going to be caused by accident, and it will probably point to a real problem they'll face. Finally, I 100% agree that the system messages are too noisy. Admins see them and don't know what to do about them. There are loud ones about theoretical future problems, not issues to be addressed now. However, by that measure this check will do practically nothing to make them noisier. |
User/Site Admins just don't do that I don't believe this is a critical error (I think ERROR and above as critical). Perhaps warning at best. I know I am being rigid on this. I just don't see this rising to a that severity. |
@kcristiano has already found his way there, but for everyone else's sake I've opened an issue dev/core#1863 to discuss severities of system checks in general. I do believe that this message should be an "error" in the rare occasions when it would appear--it represents a real, present problem for the majority of sites--but I also think that a lot of messages that appear far more often should be ratcheted down. |
Can you detail how this will rise to a Red Level Alert -Emergency Action Needed? That's how it appears to a user. I understand PSR-3, but Zero of my clients do and expect they are a pretty good measure of users. I am not comfortable with this check at an the "Error" level. |
Yeah, when an organization's donation page won't work, that's a 🚨 Red Alert 🚨 for pretty much anyone. The same goes for event registrations and Mosaico for organizations who use them. The only reason I bring up PSR-3 is that I totally understand there could be a variety of opinions on severities, but that's the standard CiviCRM uses. We have a problem that different system check writers have different ideas as to what's severe, so I'm trying to refer back to the standard so we have some level of parity among them. Put another way, I'd say the base page going missing is at least as severe as a case type referring to a relationship type that doesn't exist, not being able to write to the upload directory, or cron having stopped for over 24 hours. Those are fairly typical of the "error" level for other system checks. |
Ok you make a very valid point. This looks merge ready to me |
I have done |
Looks good to me now too. |
I'm merging this - I understand @kcristiano giving it merge-ready as 'looks OK to me but what does @christianwach think' - we have that answer now so merging |
Overview
The WordPress base page is important for rendering content in WordPress, but someone might delete the page, or the configured path might be changed so that it doesn't match the page.
This adds a system check to make sure that the page configured on the WordPress Integration settings page exists.
Before
If you delete the page at
/civicrm
, or if you accidentally change the setting to something different without having a page there, you'll have problems and won't know why.After
If there is no page with the slug specified by the WordPress Base Page setting, you get one of the following
ERROR
-level messages:Base page is the default, but no page has that slug:
![image](https://user-images.githubusercontent.com/1682375/85782024-4d194a80-b6f4-11ea-8f94-4b6087194fa1.png)
Non-standard base page, but the default
![image](https://user-images.githubusercontent.com/1682375/85781709-f9a6fc80-b6f3-11ea-8503-29462e7ba46b.png)
/civicrm
exists:Non-standard base page, and the default
![image](https://user-images.githubusercontent.com/1682375/85781874-2824d780-b6f4-11ea-93e9-1c5719823eaa.png)
/civicrm
doesn't exist either:If
is_multisite()
it will skip the whole check per comments below.Technical Details
I added a new
CRM_Utils_Check_Component_Cms
that could potentially include other CMS-specific checks.