Skip to content

Add libxml_get_external_entity_loader() #7977

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

Closed
wants to merge 1 commit into from

Conversation

@bukka
Copy link
Member

bukka commented Jul 19, 2022

Apology for the late review. Personally I would prefer introducing a new function for this (could be simply libxml_get_external_entity_loader) as it won't break backward compatibility which this does in a way that this will no longer work:

if (libxml_set_external_entity_loader($loader) === true) {
    // do something
}

I actually did a bit of search in GitHub and haven't found such piece of code (just comparisons with false that would still work) but that doesn't mean that there is no such code in private repos. So think it's not worth to risk breaking that.

@tstarling tstarling force-pushed the return-previous-loader branch from dfacdbf to 95f07fe Compare July 29, 2022 04:04
@tstarling
Copy link
Contributor Author

@bukka Done. Do you want me to squash the commits or write some docs?

@tstarling
Copy link
Contributor Author

Is this ready to go now? I think I have responded to all the comments.

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

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

It looks good to me. Please can you squash it?

@tstarling tstarling force-pushed the return-previous-loader branch from 300746d to 0466b35 Compare August 13, 2022 03:47
@tstarling
Copy link
Contributor Author

@bukka Done, squashed

@bukka
Copy link
Member

bukka commented Aug 18, 2022

@tstarling Just FYI I messaged internals if this and few other things could be added before the first 8.2 RC. If there are no objection, I will merge it later next week. If you have some spare time and could maybe use that Z_PARAM_FUNC_OR_NULL_WITH_ZVAL instead as discussed above that would be awesome!

@jrfnl
Copy link
Contributor

jrfnl commented Aug 18, 2022

🎗️ If this does go into PHP 8.2, it will need a changelog entry in UPGRADING introducing the new function.

@tstarling tstarling changed the title Make libxml_set_external_entity_loader() return the previous loader Add libxml_get_external_entity_loader() Aug 18, 2022
Add libxml_get_external_entity_loader(), which returns the currently
installed external entity loader, i.e. the value which was passed to
libxml_set_external_entity_loader() or null if no loader was installed
and the default entity loader will be used.

This allows libraries to save and restore the loader, controlling entity
expansion without interfering with the rest of the application.

Add macro Z_PARAM_FUNC_OR_NULL_WITH_ZVAL(). This allows us to get the
zval for a callable parameter without duplicating callable argument
parsing.

The saved zval keeps the object needed for fcc/fci alive, simplifying
memory management.

Fixes #76763.
@tstarling tstarling force-pushed the return-previous-loader branch from 0466b35 to 35117a6 Compare August 19, 2022 03:10
@tstarling
Copy link
Contributor Author

I added Z_PARAM_FUNC_OR_NULL_WITH_ZVAL() and added an entry to UPGRADING.

@tstarling
Copy link
Contributor Author

AppVeyor says

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test hrtime() aligns with microtime() [C:\projects\php-src\ext\standard\tests\hrtime\hrtime.phpt]
=====================================================================

Pretty sure that's not my fault.

@bukka
Copy link
Member

bukka commented Aug 28, 2022

Merged via 1179622 . Thanks!

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.

5 participants