Changeset 496


Ignore:
Timestamp:
2008-01-04T12:38:57+01:00 (7 years ago)
Author:
moo
Message:

fixed #157: support user error handler for E_STRICT. E_STRICT is now cached

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r492 r496  
    66ChangeLog
    77========
     8 * compiler errors: all compiler warning (e.g.: E_STRICT) is now cached and is supported for user handler
    89 * added module dependency
    910 * live with wrong system time: allow caching files with mtime in further
  • trunk/processor/processor.m4

    r495 r496  
    741741dnl }}}
    742742#endif
     743#ifdef E_STRICT
     744DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{
     745    DISPATCH(int, type)
     746    DISPATCH(uint, lineno)
     747    DISPATCH(int, error_len)
     748    PROC_STRING_L(error, error_len)
     749')
     750dnl }}}
     751#endif
    743752DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
    744753    zend_uint i;
     
    790799    ')
    791800#endif
     801#ifdef E_STRICT
     802    DISPATCH(zend_uint, compilererror_cnt)
     803    IFRESTORE(`
     804        COPY(compilererrors)
     805    ', `
     806        STRUCT_ARRAY(compilererror_cnt, xc_compilererror_t, compilererrors)
     807    ')
     808#endif
    792809    DISPATCH(zend_bool, have_early_binding)
    793810    DISPATCH(zend_bool, have_references)
  • trunk/utils.c

    r485 r496  
    517517#define OG(x) (sandbox->orig_##x)
    518518/* }}} */
     519#ifdef E_STRICT
     520static void xc_sandbox_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) /* {{{ */
     521{
     522    xc_compilererror_t *compilererror;
     523    xc_sandbox_t *sandbox;
     524    TSRMLS_FETCH();
     525
     526    sandbox = (xc_sandbox_t *) XG(sandbox);
     527    assert(sandbox != NULL);
     528    if (sandbox->compilererror_cnt <= sandbox->compilererror_size) {
     529        if (sandbox->compilererror_size) {
     530            sandbox->compilererror_size += 16;
     531            sandbox->compilererrors = erealloc(sandbox->compilererrors, sandbox->compilererror_size * sizeof(sandbox->compilererrors));
     532        }
     533        else {
     534            sandbox->compilererror_size = 16;
     535            sandbox->compilererrors = emalloc(sandbox->compilererror_size * sizeof(sandbox->compilererrors));
     536        }
     537    }
     538    compilererror = &sandbox->compilererrors[sandbox->compilererror_cnt++];
     539    compilererror->type   = type;
     540    compilererror->lineno = error_lineno;
     541    compilererror->error_len = zend_vspprintf(&compilererror->error, 0, format, args);
     542}
     543/* }}} */
     544#endif
    519545#ifdef ZEND_ENGINE_2_1
    520546static zend_bool xc_auto_global_callback(char *name, uint name_len TSRMLS_DC) /* {{{ */
     
    622648#ifdef E_STRICT
    623649    sandbox->orig_user_error_handler_error_reporting = EG(user_error_handler_error_reporting);
    624     EG(user_error_handler_error_reporting) &= ~E_STRICT;
    625 #endif
    626 
     650    EG(user_error_handler_error_reporting) = 0;
     651
     652    sandbox->compilererror_cnt  = 0;
     653    sandbox->compilererror_size = 0;
     654    sandbox->orig_zend_error_cb = zend_error_cb;
     655    zend_error_cb = xc_sandbox_error_cb;
     656#endif
     657
     658    XG(sandbox) = (void *) sandbox;
    627659    return sandbox;
    628660}
     
    684716    }
    685717
     718#ifdef E_STRICT
     719    /* restore trigger errors */
     720    for (i = 0; i < sandbox->compilererror_cnt; i ++) {
     721        xc_compilererror_t *error = &sandbox->compilererrors[i];
     722        CG(zend_lineno) = error->lineno;
     723        zend_error(error->type, "%s", error->error);
     724    }
     725    CG(zend_lineno) = 0;
     726#endif
     727
    686728    i = 1;
    687729    zend_hash_add(&OG(included_files), sandbox->filename, strlen(sandbox->filename) + 1, (void *)&i, sizeof(int), NULL);
     
    690732void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC) /* {{{ */
    691733{
     734    XG(sandbox) = NULL;
     735#ifdef E_STRICT
     736    EG(user_error_handler_error_reporting) = sandbox->orig_user_error_handler_error_reporting;
     737    zend_error_cb = sandbox->orig_zend_error_cb;
     738#endif
     739
    692740    /* restore first first install function/class */
    693741#ifdef HAVE_XCACHE_CONSTANT
     
    731779    memcpy(&EG(included_files), &OG(included_files), sizeof(EG(included_files)));
    732780
    733 #ifdef E_STRICT
    734     EG(user_error_handler_error_reporting) = sandbox->orig_user_error_handler_error_reporting;
    735 #endif
    736 
     781    if (sandbox->compilererrors) {
     782        int i;
     783        for (i = 0; i < sandbox->compilererror_cnt; i ++) {
     784            efree(sandbox->compilererrors[i].error);
     785        }
     786        efree(sandbox->compilererrors);
     787    }
    737788    if (sandbox->alloc) {
    738789        efree(sandbox);
  • trunk/utils.h

    r405 r496  
    8080typedef struct {
    8181    int alloc;
    82     int orig_user_error_handler_error_reporting;
    8382    char *filename;
    8483
     
    9897    Bucket    *tmp_internal_function_tail;
    9998    Bucket    *tmp_internal_class_tail;
     99
     100#ifdef E_STRICT
     101    int orig_user_error_handler_error_reporting;
     102    ZEND_API void (*orig_zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
     103    zend_uint compilererror_cnt;
     104    zend_uint compilererror_size;
     105    xc_compilererror_t *compilererrors;
     106#endif
    100107} xc_sandbox_t;
    101108
  • trunk/xcache-test.ini

    r409 r496  
     1display_error = On
    12auto_globals_jit = Off
    23
  • trunk/xcache.c

    r495 r496  
    664664        zend_u_is_auto_global(aginfo->type, aginfo->key, aginfo->key_len TSRMLS_CC);
    665665    }
     666#endif
     667#ifdef E_STRICT
     668    /* restore trigger errors */
     669    for (i = 0; i < p->compilererror_cnt; i ++) {
     670        xc_compilererror_t *error = &p->compilererrors[i];
     671        CG(zend_lineno) = error->lineno;
     672        zend_error(error->type, "%s", error->error);
     673    }
     674    CG(zend_lineno) = 0;
    666675#endif
    667676
     
    11151124    }
    11161125    /* }}} */
     1126#ifdef E_STRICT
     1127    php->compilererrors = ((xc_sandbox_t *) XG(sandbox))->compilererrors;
     1128    php->compilererror_cnt = ((xc_sandbox_t *) XG(sandbox))->compilererror_cnt;
     1129#endif
    11171130    /* {{{ find inherited classes that should be early-binding */
    11181131    php->have_early_binding = 0;
  • trunk/xcache.h

    r491 r496  
    266266typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t;
    267267typedef char xc_md5sum_t[16];
     268/* {{{ xc_compilererror_t */
     269typedef struct {
     270    int type;
     271    uint lineno;
     272    int error_len;
     273    char *error;
     274} xc_compilererror_t;
     275/* }}} */
    268276/* {{{ xc_entry_data_php_t */
    269277struct _xc_entry_data_php_t {
     
    296304    zend_uint autoglobal_cnt;
    297305    xc_autoglobal_t *autoglobals;
     306#endif
     307
     308#ifdef E_STRICT
     309    zend_uint compilererror_cnt;
     310    xc_compilererror_t *compilererrors;
    298311#endif
    299312
  • trunk/xcache_globals.h

    r435 r496  
    2121    HashTable internal_class_table;
    2222    zend_bool internal_table_copied;
     23
     24    void *sandbox;
    2325ZEND_END_MODULE_GLOBALS(xcache)
    2426
Note: See TracChangeset for help on using the changeset viewer.