-
-
Notifications
You must be signed in to change notification settings - Fork 40
Fix unit test error handlers #562
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
Conversation
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]>
Summary of ChangesHello @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
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this 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)
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)
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 ) {
🔍 WordPress Plugin Check Report
📊 Report
❌ Errors (15)📁 includes/MslsBlogCollection.php (1 error)
📁 includes/MslsContentFilter.php (1 error)
📁 includes/MslsPostTag.php (1 error)
📁 includes/MslsOptionsTaxTerm.php (1 error)
📁 includes/MslsAdmin.php (1 error)
📁 includes/MslsCustomFilter.php (1 error)
📁 includes/MslsCustomColumnTaxonomy.php (1 error)
📁 includes/MslsMetaBox.php (1 error)
📁 includes/MslsCustomColumn.php (1 error)
📁 includes/MslsPlugin.php (1 error)
📁 includes/MslsAdminBar.php (1 error)
📁 includes/MslsOptions.php (1 error)
📁 includes/ContentImport/ContentImporter.php (1 error)
📁 includes/ContentImport/Service.php (1 error)
📁 includes/deprectated.php (1 error)
|
| 📍 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
No description provided.