-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Mark filename parameter as const for zend_resolve_path() #11003
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,7 +123,7 @@ static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_ha | |
static zend_class_entry* (*accelerator_orig_inheritance_cache_get)(zend_class_entry *ce, zend_class_entry *parent, zend_class_entry **traits_and_interfaces); | ||
static zend_class_entry* (*accelerator_orig_inheritance_cache_add)(zend_class_entry *ce, zend_class_entry *proto, zend_class_entry *parent, zend_class_entry **traits_and_interfaces, HashTable *dependencies); | ||
static zend_result (*accelerator_orig_zend_stream_open_function)(zend_file_handle *handle ); | ||
static zend_string *(*accelerator_orig_zend_resolve_path)(zend_string *filename); | ||
static zend_string *(*accelerator_orig_zend_resolve_path)(const zend_string *filename); | ||
static zif_handler orig_chdir = NULL; | ||
static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL; | ||
static zend_result (*orig_post_startup_cb)(void); | ||
|
@@ -1192,7 +1192,7 @@ zend_result validate_timestamp_and_record_ex(zend_persistent_script *persistent_ | |
/* Instead of resolving full real path name each time we need to identify file, | ||
* we create a key that consist from requested file name, current working | ||
* directory, current include_path, etc */ | ||
zend_string *accel_make_persistent_key(zend_string *str) | ||
zend_string *accel_make_persistent_key(const zend_string *str) | ||
{ | ||
const char *path = ZSTR_VAL(str); | ||
size_t path_length = ZSTR_LEN(str); | ||
|
@@ -1359,7 +1359,7 @@ zend_string *accel_make_persistent_key(zend_string *str) | |
} | ||
|
||
/* not use_cwd */ | ||
return str; | ||
return (zend_string*)str; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you remove |
||
} | ||
|
||
/** | ||
|
@@ -2517,7 +2517,7 @@ static zend_result persistent_stream_open_function(zend_file_handle *handle) | |
} | ||
|
||
/* zend_resolve_path() replacement for PHP 5.3 and above */ | ||
static zend_string* persistent_zend_resolve_path(zend_string *filename) | ||
static zend_string* persistent_zend_resolve_path(const zend_string *filename) | ||
{ | ||
if (!file_cache_only && | ||
ZCG(accelerator_enabled)) { | ||
|
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
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
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
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
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
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.
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.
In general,
zend_resolve_path()
may return the same string and in case of non-interned string this requires incrementation if reference counter.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.
Right, this makes sense, but are we not doing this in practice because
tsrm_realpath()
still returns achar *
?Also, shouldn't the ZendAccelerator implementation also increment the refcount? Instead of doing what it does by returning the pointer directly instead of
zend_string_copy(str);
?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_string_copy()
just increment the refcount and return the same string. See https://github.com/php/php-src/blob/master/Zend/zend_string.h#L236There 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.
Yes. It would be great to switch to
zend_string
in all related functions, but this is going to be a big and not simple patch.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.
Yes I know this, my question is why in ZendAccelerator.c the string is returned directly without incrementing the refcount, as after your explanation it seems this should be done.