Skip to content

Conversation

@kraftbj
Copy link
Contributor

@kraftbj kraftbj commented Jan 7, 2026

Supports #46490wp-env will execute the plugin, so if starting up wp-env without having composer install to create an autoloader in a plugin, it'll fatal and exit. This would allow that and other times where someone activates a dev-uninstalled/built version of a plugin on a site.

Proposed changes:

Adds is_readable() checks around autoloader require statements in four plugins to prevent fatal errors when plugins are activated before composer install has been run.

Affected plugins:

  • classic-theme-helper-plugin — Also fixes a bug where the autoloader was never being loaded
  • mu-wpcom-plugin
  • wpcloud-sso
  • wpcomsh

Each check includes:

  • Debug logging when WP_DEBUG is enabled
  • Admin notice on the plugins page with link to setup documentation
  • Inline comment explaining the purpose of the check

Other information:

  • Have you written new tests for your changes, if applicable? (N/A — defensive checks, no unit tests needed)
  • 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?

Jetpack product discussion

N/A — Internal developer experience improvement

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

No

Testing instructions:

  1. Checkout this branch
  2. Activate one of the affected plugins without running composer install first
  3. Verify the plugin doesn't fatal
  4. Verify an admin notice appears on the plugins page
  5. Verify the notice links to the development environment documentation

…ions

Adds is_readable() checks around autoloader require statements in four plugins
to prevent fatal errors when plugins are activated before composer install
has been run. Each check includes:

- Debug logging when WP_DEBUG is enabled
- Admin notice on the plugins page with setup instructions
- Inline documentation explaining the purpose of the check

Affected plugins:
- classic-theme-helper-plugin (also fixes missing autoloader load)
- mu-wpcom-plugin
- wpcloud-sso
- wpcomsh
@kraftbj kraftbj added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress labels Jan 7, 2026
@kraftbj kraftbj self-assigned this Jan 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

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 or WordPress.com Site Helper), and enable the fix/plugin-autoloader-checks branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/plugin-autoloader-checks
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/plugin-autoloader-checks

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
Copy link
Contributor

github-actions bot commented Jan 7, 2026

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: February 3, 2026
    • Code freeze: February 3, 2026

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


Mu Wpcom plugin:

  • Next scheduled release: WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2)

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


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

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


Classic Theme helper plugin 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.


Wpcloud Sso 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.

@jp-launch-control
Copy link

jp-launch-control bot commented Jan 7, 2026

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/wpcomsh/wpcomsh.php 112/358 (31.28%) -3.28% 34 💔
projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php 0/37 (0.00%) 0.00% 33 💔

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@kraftbj kraftbj added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Jan 7, 2026
@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Jan 8, 2026
@kraftbj kraftbj added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jan 8, 2026
@kraftbj kraftbj marked this pull request as ready for review January 8, 2026 17:43
Copilot AI review requested due to automatic review settings January 8, 2026 17:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds defensive autoloader checks to four plugins to prevent fatal errors when plugins are activated before composer install has been run during development. The PR also fixes a bug in classic-theme-helper-plugin where the autoloader was never being loaded, and adds a missing jetpack-blocks dependency to the classic-theme-helper package.

Key changes:

  • Wraps autoloader require statements in is_readable() checks for graceful degradation
  • Adds developer-friendly admin notices with links to setup documentation
  • Fixes autoloader loading bug in classic-theme-helper-plugin

Reviewed changes

