PHP_RINIT_FUNCTION(drupal_extension)
{
// Initialize arrays to hold static variables on a per page request basis.
// Doing this in MINIT will make the same arrays persistent across multiple requests
// which is probably not wanted.
ZEND_INIT_MODULE_GLOBALS(drupal_extension, php_drupal_extension_init_globals, NULL)
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(drupal_extension)
{
// Apparently function_table is persistent across requests so we have to remove our
// changes or else we'll bork subsequent requests.
// TODO: Add a global flag to track whether these functions were ever overriden.
zend_hash_del(EG(function_table), "check_plain", sizeof("check_plain"));
zend_hash_del(EG(function_table), "drupal_static", sizeof("drupal_static"));
zend_hash_destroy(DRUPAL_EXTENSION_G(drupal_static_ext_zdata));
zend_hash_destroy(DRUPAL_EXTENSION_G(drupal_static_ext_zdefault));
FREE_HASHTABLE(DRUPAL_EXTENSION_G(drupal_static_ext_zdata));
FREE_HASHTABLE(DRUPAL_EXTENSION_G(drupal_static_ext_zdefault));
return SUCCESS;
}