diff options
| author | hirosan <h-marumoto@cybozu.co.jp> | 2026-01-08 19:21:57 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-08 11:21:57 +0100 |
| commit | 6709d000cd08e4e1fdba4944c7d18275d2a0a2f1 (patch) | |
| tree | eb758fff6f4e7a73241de1fcfcc86e8e924a9d2b | |
| parent | aa6edc3c0bf8fc77cda9a06320021328c924cd68 (diff) | |
| download | smarty-6709d000cd08e4e1fdba4944c7d18275d2a0a2f1.tar.gz smarty-6709d000cd08e4e1fdba4944c7d18275d2a0a2f1.tar.bz2 smarty-6709d000cd08e4e1fdba4944c7d18275d2a0a2f1.zip | |
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
| -rw-r--r-- | src/Cacheresource/File.php | 10 | ||||
| -rw-r--r-- | src/Smarty.php | 8 | ||||
| -rw-r--r-- | src/Template/Compiled.php | 2 | ||||
| -rw-r--r-- | tests/PHPUnit_Smarty.php | 6 | ||||
| -rw-r--r-- | tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php | 31 | ||||
| -rw-r--r-- | tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php | 33 | ||||
| -rw-r--r-- | tests/UnitTests/__shared/cacheresources/cacheresource.apc.php | 73 |
7 files changed, 6 insertions, 157 deletions
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 @@ -<?php -/** - * Smarty PHPunit tests for cache resource Apc - * - - * @author Uwe Tews - */ -include_once __DIR__ . '/../Memcache/CacheResourceCustomMemcacheTest.php'; -include_once __DIR__ . '/../_shared/PHPunitplugins/cacheresource.apctest.php'; - -/** - * class for cache resource file tests - * - * - * @preserveGlobalState disabled - * - */ -class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest -{ - public function setUp(): void - { - if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) { - $this->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 @@ -<?php - -use Smarty\Smarty; -use Smarty\Template; -use Smarty\Template\Cached; - -require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.apc.php'; - -class Smarty_CacheResource_Apctest extends Smarty_CacheResource_Apc -{ - public $lockTime = 0; - - public function hasLock(Smarty $smarty, Cached $cached) - { - if ($this->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 @@ -<?php - -/** - * APC CacheResource - * CacheResource Implementation based on the KeyValueStore API to use - * memcache as the storage resource for Smarty's output caching. - * * - * - - * @author Uwe Tews - */ -class Smarty_CacheResource_Apc extends \Smarty\Cacheresource\KeyValueStore -{ - - /** - * Read values for a set of keys from cache - * - * @param array $keys list of keys to fetch - * - * @return array list of values with the given keys used as indexes - * @return boolean true on success, false on failure - */ - protected function read(array $keys) - { - $_res = array(); - $res = apc_fetch($keys); - foreach ($res as $k => $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'); - } -} |