Copilot reviewed 12 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
projects/plugins/wpcomsh/wpcomsh.php Adds autoloader check with error logging and admin notice for missing composer dependencies
projects/plugins/wpcloud-sso/jetpack-wpcloud-sso.php Adds autoloader check with error logging and admin notice for missing composer dependencies
projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php Adds autoloader check with error logging and admin notice for missing composer dependencies
projects/plugins/classic-theme-helper-plugin/classic-theme-helper-plugin.php Adds autoloader check and fixes bug where autoloader was never loaded
projects/packages/classic-theme-helper/composer.json Adds missing jetpack-blocks dependency
projects/plugins/wpcomsh/composer.lock Updates classic-theme-helper reference and adds jetpack-blocks dependency
projects/plugins/mu-wpcom-plugin/composer.lock Updates classic-theme-helper reference and adds jetpack-blocks dependency
projects/plugins/jetpack/composer.lock Updates classic-theme-helper reference and adds jetpack-blocks dependency
projects/plugins/classic-theme-helper-plugin/composer.lock Adds jetpack-blocks package dependency
projects/packages/classic-theme-helper/.phan/baseline.php Updates Phan baseline after dependency addition resolved undeclared class method issues
projects/plugins/wpcomsh/changelog/fix-plugin-autoloader-checks Documents the autoloader check addition
projects/plugins/wpcloud-sso/changelog/fix-plugin-autoloader-checks Documents the autoloader check addition
projects/plugins/mu-wpcom-plugin/changelog/fix-plugin-autoloader-checks Documents the autoloader check addition
projects/plugins/classic-theme-helper-plugin/changelog/fix-plugin-autoloader-checks Documents the autoloader check and bug fix
projects/plugins/jetpack/changelog/fix-plugin-autoloader-checks Documents the package dependency update
projects/packages/classic-theme-helper/changelog/fix-plugin-autoloader-checks Documents the missing dependency addition

Comment on lines +89 to +92
if ( get_current_screen()->id !== 'plugins' ) {
return;
}

Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The get_current_screen() function may not be available or could return null when the admin_notices hook fires. This could cause a fatal error. Add a check to ensure get_current_screen() is available and returns a valid value before accessing its properties.

Suggested change
if ( get_current_screen()->id !== 'plugins' ) {
return;
}
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}
$screen = get_current_screen();
if ( ! $screen || empty( $screen->id ) || 'plugins' !== $screen->id ) {
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +67
if ( get_current_screen()->id !== 'plugins' ) {
return;
}

Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The get_current_screen() function may not be available or could return null when the admin_notices hook fires. This could cause a fatal error. Add a check to ensure get_current_screen() is available and returns a valid value before accessing its properties.

Suggested change
if ( get_current_screen()->id !== 'plugins' ) {
return;
}
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}
$screen = get_current_screen();
if ( ! $screen || empty( $screen->id ) || 'plugins' !== $screen->id ) {
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +44
if ( get_current_screen()->id !== 'plugins' ) {
return;
}

Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The get_current_screen() function may not be available or could return null when the admin_notices hook fires. This could cause a fatal error. Add a check to ensure get_current_screen() is available and returns a valid value before accessing its properties.

Suggested change
if ( get_current_screen()->id !== 'plugins' ) {
return;
}
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}
$screen = get_current_screen();
if ( ! $screen || ! isset( $screen->id ) || $screen->id !== 'plugins' ) {
return;
}

Copilot uses AI. Check for mistakes.
add_action(
'admin_notices',
function () {
if ( get_current_screen()->id !== 'plugins' ) {
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The get_current_screen() function may not be available or could return null when the admin_notices hook fires. This could cause a fatal error. Add a check to ensure get_current_screen() is available and returns a valid value before accessing its properties.

Suggested change
if ( get_current_screen()->id !== 'plugins' ) {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
if ( ! $screen || ! isset( $screen->id ) || $screen->id !== 'plugins' ) {

Copilot uses AI. Check for mistakes.
} else {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
__( 'Error loading autoloader file for Classic Theme Helper Plugin plugin', 'classic-theme-helper-plugin' )
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The error message contains redundant wording: "Classic Theme Helper Plugin plugin" should be "Classic Theme Helper Plugin" (remove the duplicate "plugin" word).

Suggested change
__( 'Error loading autoloader file for Classic Theme Helper Plugin plugin', 'classic-theme-helper-plugin' )
__( 'Error loading autoloader file for Classic Theme Helper Plugin', 'classic-theme-helper-plugin' )

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Theme Tools I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Package] Classic Theme Helper [Plugin] Classic Theme Helper Plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Wpcloud Sso [Plugin] Wpcomsh [Status] Needs Review This PR is ready for review. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants