Handle array-like unserialized objects without dynamic property writes#237
Conversation
Agent-Logs-Url: https://github.com/wp-cli/search-replace-command/sessions/2ed7e260-b7e2-4aea-af1a-639c57abcb09 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR updates SearchReplacer’s recursive object handling to avoid PHP 8.2 dynamic-property deprecation notices and to correctly write replaced values back into array-like objects (e.g., ArrayAccess-based dictionaries) using offset assignment.
Changes:
- Updated recursive replacement for iterated objects to write back via
$data[$key] = ...when the object implements\ArrayAccess. - Preserved the existing property-assignment path for non-
\ArrayAccessobjects. - Added a Behat regression scenario covering serialized
WpOrg\Requests\Utility\CaseInsensitiveDictionaryreplacement and ensuring no stderr output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/WP_CLI/SearchReplacer.php |
Adjusts object recursion to update ArrayAccess objects via offsets instead of dynamic properties. |
features/search-replace.feature |
Adds an acceptance test scenario to validate correct behavior and avoid PHP 8.2 deprecation noise. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/wp-cli/search-replace-command/sessions/465c889c-defb-4d7e-994e-41876a460be2 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the SearchReplacer to correctly handle objects implementing \ArrayAccess during recursive search and replace operations. By checking for \ArrayAccess and using array syntax for assignment where appropriate, the change avoids potential dynamic property deprecation warnings and ensures compatibility with dictionary-like objects. A new test scenario was added to verify this behavior using CaseInsensitiveDictionary. I have no feedback to provide as there were no review comments.
PHP 8.2 surfaces deprecation notices when
search-replacerecurses into unserialized array-like objects such asWpOrg\Requests\Utility\CaseInsensitiveDictionary. The current recursion path also writes replacements back incorrectly for these objects by assigning dynamic properties instead of updating their underlying dictionary storage.What changed
SearchReplacerobject recursion to detectArrayAccessobjects and write replaced values back through array-style offsets.Why this matters
Regression coverage
WpOrg\Requests\Utility\CaseInsensitiveDictionarydata.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/usr/bin/php /usr/bin/php /home/REDACTED/work/search-replace-command/search-replace-command/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php core install --url=REDACTED --title=WP CLI Site --admin_user=admin --admin_email=admin@example.com --admin_password=password1 --skip-email(dns block)If you need me to access, download, or install something from one of these locations, you can either: