summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/basic_functions.c')
-rwxr-xr-xext/standard/basic_functions.c62
1 files changed, 24 insertions, 38 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 922bcab330..d0c8805fe4 100755
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1310,7 +1310,7 @@ PHP_FUNCTION(time_sleep_until)
target_ns = (uint64_t) (target_secs * ns_per_sec);
current_ns = ((uint64_t) tm.tv_sec) * ns_per_sec + ((uint64_t) tm.tv_usec) * 1000;
if (target_ns < current_ns) {
- php_error_docref(NULL, E_WARNING, "Sleep until to time is less than current time");
+ php_error_docref(NULL, E_WARNING, "Argument #1 ($timestamp) must be greater than or equal to the current time");
RETURN_FALSE;
}
@@ -1468,9 +1468,8 @@ PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_le
break;
case 2: /*send to an address */
- php_error_docref(NULL, E_WARNING, "TCP/IP option not available!");
+ zend_value_error("TCP/IP option is not available for error logging");
return FAILURE;
- break;
case 3: /*save to a file */
stream = php_stream_open_wrapper(opt, "a", IGNORE_URL_WIN | REPORT_ERRORS, NULL);
@@ -1684,10 +1683,9 @@ static int user_shutdown_function_call(zval *zv) /* {{{ */
zval retval;
if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, NULL)) {
- zend_string *function_name
- = zend_get_callable_name(&shutdown_function_entry->arguments[0]);
- php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name));
- zend_string_release_ex(function_name, 0);
+ zend_string *function_name = zend_get_callable_name(&shutdown_function_entry->arguments[0]);
+ zend_throw_error(NULL, "Registered shutdown function %s() cannot be called, function does not exist", ZSTR_VAL(function_name));
+ zend_string_release(function_name);
return 0;
}
@@ -1719,21 +1717,10 @@ static void user_tick_function_call(user_tick_function_entry *tick_fe) /* {{{ */
tick_fe->arguments + 1
) == SUCCESS) {
zval_ptr_dtor(&retval);
-
} else {
- zval *obj, *method;
-
- if (Z_TYPE_P(function) == IS_STRING) {
- php_error_docref(NULL, E_WARNING, "Unable to call %s() - function does not exist", Z_STRVAL_P(function));
- } else if ( Z_TYPE_P(function) == IS_ARRAY
- && (obj = zend_hash_index_find(Z_ARRVAL_P(function), 0)) != NULL
- && (method = zend_hash_index_find(Z_ARRVAL_P(function), 1)) != NULL
- && Z_TYPE_P(obj) == IS_OBJECT
- && Z_TYPE_P(method) == IS_STRING) {
- php_error_docref(NULL, E_WARNING, "Unable to call %s::%s() - function does not exist", ZSTR_VAL(Z_OBJCE_P(obj)->name), Z_STRVAL_P(method));
- } else {
- php_error_docref(NULL, E_WARNING, "Unable to call tick function");
- }
+ zend_string *function_name = zend_get_callable_name(function);
+ zend_throw_error(NULL, "Registered tick function %s() cannot be called, function does not exist", ZSTR_VAL(function_name));
+ zend_string_release(function_name);
}
tick_fe->calling = 0;
@@ -1764,7 +1751,7 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_
}
if (ret && tick_fe1->calling) {
- php_error_docref(NULL, E_WARNING, "Unable to delete tick function executed at the moment");
+ zend_throw_error(NULL, "Registered tick function cannot be unregistered while it is being executed");
return 0;
}
return ret;
@@ -1818,23 +1805,22 @@ PHP_FUNCTION(register_shutdown_function)
/* Prevent entering of anything but valid callback (syntax check only!) */
if (!zend_is_callable(&shutdown_function_entry.arguments[0], 0, NULL)) {
- zend_string *callback_name
- = zend_get_callable_name(&shutdown_function_entry.arguments[0]);
- php_error_docref(NULL, E_WARNING, "Invalid shutdown callback '%s' passed", ZSTR_VAL(callback_name));
+ zend_string *callback_name = zend_get_callable_name(&shutdown_function_entry.arguments[0]);
+ zend_argument_type_error(1, "must be a valid callback, function \"%s\" not found or invalid function name", ZSTR_VAL(callback_name));
efree(shutdown_function_entry.arguments);
- zend_string_release_ex(callback_name, 0);
- RETVAL_FALSE;
- } else {
- if (!BG(user_shutdown_function_names)) {
- ALLOC_HASHTABLE(BG(user_shutdown_function_names));
- zend_hash_init(BG(user_shutdown_function_names), 0, NULL, user_shutdown_function_dtor, 0);
- }
+ zend_string_release(callback_name);
+ RETURN_THROWS();
+ }
- for (i = 0; i < shutdown_function_entry.arg_count; i++) {
- Z_TRY_ADDREF(shutdown_function_entry.arguments[i]);
- }
- zend_hash_next_index_insert_mem(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry));
+ if (!BG(user_shutdown_function_names)) {
+ ALLOC_HASHTABLE(BG(user_shutdown_function_names));
+ zend_hash_init(BG(user_shutdown_function_names), 0, NULL, user_shutdown_function_dtor, 0);
+ }
+
+ for (i = 0; i < shutdown_function_entry.arg_count; i++) {
+ Z_TRY_ADDREF(shutdown_function_entry.arguments[i]);
}
+ zend_hash_next_index_insert_mem(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry));
}
/* }}} */
@@ -2057,7 +2043,7 @@ PHP_FUNCTION(ini_get_all)
if (extname) {
if ((module = zend_hash_str_find_ptr(&module_registry, extname, extname_len)) == NULL) {
- php_error_docref(NULL, E_WARNING, "Unable to find extension '%s'", extname);
+ php_error_docref(NULL, E_WARNING, "Extension \"%s\" cannot be found", extname);
RETURN_FALSE;
}
module_number = module->module_number;
@@ -2542,7 +2528,7 @@ PHP_FUNCTION(move_uploaded_file)
if (successful) {
zend_hash_str_del(SG(rfc1867_uploaded_files), path, path_len);
} else {
- php_error_docref(NULL, E_WARNING, "Unable to move '%s' to '%s'", path, new_path);
+ php_error_docref(NULL, E_WARNING, "Unable to move \"%s\" to \"%s\"", path, new_path);
}
RETURN_BOOL(successful);