Skip to content
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

ext/standard: Refactor unserialization callback function call #17484

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jan 16, 2025

This also stores the callback function name as a zend_string

Comment on lines +1250 to +1251
/* Find unserialize callback */
zend_function *callback_fn = zend_hash_find_ptr_lc(EG(function_table), PG(unserialize_callback_func));
Copy link
Member

Choose a reason for hiding this comment

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

This breaks some valid callback names, such as:

  • \foo (leading \)
  • Foo::bar (static method)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I didn't think of static methods, I'll add some tests to ensure this doesn't get missed. And I'll think about a solution if there is a good one.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't understand why you replaced call_user_function() with a manual function lookup + zend_call_known_function. Is there a particular reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am trying to see if it is possible to get rid of the function_name field of the FCI struct, and there are not many uses of call_user_function() (currently 29) on top of it having the now useless symbol_table argument (yes I know it's a macro so it doesn't matter).

Comment on lines +1252 to +1256
if (callback_fn == NULL) {
zend_string_release_ex(class_name, 0);
zend_throw_error(NULL, "Unserialization function %s is not defined", ZSTR_VAL(PG(unserialize_callback_func)));
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This uses space indentation

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.

2 participants