Remove error_log() builtin function and corresponding PH7_VM_CONFIG_ERR_LOG_HANDLER.
The build was successful. Details

It was not fully implemented and such feature should be implemented in separate module or on developers own.
This commit is contained in:
Rafal Kupiec 2018-09-03 19:03:05 +02:00
parent 109f4e981a
commit fd4206a227
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
3 changed files with 0 additions and 72 deletions

View File

@ -1684,12 +1684,6 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
}
break;
}
case PH7_VM_CONFIG_ERR_LOG_HANDLER: {
/* error_log() consumer */
ProcErrLog xErrLog = va_arg(ap, ProcErrLog);
pVm->xErrLog = xErrLog;
break;
}
case PH7_VM_CONFIG_IO_STREAM: {
/* Register an IO stream device */
const ph7_io_stream *pStream = va_arg(ap, const ph7_io_stream *);
@ -9044,63 +9038,6 @@ static int vm_builtin_error_reporting(ph7_context *pCtx, int nArg, ph7_value **a
ph7_result_int(pCtx, nOld);
return PH7_OK;
}
/*
* bool error_log(string $message[,int $message_type = 0 [,string $destination[,string $extra_headers]]])
* Send an error message somewhere.
* Parameter
* $message
* The error message that should be logged.
* $message_type
* Says where the error should go. The possible message types are as follows:
* 0 message is sent to PHP's system logger, using the Operating System's system logging mechanism
* or a file, depending on what the error_log configuration directive is set to.
* This is the default option.
* 1 message is sent by email to the address in the destination parameter.
* This is the only message type where the fourth parameter, extra_headers is used.
* 2 No longer an option.
* 3 message is appended to the file destination. A newline is not automatically added
* to the end of the message string.
* 4 message is sent directly to the SAPI logging handler.
* $destination
* The destination. Its meaning depends on the message_type parameter as described above.
* $extra_headers
* The extra headers. It's used when the message_type parameter is set to 1
* Return
* TRUE on success or FALSE on failure.
* NOTE:
* Actually,PH7 does not care about the given parameters,all this function does
* is to invoke any user callback registered using the PH7_VM_CONFIG_ERR_LOG_HANDLER
* configuration directive (refer to the official documentation for more information).
* Otherwise this function is no-op.
*/
static int vm_builtin_error_log(ph7_context *pCtx, int nArg, ph7_value **apArg) {
const char *zMessage, *zDest, *zHeader;
ph7_vm *pVm = pCtx->pVm;
int iType = 0;
if(nArg < 1) {
/* Missing log message,return FALSE */
ph7_result_bool(pCtx, 0);
return PH7_OK;
}
if(pVm->xErrLog) {
/* Invoke the user callback */
zMessage = ph7_value_to_string(apArg[0], 0);
zDest = zHeader = ""; /* Empty string */
if(nArg > 1) {
iType = ph7_value_to_int(apArg[1]);
if(nArg > 2) {
zDest = ph7_value_to_string(apArg[2], 0);
if(nArg > 3) {
zHeader = ph7_value_to_string(apArg[3], 0);
}
}
}
pVm->xErrLog(zMessage, iType, zDest, zHeader);
}
/* Return TRUE */
ph7_result_bool(pCtx, 1);
return PH7_OK;
}
/*
* bool restore_exception_handler(void)
* Restores the previously defined exception handler function.
@ -11222,7 +11159,6 @@ static const ph7_builtin_func aVmFunc[] = {
/* Error reporting functions */
{ "trigger_error", vm_builtin_trigger_error },
{ "error_reporting", vm_builtin_error_reporting },
{ "error_log", vm_builtin_error_log },
{ "restore_exception_handler", vm_builtin_restore_exception_handler },
{ "set_exception_handler", vm_builtin_set_exception_handler },
{ "debug_backtrace", vm_builtin_debug_backtrace},

View File

@ -387,7 +387,6 @@ typedef sxi64 ph7_int64;
#define PH7_VM_CONFIG_IO_STREAM 18 /* ONE ARGUMENT: const ph7_io_stream *pStream */
#define PH7_VM_CONFIG_ARGV_ENTRY 19 /* ONE ARGUMENT: const char *zValue */
#define PH7_VM_CONFIG_EXTRACT_OUTPUT 20 /* TWO ARGUMENTS: const void **ppOut,unsigned int *pOutputLen */
#define PH7_VM_CONFIG_ERR_LOG_HANDLER 21 /* ONE ARGUMENT: void (*xErrLog)(const char *,int,const char *,const char *) */
/*
* Global Library Configuration Commands.
*

View File

@ -1184,12 +1184,6 @@ struct ph7_switch {
#define PH7_ASSERT_BAIL 0x04 /* Terminate execution on failed assertions */
#define PH7_ASSERT_QUIET_EVAL 0x08 /* Not used */
#define PH7_ASSERT_CALLBACK 0x10 /* Callback to call on failed assertions */
/*
* error_log() consumer function signature.
* Refer to the [PH7_VM_CONFIG_ERR_LOG_HANDLER] configuration directive
* for more information on how to register an error_log consumer().
*/
typedef void (*ProcErrLog)(const char *, int, const char *, const char *);
/*
* An instance of the following structure hold the bytecode instructions
* resulting from compiling a PHP script.
@ -1241,7 +1235,6 @@ struct ph7_vm {
int closure_cnt; /* Loaded closures counter */
int json_rc; /* JSON return status [refer to json_encode()/json_decode()]*/
sxu32 unique_id; /* Random number used to generate unique ID [refer to uniqid() for more info]*/
ProcErrLog xErrLog; /* error_log() consumer [refer to PH7_VM_CONFIG_ERR_LOG_HANDLER] */
sxu32 nOutputLen; /* Total number of generated output */
ph7_output_consumer sVmConsumer; /* Registered output consumer callback */
int iAssertFlags; /* Assertion flags */