diff --git a/aware.c b/aware.c index 4a9fe9b..e121388 100644 --- a/aware.c +++ b/aware.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 / aware | +----------------------------------------------------------------------+ - | Copyright (c) 2009 Mikko Koppanen | + | Copyright (c) Mikko Koppanen, Jess Portnoy | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -12,11 +12,14 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Mikko Kopppanen | + | Authors: | + | Mikko Kopppanen | + | Jess Portnoy | +----------------------------------------------------------------------+ */ #include "php_aware_private.h" +#include "php_aware.h" #include "Zend/zend_builtin_functions.h" #include "ext/standard/php_string.h" @@ -39,7 +42,7 @@ PHP_FUNCTION(aware_event_trigger) { char *message; int message_len; - char *error_filename; + const char *error_filename; int error_lineno = 0; long type; @@ -176,8 +179,8 @@ PHP_FUNCTION(aware_set_error_handler) /* free previous error handler */ if (AWARE_G(user_error_handler)) { - zval_dtor(AWARE_G(user_error_handler)); - FREE_ZVAL(AWARE_G(user_error_handler)); + //zval_ptr_dtor(&AWARE_G(user_error_handler)); + //FREE_ZVAL(AWARE_G(user_error_handler)); } ALLOC_INIT_ZVAL(AWARE_G(user_error_handler)); @@ -189,7 +192,7 @@ PHP_FUNCTION(aware_set_error_handler) zval_dtor(EG(user_error_handler)); ZVAL_STRING(EG(user_error_handler), "__aware_error_handler_callback", 1); } else { - zval_dtor(AWARE_G(user_error_handler)); + zval_ptr_dtor(&AWARE_G(user_error_handler)); FREE_ZVAL(AWARE_G(user_error_handler)); AWARE_G(user_error_handler) = NULL; } @@ -202,8 +205,8 @@ PHP_FUNCTION(aware_restore_error_handler) AWARE_G(orig_restore_error_handler)(INTERNAL_FUNCTION_PARAM_PASSTHRU); if (AWARE_G(user_error_handler)) { - zval_dtor(AWARE_G(user_error_handler)); - FREE_ZVAL(AWARE_G(user_error_handler)); + zval_ptr_dtor(&AWARE_G(user_error_handler)); + //FREE_ZVAL(AWARE_G(user_error_handler)); AWARE_G(user_error_handler) = NULL; } @@ -219,8 +222,8 @@ PHP_FUNCTION(aware_restore_error_handler) zend_ptr_stack_push(&AWARE_G(user_error_handlers), tmp); if (AWARE_G(user_error_handler)) { - zval_dtor(AWARE_G(user_error_handler)); - FREE_ZVAL(AWARE_G(user_error_handler)); + zval_ptr_dtor(&AWARE_G(user_error_handler)); + //FREE_ZVAL(AWARE_G(user_error_handler)); } ALLOC_INIT_ZVAL(AWARE_G(user_error_handler)); ZVAL_STRING(AWARE_G(user_error_handler), Z_STRVAL_P(tmp), 1); @@ -294,7 +297,12 @@ void php_aware_capture_error_ex(zval *event, int type, const char *error_filenam if (AWARE_G(log_backtrace)) { zval *btrace; ALLOC_INIT_ZVAL(btrace); +#if PHP_API_VERSION <= PHP_5_3_X_API_NO zend_fetch_debug_backtrace(btrace, 0, 0 TSRMLS_CC); +#else +// TODO: introduce a directive for the amount of stack frames returned instead of hard coded 1000? + zend_fetch_debug_backtrace(btrace, 0, 0 TSRMLS_CC,1000); +#endif add_assoc_zval(event, "backtrace", btrace); } @@ -358,7 +366,7 @@ void php_aware_invoke_handler(int type TSRMLS_DC, const char *error_filename, co va_end(args); } -static void php_aware_display_error_page(const char *filename) +static void php_aware_display_error_page(char *filename) { php_stream *stream = php_stream_open_wrapper(filename, "r", ENFORCE_SAFE_MODE & ~REPORT_ERRORS, NULL); @@ -404,7 +412,7 @@ void php_aware_capture_error(int type, const char *error_filename, const uint er /* Aware internal errors go through here */ MY_AWARE_EXPORTS void php_aware_original_error_cb(int type TSRMLS_DC, const char *format, ...) { - char *error_filename; + const char *error_filename; int error_lineno = 0; va_list args; @@ -515,6 +523,8 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("aware.slow_request_threshold", "0", PHP_INI_PERDIR, OnUpdateLong, slow_request_threshold, zend_aware_globals, aware_globals) STD_PHP_INI_ENTRY("aware.memory_usage_threshold", "0", PHP_INI_PERDIR, OnUpdateLong, memory_usage_threshold, zend_aware_globals, aware_globals) + STD_PHP_INI_ENTRY("aware.source_baseurl", "https://github.com/youruser/yourrepo", PHP_INI_ALL, OnUpdateString, source_baseurl, zend_aware_globals, aware_globals) + STD_PHP_INI_ENTRY("aware.appname", "JaM", PHP_INI_ALL, OnUpdateString, appname, zend_aware_globals, aware_globals) /* Display pretty error pages if display_errors=0 and the error is fatal */ STD_PHP_INI_ENTRY("aware.error_page", NULL, PHP_INI_PERDIR, OnUpdateString, error_page, zend_aware_globals, aware_globals) @@ -556,6 +566,8 @@ PHP_GINIT_FUNCTION(aware) aware_globals->orig_set_error_handler = NULL; aware_globals->user_error_handler = NULL; + aware_globals->source_baseurl = "https://github.com/youruser/yourrepo"; + aware_globals->appname = "JaM"; aware_globals->error_page = NULL; php_aware_cache_init(&(aware_globals->s_cache)); @@ -612,8 +624,9 @@ static void php_aware_restore_error_handling(TSRMLS_D) zend_ptr_stack_destroy(&AWARE_G(user_error_handlers)); if (AWARE_G(user_error_handler)) { - zval_dtor(AWARE_G(user_error_handler)); - FREE_ZVAL(AWARE_G(user_error_handler)); + //zval_dtor(AWARE_G(user_error_handler)); + //zval_ptr_dtor(&AWARE_G(user_error_handler)); + //FREE_ZVAL(AWARE_G(user_error_handler)); } if (zend_hash_find(EG(function_table), "set_error_handler", sizeof("set_error_handler"), (void **)&orig_set_error_handler) == SUCCESS) { diff --git a/aware_storage.c b/aware_storage.c index 1f8d2f4..abe637d 100644 --- a/aware_storage.c +++ b/aware_storage.c @@ -197,8 +197,8 @@ void php_aware_storage_store(php_aware_storage_module *mod, const char *uuid, zv php_aware_original_error_cb(E_WARNING TSRMLS_CC, "Failed to connect the storage module (%s)", mod->name); return; } - - if (mod->store(uuid, event, error_filename, error_lineno TSRMLS_CC) == AwareOperationFailed) { + + if (mod->store(uuid, event, error_filename, error_lineno TSRMLS_CC,type,AWARE_G(appname),AWARE_G(source_baseurl)) == AwareOperationFailed) { php_aware_original_error_cb(E_WARNING TSRMLS_CC, "Failed to store the event %s (%s)", uuid, mod->name); } diff --git a/php_aware.h b/php_aware.h index 40b0c89..669e505 100644 --- a/php_aware.h +++ b/php_aware.h @@ -37,6 +37,13 @@ #include +#define PHP_5_3_X_API_NO 20090626 +#define PHP_5_3_X_API_NO 20090626 +#define PHP_5_4_X_API_NO 20100525 +#define PHP_5_5_X_API_NO 20121212 +#define PHP_5_6_X_API_NO 20131226 + + /* Original error callback */ typedef void (*php_aware_orig_error_cb_t)(int, const char *, const uint, const char *, va_list); @@ -89,7 +96,8 @@ ZEND_BEGIN_MODULE_GLOBALS(aware) HashTable module_error_reporting; /* hashtable containing error reporting levels for different storage modules */ php_aware_serialize_cache s_cache; /* serialize cache, repeated serializations are stored here */ - + char *source_baseurl; /* base URL of your code repo, for displaying a link to the file when reporting the error */ + char *appname; /* report the appname in which the err was triggered */ char *error_page; /* Display pretty error page on fatal if set */ ZEND_END_MODULE_GLOBALS(aware) diff --git a/php_aware_storage.h b/php_aware_storage.h index b015514..739e736 100644 --- a/php_aware_storage.h +++ b/php_aware_storage.h @@ -49,7 +49,7 @@ typedef enum _AwareModuleRegisterStatus { */ #define PHP_AWARE_CONNECT_ARGS TSRMLS_D #define PHP_AWARE_GET_ARGS const char *uuid, zval *event TSRMLS_DC -#define PHP_AWARE_STORE_ARGS const char *uuid, zval *event, const char *error_filename, long error_lineno TSRMLS_DC +#define PHP_AWARE_STORE_ARGS const char *uuid, zval *event, const char *error_filename, long error_lineno TSRMLS_DC, long type, const char *appname, const char *source_baseurl #define PHP_AWARE_GET_LIST_ARGS long start, long limit, zval *events TSRMLS_DC #define PHP_AWARE_DELETE_ARGS const char *uuid TSRMLS_DC #define PHP_AWARE_DISCONNECT_ARGS TSRMLS_D diff --git a/storage/elasticsearch/aware_elasticsearch.c b/storage/elasticsearch/aware_elasticsearch.c new file mode 100644 index 0000000..f68de23 --- /dev/null +++ b/storage/elasticsearch/aware_elasticsearch.c @@ -0,0 +1,297 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 / aware | + +----------------------------------------------------------------------+ + | Copyright (c) Jess Portnoy | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | Jess Portnoy | + +----------------------------------------------------------------------+ +*/ + +#include "php_aware_elasticsearch.h" + +/* holder for curl fetch */ +struct curl_fetch_st { + char *payload; + size_t size; +}; + +/* callback for curl fetch */ +size_t curl_callback (void *contents, size_t size, size_t nmemb, void *userp) { + size_t realsize = size * nmemb; /* calculate buffer size */ + struct curl_fetch_st *p = (struct curl_fetch_st *) userp; /* cast pointer to fetch struct */ + + /* expand buffer */ + p->payload = (char *) realloc(p->payload, p->size + realsize + 1); + + /* check buffer */ + if (p->payload == NULL) { + /* this isn't good */ + aware_printf("ERROR: Failed to expand buffer in curl_callback"); + /* free buffer */ + free(p->payload); + /* return */ + return -1; + } + + /* copy contents to buffer */ + memcpy(&(p->payload[p->size]), contents, realsize); + + /* set new buffer size */ + p->size += realsize; + + /* ensure null termination */ + p->payload[p->size] = 0; + + /* return size */ + return realsize; +} +/* fetch and return url body via curl */ +CURLcode curl_fetch_url(CURL *ch, const char *url, struct curl_fetch_st *fetch) { + CURLcode rcode; /* curl result code */ + + /* init payload */ + fetch->payload = (char *) calloc(1, sizeof(fetch->payload)); + + /* check payload */ + if (fetch->payload == NULL) { + /* log error */ + aware_printf("ERROR: Failed to allocate payload in curl_fetch_url"); + /* return error */ + return CURLE_FAILED_INIT; + } + + /* init size */ + fetch->size = 0; + + /* set url to fetch */ + curl_easy_setopt(ch, CURLOPT_URL, url); + + /* set calback function */ + curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, curl_callback); + + /* pass fetch struct pointer */ + curl_easy_setopt(ch, CURLOPT_WRITEDATA, (void *) fetch); + + /* set default user agent */ + curl_easy_setopt(ch, CURLOPT_USERAGENT, "php-aware-elasticsearch/1.0"); + + /* set timeout */ + curl_easy_setopt(ch, CURLOPT_TIMEOUT, 5); + + /* enable location redirects */ + curl_easy_setopt(ch, CURLOPT_FOLLOWLOCATION, 1); + + /* set maximum allowed redirects */ + curl_easy_setopt(ch, CURLOPT_MAXREDIRS, 1); + + /* fetch the url */ + rcode = curl_easy_perform(ch); + + /* return */ + return rcode; +} +ZEND_DECLARE_MODULE_GLOBALS(aware_elasticsearch) + +php_aware_storage_module php_aware_storage_module_elasticsearch = { + PHP_AWARE_STORAGE_MOD(elasticsearch) +}; + +PHP_AWARE_CONNECT_FUNC(elasticsearch) +{ + return AwareOperationNotSupported; +} + +PHP_AWARE_GET_FUNC(elasticsearch) +{ + return AwareOperationNotSupported; +} + +PHP_AWARE_STORE_FUNC(elasticsearch) +{ + /*const char *uuid; + zval *event; + long type; + const char *error_filename; + long error_lineno;*/ + + zval **ppzval; + CURL *ch; /* curl handle */ + CURLcode rcode; /* curl result code */ + char hostname[255]; + gethostname(hostname,255); + + json_object *json; /* json post body */ + enum json_tokener_error jerr = json_tokener_success; /* json parse error */ + + struct curl_fetch_st curl_fetch; /* curl fetch struct */ + struct curl_fetch_st *cf = &curl_fetch; /* pointer to fetch struct */ + struct curl_slist *headers = NULL; /* http headers to send with request */ + + + /* init curl handle */ + if ((ch = curl_easy_init()) == NULL) { + /* log error */ + aware_printf("ERROR: Failed to create curl handle in fetch_session"); + /* return error */ + return 1; + } + + /* set content type */ + headers = curl_slist_append(headers, "Accept: application/json"); + headers = curl_slist_append(headers, "Content-Type: application/json"); + + /* create json object for post */ + json = json_object_new_object(); + /* build post data */ + if (zend_hash_find(Z_ARRVAL_P(event), "error_message", sizeof("error_message"), (void **) &ppzval) == SUCCESS) { + json_object_object_add(json, "error", json_object_new_string(Z_STRVAL_PP(ppzval))); + } else { + json_object_object_add(json, "error", json_object_new_string("No error message")); + } + json_object_object_add(json, "source", json_object_new_string(appname)); + //char *source_url; + //spprintf(&source_url, 2048, "%s/%s#L%ld", source_baseurl,error_filename, error_lineno); + //json_object_object_add(json, "source_url", json_object_new_string(source_url)); + //efree(source_url); + char *error_file_line; + spprintf(&error_file_line, MAXPATHLEN + 256, "%s:%ld", error_filename, error_lineno); + json_object_object_add(json, "file", json_object_new_string(error_file_line)); + efree(error_file_line); + json_object_object_add(json, "hostname", json_object_new_string(hostname)); + json_object_object_add(json, "error_type", json_object_new_int((int)type)); + json_object_object_add(json, "timestamp", json_object_new_int(time(NULL))); + + /* set curl options */ + curl_easy_setopt(ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_easy_setopt(ch, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(ch, CURLOPT_POSTFIELDS, json_object_to_json_string(json)); + + /* fetch page and capture return code */ + rcode = curl_fetch_url(ch, AWARE_ELASTICSEARCH_G(host), cf); + + /* cleanup curl handle */ + curl_easy_cleanup(ch); + + /* free headers */ + curl_slist_free_all(headers); + + /* free json object */ + json_object_put(json); + + /* check return code */ + if (rcode != CURLE_OK || cf->size < 1) { + /* log error */ + aware_printf("ERROR: Failed to fetch url (%s) - curl said: %s", + url, curl_easy_strerror(rcode)); + /* return error */ + return AwareOperationFailed; + } + + //if (zend_hash_find(Z_ARRVAL_P(event), "error_message", sizeof("error_message"), (void **) &ppzval) == SUCCESS) { + //} + return AwareOperationSuccess; +} + +PHP_AWARE_GET_LIST_FUNC(elasticsearch) +{ + return AwareOperationNotSupported; +} + +PHP_AWARE_DELETE_FUNC(elasticsearch) +{ + return AwareOperationNotSupported; +} + +PHP_AWARE_DISCONNECT_FUNC(elasticsearch) +{ + return AwareOperationNotSupported; +} + +PHP_INI_BEGIN() + STD_PHP_INI_ENTRY("aware_elasticsearch.host", "http://localhost:9200/php-aware/events", PHP_INI_SYSTEM, OnUpdateString, host, zend_aware_elasticsearch_globals, aware_elasticsearch_globals) +PHP_INI_END() + +static void php_aware_elasticsearch_init_globals(zend_aware_elasticsearch_globals *aware_elasticsearch_globals) +{ + aware_elasticsearch_globals->host = "http://localhost:9200/php-aware/events"; +} + +/* {{{ PHP_MINIT_FUNCTION(aware_elasticsearch) */ +PHP_MINIT_FUNCTION(aware_elasticsearch) +{ + AwareModuleRegisterStatus reg_status; + + ZEND_INIT_MODULE_GLOBALS(aware_elasticsearch, php_aware_elasticsearch_init_globals, NULL); + REGISTER_INI_ENTRIES(); + + reg_status = PHP_AWARE_STORAGE_REGISTER(elasticsearch); + + switch (reg_status) + { + case AwareModuleRegistered: + AWARE_ELASTICSEARCH_G(enabled) = 1; + break; + + case AwareModuleFailed: + AWARE_ELASTICSEARCH_G(enabled) = 0; + return FAILURE; + break; + + case AwareModuleNotConfigured: + AWARE_ELASTICSEARCH_G(enabled) = 0; + break; + } + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION(aware_elasticsearch) */ +PHP_MSHUTDOWN_FUNCTION(aware_elasticsearch) +{ + UNREGISTER_INI_ENTRIES(); + return SUCCESS; +} + +/* }}} */ + +/* {{{ PHP_MINFO_FUNCTION(aware_elasticsearch) */ +PHP_MINFO_FUNCTION(aware_elasticsearch) +{ + php_info_print_table_start(); + php_info_print_table_row(2, "aware_elasticsearch storage", "enabled"); + php_info_print_table_row(2, "aware_elasticsearch version", PHP_AWARE_ELASTICSEARCH_EXTVER); + php_info_print_table_end(); + + DISPLAY_INI_ENTRIES(); +} + +static zend_function_entry aware_elasticsearch_functions[] = { + {NULL, NULL, NULL} +}; + +zend_module_entry aware_elasticsearch_module_entry = { + STANDARD_MODULE_HEADER, + "aware_elasticsearch", + aware_elasticsearch_functions, + PHP_MINIT(aware_elasticsearch), + PHP_MSHUTDOWN(aware_elasticsearch), + NULL, + NULL, + PHP_MINFO(aware_elasticsearch), + PHP_AWARE_ELASTICSEARCH_EXTVER, + STANDARD_MODULE_PROPERTIES +}; + +#ifdef COMPILE_DL_AWARE_ELASTICSEARCH +ZEND_GET_MODULE(aware_elasticsearch) +#endif diff --git a/storage/elasticsearch/config.m4 b/storage/elasticsearch/config.m4 new file mode 100644 index 0000000..7fb3a05 --- /dev/null +++ b/storage/elasticsearch/config.m4 @@ -0,0 +1,45 @@ +PHP_ARG_ENABLE(aware-elasticsearch, whether to enable aware elasticsearch backend, +[ --enable-aware-elasticsearch Enable aware elasticsearch backend]) + +PHP_ARG_ENABLE(aware-debug, whether to enable debugging, +[ --enable-aware-debug Enable debugging], no, no) + +if test "$PHP_AWARE_ELASTICSEARCH" != "no"; then + + if test "$PHP_AWARE_DEBUG" != "no"; then + AC_DEFINE([_AWARE_DEBUG_], 1, [Enable debugging]) + fi + for i in /usr /usr/local /opt /opt/local; do + if test -r "$i/include/curl/curl.h"; then + PHP_AWARE_LIBCURL=$i + break; + fi + done + + if test -z $PHP_AWARE_LIBCURL; then + AC_MSG_ERROR([libcurl not found]) + fi + + AC_MSG_RESULT([$PHP_AWARE_LIBCURL]) + PHP_ADD_INCLUDE("$PHP_AWARE_LIBCURL/include") + PHP_ADD_LIBRARY_WITH_PATH(curl, "$PHP_AWARE_LIBCURL/lib", AWARE_ELASTICSEARCH_SHARED_LIBADD) + + for i in /usr /usr/local /opt /opt/local; do + if test -r "$i/include/json-c/json.h"; then + PHP_AWARE_LIBJSONC=$i + break; + fi + done + + if test -z $PHP_AWARE_LIBJSONC; then + AC_MSG_ERROR([libjson-c not found]) + fi + + AC_MSG_RESULT([$PHP_AWARE_LIBJSONC]) + PHP_ADD_INCLUDE("$PHP_AWARE_LIBJSONC/include") + PHP_ADD_LIBRARY_WITH_PATH(json-c, "$PHP_AWARE_LIBCURL/lib", AWARE_ELASTICSEARCH_SHARED_LIBADD) + PHP_SUBST(AWARE_ELASTICSEARCH_SHARED_LIBADD) + + PHP_NEW_EXTENSION(aware_elasticsearch, aware_elasticsearch.c, $ext_shared) + PHP_ADD_EXTENSION_DEP(aware_elasticsearch, aware) +fi diff --git a/storage/elasticsearch/php_aware_elasticsearch.h b/storage/elasticsearch/php_aware_elasticsearch.h new file mode 100644 index 0000000..5636211 --- /dev/null +++ b/storage/elasticsearch/php_aware_elasticsearch.h @@ -0,0 +1,67 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 / aware | + +----------------------------------------------------------------------+ + | Copyright (c) Jess Portnoy | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | Jess Portnoy | + +----------------------------------------------------------------------+ +*/ + +#ifndef _PHP_AWARE_ELASTICSEARCH_H_ +# define _PHP_AWARE_ELASTICSEARCH_H_ + +#define PHP_AWARE_ELASTICSEARCH_EXTVER "0.0.1-dev" + +#include "php.h" +#include "php_ini.h" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef ZTS +# include "TSRM.h" +#endif + +#include "../../php_aware.h" +#include "../../php_aware_storage.h" +/* json-c (https://github.com/json-c/json-c) */ +#include + +/* libcurl (http://curl.haxx.se/libcurl/c) */ +#include + +ZEND_BEGIN_MODULE_GLOBALS(aware_elasticsearch) + char *host; + zend_bool enabled; +ZEND_END_MODULE_GLOBALS(aware_elasticsearch) + +ZEND_EXTERN_MODULE_GLOBALS(aware_elasticsearch) + +#ifdef ZTS +# define AWARE_ELASTICSEARCH_G(v) TSRMG(aware_elasticsearch_globals_id, zend_aware_elasticsearch_globals *, v) +#else +# define AWARE_ELASTICSEARCH_G(v) (aware_elasticsearch_globals.v) +#endif + +/* Hook into aware module */ +extern php_aware_storage_module php_aware_storage_module_elasticsearch; +#define php_aware_storage_module_elasticsearch_ptr &php_aware_storage_module_elasticsearch + +/* Normal PHP entry */ +extern zend_module_entry aware_elasticsearch_module_entry; +#define phpext_aware_elasticsearch_ptr &aware_elasticsearch_module_entry + +PHP_AWARE_STORAGE_FUNCS(elasticsearch); + +#endif diff --git a/storage/email/aware_email.c b/storage/email/aware_email.c index 38ab93a..56c169b 100644 --- a/storage/email/aware_email.c +++ b/storage/email/aware_email.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 / aware | +----------------------------------------------------------------------+ - | Copyright (c) 2009 Mikko Koppanen | + | Copyright (c) Mikko Koppanen, Jess Portnoy | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -12,7 +12,9 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Mikko Kopppanen | + | Authors: | + | Mikko Kopppanen | + | Jess Portnoy | +----------------------------------------------------------------------+ */ @@ -45,18 +47,34 @@ PHP_AWARE_STORE_FUNC(email) Error body */ MAKE_STD_ZVAL(args[2]); +#if ZEND_MODULE_API_NO <= PHP_5_3_X_API_NO php_start_ob_buffer(NULL, 4096, 0 TSRMLS_CC); +#else + php_output_start_user(NULL, 4096, PHP_OUTPUT_HANDLER_STDFLAGS); +#endif php_var_dump(&event, AWARE_G(depth) TSRMLS_CC); +#if ZEND_MODULE_API_NO <= PHP_5_3_X_API_NO if (php_ob_get_buffer(args[2] TSRMLS_CC) == FAILURE) { +#else + if (php_output_get_contents(args[2] TSRMLS_CC) == FAILURE) { +#endif zval_dtor(args[2]); FREE_ZVAL(args[2]); +#if ZEND_MODULE_API_NO <= PHP_5_3_X_API_NO php_end_ob_buffer(0, 0 TSRMLS_CC); +#else + php_output_end(); +#endif return AwareOperationFailed; } +#if ZEND_MODULE_API_NO <= PHP_5_3_X_API_NO php_end_ob_buffer(0, 0 TSRMLS_CC); +#else + php_output_end(); +#endif MAKE_STD_ZVAL(fname); ZVAL_STRING(fname, "mail", 1); @@ -193,4 +211,4 @@ zend_module_entry aware_email_module_entry = { #ifdef COMPILE_DL_AWARE_EMAIL ZEND_GET_MODULE(aware_email) -#endif \ No newline at end of file +#endif