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

Boost: Update cache exceptions UI to indicate if there's an invalid pattern #35984

Merged
merged 4 commits into from
Feb 29, 2024

Conversation

dilirity
Copy link
Member

Part of #35768

Proposed changes:

  • Update the exceptions UI to check if there's an invalid pattern;
  • Disable button if there's an invalid pattern;
  • Update patterns to make sure they are valid before saving them to DB:
    • Remove home URL;
    • Always add a leading slash;
    • Make sure the wild card (.*) is the same across all patterns;
    • Remove double slashes;
    • Trim.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

n/a

Does this pull request change what data or activity we track or use?

no

Testing instructions:

  • Plan around with adding various patterns to the exceptions UI and make sure it behaves accordingly.

@dilirity dilirity added [Status] Needs Team Review [Plugin] Boost A feature to speed up the site and improve performance. [Boost Feature] Cache labels Feb 27, 2024
@dilirity dilirity requested a review from a team February 27, 2024 12:46
@dilirity dilirity self-assigned this Feb 27, 2024
@dilirity dilirity mentioned this pull request Feb 27, 2024
6 tasks
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Boost plugin:

  • Next scheduled release: March 5, 2024.
  • Scheduled code freeze: February 26, 2024.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

@donnchawp donnchawp left a comment

Choose a reason for hiding this comment

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

Works as advertised. Some changes weren't applied until I refreshed the page (like trimming the whitespace), but the list of exceptions was saved correctly.

@thingalon
Copy link
Member

I get the following error when trying to load wp-admin:

[28-Feb-2024 04:29:02 UTC] PHP Fatal error: Uncaught Automattic\Jetpack\WP_JS_Data_Sync\Schema\Schema_Error: > Failed to parse value using: string or void in /usr/local/src/jetpack-monorepo/projects/packages/wp-js-data-sync/src/schema/class-schema-parser.php:119
Stack trace:
#0 /usr/local/src/jetpack-monorepo/projects/packages/wp-js-data-sync/src/class-data-sync-entry-adapter.php(66): Automattic\Jetpack\WP_JS_Data_Sync\Schema\Schema_Parser->parse()
#1 /usr/local/src/jetpack-monorepo/projects/packages/wp-js-data-sync/src/class-data-sync.php(147): Automattic\Jetpack\WP_JS_Data_Sync\Data_Sync_Entry_Adapter->get()
#2 /var/www/html/wp-includes/class-wp-hook.php(324): Automattic\Jetpack\WP_JS_Data_Sync\Data_Sync->_print_options_script_tag()
#3 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#4 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action()
#5 /var/www/html/wp-admin/admin.php(259): do_action()
#6 {main}
thrown in /usr/local/src/jetpack-monorepo/projects/packages/wp-js-data-sync/src/schema/class-schema-parser.php on line 119

Even after running build all.

@dilirity
Copy link
Member Author

dilirity commented Feb 28, 2024

@thingalon I'm unable to reproduce this after building all. Unfortunately, the error you provided isn't of much help 😞

If you manage to get the error, can you add these to your wp-config.php and see if the debug.log has more information?

define( 'DATASYNC_DEBUG', true );
define( 'DATASYNC_VERBOSE', true );
define( 'DATASYNC_TRACE', true );

Would like to get to the bottom of this.

EDIT:
This wouldn't help. @pyronaur any ideas how to pinpoint this?

I got an idea! I'm pretty sure it's an outdated DB value (though not sure how, since this only touches the config.php file). Could you check your wp_options table for %page_cache% and paste here the values you have (when you have the error present)? I got a similar error just now by having an outdated value for a schema that changed.

@thingalon
Copy link
Member

@dilirity - ok I tracked it down and the error is NOT a problem with this PR.

In fact, the error is @pyronaur 's DATASYNC_DEBUG setting doing exactly what it should do. So, chalk this error up to a win I should have looked at in more detail.

Your branch is a couple of revisions behind trunk. In trunk the page_cache_error datasync type is an associative array. In your (slightly old) version of our datasync setup it's a nullable string.

Because I keep DATASYNC_DEBUG defined to true in my dev environment, I saw that array data being thrown away for being the incorrect type as a grey screen. When I removed that constant the Boost dashboard loaded just fine.

So, no major problem here - actually a demonstration of a win.

Copy link
Member

@thingalon thingalon left a comment

Choose a reason for hiding this comment

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

Does what it says on the tin :)

Comment on lines +86 to +87
'*' => '(.*)',
'(*)' => '(.*)',
Copy link
Member

Choose a reason for hiding this comment

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

Cheese* is a valid regexp which will match chees, cheese, cheeseeee, etc.

However, it seems like a pattern that users are very unlikely to want.

I think I'm ok with the guard-rails you've put here, because for most users this will put them on the right path. But I did want to note this will make some esoteric regexps impossible to enter.

@thingalon thingalon enabled auto-merge (squash) February 29, 2024 03:07
@thingalon thingalon merged commit 2a4586e into trunk Feb 29, 2024
50 of 51 checks passed
@thingalon thingalon deleted the update/boost/invalid-exceptions-ui-feedback branch February 29, 2024 03:11
thingalon pushed a commit that referenced this pull request Mar 1, 2024
…attern (#35984)

* Add error if there's a problem with a pattern during input

* Add pattern sanitization before storing to DB

* add changelog

---------

Co-authored-by: Mark George <thingalon@gmail.com>
@thingalon
Copy link
Member

Cherry-picked to 3.1.0 in ba914ab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Boost Feature] Page Cache [Plugin] Boost A feature to speed up the site and improve performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants