Repository navigation
Conversation
PHP 8.6 deprecates calling `is_a()` with a string when `$allow_string` is false. `IXR_Server` checks method results, which are often strings, with `is_a( $result, 'IXR_Error' )`, and `IXR_IntrospectionServer` does the same for `date` arguments. `instanceof` gives the same result without the deprecation. Props dhrupo. Fixes #66418.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
For a PHP 8.6 run on trunk, I do see the these errors:
17) Tests_XMLRPC_Basic::test_multicall_with_non_array_params Calling is_a() with a string when $allow_string is false /var/www/src/wp-includes/IXR/class-IXR-server.php:237 /var/www/tests/phpunit/tests/xmlrpc/basic.php:181 18) Tests_XMLRPC_Basic::test_multicall_with_missing_params Calling is_a() with a string when $allow_string is false /var/www/src/wp-includes/IXR/class-IXR-server.php:237 /var/www/tests/phpunit/tests/xmlrpc/basic.php:245 19) Tests_XMLRPC_Basic::test_multicall_with_non_struct_entry Calling is_a() with a string when $allow_string is false /var/www/src/wp-includes/IXR/class-IXR-server.php:237 /var/www/tests/phpunit/tests/xmlrpc/basic.php:282 20) Tests_XMLRPC_Basic::test_multicall_with_missing_method_name Calling is_a() with a string when $allow_string is false /var/www/src/wp-includes/IXR/class-IXR-server.php:237 /var/www/tests/phpunit/tests/xmlrpc/basic.php:309
These are fixed in the corresponding run on this branch.
Replace the `is_object() && is_a()` checks for `IXR_Date` and `IXR_Base64` with `instanceof`, which drops the redundant `is_object()` guard and matches the class checks in `IXR_Server` and `IXR_IntrospectionServer`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add tests for the IXR code paths that check values against an IXR class: `IXR_Server::multiCall()` with scalar and array method results, `IXR_IntrospectionServer::call()` with string, class-name, and integer arguments for a date parameter (and with a real `IXR_Date`), and `IXR_Value::calculateType()` for date, base64, and string values. With deprecations converted to exceptions, these fail on PHP 8.6 if any of the checks goes back to calling `is_a()` with a string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@dhrupo Please review my additional changes. |
|
Looks great, thanks for extending it. The |
Matches the IXR change: PHP 8.6 deprecates `is_a()` with a string when `$allow_string` is false. Text_Diff edits are always `Text_Diff_Op` objects, so the result does not change; this keeps the bundled library consistent with the rest of core. Adds tests for the edit counts and checks that use these class checks. See #66418.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the changes are accompanied by regression coverage for the updated XML-RPC and Text Diff type checks.
No open issues 🎉
What changed in this PR
This pull request replaces deprecated is_a() checks with instanceof in the XML-RPC IXR and Text Diff implementations, avoiding PHP 8.6 deprecation notices while preserving type-checking behavior.
Changes:
- Updated IXR server, introspection, and value checks to use
instanceof. - Updated Text Diff operation and renderer checks.
- Added XML-RPC and Text Diff regression coverage.
| File | Description |
|---|---|
tests/phpunit/tests/xmlrpc/basic.php |
Adds regression coverage for XML-RPC type checks, scalar results, date arguments, and IXR values. |
tests/phpunit/tests/diff/textDiff.php |
Adds coverage for Text Diff operation counts and copied context rendering. |
src/wp-includes/Text/Diff/Renderer.php |
Uses instanceof when processing copied diff blocks. |
src/wp-includes/Text/Diff.php |
Uses instanceof for diff operation classification. |
src/wp-includes/IXR/class-IXR-value.php |
Uses instanceof for IXR date and base64 value detection. |
src/wp-includes/IXR/class-IXR-server.php |
Uses instanceof IXR_Error for regular and multicall responses. |
src/wp-includes/IXR/class-IXR-introspectionserver.php |
Uses instanceof IXR_Date for date argument validation. |
Review effort: Lite
peterwilsoncc
left a comment
There was a problem hiding this comment.
The source changes look good to me. I've added some notes in the test suite.
| /** | ||
| * Data provider. | ||
| * | ||
| * @return array[] |
There was a problem hiding this comment.
Use a phpstan return type... @westonruter pinging you for advice here.
| } | ||
|
|
||
| /** | ||
| * @ticket 66418 |
There was a problem hiding this comment.
Add a one line summary at the top of each test.
For this one it might be:
/**
* Ensure edit counts are correct.
🔢 Applies to other tests too.
| $this->assertIXRError( $result ); | ||
| $this->assertSame( -32602, $result->code ); |
There was a problem hiding this comment.
Tests with multiple assertions should have a unique $message parameter for each assertion. This is to aid debugging at a later date.
🔢 Applies to other new tests with multiple assertions.
PHP 8.6 deprecates calling
is_a()with a string when$allow_stringis false.IXR_Serverchecks method results, which are often strings, withis_a( $result, 'IXR_Error' ), andIXR_IntrospectionServerdoes the same fordatearguments. This usesinstanceof, which gives the same result without the deprecation.Testing
--group xmlrpchas 4 errors (theTests_XMLRPC_Basic::test_multicall_*tests, "Calling is_a() with a string when $allow_string is false").OK (368 tests, 1383 assertions)on PHP 7.4.33, 8.5.12 and 8.6.0-dev.Trac ticket: https://core.trac.wordpress.org/ticket/66418
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Finding the issue by running the test suite on PHP 8.6, writing the change and running the checks above. I reviewed the change and checked the results myself.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.