Skip to content

fix: handle array ids in bulk action admin notices - #753

Open
rahulyadav911 wants to merge 1 commit into
mainfrom
fix/bulk-actions-array-ids
Open

fix: handle array ids in bulk action admin notices#753
rahulyadav911 wants to merge 1 commit into
mainfrom
fix/bulk-actions-array-ids

Conversation

@rahulyadav911

@rahulyadav911 rahulyadav911 commented Aug 11, 2026

Copy link
Copy Markdown

Task:: Error Report on bulk-actions.php

Description:: Fixed a TypeError in bulk-actions.php that occurred when the ids parameter was passed as an array instead of a comma-separated string.
Previously, the code directly used explode(',', $_REQUEST['ids']), which caused a fatal error when $_REQUEST['ids'] was an array.
Updated the logic to support both formats by checking whether the ids value is an array or a string before processing it.
This resolves the fatal error encountered when updating category protection through the Simple Membership plugin.

Before:: Link
After:: Link

Summary by CodeRabbit

  • Bug Fixes
    • Improved admin notice handling for selections submitted as arrays or comma-separated values.
    • Correctly processes escaped request data when counting selected posts.

@rahulyadav911 rahulyadav911 self-assigned this Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The admin bulk notice handler now unslashes the ids request value, accepts arrays, and continues to parse comma-separated strings before counting selected posts.

Changes

Admin notice ID parsing

Layer / File(s) Summary
Normalize bulk notice IDs
includes/admin/bulk-actions.php
custom_bulk_admin_notices() preserves array input and parses comma-separated scalar input after unslashing the request value.

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested reviewers: akhill2020

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix for handling array IDs in bulk action admin notices.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bulk-actions-array-ids

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.2.7)

PHP Warning: require(/vendor/composer/../guzzlehttp/promises/src/functions_include.php): Failed to open stream: No such file or directory in /vendor/composer/autoload_real.php on line 39
Warning: require(/vendor/composer/../guzzlehttp/promises/src/functions_include.php): Failed to open stream: No such file or directory in /vendor/composer/autoload_real.php on line 39
PHP Fatal error: Uncaught Error: Failed opening required '/vendor/composer/../guzzlehttp/promises/src/functions_include.php' (include_path='.:/usr/share/pear:/usr/share/php') in /vendor/composer/autoload_real.php:39
Stack trace:
#0 /vendor/composer/autoload_real.php(43): {closure}()
#1 /vendor/autoload.php(22): ComposerAutoloaderInit31080e90d20105286322e2005cb9fe16::getLoader()
#2 phar:///usr/bin/phpstan/bin/phpstan(49): require_once('...')
#3 phar:///usr/bin/phpstan/bin/phpstan(110): _PHPStan_88a9c7bcc{closure}()
#4 /usr/bin/phpstan(7): require('...')
#5 {main}
thrown in /vendor/composer/autoload_real.php on line 39
Fatal error: Uncaught Error: Failed opening required '/vendor/composer/../guzzlehttp/promises/src/functions_include.php' (include_path='.:/usr/share/pear:/usr/share/php') in /vendor/composer/autoload_real.php:39
Stack trace:
#0 /vendor/composer/autoload_real.php(43): {closure}()
#1 /vendor/autoload.php(22): ComposerAutoloaderInit31080e90d20105286322e2005cb9fe16::getLoader()
#2 phar:///usr/bin/phpstan/bin/phpstan(49): require_once('...')
#3 phar:///usr/bin/phpstan/bin/phpstan(110): _PHPStan_88a9c7bcc{closure}()
#4 /usr/bin/phpstan(7): require('...')
#5 {main}
thrown in /vendor/composer/autoload_real.php on line 39


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
includes/admin/bulk-actions.php (1)

204-205: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for both request formats.

Test custom_bulk_admin_notices() with ids as an array and as a comma-separated string. Verify that both inputs produce the correct selected-post count.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@includes/admin/bulk-actions.php` around lines 204 - 205, Add regression tests
for custom_bulk_admin_notices() covering ids supplied as an array and as a
comma-separated string, and assert that each format produces the correct
selected-post count. Reuse the existing test setup and notice-count expectations
without changing the request parsing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@includes/admin/bulk-actions.php`:
- Around line 204-205: Add regression tests for custom_bulk_admin_notices()
covering ids supplied as an array and as a comma-separated string, and assert
that each format produces the correct selected-post count. Reuse the existing
test setup and notice-count expectations without changing the request parsing
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dc9c85ea-ac7e-46d5-b37d-a6d65b7beed3

📥 Commits

Reviewing files that changed from the base of the PR and between 37134fd and 2c601ce.

📒 Files selected for processing (1)
  • includes/admin/bulk-actions.php

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