Changeset 23921

Show
Ignore:
Timestamp:
11/05/09 14:43:28 (4 months ago)
Author:
indeyets
Message:

[BREAKING CHANGE] introducing midgard.superglobals_compat ini-setting. by default it is off and superglobals are not registered. should be turned on for ragnaland and other "old" software

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/apis/php5/midgard.c

    r23884 r23921  
    252252        NULL, 
    253253        midgard2_deps, 
    254         "midgard2"
     254        MIDGARD_PACKAGE_NAME
    255255        midgard2_functions, 
    256256        PHP_MINIT(midgard2), 
     
    268268 
    269269PHP_INI_BEGIN() 
    270         STD_PHP_INI_ENTRY("midgard.configuration",      "",  PHP_INI_SYSTEM, OnUpdateString, midgard_configuration,      zend_midgard2_globals, midgard2_globals) 
    271         STD_PHP_INI_ENTRY("midgard.configuration_file", "",  PHP_INI_SYSTEM, OnUpdateString, midgard_configuration_file, zend_midgard2_globals, midgard2_globals) 
    272         STD_PHP_INI_BOOLEAN("midgard.http",             "0", PHP_INI_SYSTEM, OnUpdateBool,   midgard_http,               zend_midgard2_globals, midgard2_globals) 
    273         STD_PHP_INI_BOOLEAN("midgard.engine",           "1", PHP_INI_ALL,    OnUpdateBool,   midgard_engine,             zend_midgard2_globals, midgard2_globals) 
    274         STD_PHP_INI_BOOLEAN("midgard.memory_debug",     "0", PHP_INI_ALL,    OnUpdateBool,   midgard_memory_debug,       zend_midgard2_globals, midgard2_globals) 
     270        STD_PHP_INI_ENTRY("midgard.configuration",         "",  PHP_INI_SYSTEM, OnUpdateString, midgard_configuration,      zend_midgard2_globals, midgard2_globals) 
     271        STD_PHP_INI_ENTRY("midgard.configuration_file",    "",  PHP_INI_SYSTEM, OnUpdateString, midgard_configuration_file, zend_midgard2_globals, midgard2_globals) 
     272        STD_PHP_INI_BOOLEAN("midgard.http",                "0", PHP_INI_SYSTEM, OnUpdateBool,   midgard_http,               zend_midgard2_globals, midgard2_globals) 
     273        STD_PHP_INI_BOOLEAN("midgard.engine",              "1", PHP_INI_ALL,    OnUpdateBool,   midgard_engine,             zend_midgard2_globals, midgard2_globals) 
     274        STD_PHP_INI_BOOLEAN("midgard.memory_debug",        "0", PHP_INI_ALL,    OnUpdateBool,   midgard_memory_debug,       zend_midgard2_globals, midgard2_globals) 
     275        STD_PHP_INI_BOOLEAN("midgard.superglobals_compat", "0", PHP_INI_SYSTEM, OnUpdateBool,   superglobals_compat,        zend_midgard2_globals, midgard2_globals) 
    275276        // quota isn't used? 
    276277        // STD_PHP_INI_BOOLEAN("midgard.quota",        "0", PHP_INI_ALL,    OnUpdateBool, midgard_quota,        midgard2_globals *, midgard2_globals) 
     
    336337 
    337338        ze = zend_get_extension(MIDGARD_PACKAGE_NAME); 
     339 
    338340        if (ze != NULL) { 
    339                 php_error(E_NOTICE, "Module midgard2 already loaded. It's recommended to load it via php.ini"); 
     341                php_error(E_NOTICE, "Module %s already loaded. It's recommended to load it via php.ini", MIDGARD_PACKAGE_NAME); 
    340342                return SUCCESS; 
    341343        } 
    342344 
    343         zend_register_auto_global("_MIDGARD", sizeof("_MIDGARD")-1, NULL TSRMLS_CC); 
    344         zend_register_auto_global("_MIDCOM", sizeof("_MIDCOM")-1, NULL  TSRMLS_CC); 
    345         zend_register_auto_global("_MIDGARD_CONNECTION", sizeof("_MIDGARD_CONNECTION")-1, NULL  TSRMLS_CC); 
    346  
    347         /* 
    348         zend_module_entry *module; 
    349         int rv = zend_hash_find(&module_registry, "midgard2", strlen("midgard2")+1, (void**)&module); 
    350         if (rv == SUCCESS) 
    351                 return SUCCESS; 
    352         */ 
    353  
    354345        global_loghandler = g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_MASK, midgard_error_default_log, NULL); 
    355346 
    356347        //g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); 
    357         //g_log_set_fatal_mask("GLib-GObject", G_LOG_LEVEL_CRITICAL);   
     348        //g_log_set_fatal_mask("GLib-GObject", G_LOG_LEVEL_CRITICAL); 
    358349 
    359350        /* Get DateTime class pointer and set global */ 
     
    386377        ce_midgard_error_exception = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC); 
    387378 
     379        // Init various classes 
    388380        php_reflection_workaround_init(module_number);   
    389381        php_midgard_reflection_property_init(module_number); 
     
    463455        REGISTER_INI_ENTRIES(); 
    464456 
     457        if (MGDG(superglobals_compat)) { 
     458                php_error(E_DEPRECATED, "midgard.superglobals_compat option is deprecated and might be removed in next release"); 
     459 
     460                zend_register_auto_global("_MIDGARD",            sizeof("_MIDGARD")-1,            NULL TSRMLS_CC); 
     461                zend_register_auto_global("_MIDCOM",             sizeof("_MIDCOM")-1,             NULL TSRMLS_CC); 
     462                zend_register_auto_global("_MIDGARD_CONNECTION", sizeof("_MIDGARD_CONNECTION")-1, NULL TSRMLS_CC); 
     463        } 
     464 
    465465        /* midgard.http is on so we populate list of all available configs */ 
    466466        if (php_midgard_is_http_env()) { 
     
    487487        php_midgard_log_enabled = TRUE; 
    488488 
    489         // php_error(E_NOTICE, "MODULE INIT - PID IS %d", getpid()); 
     489        if (MGDG(midgard_memory_debug)) { 
     490                php_printf("MINIT done (pid = %d)\n", getpid()); 
     491        } 
    490492 
    491493        return SUCCESS; 
     
    598600                 * It simply forces Zend to not unload midgard module */ 
    599601                zend_module_entry *module; 
    600                 int rv = zend_hash_find(&module_registry, "midgard2", strlen("midgard2")+1, (void**)&module); 
     602                int rv = zend_hash_find(&module_registry, MIDGARD_PACKAGE_NAME, strlen(MIDGARD_PACKAGE_NAME) + 1, (void**)&module); 
    601603                if (rv == SUCCESS) { 
    602604                        php_printf("---> disable module handle\n"); 
  • trunk/midgard/apis/php5/php_midgard.h

    r23912 r23921  
    108108        zend_bool midgard_http; 
    109109        zend_bool midgard_memory_debug; 
     110        zend_bool superglobals_compat; 
    110111ZEND_END_MODULE_GLOBALS(midgard2) 
    111112 
  • trunk/midgard/apis/php5/php_midgard__helpers.h

    r23879 r23921  
    1313/* These macros are available since 5.3, so we add them in 5.2 */ 
    1414#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2 
     15# define E_DEPRECATED E_NOTICE 
    1516# define Z_SET_ISREF_P(ptr) (ptr)->is_ref = 1 
    1617# define Z_REFCOUNT_P(ptr) (ptr)->refcount