-
Notifications
You must be signed in to change notification settings - Fork 8k
Zend: move class autoloading from SPL to Zend #21001
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
base: master
Are you sure you want to change the base?
Conversation
|
This would make the session extension not depend on the spl, yes (meaning the https://bugs.php.net/53141 would be resolved). But the main issue there would still be present - that loop of the registered extensions isn't done optimal yet and it has issues with cyclic dependencies (extension A depends on B, and extension B depends on A). |
2e649a2 to
534f17c
Compare
The primary motivation for this change is that this sort of functionality should reside in core and not in an extension. The reason being is that this causes issues in regard to extension dependencies and resolution, something that prevents phpGH-14544.
534f17c to
03d0260
Compare
Are there any other case of cyclic dependencies? Because if not and if we can detect them and error during build/compilation, that would be a more sensible approach IMHO. As cyclic dependencies just cause a lot of pain. |
Yes. Probably there are. That loop would need to be refactored somehow. Because there might be cases like this: And I can't be sure here. When looping through a list of all enabled extensions (that is retrieved from the
And that first part is probably needed for cases as described in above linked issue (or in that session and spl hidden dependency). I can't explain this properly as I would need to go through the code in more details to better understand this issue and use proper terminology here. Basically, what the code should ideally do is:
For example, another issue here is this: #14067 But I totally understand that doing this is difficult. So whatever you can do here, all good and I agree. |
| return false; | ||
| } | ||
|
|
||
| ZEND_API void zend_autoload_fcc_map_to_callable_zval_map(zval *return_value) { |
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.
| ZEND_API void zend_autoload_fcc_map_to_callable_zval_map(zval *return_value) { | |
| ZEND_API zend_array *zend_class_autoload_functions_as_callables(void) { |
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.
If I do this I seem to be hitting a GC issue if I return (zend_array*)&zend_empty_array; and then on the call site just do RETURN_ARR(zend_autoload_fcc_map_to_callable_zval_map());.
Do I need to do something special?
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.
Oh I see, that's because zend_empty_array is not collectable so the zval must be marked as such. ZVAL_EMPTY_ARRAY() takes care of that, but it can not be achieved cleanly with the signature I was suggesting.
So I withdraw the signature change from my suggestion:
ZEND_API void zend_class_autoload_functions_as_callables(zval *return_value) {
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.
Will revert then and add a comment explain why we do this :)
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.
Looks good to me otherwise (if the zend_autoload_fcc_map_to_callable_zval_map() change I suggested earlier is reverted)
The primary motivation for this change is that this sort of functionality should reside in core and not in an extension.
The reason being is that this causes issues in regard to extension dependencies and resolution, something that prevents GH-14544.
Moreover, we might want to extend the autoloading functionality (by allowing other symbols to be autoloader or registering a class map).