Skip to content

Conversation

@lloc
Copy link
Owner

@lloc lloc commented Jan 27, 2026

No description provided.

lloc and others added 3 commits January 27, 2026 18:17
Remove orphaned restore_error_handler() call in tearDown() that was
removing PHPUnit's error handler without a matching set_error_handler()
in setUp(). This caused "Test code or tested code removed error handlers
other than its own" warnings in PHPUnit 10+.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lloc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the project's maintainability and development workflow through targeted code refinements. It simplifies the PHP compatibility testing setup, removes boilerplate code by centralizing or eliminating redundant WordPress constant checks, and optimizes a user counting condition. Furthermore, it addresses an aspect of unit test error handling, contributing to a more robust and efficient testing environment.

Highlights

  • PHP Compatibility Script Simplification: The composer.json file has been updated to consolidate multiple PHP compatibility phpcs scripts (for PHP 7.4, 8.2, 8.3, 8.4) into a single, more flexible script that targets PHP 7.4 and above.
  • Redundant ABSPATH Checks Removal: Numerous PHP files across the includes/ directory have had the if ( ! defined( 'ABSPATH' ) ) { exit; } block removed, streamlining the codebase by eliminating repetitive WordPress constant checks.
  • Optimized User Count Logic: In includes/MslsBlogCollection.php, a redundant isset() check for user_count['total_users'] has been removed, simplifying the condition for user list limitation.
  • Unit Test Error Handler Fix: The restore_error_handler() call has been removed from the tearDown() method in tests/phpunit/MslsUnitTestCase.php, addressing an issue or simplifying the error handling mechanism during unit tests.
  • Development Dependency Downgrade: The @wordpress/scripts development dependency in package.json has been slightly downgraded from ^31.3.0 to ^31.1.0.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request focuses on fixing unit test error handlers. The changes include consolidating PHPCS scripts, removing ABSPATH checks from many files, adjusting a condition in MslsBlogCollection, downgrading a development dependency, and modifying the test case teardown. While most changes appear to support the stated goal, I've identified a potential security concern with the removal of ABSPATH checks and a change that reduces code robustness. My review provides specific feedback on these points with suggestions for improvement.

I am having trouble creating individual review comments. Click here to see my feedback.

includes/MslsPlugin.php (5-7)

high

This pull request removes the if ( ! defined( 'ABSPATH' ) ) { exit; } guard from multiple files. This is a standard security measure in WordPress to prevent direct access to PHP files. While this might be necessary to get unit tests to run, a better practice is to define ABSPATH in your test suite's bootstrap file (e.g., tests/phpunit/bootstrap.php). This would allow the tests to run while keeping this important security check in place for production environments. Removing these guards can expose the plugin to potential path disclosure vulnerabilities if a server is misconfigured.

includes/MslsBlogCollection.php (317)

medium

The isset() check for $user_count['total_users'] was removed. While count_users() is expected to always return this key, the result is filterable via the count_users filter, which could lead to the key being absent. Removing the check makes the code less robust and could lead to "Undefined array key" PHP notices. It is safer to restore the isset() check to prevent potential issues.

            if ( isset( $user_count['total_users'] ) && $user_count['total_users'] > $number ) {

@github-actions
Copy link

github-actions bot commented Jan 27, 2026

🔍 WordPress Plugin Check Report

❌ Status: Failed

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
36 15 21

❌ Errors (15)

📁 includes/MslsBlogCollection.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsContentFilter.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsPostTag.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsOptionsTaxTerm.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsAdmin.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsCustomFilter.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsCustomColumnTaxonomy.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsMetaBox.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsCustomColumn.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsPlugin.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsAdminBar.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/MslsOptions.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/ContentImport/ContentImporter.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/ContentImport/Service.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;
📁 includes/deprectated.php (1 error)
📍 Line 🔖 Check 💬 Message
0 missing_direct_file_access_protection PHP file should prevent direct access. Add a check like: if ( ! defined( 'ABSPATH' ) ) exit;

⚠️ Warnings (21)

📁 includes/MslsPostTag.php (2 warnings)
📍 Line 🔖 Check 💬 Message
111 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ADD_INPUT_ACTION".
145 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_EDIT_INPUT_ACTION".
📁 includes/MslsAdmin.php (2 warnings)
📍 Line 🔖 Check 💬 Message
238 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_REGISTER_ACTION".
337 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ACTION_PREFIX . $section".
📁 includes/MslsCustomFilter.php (1 warning)
📍 Line 🔖 Check 💬 Message
82 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
📁 includes/ContentImport/ContentImporter.php (2 warnings)
📍 Line 🔖 Check 💬 Message
284 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_BEFORE_IMPORT_ACTION".
345 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_AFTER_IMPORT_ACTION".
📁 includes/MslsBlog.php (2 warnings)
📍 Line 🔖 Check 💬 Message
142 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_GET_PERMALINK_HOOK".
195 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK".
📁 includes/MslsPostTagClassic.php (2 warnings)
📍 Line 🔖 Check 💬 Message
39 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ADD_INPUT_ACTION".
71 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_EDIT_INPUT_ACTION".
📁 includes/Component/Input/Select.php (1 warning)
📍 Line 🔖 Check 💬 Message
39 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::RENDER_FILTER".
📁 includes/MslsOutput.php (6 warnings)
📍 Line 🔖 Check 💬 Message
89 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_GET_HOOK".
118 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATE_LINKS_HOOK".
134 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATE_LINKS_DEFAULT_HOOK".
137 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATE_LINKS_ARR_HOOK".
150 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_NO_TRANSLATION_FOUND_HOOK".
181 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_GET_TAGS_HOOK".
📁 includes/Map/HrefLang.php (1 warning)
📍 Line 🔖 Check 💬 Message
69 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_HEAD_HREFLANG_HOOK".
📁 includes/MslsWidget.php (1 warning)
📍 Line 🔖 Check 💬 Message
58 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATIVE_CONTENT_HOOK".
📁 includes/MslsMain.php (1 warning)
📍 Line 🔖 Check 💬 Message
143 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_SAVE_ACTION".

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@lloc lloc merged commit f723349 into master Jan 27, 2026
5 of 6 checks passed
@lloc lloc deleted the fix-unit-test-error-handlers branch January 27, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants