diff --git a/.appveyor.yml b/.appveyor.yml index 9d07c2b1e4..e8c068d6bc 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -38,4 +38,4 @@ before_test: test_script: - cd C:\projects\yii2 - - vendor\bin\phpunit --exclude-group mssql,mysql,pgsql,sqlite,db,oci,wincache,xcache,zenddata,cubrid + - vendor\bin\phpunit --exclude-group mssql,mysql,pgsql,sqlite,db,oci,wincache,cubrid diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed8393e0fd..ddd47c7eed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: env: DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi" EXTENSIONS: ${{ matrix.php < 8.0 && 'apc' || 'apcu' }}, curl, dom, imagick, intl, mbstring, mcrypt, memcached - PHPUNIT_COMMAND: --verbose --exclude-group db,wincache,xcache,zenddata --coverage-clover=coverage.xml --colors=always + PHPUNIT_COMMAND: --verbose --exclude-group db,wincache --coverage-clover=coverage.xml --colors=always XDEBUG_MODE: coverage runs-on: ubuntu-latest diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b01aa06c2..d7797e8712 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -109,5 +109,5 @@ travis: - docker-compose up --build -d # wait for dbs ... - sleep 10 - - docker-compose run --rm php vendor/bin/phpunit -v --exclude mssql,cubrid,oci,wincache,xcache,zenddata,cubrid + - docker-compose run --rm php vendor/bin/phpunit -v --exclude mssql,cubrid,oci,wincache,cubrid diff --git a/docs/guide-es/caching-data.md b/docs/guide-es/caching-data.md index 7aa09cd71c..3adc25f5c8 100644 --- a/docs/guide-es/caching-data.md +++ b/docs/guide-es/caching-data.md @@ -79,8 +79,6 @@ se muestra un listado con los componentes de caché disponibles: * [[yii\caching\MemCache]]: utiliza las extensiones de PHP [memcache](https://www.php.net/manual/es/book.memcache.php) y [memcached](https://www.php.net/manual/es/book.memcached.php). Esta opción puede ser considerada como la más rápida cuando la caché es manejada en una aplicación distribuida (ej. con varios servidores, con balance de carga, etc..) * [[yii\redis\Cache]]: implementa un componente de caché basado en [Redis](https://redis.io/) que almacenan pares clave-valor (requiere la versión 2.6.12 de redis). * [[yii\caching\WinCache]]: utiliza la extensión de PHP [WinCache](https://iis.net/downloads/microsoft/wincache-extension) ([ver también](https://www.php.net/manual/es/book.wincache.php)). -* [[yii\caching\XCache]] _(deprecated)_: utiliza la extensión de PHP [XCache](https://en.wikipedia.org/wiki/List_of_PHP_accelerators#XCache). -* [[yii\caching\ZendDataCache]] _(deprecated)_: utiliza [Zend Data Cache](https://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm) como el medio fundamental de caché. > Tip: Puedes utilizar diferentes tipos de almacenamiento de caché en la misma aplicación. Una estrategia común es la de usar almacenamiento de caché en memoria para almacenar datos que son pequeños pero que son utilizados constantemente (ej. datos estadísticos), y utilizar el almacenamiento de caché en archivos o en base de datos para guardar datos que son grandes y utilizados con menor frecuencia (ej. contenido de página). diff --git a/docs/guide-fr/caching-data.md b/docs/guide-fr/caching-data.md index 5f5cdcb8ae..13fcd05177 100644 --- a/docs/guide-fr/caching-data.md +++ b/docs/guide-fr/caching-data.md @@ -100,10 +100,6 @@ Yii prend en charge un large panel de supports de stockage pour cache. Ce qui su (une version de redis égale ou supérieure à 2.6.12 est nécessaire). * [[yii\caching\WinCache]]: utilise le [WinCache](https://iis.net/downloads/microsoft/wincache-extension) PHP ([voir aussi l'extension](https://www.php.net/manual/fr/book.wincache.php)). -* [[yii\caching\XCache]] _(deprecated)_: utilise l'extension PHP [XCache](https://en.wikipedia.org/wiki/List_of_PHP_accelerators#XCache). -* [[yii\caching\ZendDataCache]] _(deprecated)_: utilise le - [cache de données Zend](https://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm) - en tant que médium de cache sous-jacent. > Tip: vous pouvez utiliser différents supports de stockage pour cache dans la même application. Une stratégie courante est d'utiliser un support de stockage pour cache basé sur la mémoire pour stocker des données de petite taille mais d'usage constant (p. ex. des données statistiques), et d'utiliser des supports de stockage pour cache basés sur des fichiers ou des bases de données pour stocker des données volumineuses et utilisées moins souvent (p. ex. des contenus de pages). diff --git a/docs/guide-ja/caching-data.md b/docs/guide-ja/caching-data.md index e0d82eda60..d19a1471b5 100644 --- a/docs/guide-ja/caching-data.md +++ b/docs/guide-ja/caching-data.md @@ -128,10 +128,6 @@ Yii はさまざまなキャッシュ・ストレージをサポートしてい (Redis の バージョン 2.6.12 以降が必要とされます) 。 * [[yii\caching\WinCache]]: PHP の [WinCache](https://iis.net/downloads/microsoft/wincache-extension) エクステンションを使用します。 ([参照リンク](https://www.php.net/manual/ja/book.wincache.php)) -* [[yii\caching\XCache]] _(非推奨)_: PHP の [XCache](https://en.wikipedia.org/wiki/List_of_PHP_accelerators#XCache) 拡張モジュールを使用します。 -* [[yii\caching\ZendDataCache]] _(非推奨)_: - キャッシュ・メディアとして [Zend Data Cache](https://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm) - を使用します。 > Tip: 同じアプリケーション内で異なるキャッシュを使用することもできます。 diff --git a/docs/guide-pt-BR/caching-data.md b/docs/guide-pt-BR/caching-data.md index 3ac696c820..d39a493bfc 100644 --- a/docs/guide-pt-BR/caching-data.md +++ b/docs/guide-pt-BR/caching-data.md @@ -96,10 +96,6 @@ Yii suporta uma ampla gama de sistemas de cache. A seguir um resumo: [Redis](https://redis.io/) (requer redis versão 2.6.12 ou mais recente). * [[yii\caching\WinCache]]: usa a extensão PHP [WinCache](https://iis.net/downloads/microsoft/wincache-extension) ([veja também](https://www.php.net/manual/pt_BR/book.wincache.php)). -* [[yii\caching\XCache]] _(deprecated)_: usa a extensão PHP [XCache](https://en.wikipedia.org/wiki/List_of_PHP_accelerators#XCache). -* [[yii\caching\ZendDataCache]] _(deprecated)_: usa - [Cache de Dados Zend](https://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm) - como o meio de cache subjacente. > Dica: Você pode usar vários tipos de cache na mesma aplicação. Uma estratégia comum é usar caches baseados diff --git a/docs/guide-ru/caching-data.md b/docs/guide-ru/caching-data.md index 781fa94358..43c7d75408 100644 --- a/docs/guide-ru/caching-data.md +++ b/docs/guide-ru/caching-data.md @@ -102,8 +102,6 @@ Yii поддерживает множество хранилищ кэша: * [[yii\caching\MemCache]]: использует расширения PHP [memcache](https://www.php.net/manual/ru/book.memcache.php) и [memcached](https://www.php.net/manual/ru/book.memcached.php). Этот вариант может рассматриваться как самый быстрый при работе в распределенных приложениях (например, с несколькими серверами, балансировкой нагрузки и так далее); * [[yii\redis\Cache]]: реализует компонент кэша на основе [Redis](https://redis.io/), хранилища ключ-значение (требуется Redis версии 2.6.12 или выше); * [[yii\caching\WinCache]]: использует расширение PHP [WinCache](https://iis.net/downloads/microsoft/wincache-extension) ([смотрите также](https://www.php.net/manual/ru/book.wincache.php)); -* [[yii\caching\XCache]] _(deprecated)_: использует расширение PHP [XCache](https://en.wikipedia.org/wiki/List_of_PHP_accelerators#XCache); -* [[yii\caching\ZendDataCache]] _(deprecated)_: использует [Zend Data Cache](https://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm). > Tip: Вы можете использовать разные способы хранения кэша в одном приложении. Общая стратегия заключается в использовании памяти под хранение небольших часто используемых данных (например, статистические данные). Для больших и реже используемых данных (например, содержимое страницы) лучше использовать файлы или базу данных. diff --git a/docs/guide-zh-CN/caching-data.md b/docs/guide-zh-CN/caching-data.md index 2fd3e3cfa5..a537579b49 100644 --- a/docs/guide-zh-CN/caching-data.md +++ b/docs/guide-zh-CN/caching-data.md @@ -128,10 +128,6 @@ Yii 支持一系列缓存存储器,概况如下: (需要 redis 2.6.12 及以上版本的支持 )。 * [[yii\caching\WinCache]]:使用 PHP [WinCache](https://iis.net/downloads/microsoft/wincache-extension) ([另可参考](https://www.php.net/manual/zh/book.wincache.php))扩展. -* [[yii\caching\XCache]]:使用 PHP [XCache](https://en.wikipedia.org/wiki/List_of_PHP_accelerators#XCache)扩展。 -* [[yii\caching\ZendDataCache]]:使用 - [Zend Data Cache](https://files.zend.com/help/Zend-Server-6/zend- server.htm#data_cache_component.htm) - 作为底层缓存媒介。 > Tip: 你可以在同一个应用程序中使用不同的缓存存储器。一个常见的策略是使用基于内存的缓存存储器 diff --git a/docs/guide/caching-data.md b/docs/guide/caching-data.md index 2666e544d4..89b1e54506 100644 --- a/docs/guide/caching-data.md +++ b/docs/guide/caching-data.md @@ -130,11 +130,6 @@ Yii supports a wide range of cache storage. The following is a summary: (redis version 2.6.12 or higher is required). * [[yii\caching\WinCache]]: uses PHP [WinCache](https://iis.net/downloads/microsoft/wincache-extension) ([see also](https://www.php.net/manual/en/book.wincache.php)) extension. -* [[yii\caching\XCache]] _(deprecated)_: uses PHP [XCache](https://en.wikipedia.org/wiki/List_of_PHP_accelerators#XCache) extension. -* [[yii\caching\ZendDataCache]] _(deprecated)_: uses - [Zend Data Cache](https://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm) - as the underlying caching medium. - > Tip: You may use different cache storage in the same application. A common strategy is to use memory-based cache storage to store data that is small but constantly used (e.g. statistical data), and use file-based diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 5a31ff5d71..8dab880b17 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,7 +1,7 @@ Yii Framework 2 Change Log ========================== -2.0.54 under development +2.0.60 under development ------------------------ - Bug #20483: Fix `CompositeAuth` making bad assumptions on `AuthInterface` implementations (sammousa) - Bug #20432: Fix PHPStan/Psalm annotations for `ActiveQuery::asArray` (max-s-lab) @@ -33,6 +33,7 @@ Yii Framework 2 Change Log - Bug #20524: Fix PHPStan/Psalm annotations in `Yii::createObject` (max-s-lab) - Bug #20530: Fix notice "Object of class DateTimeImmutable could not be converted to int" in `CookieCollection::has` (max-s-lab) - Enh #20539: Update minimum PHP version requirement from `7.3` to `7.4` (terabytesoftw) +- Bug #20541: Remove deprecated caching components: `XCache` and `ZendDataCache`, and update related tests and documentation (terabytesoftw) 2.0.53 June 27, 2025 diff --git a/framework/UPGRADE.md b/framework/UPGRADE.md index 3c57a0cf3b..29e4ac754e 100644 --- a/framework/UPGRADE.md +++ b/framework/UPGRADE.md @@ -51,6 +51,12 @@ if you want to upgrade from version A to version C and there is version B between A and C, you need to follow the instructions for both A and B. +Upgrade from Yii 2.0.60 +----------------------- + +* Deprecated caching components: `XCache` and `ZendDataCache` have been removed. If you were using these components, you +will need to replace them with alternative caching solutions. + Upgrade from Yii 2.0.52 ----------------------- diff --git a/framework/caching/XCache.php b/framework/caching/XCache.php deleted file mode 100644 index 2b40d164a5..0000000000 --- a/framework/caching/XCache.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @since 2.0 - * @deprecated since 2.0.14. This class will be removed in 2.1.0. - */ -class XCache extends Cache -{ - /** - * Checks whether a specified key exists in the cache. - * This can be faster than getting the value from the cache if the data is big. - * Note that this method does not check whether the dependency associated - * with the cached data, if there is any, has changed. So a call to [[get]] - * may return false while exists returns true. - * @param mixed $key a key identifying the cached value. This can be a simple string or - * a complex data structure consisting of factors representing the key. - * @return bool true if a value exists in cache, false if the value is not in the cache or expired. - */ - public function exists($key) - { - $key = $this->buildKey($key); - - return xcache_isset($key); - } - - /** - * Retrieves a value from cache with a specified key. - * This is the implementation of the method declared in the parent class. - * @param string $key a unique key identifying the cached value - * @return mixed|false the value stored in cache, false if the value is not in the cache or expired. - */ - protected function getValue($key) - { - return xcache_isset($key) ? xcache_get($key) : false; - } - - /** - * Stores a value identified by a key in cache. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function setValue($key, $value, $duration) - { - return xcache_set($key, $value, $duration); - } - - /** - * Stores a value identified by a key into cache if the cache does not contain this key. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function addValue($key, $value, $duration) - { - return !xcache_isset($key) ? $this->setValue($key, $value, $duration) : false; - } - - /** - * Deletes a value with the specified key from cache - * This is the implementation of the method declared in the parent class. - * @param string $key the key of the value to be deleted - * @return bool if no error happens during deletion - */ - protected function deleteValue($key) - { - return xcache_unset($key); - } - - /** - * Deletes all values from cache. - * This is the implementation of the method declared in the parent class. - * @return bool whether the flush operation was successful. - */ - protected function flushValues() - { - for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) { - xcache_clear_cache(XC_TYPE_VAR, $i); - } - - return true; - } -} diff --git a/framework/caching/ZendDataCache.php b/framework/caching/ZendDataCache.php deleted file mode 100644 index 0f49501db4..0000000000 --- a/framework/caching/ZendDataCache.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @since 2.0 - * @deprecated since 2.0.14. This class will be removed in 2.1.0. - */ -class ZendDataCache extends Cache -{ - /** - * Retrieves a value from cache with a specified key. - * This is the implementation of the method declared in the parent class. - * @param string $key a unique key identifying the cached value - * @return mixed|false the value stored in cache, false if the value is not in the cache or expired. - */ - protected function getValue($key) - { - $result = zend_shm_cache_fetch($key); - - return $result === null ? false : $result; - } - - /** - * Stores a value identified by a key in cache. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function setValue($key, $value, $duration) - { - return zend_shm_cache_store($key, $value, $duration); - } - - /** - * Stores a value identified by a key into cache if the cache does not contain this key. - * This is the implementation of the method declared in the parent class. - * - * @param string $key the key identifying the value to be cached - * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]], - * it could be something else. - * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire. - * @return bool true if the value is successfully stored into cache, false otherwise - */ - protected function addValue($key, $value, $duration) - { - return zend_shm_cache_fetch($key) === null ? $this->setValue($key, $value, $duration) : false; - } - - /** - * Deletes a value with the specified key from cache - * This is the implementation of the method declared in the parent class. - * @param string $key the key of the value to be deleted - * @return bool if no error happens during deletion - */ - protected function deleteValue($key) - { - return zend_shm_cache_delete($key); - } - - /** - * Deletes all values from cache. - * This is the implementation of the method declared in the parent class. - * @return bool whether the flush operation was successful. - */ - protected function flushValues() - { - return zend_shm_cache_clear(); - } -} diff --git a/framework/classes.php b/framework/classes.php index 03b69c92a5..114cbb1bdc 100644 --- a/framework/classes.php +++ b/framework/classes.php @@ -86,8 +86,6 @@ return [ 'yii\caching\MemCacheServer' => YII2_PATH . '/caching/MemCacheServer.php', 'yii\caching\TagDependency' => YII2_PATH . '/caching/TagDependency.php', 'yii\caching\WinCache' => YII2_PATH . '/caching/WinCache.php', - 'yii\caching\XCache' => YII2_PATH . '/caching/XCache.php', - 'yii\caching\ZendDataCache' => YII2_PATH . '/caching/ZendDataCache.php', 'yii\captcha\Captcha' => YII2_PATH . '/captcha/Captcha.php', 'yii\captcha\CaptchaAction' => YII2_PATH . '/captcha/CaptchaAction.php', 'yii\captcha\CaptchaAsset' => YII2_PATH . '/captcha/CaptchaAsset.php', diff --git a/phpstan-baseline-7x.neon b/phpstan-baseline-7x.neon index 4983392731..612a53bf9a 100644 --- a/phpstan-baseline-7x.neon +++ b/phpstan-baseline-7x.neon @@ -10,11 +10,6 @@ parameters: count: 1 path: framework/behaviors/AttributeTypecastBehavior.php - - - message: "#^Constant XC_TYPE_VAR not found\\.$#" - count: 2 - path: framework/caching/XCache.php - - message: "#^Method yii\\\\console\\\\controllers\\\\CacheController\\:\\:actionFlushSchema\\(\\) should return int but return statement is missing\\.$#" count: 1 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7eb31e9683..b954ad65f4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5,11 +5,6 @@ parameters: count: 1 path: build/controllers/DevController.php - - - message: "#^Constant XC_TYPE_VAR not found\\.$#" - count: 2 - path: framework/caching/XCache.php - - message: "#^Method yii\\\\console\\\\controllers\\\\CacheController\\:\\:actionFlushSchema\\(\\) should return int but return statement is missing\\.$#" count: 1 diff --git a/tests/README.md b/tests/README.md index d4bbe4ecf2..11b110bbe0 100644 --- a/tests/README.md +++ b/tests/README.md @@ -85,7 +85,7 @@ Run a group of unit tests docker-compose run php vendor/bin/phpunit -v --group caching,db docker-compose run php vendor/bin/phpunit -v --exclude base,caching,db,i18n,log,mutex,rbac,validators,web - docker-compose run php vendor/bin/phpunit -v --exclude mssql,oci,wincache,xcache,zenddata,cubrid + docker-compose run php vendor/bin/phpunit -v --exclude mssql,oci,wincache,cubrid > Note: Documentation about [installing additional extensions](https://github.com/yiisoft/yii2-docker/blob/master/docs/install-extensions.md) can be found at `yiisoft/yii2-docker`. diff --git a/tests/framework/caching/XCacheTest.php b/tests/framework/caching/XCacheTest.php deleted file mode 100644 index 68859325ff..0000000000 --- a/tests/framework/caching/XCacheTest.php +++ /dev/null @@ -1,36 +0,0 @@ -markTestSkipped('XCache not installed. Skipping.'); - } - - if ($this->_cacheInstance === null) { - $this->_cacheInstance = new XCache(); - } - - return $this->_cacheInstance; - } -} diff --git a/tests/framework/caching/ZendDataCacheTest.php b/tests/framework/caching/ZendDataCacheTest.php deleted file mode 100644 index 728b004295..0000000000 --- a/tests/framework/caching/ZendDataCacheTest.php +++ /dev/null @@ -1,36 +0,0 @@ -markTestSkipped('Zend Data cache not installed. Skipping.'); - } - - if ($this->_cacheInstance === null) { - $this->_cacheInstance = new ZendDataCache(); - } - - return $this->_cacheInstance; - } -}