Skip to content
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

Replace (int) parser conversion with spl_object_hash #875

Merged
merged 11 commits into from
Mar 10, 2025
Merged

Conversation

onli
Copy link
Member

@onli onli commented Feb 23, 2025

The (int) conversion does not work anymore since PHP 8 changed the xml parser from being a resource to being an object. Hardcoding it to a number, the initial fix, destroys the logic of having multiple parsers available and was not done everywhere. The object hash approach should be a valid replacement.

Draft, as still to be tested. Fixes #874

onli added 10 commits February 23, 2025 08:59
The (int) conversion does not work anymore since PHP 8 changed the xml parser from being a resource to being an object. Hardcoding it to a number, the initial fix, destroys the logic of having multiple parsers available and was not done everywhere. The object hash approach should be a valid replacement.
@onli onli marked this pull request as ready for review February 25, 2025 00:33
@onli onli requested a review from garvinhicking February 25, 2025 00:34
@onli
Copy link
Member Author

onli commented Feb 25, 2025

I added tests and made them pass.

Main question now: This approach of patching our old XML/RPC.php, is that the way we want to continue? The lib was already patched for s9y, so I went that route. But also because I saw no clear maintained replacement - https://pear.php.net/package/XML_RPC points to the abandoned https://pear.php.net/package/XML_RPC2.

If there is a candidate, that could be suggested instead. https://gggeek.github.io/phpxmlrpc/ looks good, but would be a different API - probably easy enough for serendipity_event_weblogping, but I did not look into serendipity_event_xmlrpc, where the server component could change a lot.

Edit: By now I'm convinced we should merge this. If/when we want to replace the lib it can be a separate task, ideally for someone wanting to maintain serendipity_event_xmlrpc.

Copy link
Member

@garvinhicking garvinhicking left a comment

Choose a reason for hiding this comment

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

Looking good, just two minor things!

@@ -1433,7 +1433,9 @@ function parseResponse($data = '')

$encoding = $this->getEncoding($data);
$parser_resource = xml_parser_create($encoding);
$parser = 1;
Copy link
Member

Choose a reason for hiding this comment

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

This was a scalar value, maybe copy pasta mistake?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was a mistake I did in a6619f7#r152820624. I needed a replacement for (int) $parser_resource;, and though this could just be hardcoded to a number. That might even be feasible, but not when changing it only at one of the places that creates $parser like this. The replacement is the point of this PR, to use $parser = is_resource($parser_resource) ? ((int) $parser_resource) : spl_object_hash($parser_resource); everywhere.

Co-authored-by: Garvin Hicking <blog@garv.in>
@onli onli merged commit 3b8cead into master Mar 10, 2025
5 checks passed
@onli onli deleted the feature/PHP8RPCfix branch March 10, 2025 15:24
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.

Fix XML/RPC parser_resource approach
2 participants