From d039f56af00fb98b2b03f54f00ce4bb1436e9932 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 22 Jun 2014 22:49:33 +0200 Subject: [ticket/12387] Use the hash as query_id for caching PHPBB3-12387 --- phpBB/phpbb/cache/driver/file.php | 8 ++++---- phpBB/phpbb/cache/driver/memory.php | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index b32af32d25..fbd3b571f7 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -396,13 +396,13 @@ class file extends \phpbb\cache\driver\base { // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); + $query_id = md5($query); - if (($rowset = $this->_read('sql_' . md5($query))) === false) + if (($rowset = $this->_read('sql_' . $query_id)) === false) { return false; } - $query_id = sizeof($this->sql_rowset); $this->sql_rowset[$query_id] = $rowset; $this->sql_row_pointer[$query_id] = 0; @@ -417,7 +417,7 @@ class file extends \phpbb\cache\driver\base // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = sizeof($this->sql_rowset); + $query_id = md5($query); $this->sql_rowset[$query_id] = array(); $this->sql_row_pointer[$query_id] = 0; @@ -427,7 +427,7 @@ class file extends \phpbb\cache\driver\base } $db->sql_freeresult($query_result); - if ($this->_write('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl + time(), $query)) + if ($this->_write('sql_' . $query_id, $this->sql_rowset[$query_id], $ttl + time(), $query)) { return $query_id; } diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index 5dee375192..cb2b6a10a7 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -266,9 +266,9 @@ abstract class memory extends \phpbb\cache\driver\base { // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = sizeof($this->sql_rowset); + $query_id = md5($query); - if (($result = $this->_read('sql_' . md5($query))) === false) + if (($result = $this->_read('sql_' . $query_id)) === false) { return false; } @@ -286,7 +286,7 @@ abstract class memory extends \phpbb\cache\driver\base { // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $hash = md5($query); + $query_id = md5($query); // determine which tables this query belongs to // Some queries use backticks, namely the get_database_size() query @@ -315,14 +315,13 @@ abstract class memory extends \phpbb\cache\driver\base $temp = array(); } - $temp[$hash] = true; + $temp[$query_id] = true; // This must never expire $this->_write('sql_' . $table_name, $temp, 0); } // store them in the right place - $query_id = sizeof($this->sql_rowset); $this->sql_rowset[$query_id] = array(); $this->sql_row_pointer[$query_id] = 0; @@ -332,7 +331,7 @@ abstract class memory extends \phpbb\cache\driver\base } $db->sql_freeresult($query_result); - $this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); + $this->_write('sql_' . $query_id, $this->sql_rowset[$query_id], $ttl); return $query_id; } -- cgit v1.2.1 From a5bfc76a73a213a388126d0f697ba64f27a4b00d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 14 Sep 2014 21:18:20 +0200 Subject: [ticket/13063] Introduces a new \phpbb\routing\router class PHPBB3-13063 --- phpBB/phpbb/cache/driver/base.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php index b357431589..c83b928a12 100644 --- a/phpBB/phpbb/cache/driver/base.php +++ b/phpBB/phpbb/cache/driver/base.php @@ -50,6 +50,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface } else if (strpos($filename, 'container_') === 0 || strpos($filename, 'url_matcher') === 0 || + strpos($filename, 'url_generator') === 0 || strpos($filename, 'sql_') === 0 || strpos($filename, 'data_') === 0) { -- cgit v1.2.1 From aa061aa7c9187009f220e62252a53b49dad7644a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 29 Sep 2014 16:06:56 +0200 Subject: [ticket/12620] Uses a cache directory per environment PHPBB3-12620 --- phpBB/phpbb/cache/driver/file.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index adfe87b740..d3708fe9a0 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -28,7 +28,12 @@ class file extends \phpbb\cache\driver\base function __construct($cache_dir = null) { global $phpbb_root_path; - $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/'; + $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'; + + if (!is_dir($this->cache_dir)) + { + @mkdir($this->cache_dir, 0777, true); + } } /** -- cgit v1.2.1 From acc91a2bbf28656d4a6917b457ba3dd6b4e02e37 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 11 Nov 2014 17:59:41 +0100 Subject: [ticket/12620] Use the container to get the environment name PHPBB3-12620 --- phpBB/phpbb/cache/driver/file.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index d3708fe9a0..114959c06c 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -27,8 +27,9 @@ class file extends \phpbb\cache\driver\base */ function __construct($cache_dir = null) { - global $phpbb_root_path; - $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'; + global $phpbb_root_path, $phpbb_container; + + $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/'; if (!is_dir($this->cache_dir)) { -- cgit v1.2.1 From 79d4ff553844fa80be4da9286239f62a45489072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 11 Jan 2015 17:32:31 +0100 Subject: [ticket/13494] Update calls to `set_config()` PHPBB3-13494 --- phpBB/phpbb/cache/driver/eaccelerator.php | 4 +++- phpBB/phpbb/cache/driver/file.php | 4 ++-- phpBB/phpbb/cache/driver/memory.php | 5 +++-- phpBB/phpbb/cache/driver/null.php | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/eaccelerator.php b/phpBB/phpbb/cache/driver/eaccelerator.php index 1697758acc..740855144f 100644 --- a/phpBB/phpbb/cache/driver/eaccelerator.php +++ b/phpBB/phpbb/cache/driver/eaccelerator.php @@ -44,9 +44,11 @@ class eaccelerator extends \phpbb\cache\driver\memory */ function tidy() { + global $config; + eaccelerator_gc(); - set_config('cache_last_gc', time(), true); + $config->set('cache_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 114959c06c..9c63d0010c 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -95,7 +95,7 @@ class file extends \phpbb\cache\driver\base */ function tidy() { - global $phpEx; + global $config, $phpEx; $dir = @opendir($this->cache_dir); @@ -149,7 +149,7 @@ class file extends \phpbb\cache\driver\base } } - set_config('cache_last_gc', time(), true); + $config->set('cache_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index 0cef9c3483..baae22d809 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -81,9 +81,10 @@ abstract class memory extends \phpbb\cache\driver\base */ function tidy() { - // cache has auto GC, no need to have any code here :) + global $config; - set_config('cache_last_gc', time(), true); + // cache has auto GC, no need to have any code here :) + $config->set('cache_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/cache/driver/null.php b/phpBB/phpbb/cache/driver/null.php index a45cf97862..298731ea54 100644 --- a/phpBB/phpbb/cache/driver/null.php +++ b/phpBB/phpbb/cache/driver/null.php @@ -52,8 +52,10 @@ class null extends \phpbb\cache\driver\base */ function tidy() { + global $config; + // This cache always has a tidy room. - set_config('cache_last_gc', time(), true); + $config->set('cache_last_gc', time(), false); } /** -- cgit v1.2.1 From 4bdef6fd21a5dcab455b0cd1ee2652de606929c3 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 12 Mar 2015 00:25:00 +0100 Subject: [ticket/13697] Moving filesystem related functions to filesystem service * Moving filesystem service to \phpbb\filesystem namespace * Wraping Symfony's Filesystem component * Moving filesystem related functions from includes/functions.php into \phpbb\filesystem\filesystem Functions moved (and deprecated): - phpbb_chmod - phpbb_is_writable - phpbb_is_absolute - phpbb_own_realpath - phpbb_realpath * Adding interface for filesystem service PHPBB3-13697 --- phpBB/phpbb/cache/driver/base.php | 8 ++------ phpBB/phpbb/cache/driver/file.php | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php index c83b928a12..55cd4668de 100644 --- a/phpBB/phpbb/cache/driver/base.php +++ b/phpBB/phpbb/cache/driver/base.php @@ -177,13 +177,9 @@ abstract class base implements \phpbb\cache\driver\driver_interface */ function remove_file($filename, $check = false) { - if (!function_exists('phpbb_is_writable')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions.' . $phpEx); - } + global $phpbb_filesystem; - if ($check && !phpbb_is_writable($this->cache_dir)) + if ($check && !$phpbb_filesystem->is_writable($this->cache_dir)) { // E_USER_ERROR - not using language entry - intended. trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 32086458ee..bb055d3acf 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -20,6 +20,11 @@ class file extends \phpbb\cache\driver\base { var $var_expires = array(); + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + /** * Set cache path * @@ -30,6 +35,7 @@ class file extends \phpbb\cache\driver\base global $phpbb_root_path, $phpbb_container; $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/'; + $this->filesystem = new \phpbb\filesystem\filesystem(); if (!is_dir($this->cache_dir)) { @@ -69,14 +75,8 @@ class file extends \phpbb\cache\driver\base if (!$this->_write('data_global')) { - if (!function_exists('phpbb_is_writable')) - { - global $phpbb_root_path; - include($phpbb_root_path . 'includes/functions.' . $phpEx); - } - // Now, this occurred how often? ... phew, just tell the user then... - if (!phpbb_is_writable($this->cache_dir)) + if (!$this->filesystem->is_writable($this->cache_dir)) { // We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload()) die('Fatal: ' . $this->cache_dir . ' is NOT writable.'); @@ -574,13 +574,14 @@ class file extends \phpbb\cache\driver\base fclose($handle); - if (!function_exists('phpbb_chmod')) + try { - global $phpbb_root_path; - include($phpbb_root_path . 'includes/functions.' . $phpEx); + $this->filesystem->phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing } - - phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE); $return_value = true; } -- cgit v1.2.1 From b3cc20a575da12e7b66f3883dcc7f0eb6ca82ad8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 May 2015 10:09:37 +0200 Subject: [ticket/13782] Rename null driver to dummy for PHP7 compatibility PHPBB3-13782 --- phpBB/phpbb/cache/driver/dummy.php | 153 +++++++++++++++++++++++++++++++++++++ phpBB/phpbb/cache/driver/null.php | 153 ------------------------------------- 2 files changed, 153 insertions(+), 153 deletions(-) create mode 100644 phpBB/phpbb/cache/driver/dummy.php delete mode 100644 phpBB/phpbb/cache/driver/null.php (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/dummy.php b/phpBB/phpbb/cache/driver/dummy.php new file mode 100644 index 0000000000..1f74f6dd77 --- /dev/null +++ b/phpBB/phpbb/cache/driver/dummy.php @@ -0,0 +1,153 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\cache\driver; + +/** +* ACM dummy Caching +*/ +class dummy extends \phpbb\cache\driver\base +{ + /** + * Set cache path + */ + function __construct() + { + } + + /** + * {@inheritDoc} + */ + function load() + { + return true; + } + + /** + * {@inheritDoc} + */ + function unload() + { + } + + /** + * {@inheritDoc} + */ + function save() + { + } + + /** + * {@inheritDoc} + */ + function tidy() + { + global $config; + + // This cache always has a tidy room. + $config->set('cache_last_gc', time(), false); + } + + /** + * {@inheritDoc} + */ + function get($var_name) + { + return false; + } + + /** + * {@inheritDoc} + */ + function put($var_name, $var, $ttl = 0) + { + } + + /** + * {@inheritDoc} + */ + function purge() + { + } + + /** + * {@inheritDoc} + */ + function destroy($var_name, $table = '') + { + } + + /** + * {@inheritDoc} + */ + function _exists($var_name) + { + return false; + } + + /** + * {@inheritDoc} + */ + function sql_load($query) + { + return false; + } + + /** + * {@inheritDoc} + */ + function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) + { + return $query_result; + } + + /** + * {@inheritDoc} + */ + function sql_exists($query_id) + { + return false; + } + + /** + * {@inheritDoc} + */ + function sql_fetchrow($query_id) + { + return false; + } + + /** + * {@inheritDoc} + */ + function sql_fetchfield($query_id, $field) + { + return false; + } + + /** + * {@inheritDoc} + */ + function sql_rowseek($rownum, $query_id) + { + return false; + } + + /** + * {@inheritDoc} + */ + function sql_freeresult($query_id) + { + return false; + } +} diff --git a/phpBB/phpbb/cache/driver/null.php b/phpBB/phpbb/cache/driver/null.php deleted file mode 100644 index 298731ea54..0000000000 --- a/phpBB/phpbb/cache/driver/null.php +++ /dev/null @@ -1,153 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\cache\driver; - -/** -* ACM Null Caching -*/ -class null extends \phpbb\cache\driver\base -{ - /** - * Set cache path - */ - function __construct() - { - } - - /** - * {@inheritDoc} - */ - function load() - { - return true; - } - - /** - * {@inheritDoc} - */ - function unload() - { - } - - /** - * {@inheritDoc} - */ - function save() - { - } - - /** - * {@inheritDoc} - */ - function tidy() - { - global $config; - - // This cache always has a tidy room. - $config->set('cache_last_gc', time(), false); - } - - /** - * {@inheritDoc} - */ - function get($var_name) - { - return false; - } - - /** - * {@inheritDoc} - */ - function put($var_name, $var, $ttl = 0) - { - } - - /** - * {@inheritDoc} - */ - function purge() - { - } - - /** - * {@inheritDoc} - */ - function destroy($var_name, $table = '') - { - } - - /** - * {@inheritDoc} - */ - function _exists($var_name) - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_load($query) - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) - { - return $query_result; - } - - /** - * {@inheritDoc} - */ - function sql_exists($query_id) - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchrow($query_id) - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_fetchfield($query_id, $field) - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_rowseek($rownum, $query_id) - { - return false; - } - - /** - * {@inheritDoc} - */ - function sql_freeresult($query_id) - { - return false; - } -} -- cgit v1.2.1 From cc38bf550b6d044938532d96a98dd92767e69b61 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 25 Jan 2016 13:50:23 +0100 Subject: [ticket/14129] Caches extensions autoloaders PHPBB3-14129 --- phpBB/phpbb/cache/driver/base.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php index 55cd4668de..85762c4d95 100644 --- a/phpBB/phpbb/cache/driver/base.php +++ b/phpBB/phpbb/cache/driver/base.php @@ -49,6 +49,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface $this->remove_dir($fileInfo->getPathname()); } else if (strpos($filename, 'container_') === 0 || + strpos($filename, 'autoload_') === 0 || strpos($filename, 'url_matcher') === 0 || strpos($filename, 'url_generator') === 0 || strpos($filename, 'sql_') === 0 || -- cgit v1.2.1 From 56c2caf6c0778c0da48fe0ac688c893777b89ee4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 22:48:58 +0100 Subject: [ticket/14555] Uniformize cache directory usages PHPBB3-14555 --- phpBB/phpbb/cache/driver/file.php | 4 ++-- phpBB/phpbb/cache/driver/memory.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index d994394249..a210d877f0 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -32,9 +32,9 @@ class file extends \phpbb\cache\driver\base */ function __construct($cache_dir = null) { - global $phpbb_root_path, $phpbb_container; + global $phpbb_container; - $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/'; + $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_container->getParameter('core.cache_dir'); $this->filesystem = new \phpbb\filesystem\filesystem(); if (!is_dir($this->cache_dir)) diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index baae22d809..cc03804705 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -25,9 +25,9 @@ abstract class memory extends \phpbb\cache\driver\base */ function __construct() { - global $phpbb_root_path, $dbname, $table_prefix; + global $phpbb_root_path, $dbname, $table_prefix, $phpbb_container; - $this->cache_dir = $phpbb_root_path . 'cache/'; + $this->cache_dir = $phpbb_container->getParameter('core.cache_dir'); $this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_'; if (!isset($this->extension) || !extension_loaded($this->extension)) -- cgit v1.2.1 From 7f408e4b4184e4c850156090e648fc120985c975 Mon Sep 17 00:00:00 2001 From: v12mike Date: Mon, 26 Jun 2017 12:43:23 +0100 Subject: [PHPBB3-15247] Add support for php v7 APCu cache API Add new cache driver apcu.php (based closely on existing APC cache driver) Add new unit test apcu_driver_test.php for the new driver Update RUNNING_TESTS.md to clarify requirements for apc, apcu and apc_bc extensions and add a couple of general hints to RUNNING_TESTS.md PHPBB3-15247 --- phpBB/phpbb/cache/driver/apcu.php | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 phpBB/phpbb/cache/driver/apcu.php (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php new file mode 100644 index 0000000000..40192e4026 --- /dev/null +++ b/phpBB/phpbb/cache/driver/apcu.php @@ -0,0 +1,70 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\cache\driver; + +/** +* ACM for APCU +*/ +class apcu extends \phpbb\cache\driver\memory +{ + var $extension = 'apcu'; + + /** + * {@inheritDoc} + */ + function purge() + { + apcu_clear_cache(); + + parent::purge(); + } + + /** + * Fetch an item from the cache + * + * @access protected + * @param string $var Cache key + * @return mixed Cached data + */ + function _read($var) + { + return apcu_fetch($this->key_prefix . $var); + } + + /** + * Store data in the cache + * + * @access protected + * @param string $var Cache key + * @param mixed $data Data to store + * @param int $ttl Time-to-live of cached data + * @return bool True if the operation succeeded + */ + function _write($var, $data, $ttl = 2592000) + { + return apcu_store($this->key_prefix . $var, $data, $ttl); + } + + /** + * Remove an item from the cache + * + * @access protected + * @param string $var Cache key + * @return bool True if the operation succeeded + */ + function _delete($var) + { + return apcu_delete($this->key_prefix . $var); + } +} -- cgit v1.2.1 From ef404d0f95a3fd47c936239c1f6392b5851440b9 Mon Sep 17 00:00:00 2001 From: abyssmedia <30393121+abyssmedia@users.noreply.github.com> Date: Mon, 24 Jul 2017 00:04:43 +0400 Subject: [ticket/15303] Correctly refer to $memcached and not $memcache PHPBB3-15303 --- phpBB/phpbb/cache/driver/memcached.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/memcached.php b/phpBB/phpbb/cache/driver/memcached.php index a7da22d7e8..808e15afe8 100644 --- a/phpBB/phpbb/cache/driver/memcached.php +++ b/phpBB/phpbb/cache/driver/memcached.php @@ -68,7 +68,7 @@ class memcached extends \phpbb\cache\driver\memory foreach (explode(',', PHPBB_ACM_MEMCACHE) as $u) { preg_match('#(.*)/(\d+)#', $u, $parts); - $this->memcache->addServer(trim($parts[1]), (int) trim($parts[2])); + $this->memcached->addServer(trim($parts[1]), (int) trim($parts[2])); } } -- cgit v1.2.1 From a6c9119dfa1cf812292fffe1131f3b9f3bfebfc7 Mon Sep 17 00:00:00 2001 From: Jagoba Los Arcos Date: Sun, 13 Aug 2017 22:49:24 +0200 Subject: [ticket/15320] Redis cache does not save keys withouth expiration In some functions like sql_save in cache/memory.php, code try to save a key/value in cache with ttl = 0 so key should never expire. In current redis.php cache driver, it fails so key never get cached. This cause for example that when you create a subforum, it not appear in the forum box in the admincp. To solve, if ttl is 0, we use redis->set instead of setex --- phpBB/phpbb/cache/driver/redis.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/redis.php b/phpBB/phpbb/cache/driver/redis.php index eda774491c..8c9cd933a5 100644 --- a/phpBB/phpbb/cache/driver/redis.php +++ b/phpBB/phpbb/cache/driver/redis.php @@ -137,6 +137,10 @@ class redis extends \phpbb\cache\driver\memory */ function _write($var, $data, $ttl = 2592000) { + if($ttl == 0) + { + return $this->redis->set($var, $data); + } return $this->redis->setex($var, $ttl, $data); } -- cgit v1.2.1 From 4e5fd9a6e925487fe424538f4a2e6905f00da43d Mon Sep 17 00:00:00 2001 From: Jagoba Los Arcos Date: Mon, 14 Aug 2017 13:00:54 +0200 Subject: [ticket/15320] Fix to accomplish coding guidelines --- phpBB/phpbb/cache/driver/redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/redis.php b/phpBB/phpbb/cache/driver/redis.php index 8c9cd933a5..eaeb529918 100644 --- a/phpBB/phpbb/cache/driver/redis.php +++ b/phpBB/phpbb/cache/driver/redis.php @@ -137,7 +137,7 @@ class redis extends \phpbb\cache\driver\memory */ function _write($var, $data, $ttl = 2592000) { - if($ttl == 0) + if ($ttl == 0) { return $this->redis->set($var, $data); } -- cgit v1.2.1 From f1f35f7f3d7deb6316d1582a81462f7eab32821d Mon Sep 17 00:00:00 2001 From: kasimi Date: Sat, 16 Sep 2017 11:10:04 +0200 Subject: [ticket/15365] Fix invalidating OPcache PHPBB3-15365 --- phpBB/phpbb/cache/driver/file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 497f00c06b..e9d2ba8e04 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -576,7 +576,7 @@ class file extends \phpbb\cache\driver\base if (function_exists('opcache_invalidate')) { - @opcache_invalidate($this->cache_file); + @opcache_invalidate($file); } try -- cgit v1.2.1 From 5aceccf00b4fd8fe5191e07d9259b17213f38921 Mon Sep 17 00:00:00 2001 From: Julien Tant Date: Sun, 15 Oct 2017 03:02:43 +0200 Subject: [ticket/15401] Use separate constant for memcached driver config PHPBB3-15401 --- phpBB/phpbb/cache/driver/memcached.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/memcached.php b/phpBB/phpbb/cache/driver/memcached.php index 808e15afe8..7d66759ec2 100644 --- a/phpBB/phpbb/cache/driver/memcached.php +++ b/phpBB/phpbb/cache/driver/memcached.php @@ -65,7 +65,7 @@ class memcached extends \phpbb\cache\driver\memory $this->memcached->setOption(\Memcached::OPT_COMPRESSION, false); } - foreach (explode(',', PHPBB_ACM_MEMCACHE) as $u) + foreach (explode(',', PHPBB_ACM_MEMCACHED) as $u) { preg_match('#(.*)/(\d+)#', $u, $parts); $this->memcached->addServer(trim($parts[1]), (int) trim($parts[2])); -- cgit v1.2.1 From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- phpBB/phpbb/cache/driver/base.php | 6 +++--- phpBB/phpbb/cache/driver/file.php | 4 ++-- phpBB/phpbb/cache/driver/memory.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php index f4b3dc278d..3eca521148 100644 --- a/phpBB/phpbb/cache/driver/base.php +++ b/phpBB/phpbb/cache/driver/base.php @@ -123,7 +123,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface */ function sql_fetchrow($query_id) { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + if ($this->sql_row_pointer[$query_id] < count($this->sql_rowset[$query_id])) { return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++]; } @@ -136,7 +136,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface */ function sql_fetchfield($query_id, $field) { - if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id])) + if ($this->sql_row_pointer[$query_id] < count($this->sql_rowset[$query_id])) { return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++][$field] : false; } @@ -149,7 +149,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface */ function sql_rowseek($rownum, $query_id) { - if ($rownum >= sizeof($this->sql_rowset[$query_id])) + if ($rownum >= count($this->sql_rowset[$query_id])) { return false; } diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index e9d2ba8e04..de6f444251 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -135,7 +135,7 @@ class file extends \phpbb\cache\driver\base if (file_exists($this->cache_dir . 'data_global.' . $phpEx)) { - if (!sizeof($this->vars)) + if (!count($this->vars)) { $this->load(); } @@ -290,7 +290,7 @@ class file extends \phpbb\cache\driver\base } else { - if (!sizeof($this->vars)) + if (!count($this->vars)) { $this->load(); } diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index cc03804705..052f40c243 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -188,7 +188,7 @@ abstract class memory extends \phpbb\cache\driver\base } else { - if (!sizeof($this->vars)) + if (!count($this->vars)) { $this->load(); } -- cgit v1.2.1 From c7631635fa738f4c7df45f6f671d2eb47f2f72a3 Mon Sep 17 00:00:00 2001 From: hubaishan Date: Sun, 16 Sep 2018 06:38:58 +0300 Subject: [ticket/15791] php 7.2 count() bug in memory cache driver function `_read` in classes inherted from `memory` may returns `false` but `$vars` must be an array PHPBB3-15791 --- phpBB/phpbb/cache/driver/memory.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index 052f40c243..eba9549877 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -51,10 +51,11 @@ abstract class memory extends \phpbb\cache\driver\base function load() { // grab the global cache - $this->vars = $this->_read('global'); + $data = $this->_read('global'); - if ($this->vars !== false) + if ($data !== false) { + $this->vars = $data; return true; } -- cgit v1.2.1 From 02234783c6f0fd9b15faf7a17d3bb8b1d39da557 Mon Sep 17 00:00:00 2001 From: v12mike Date: Sun, 15 Jul 2018 21:50:18 +0100 Subject: [ticket/15726] Implement selective purge in APCu cache driver The current APCu cache driver implements a global clearing of the APCu when the phpBB cache is purged. This is inappropriate if there are other phpBB boards, or other php applications sharing the APCu cache. This patch changes the behviour so that only cache entries matching the key_prefix of this board are cleared by a phpBB cache purge. The APCu unit test script has been updated to test this behaviour. It has also been updated so that the test case can be run individually previously it relied on initialisations made in other test scripts. PHPBB3-15726 --- phpBB/phpbb/cache/driver/apcu.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 phpBB/phpbb/cache/driver/apcu.php (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php old mode 100644 new mode 100755 index 40192e4026..6a65e7155a --- a/phpBB/phpbb/cache/driver/apcu.php +++ b/phpBB/phpbb/cache/driver/apcu.php @@ -25,7 +25,11 @@ class apcu extends \phpbb\cache\driver\memory */ function purge() { - apcu_clear_cache(); + /* use an iterator to selectively clear our cache entries without + disturbing any other cache users + (e.g. other phpBB boards hosted on this server) */ + apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#')); + parent::purge(); } -- cgit v1.2.1 From 63a3033f15428b1af9a121708eb4a2bd4bef43c0 Mon Sep 17 00:00:00 2001 From: v12mike Date: Mon, 16 Jul 2018 06:36:38 +0200 Subject: [ticket/15726] Implement selective purge in APCu cache driver Fix whitespace PHPBB3-15726 --- phpBB/phpbb/cache/driver/apcu.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php index 6a65e7155a..754fb1fce2 100755 --- a/phpBB/phpbb/cache/driver/apcu.php +++ b/phpBB/phpbb/cache/driver/apcu.php @@ -25,11 +25,10 @@ class apcu extends \phpbb\cache\driver\memory */ function purge() { - /* use an iterator to selectively clear our cache entries without - disturbing any other cache users - (e.g. other phpBB boards hosted on this server) */ - apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#')); - + /* use an iterator to selectively clear our cache entries without + disturbing any other cache users + (e.g. other phpBB boards hosted on this server) */ + apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#')); parent::purge(); } -- cgit v1.2.1 From 7d4d9770cfc38d613c3cf2b8495d2f8e63623ebd Mon Sep 17 00:00:00 2001 From: v12mike Date: Mon, 16 Jul 2018 07:26:14 +0100 Subject: [ticket/15726] Implement selective purge in APCu cache driver fix file permissions PHPBB3-15726 --- phpBB/phpbb/cache/driver/apcu.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 phpBB/phpbb/cache/driver/apcu.php (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php old mode 100755 new mode 100644 -- cgit v1.2.1 From bf9af922208ad93c2afbe4fa9462f8914c8d4363 Mon Sep 17 00:00:00 2001 From: v12mike Date: Wed, 25 Jul 2018 19:36:25 +0100 Subject: [ticket/15726] Implement selective purge in APCu cache driver Correcting code formatting and whitespace PHPBB3-15726 --- phpBB/phpbb/cache/driver/apcu.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php index 754fb1fce2..e40d5a376c 100644 --- a/phpBB/phpbb/cache/driver/apcu.php +++ b/phpBB/phpbb/cache/driver/apcu.php @@ -25,9 +25,10 @@ class apcu extends \phpbb\cache\driver\memory */ function purge() { - /* use an iterator to selectively clear our cache entries without - disturbing any other cache users - (e.g. other phpBB boards hosted on this server) */ + /* + Use an iterator to selectively clear our cache entries without disturbing + any other cache users (e.g. other phpBB boards hosted on this server) + */ apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#')); parent::purge(); -- cgit v1.2.1 From 7f1f64b1dcebb28ab575e1905676471b473d08ed Mon Sep 17 00:00:00 2001 From: v12mike Date: Thu, 26 Jul 2018 06:09:02 +0100 Subject: [ticket/15726] Implement selective purge in APCu cache driver Fix whitespace PHPBB3-15726 --- phpBB/phpbb/cache/driver/apcu.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php index e40d5a376c..3a63a97e4e 100644 --- a/phpBB/phpbb/cache/driver/apcu.php +++ b/phpBB/phpbb/cache/driver/apcu.php @@ -25,9 +25,9 @@ class apcu extends \phpbb\cache\driver\memory */ function purge() { - /* - Use an iterator to selectively clear our cache entries without disturbing - any other cache users (e.g. other phpBB boards hosted on this server) + /* + * Use an iterator to selectively clear our cache entries without disturbing + * any other cache users (e.g. other phpBB boards hosted on this server) */ apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#')); -- cgit v1.2.1 From 33268e5a72b3858c09d97bb696a21911ec139815 Mon Sep 17 00:00:00 2001 From: v12mike Date: Thu, 26 Jul 2018 17:24:42 +0200 Subject: [ticket/15726] Implement selective purge in APCu cache driver Edit comment PHPBB3-15726 --- phpBB/phpbb/cache/driver/apcu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php index 3a63a97e4e..4b06fdb002 100644 --- a/phpBB/phpbb/cache/driver/apcu.php +++ b/phpBB/phpbb/cache/driver/apcu.php @@ -26,7 +26,7 @@ class apcu extends \phpbb\cache\driver\memory function purge() { /* - * Use an iterator to selectively clear our cache entries without disturbing + * Use an iterator to selectively delete our cache entries without disturbing * any other cache users (e.g. other phpBB boards hosted on this server) */ apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#')); -- cgit v1.2.1 From 5edb33036654fad4df63507f00934b0d078e2756 Mon Sep 17 00:00:00 2001 From: v12mike Date: Sun, 29 Jul 2018 09:15:12 +0100 Subject: [ticket/15726] Implement selective purge in APCu fix indentation of comment PHPBB3-15726 --- phpBB/phpbb/cache/driver/apcu.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/cache/driver') diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php index 4b06fdb002..c96cf0de57 100644 --- a/phpBB/phpbb/cache/driver/apcu.php +++ b/phpBB/phpbb/cache/driver/apcu.php @@ -25,10 +25,10 @@ class apcu extends \phpbb\cache\driver\memory */ function purge() { - /* - * Use an iterator to selectively delete our cache entries without disturbing - * any other cache users (e.g. other phpBB boards hosted on this server) - */ + /* + * Use an iterator to selectively delete our cache entries without disturbing + * any other cache users (e.g. other phpBB boards hosted on this server) + */ apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#')); parent::purge(); -- cgit v1.2.1