From 1e4afd49906e9a62b72313bb0cd031e751a97afc Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Fri, 17 Feb 2023 21:54:09 -0500 Subject: [PATCH] update StandardModule.php --- zend/StandardModule.php | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/zend/StandardModule.php b/zend/StandardModule.php index a2956a9..5e91298 100644 --- a/zend/StandardModule.php +++ b/zend/StandardModule.php @@ -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); } } @@ -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); + } } /**