-
Notifications
You must be signed in to change notification settings - Fork 89
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
Conversation
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.
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 |
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.
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; |
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.
This was a scalar value, maybe copy pasta mistake?
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.
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>
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