Skip to content

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Oct 16, 2025

No description provided.

@Girgias Girgias marked this pull request as ready for review October 16, 2025 09:53
@Girgias Girgias requested a review from nielsdos October 16, 2025 09:53
/* }}} */

static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, char *f404, size_t f404_len) /* {{{ */
static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, zend_string *f404) /* {{{ */
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this particular commit is an improvement as it just adds extra NULL checks

Copy link
Member Author

Choose a reason for hiding this comment

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

My main motivation was to make phar_file_action() use zend_strings in the long run, but to do so I need all the inputs to ideally also be zstrs

Copy link
Member

Choose a reason for hiding this comment

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

Does phar_file_action benefit that much from zend_strings?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could propagate it down to phar_mung_server_vars() to use some nicer zstr APIs and prevent a call to ZVAL_STRINGL()

Copy link
Member

Choose a reason for hiding this comment

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

Okay I see, fine then

#include "stub.h" /* Generated phar_get_stub() function from makestub.php script */

zend_string *phar_create_default_stub(const char *index_php, const char *web_index, char **error) /* {{{ */
zend_string *phar_create_default_stub(const zend_string *php_index_str, const zend_string *web_index_str, char **error) /* {{{ */
Copy link
Member

Choose a reason for hiding this comment

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

I think the old code in this function is clearer.
High chance that the compiler pre-computes the string length anyway in the !index and !web_index branches, so no need to optimize that.
The changes to "P" instead of "S" in ZPP should be kept though

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I also keep the change where it returns NULL in case the path is over 400 even if error == NULL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also the other motivation was to get rid of a strlen call that is not needed

Copy link
Member

Choose a reason for hiding this comment

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

Should I also keep the change where it returns NULL in case the path is over 400 even if error == NULL?

Yes

Also the other motivation was to get rid of a strlen call that is not needed

Right, but I think the compiler is smart enough to avoid it.

Anyway, reading this again it's clearer to me now, so you may keep it anyway.

@Girgias Girgias merged commit ad9c60f into php:master Oct 16, 2025
9 of 10 checks passed
@Girgias Girgias deleted the phar-web-zstr branch October 16, 2025 20:29
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