Skip to content

ext/xml: Refactor extension to use FCC instead of zvals for handlers - #12340

Merged
Girgias merged 26 commits into
php:masterfrom
Girgias:ext-xml-zval-to-fcc
Oct 20, 2023
Merged

ext/xml: Refactor extension to use FCC instead of zvals for handlers#12340
Girgias merged 26 commits into
php:masterfrom
Girgias:ext-xml-zval-to-fcc

Conversation

@Girgias

@Girgias Girgias commented Oct 1, 2023

Copy link
Copy Markdown
Member

To get proper errors and sensible behaviour, as the current behaviour is somewhat insane and part of it should be axed ASAP

Skipping CI due to known issues and failures regarding the GC and exceptions being swallowed

@Girgias
Girgias requested a review from ndossche October 1, 2023 18:26
@Girgias Girgias changed the title [skip ci] [W.I.P.] ext/xml: Refactor extension to use FCC instead of zvals for handlers [W.I.P.] ext/xml: Refactor extension to use FCC instead of zvals for handlers Oct 1, 2023
@Girgias
Girgias force-pushed the ext-xml-zval-to-fcc branch from 88ad6ff to 01a8927 Compare October 1, 2023 18:34
@Girgias

Girgias commented Oct 1, 2023

Copy link
Copy Markdown
Member Author

Related to: php/doc-en#1391

@ndossche

ndossche commented Oct 1, 2023

Copy link
Copy Markdown
Member

Pushed fixes, ext/xml tests now pass, but I haven't given this a full review yet (and there's some TODOs, so I'll wait maybe for those)

EDIT: this test fails Zend/tests/arginfo_zpp_mismatch.phpt: xml.c:1250: zif_xml_set_character_data_handler: Assertion parser' failed`, so probably a check missing or an assertion that should be a check instead. All ext/xml tests succeed though

@Girgias
Girgias force-pushed the ext-xml-zval-to-fcc branch from 1afecb6 to 3c66a18 Compare October 3, 2023 13:51
@Girgias
Girgias marked this pull request as ready for review October 3, 2023 13:51
@Girgias Girgias changed the title [W.I.P.] ext/xml: Refactor extension to use FCC instead of zvals for handlers ext/xml: Refactor extension to use FCC instead of zvals for handlers Oct 3, 2023

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks mostly good, just minor comments.
And a potential BC problem, it's a problem because it's silent imo unlike the other BC change.

Comment thread UPGRADING Outdated
Comment thread ext/xml/xml.c Outdated
Comment thread ext/xml/xml.c Outdated
Comment thread ext/xml/xml.c Outdated
Comment thread ext/xml/xml.c Outdated
Comment thread ext/xml/xml.c Outdated
Comment thread ext/xml/xml.c Outdated
Comment thread ext/xml/xml.c Outdated
Comment thread UPGRADING Outdated
@Girgias
Girgias force-pushed the ext-xml-zval-to-fcc branch from f7a6fd4 to f9ccae9 Compare October 9, 2023 14:05
@Girgias
Girgias force-pushed the ext-xml-zval-to-fcc branch from f9ccae9 to edc99d5 Compare October 10, 2023 13:31

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good apart from two silly nits.
Thanks for working on this.

Comment thread ext/xml/xml.c Outdated
Comment thread ext/xml/tests/set_element_handler_trampoline_errors.phpt
k00ni added a commit to semsol/arc2 that referenced this pull request Oct 20, 2023
Use proper callables instead.

Related to: php/php-src#12340

Co-authored-by: Konrad Abicht <hi@inspirito.de>
@Girgias
Girgias merged commit 0e5d654 into php:master Oct 20, 2023
@Girgias
Girgias deleted the ext-xml-zval-to-fcc branch October 20, 2023 12:14
Comment thread ext/xml/xml.stub.php
* @param callable $start_handler
* @param callable $end_handler
*/
function xml_set_element_handler(XMLParser $parser, $start_handler, $end_handler): true {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @Girgias you changed the stub signature from callable to callable|string|null.

Can you confirm this is not a PHP 8.4-related change, and this should have been the original param phpdoc ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes and no. The string needs to be the name of a method that exists on the object passed to xml_set_object() or the empty string to disable it, however the callability check used to be only performed when attempting to call the method, rather than how a callable type check works on function setting.

So really it is meant to be callable but wasn't due to how the implementation worked, it will be ?callable in PHP 9.

adrian-enspired pushed a commit to adrian-enspired/php-src that referenced this pull request Aug 4, 2026
…hp#12340)

To get proper errors and sensible behaviour, as the current behaviour is somewhat insane and part of it should be axed ASAP.

The behaviour is mostly intact with some minor BC breaks which are mentioned in UPGRADING.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants