Skip to content

Backup: Prevent _load_textdomain_just_in_time PHP notices by adding admin_menu hook #42396

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

Merged
merged 5 commits into from
Mar 18, 2025

Conversation

coder-karen
Copy link
Contributor

@coder-karen coder-karen commented Mar 12, 2025

Fixes #42395

Proposed changes:

  • This PR moves the 'VaultPress Backup' admin menu addition to it's own function, hooked into the admin_menu filter.
  • This ensures that translations are not loaded too early, preventing PHP notices in the upcoming WordPress 6.8 release if your site language is the default US English (as well as currently in 6.7.2, if you use a different translation of WordPress such as Deutsch )

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

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

No.

Testing instructions:

On a self-hosted test site, with Jetpack Backup installed and active, assuming your site language is set to English:

  • Install the WordPress Beta Tester plugin
  • Go to Tools > Beta Testing, and set the plugin to use Beta/RC Only (in order to upgrade to WP 6.8-beta2)
  • Go to Dashboard > Updates, and update to WP 6.8-beta2.
  • Load any page, and check error logs. You should see PHP Notice: Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>jetpack-backup</code> domain was triggered too early.

This is also reproducible using a different site language on the current WP version, on self-hosted:

  • Set the site language in /wp-admin/options-general.php
  • Reinstall the current WP version at /wp-admin/update-core.php
  • Load any page, and check error logs. You should see the notice mentioned earlier.

Then, apply this PR and follow the same steps. Those notices should be gone, and the VaultPress Backup admin menu item should still be visible.

@coder-karen coder-karen added [Type] Bug When a feature is broken and / or not performing as intended [Status] In Progress labels Mar 12, 2025
@coder-karen coder-karen self-assigned this Mar 12, 2025
Copy link
Contributor

github-actions bot commented Mar 12, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/backup-l10n-textdomain-hook-load-order branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/backup-l10n-textdomain-hook-load-order

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Package] Backup [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Mar 12, 2025
Copy link
Contributor

github-actions bot commented Mar 12, 2025

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 Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: April 1, 2025
    • Code freeze: March 30, 2025

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


Backup plugin:

No scheduled milestone found for this plugin.

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

Copy link

jp-launch-control bot commented Mar 12, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/backup/src/class-jetpack-backup.php 23/379 (6.07%) -0.03% 2 ❤️‍🩹

Full summary · PHP report · JS report

@coder-karen coder-karen marked this pull request as ready for review March 12, 2025 16:20
@coder-karen coder-karen requested review from a team March 12, 2025 16:30
@coder-karen coder-karen added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Mar 12, 2025
@fgiannar fgiannar self-requested a review March 14, 2025 07:05
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

Thanks Karen!

I can confirm that the PHP Warnings are no longer there however while testing on a JN site I noticed that "Akismet Anti-spam" disappeared from the admin menu with the current branch.

Jetpack Backup Bleeding Edge:
Screenshot 2025-03-14 at 09 14 23

Jetpack Backup current branch:
Screenshot 2025-03-14 at 09 14 40

@fgiannar fgiannar added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Mar 14, 2025
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Would it be worth looking at the other standalone plugins at the same time, since they all follow the same pattern?

@coder-karen
Copy link
Contributor Author

@fgiannar good catch, thank you!

It looks like the issue you reported is only replicable in that scenario - VaultPress Backup active, Akismet active, and no other standalones including Jetpack.

Would it be worth looking at the other standalone plugins at the same time, since they all follow the same pattern?

@jeherve, yes, good idea. In doing so, I noticed that Boost, Search and VideoPress also already have this issue - when active with only Akismet active as well (no Jetpack). I've created an issue here: #42497

I should also add that in testing I tested with all other standalones included at the same time, and the translation issue only occurred with VaultPress Backup. The disappearing menu item appears to only be an issue in the scenario mentioned above.

By changing the admin_menu hook priority for VaultPress Backup, this solves the issue in the specific case mentioned above as we make sure VaultPress Backup is registered before Akismet, and doesn't affect it's placement when with other standalones. It also prevents the textdomain issue as the textdomain is loaded at that stage.

@coder-karen coder-karen added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Mar 17, 2025
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the Akismet related fix and related comments 🚢

@fgiannar fgiannar added the [Status] Ready to Merge Go ahead, you can push that green button! label Mar 18, 2025
@fgiannar fgiannar removed the [Status] Needs Review This PR is ready for review. label Mar 18, 2025
@coder-karen coder-karen merged commit 7a4a200 into trunk Mar 18, 2025
70 checks passed
@coder-karen coder-karen deleted the fix/backup-l10n-textdomain-hook-load-order branch March 18, 2025 15:31
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Backup [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jetpack Backup: WordPress 6.8 compatibility - _load_textdomain_just_in_time doing it wrong notice being logged
3 participants