Skip to content

Commit

Permalink
update StandardModule.php
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Feb 18, 2023
1 parent 508fe5d commit 1e4afd4
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions zend/StandardModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,8 @@ final public function module_destructor(): void
$this->global_rsrc = null;
}

$this->ze_other_ptr = null;
$this->ze_other = null;
$this->reflection = null;
if (!$this->module_destructor_linked)
static::clear_module();

/**
* Will cause `PHP_MSHUTDOWN_FUNCTION()` and `PHP_GSHUTDOWN_FUNCTION()` to execute.
*/
\zend_hash_delete($this->module_name);
}
}

Expand All @@ -236,12 +228,31 @@ final protected static function set_module(\StandardModule $module): void
self::$global_module[static::class] = $module;
}

/**
* Force clear and shutdown module.
* - Will cause `PHP_MSHUTDOWN_FUNCTION()` and `PHP_GSHUTDOWN_FUNCTION()` to execute.
*
* @return void
*/
final public static function clear_module(): void
{
if (\PHP_ZTS)
self::$global_module[\ze_ffi()->tsrm_thread_id()] = null;
else
self::$global_module[static::class] = null;
/** @var static */
$module = (\PHP_ZTS)
? self::$global_module[\ze_ffi()->tsrm_thread_id()]
: self::$global_module[static::class];

if (!\is_null($module)) {
if (\PHP_ZTS)
self::$global_module[\ze_ffi()->tsrm_thread_id()] = null;
else
self::$global_module[static::class] = null;

\zend_hash_delete($module->module_name);
$module->ze_other_ptr = null;
$module->ze_other = null;
$module->reflection = null;
\zval_del_ref($module);
}
}

/**
Expand Down

0 comments on commit 1e4afd4

Please sign in to comment.