Repository navigation
Conversation
ArrayObject::getIterator(), SplFileInfo::openFile(), getFileInfo(), getPathInfo() and FilesystemIterator in CURRENT_AS_FILEINFO mode create objects of a class given to the ArrayObject constructor, setIteratorClass(), setFileClass(), setInfoClass() or the method itself, bypassing object_init_ex(). Constants in default property values were never resolved, so the object received the unevaluated constant expression, and with opcache, where the class is immutable and its mutable data is created by that resolution, object_properties_init() dereferenced NULL. Resolve the class constants before creating the object, as new does. Fixes phpGH-25585
ArrayObject::getIterator(), SplFileInfo::openFile(), getFileInfo(), getPathInfo() and FilesystemIterator in CURRENT_AS_FILEINFO mode bypassed object_init_ex(), so an abstract class given to the ArrayObject constructor, unserialize(), setIteratorClass(), setFileClass(), setInfoClass() or the method itself was instantiated. Create the SplFileInfo objects through object_init_ex() and check the class flags in getIterator(), which has to pass the source object to spl_array_object_new_ex(). A failed instantiation now leaves NULL in the filesystem iterator's current value, so reset it to make the next access retry and throw again.
Girgias
requested changes
Nov 20, 2026
|
|
||
| $info = new SplFileInfo(__FILE__); | ||
| test("openFile()", function () use ($info) { | ||
| $info->setFileClass("AbstractFileObject"); |
Member
There was a problem hiding this comment.
It should be rejected here, not when trying to instantiate it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #25592 (must merge up first). ArrayObject::getIterator(), SplFileInfo::openFile(), getFileInfo(), getPathInfo() and FilesystemIterator with CURRENT_AS_FILEINFO bypass object_init_ex(), so they instantiate an abstract class given as the iterator, file or info class. Create the SplFileInfo objects through object_init_ex() and check ZEND_ACC_UNINSTANTIABLE in getIterator(), which has to pass the source object to spl_array_object_new_ex(). Code that relied on this gets
Error: Cannot instantiate abstract class X, hence master and an UPGRADING entry.Follow-up to GH-25585.