summaryrefslogtreecommitdiff
path: root/ext/opcache/zend_accelerator_module.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/opcache/zend_accelerator_module.c')
-rw-r--r--ext/opcache/zend_accelerator_module.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index d68ab9531a..d2d847678e 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -116,7 +116,7 @@ static ZEND_INI_MH(OnEnable)
return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
} else {
/* It may be only temporary disabled */
- zend_bool *p = (zend_bool *) ZEND_INI_GET_ADDR();
+ bool *p = (bool *) ZEND_INI_GET_ADDR();
if ((ZSTR_LEN(new_value) == 2 && strcasecmp("on", ZSTR_VAL(new_value)) == 0) ||
(ZSTR_LEN(new_value) == 3 && strcasecmp("yes", ZSTR_VAL(new_value)) == 0) ||
(ZSTR_LEN(new_value) == 4 && strcasecmp("true", ZSTR_VAL(new_value)) == 0) ||
@@ -310,17 +310,21 @@ ZEND_INI_END()
static int filename_is_in_cache(zend_string *filename)
{
- char *key;
- int key_length;
+ zend_string *key;
- key = accel_make_persistent_key(ZSTR_VAL(filename), ZSTR_LEN(filename), &key_length);
+ key = accel_make_persistent_key(filename);
if (key != NULL) {
- zend_persistent_script *persistent_script = zend_accel_hash_str_find(&ZCSG(hash), key, key_length);
+ zend_persistent_script *persistent_script = zend_accel_hash_find(&ZCSG(hash), key);
if (persistent_script && !persistent_script->corrupted) {
if (ZCG(accel_directives).validate_timestamps) {
zend_file_handle handle;
- zend_stream_init_filename(&handle, ZSTR_VAL(filename));
- return validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS;
+ int ret;
+
+ zend_stream_init_filename_ex(&handle, filename);
+ ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS
+ ? 1 : 0;
+ zend_destroy_file_handle(&handle);
+ return ret;
}
return 1;
@@ -332,15 +336,14 @@ static int filename_is_in_cache(zend_string *filename)
static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
{
- zval zfilename;
+ if (ZEND_NUM_ARGS() == 1) {
+ zval *zv = ZEND_CALL_ARG(execute_data , 1);
- if (ZEND_NUM_ARGS() != 1 ||
- zend_get_parameters_array_ex(1, &zfilename) == FAILURE ||
- Z_TYPE(zfilename) != IS_STRING ||
- Z_STRLEN(zfilename) == 0) {
- return 0;
+ if (Z_TYPE_P(zv) == IS_STRING && Z_STRLEN_P(zv) != 0) {
+ return filename_is_in_cache(Z_STR_P(zv));
+ }
}
- return filename_is_in_cache(Z_STR(zfilename));
+ return 0;
}
static ZEND_NAMED_FUNCTION(accel_file_exists)
@@ -572,7 +575,7 @@ ZEND_FUNCTION(opcache_get_status)
{
zend_long reqs;
zval memory_usage, statistics, scripts;
- zend_bool fetch_scripts = 1;
+ bool fetch_scripts = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &fetch_scripts) == FAILURE) {
RETURN_THROWS();
@@ -837,11 +840,10 @@ ZEND_FUNCTION(opcache_reset)
/* {{{ Invalidates cached script (in necessary or forced) */
ZEND_FUNCTION(opcache_invalidate)
{
- char *script_name;
- size_t script_name_len;
- zend_bool force = 0;
+ zend_string *script_name;
+ bool force = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &script_name, &script_name_len, &force) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &script_name, &force) == FAILURE) {
RETURN_THROWS();
}
@@ -849,7 +851,7 @@ ZEND_FUNCTION(opcache_invalidate)
RETURN_FALSE;
}
- if (zend_accel_invalidate(script_name, script_name_len, force) == SUCCESS) {
+ if (zend_accel_invalidate(script_name, force) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -858,14 +860,13 @@ ZEND_FUNCTION(opcache_invalidate)
ZEND_FUNCTION(opcache_compile_file)
{
- char *script_name;
- size_t script_name_len;
+ zend_string *script_name;
zend_file_handle handle;
zend_op_array *op_array = NULL;
zend_execute_data *orig_execute_data = NULL;
uint32_t orig_compiler_options;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &script_name, &script_name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &script_name) == FAILURE) {
RETURN_THROWS();
}
@@ -874,7 +875,7 @@ ZEND_FUNCTION(opcache_compile_file)
RETURN_FALSE;
}
- zend_stream_init_filename(&handle, script_name);
+ zend_stream_init_filename_ex(&handle, script_name);
orig_execute_data = EG(current_execute_data);
orig_compiler_options = CG(compiler_options);
@@ -890,7 +891,7 @@ ZEND_FUNCTION(opcache_compile_file)
op_array = persistent_compile_file(&handle, ZEND_INCLUDE);
} zend_catch {
EG(current_execute_data) = orig_execute_data;
- zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " could not compile file %s", handle.filename);
+ zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " could not compile file %s", ZSTR_VAL(handle.filename));
} zend_end_try();
}
@@ -911,9 +912,9 @@ ZEND_FUNCTION(opcache_is_script_cached)
{
zend_string *script_name;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &script_name) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STR(script_name)
+ ZEND_PARSE_PARAMETERS_END();
if (!validate_api_restriction()) {
RETURN_FALSE;