From 6709d000cd08e4e1fdba4944c7d18275d2a0a2f1 Mon Sep 17 00:00:00 2001 From: hirosan Date: Thu, 8 Jan 2026 19:21:57 +0900 Subject: Fix static analysis warnings for isDot() and remove deprecated APC support (#1164) * Fix static analysis warnings for isDot() * Remove deprecated APC support * Remove redundant isDot() check and fix static analysis warnings --- src/Cacheresource/File.php | 10 +-- src/Smarty.php | 8 +-- src/Template/Compiled.php | 2 - tests/PHPUnit_Smarty.php | 6 +- .../Apc/CacheResourceCustomApcTest.php | 31 --------- .../PHPunitplugins/cacheresource.apctest.php | 33 ---------- .../__shared/cacheresources/cacheresource.apc.php | 73 ---------------------- 7 files changed, 6 insertions(+), 157 deletions(-) delete mode 100644 tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php delete mode 100644 tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php delete mode 100644 tests/UnitTests/__shared/cacheresources/cacheresource.apc.php diff --git a/src/Cacheresource/File.php b/src/Cacheresource/File.php index 4b4198ec..3cb09b5e 100644 --- a/src/Cacheresource/File.php +++ b/src/Cacheresource/File.php @@ -127,8 +127,6 @@ class File extends Base && (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1 ) { opcache_invalidate($_template->getCached()->filepath, true); - } elseif (function_exists('apc_compile_file')) { - apc_compile_file($_template->getCached()->filepath); } $cached = $_template->getCached(); $cached->timestamp = $cached->exists = is_file($cached->filepath); @@ -223,10 +221,8 @@ class File extends Base $_filepath = (string)$_file; // directory ? if ($_file->isDir()) { - if (!$_cache->isDot()) { - // delete folder if empty - @rmdir($_file->getPathname()); - } + // delete folder if empty + @rmdir($_file->getPathname()); } else { // delete only php files if (substr($_filepath, -4) !== '.php') { @@ -279,8 +275,6 @@ class File extends Base && (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1) ) { opcache_invalidate($_filepath, true); - } elseif (function_exists('apc_delete_file')) { - apc_delete_file($_filepath); } } } diff --git a/src/Smarty.php b/src/Smarty.php index b53a36c2..73df97ed 100644 --- a/src/Smarty.php +++ b/src/Smarty.php @@ -1344,10 +1344,8 @@ class Smarty extends \Smarty\TemplateBase { } $_filepath = (string)$_file; if ($_file->isDir()) { - if (!$_compile->isDot()) { - // delete folder if empty - @rmdir($_file->getPathname()); - } + // delete folder if empty + @rmdir($_file->getPathname()); } else { // delete only php files if (substr($_filepath, -4) !== '.php') { @@ -1385,8 +1383,6 @@ class Smarty extends \Smarty\TemplateBase { && (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api')) < 1) ) { opcache_invalidate($_filepath, true); - } elseif (function_exists('apc_delete_file')) { - apc_delete_file($_filepath); } } } diff --git a/src/Template/Compiled.php b/src/Template/Compiled.php index 5a07db0e..e5e2aec7 100644 --- a/src/Template/Compiled.php +++ b/src/Template/Compiled.php @@ -251,8 +251,6 @@ class Compiled extends GeneratedPhpFile { && (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1) ) { opcache_invalidate($this->filepath, true); - } elseif (function_exists('apc_compile_file')) { - apc_compile_file($this->filepath); } } if (defined('HHVM_VERSION')) { diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index 029c8f90..39663c1f 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -291,10 +291,8 @@ KEY `name` (`name`) } // directory ? if ($file->isDir()) { - if (!$ri->isDot()) { - // delete folder if empty - @rmdir($file->getPathname()); - } + // delete folder if empty + @rmdir($file->getPathname()); } else { unlink($file->getPathname()); } diff --git a/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php b/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php deleted file mode 100644 index d75382d0..00000000 --- a/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php +++ /dev/null @@ -1,31 +0,0 @@ -markTestSkipped('APC cache not available'); - } - $this->setUpSmarty(__DIR__); - parent::setUp(); - $this->smarty->setCachingType('apc'); - $this->smarty->registerCacheResource('apc', new Smarty_CacheResource_Apctest()); - } -} - diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php deleted file mode 100644 index 38b061dc..00000000 --- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php +++ /dev/null @@ -1,33 +0,0 @@ -lockTime) { - $this->lockTime--; - if (!$this->lockTime) { - $this->releaseLock($smarty, $cached); - } - } - return parent::hasLock($smarty, $cached); - } - - public function get(Template $_template) - { - $this->contents = array(); - $this->timestamps = array(); - $t = $this->getContent($_template); - - return $t ? $t : null; - } - -} diff --git a/tests/UnitTests/__shared/cacheresources/cacheresource.apc.php b/tests/UnitTests/__shared/cacheresources/cacheresource.apc.php deleted file mode 100644 index 3f437888..00000000 --- a/tests/UnitTests/__shared/cacheresources/cacheresource.apc.php +++ /dev/null @@ -1,73 +0,0 @@ - $v) { - $_res[ $k ] = $v; - } - return $_res; - } - - /** - * Save values for a set of keys to cache - * - * @param array $keys list of values to save - * @param int $expire expiration time - * - * @return boolean true on success, false on failure - */ - protected function write(array $keys, $expire = null) - { - foreach ($keys as $k => $v) { - apc_store($k, $v, $expire); - } - return true; - } - - /** - * Remove values from cache - * - * @param array $keys list of keys to delete - * - * @return boolean true on success, false on failure - */ - protected function delete(array $keys) - { - foreach ($keys as $k) { - apc_delete($k); - } - return true; - } - - /** - * Remove *all* values from cache - * - * @return boolean true on success, false on failure - */ - protected function purge() - { - return apc_clear_cache('user'); - } -} -- cgit v1.3