mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 22:38:52 +00:00
[ticket/12789] Move duplicated functions to the base class
PHPBB3-12789
This commit is contained in:
parent
e7251252ce
commit
e07e9f6cee
3 changed files with 215 additions and 417 deletions
213
phpBB/phpbb/cache/driver/base.php
vendored
213
phpBB/phpbb/cache/driver/base.php
vendored
|
@ -15,4 +15,217 @@ namespace phpbb\cache\driver;
|
||||||
|
|
||||||
abstract class base implements \phpbb\cache\driver\driver_interface
|
abstract class base implements \phpbb\cache\driver\driver_interface
|
||||||
{
|
{
|
||||||
|
var $vars = array();
|
||||||
|
var $is_modified = false;
|
||||||
|
|
||||||
|
var $sql_rowset = array();
|
||||||
|
var $sql_row_pointer = array();
|
||||||
|
var $cache_dir = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function purge()
|
||||||
|
{
|
||||||
|
// Purge all phpbb cache files
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$iterator = new \DirectoryIterator($this->cache_dir);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($iterator as $fileInfo)
|
||||||
|
{
|
||||||
|
if ($fileInfo->isDot())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$filename = $fileInfo->getFilename();
|
||||||
|
if ($fileInfo->isDir())
|
||||||
|
{
|
||||||
|
$this->remove_dir($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
else if (strpos($filename, 'container_') === 0 ||
|
||||||
|
strpos($filename, 'url_matcher') === 0 ||
|
||||||
|
strpos($filename, 'sql_') === 0 ||
|
||||||
|
strpos($filename, 'data_') === 0)
|
||||||
|
{
|
||||||
|
$this->remove_file($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($this->vars);
|
||||||
|
unset($this->sql_rowset);
|
||||||
|
unset($this->sql_row_pointer);
|
||||||
|
|
||||||
|
$this->vars = array();
|
||||||
|
$this->sql_rowset = array();
|
||||||
|
$this->sql_row_pointer = array();
|
||||||
|
|
||||||
|
$this->is_modified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function unload()
|
||||||
|
{
|
||||||
|
$this->save();
|
||||||
|
unset($this->vars);
|
||||||
|
unset($this->sql_rowset);
|
||||||
|
unset($this->sql_row_pointer);
|
||||||
|
|
||||||
|
$this->vars = array();
|
||||||
|
$this->sql_rowset = array();
|
||||||
|
$this->sql_row_pointer = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function sql_load($query)
|
||||||
|
{
|
||||||
|
// Remove extra spaces and tabs
|
||||||
|
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||||
|
|
||||||
|
if (($rowset = $this->_read('sql_' . md5($query))) === false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query_id = sizeof($this->sql_rowset);
|
||||||
|
$this->sql_rowset[$query_id] = $rowset;
|
||||||
|
$this->sql_row_pointer[$query_id] = 0;
|
||||||
|
|
||||||
|
return $query_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function sql_exists($query_id)
|
||||||
|
{
|
||||||
|
return isset($this->sql_rowset[$query_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function sql_fetchrow($query_id)
|
||||||
|
{
|
||||||
|
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||||
|
{
|
||||||
|
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function sql_fetchfield($query_id, $field)
|
||||||
|
{
|
||||||
|
if ($this->sql_row_pointer[$query_id] < sizeof($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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function sql_rowseek($rownum, $query_id)
|
||||||
|
{
|
||||||
|
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->sql_row_pointer[$query_id] = $rownum;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function sql_freeresult($query_id)
|
||||||
|
{
|
||||||
|
if (!isset($this->sql_rowset[$query_id]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($this->sql_rowset[$query_id]);
|
||||||
|
unset($this->sql_row_pointer[$query_id]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes/unlinks file
|
||||||
|
*
|
||||||
|
* @param string $filename Filename to remove
|
||||||
|
* @param bool $check Check file permissions
|
||||||
|
* @return bool True if the file was successfully removed, otherwise false
|
||||||
|
*/
|
||||||
|
function remove_file($filename, $check = false)
|
||||||
|
{
|
||||||
|
if (!function_exists('phpbb_is_writable'))
|
||||||
|
{
|
||||||
|
global $phpbb_root_path, $phpEx;
|
||||||
|
include($phpbb_root_path . 'includes/functions.' . $phpEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($check && !phpbb_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return @unlink($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove directory
|
||||||
|
*
|
||||||
|
* @param string $dir Directory to remove
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
protected function remove_dir($dir)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$iterator = new \DirectoryIterator($dir);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($iterator as $fileInfo)
|
||||||
|
{
|
||||||
|
if ($fileInfo->isDot())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fileInfo->isDir())
|
||||||
|
{
|
||||||
|
$this->remove_dir($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->remove_file($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@rmdir($dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
204
phpBB/phpbb/cache/driver/file.php
vendored
204
phpBB/phpbb/cache/driver/file.php
vendored
|
@ -18,13 +18,7 @@ namespace phpbb\cache\driver;
|
||||||
*/
|
*/
|
||||||
class file extends \phpbb\cache\driver\base
|
class file extends \phpbb\cache\driver\base
|
||||||
{
|
{
|
||||||
var $vars = array();
|
|
||||||
var $var_expires = array();
|
var $var_expires = array();
|
||||||
var $is_modified = false;
|
|
||||||
|
|
||||||
var $sql_rowset = array();
|
|
||||||
var $sql_row_pointer = array();
|
|
||||||
var $cache_dir = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set cache path
|
* Set cache path
|
||||||
|
@ -50,16 +44,9 @@ class file extends \phpbb\cache\driver\base
|
||||||
*/
|
*/
|
||||||
function unload()
|
function unload()
|
||||||
{
|
{
|
||||||
$this->save();
|
parent::unload();
|
||||||
unset($this->vars);
|
|
||||||
unset($this->var_expires);
|
unset($this->var_expires);
|
||||||
unset($this->sql_rowset);
|
|
||||||
unset($this->sql_row_pointer);
|
|
||||||
|
|
||||||
$this->vars = array();
|
|
||||||
$this->var_expires = array();
|
$this->var_expires = array();
|
||||||
$this->sql_rowset = array();
|
|
||||||
$this->sql_row_pointer = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,8 +153,6 @@ class file extends \phpbb\cache\driver\base
|
||||||
{
|
{
|
||||||
if ($var_name[0] == '_')
|
if ($var_name[0] == '_')
|
||||||
{
|
{
|
||||||
global $phpEx;
|
|
||||||
|
|
||||||
if (!$this->_exists($var_name))
|
if (!$this->_exists($var_name))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -203,85 +188,8 @@ class file extends \phpbb\cache\driver\base
|
||||||
*/
|
*/
|
||||||
function purge()
|
function purge()
|
||||||
{
|
{
|
||||||
// Purge all phpbb cache files
|
parent::purge();
|
||||||
try
|
|
||||||
{
|
|
||||||
$iterator = new \DirectoryIterator($this->cache_dir);
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($iterator as $fileInfo)
|
|
||||||
{
|
|
||||||
if ($fileInfo->isDot())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$filename = $fileInfo->getFilename();
|
|
||||||
if ($fileInfo->isDir())
|
|
||||||
{
|
|
||||||
$this->remove_dir($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
else if (strpos($filename, 'container_') === 0 ||
|
|
||||||
strpos($filename, 'url_matcher') === 0 ||
|
|
||||||
strpos($filename, 'sql_') === 0 ||
|
|
||||||
strpos($filename, 'data_') === 0)
|
|
||||||
{
|
|
||||||
$this->remove_file($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($this->vars);
|
|
||||||
unset($this->var_expires);
|
|
||||||
unset($this->sql_rowset);
|
|
||||||
unset($this->sql_row_pointer);
|
|
||||||
|
|
||||||
$this->vars = array();
|
|
||||||
$this->var_expires = array();
|
$this->var_expires = array();
|
||||||
$this->sql_rowset = array();
|
|
||||||
$this->sql_row_pointer = array();
|
|
||||||
|
|
||||||
$this->is_modified = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove directory
|
|
||||||
*
|
|
||||||
* @param string $dir Directory to remove
|
|
||||||
*
|
|
||||||
* @return null
|
|
||||||
*/
|
|
||||||
protected function remove_dir($dir)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$iterator = new \DirectoryIterator($dir);
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($iterator as $fileInfo)
|
|
||||||
{
|
|
||||||
if ($fileInfo->isDot())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($fileInfo->isDir())
|
|
||||||
{
|
|
||||||
$this->remove_dir($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->remove_file($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@rmdir($dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -389,26 +297,6 @@ class file extends \phpbb\cache\driver\base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_load($query)
|
|
||||||
{
|
|
||||||
// Remove extra spaces and tabs
|
|
||||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
|
||||||
|
|
||||||
if (($rowset = $this->_read('sql_' . md5($query))) === false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$query_id = sizeof($this->sql_rowset);
|
|
||||||
$this->sql_rowset[$query_id] = $rowset;
|
|
||||||
$this->sql_row_pointer[$query_id] = 0;
|
|
||||||
|
|
||||||
return $query_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -435,70 +323,6 @@ class file extends \phpbb\cache\driver\base
|
||||||
return $query_result;
|
return $query_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_exists($query_id)
|
|
||||||
{
|
|
||||||
return isset($this->sql_rowset[$query_id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_fetchrow($query_id)
|
|
||||||
{
|
|
||||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
|
||||||
{
|
|
||||||
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_fetchfield($query_id, $field)
|
|
||||||
{
|
|
||||||
if ($this->sql_row_pointer[$query_id] < sizeof($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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_rowseek($rownum, $query_id)
|
|
||||||
{
|
|
||||||
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->sql_row_pointer[$query_id] = $rownum;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_freeresult($query_id)
|
|
||||||
{
|
|
||||||
if (!isset($this->sql_rowset[$query_id]))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($this->sql_rowset[$query_id]);
|
|
||||||
unset($this->sql_row_pointer[$query_id]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read cached data from a specified file
|
* Read cached data from a specified file
|
||||||
*
|
*
|
||||||
|
@ -760,28 +584,4 @@ class file extends \phpbb\cache\driver\base
|
||||||
|
|
||||||
return $return_value;
|
return $return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes/unlinks file
|
|
||||||
*
|
|
||||||
* @param string $filename Filename to remove
|
|
||||||
* @param bool $check Check file permissions
|
|
||||||
* @return bool True if the file was successfully removed, otherwise false
|
|
||||||
*/
|
|
||||||
function remove_file($filename, $check = false)
|
|
||||||
{
|
|
||||||
if (!function_exists('phpbb_is_writable'))
|
|
||||||
{
|
|
||||||
global $phpbb_root_path, $phpEx;
|
|
||||||
include($phpbb_root_path . 'includes/functions.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($check && !phpbb_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return @unlink($filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
215
phpBB/phpbb/cache/driver/memory.php
vendored
215
phpBB/phpbb/cache/driver/memory.php
vendored
|
@ -20,13 +20,6 @@ abstract class memory extends \phpbb\cache\driver\base
|
||||||
{
|
{
|
||||||
var $key_prefix;
|
var $key_prefix;
|
||||||
|
|
||||||
var $vars = array();
|
|
||||||
var $is_modified = false;
|
|
||||||
|
|
||||||
var $sql_rowset = array();
|
|
||||||
var $sql_row_pointer = array();
|
|
||||||
var $cache_dir = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set cache path
|
* Set cache path
|
||||||
*/
|
*/
|
||||||
|
@ -68,21 +61,6 @@ abstract class memory extends \phpbb\cache\driver\base
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function unload()
|
|
||||||
{
|
|
||||||
$this->save();
|
|
||||||
unset($this->vars);
|
|
||||||
unset($this->sql_rowset);
|
|
||||||
unset($this->sql_row_pointer);
|
|
||||||
|
|
||||||
$this->vars = array();
|
|
||||||
$this->sql_rowset = array();
|
|
||||||
$this->sql_row_pointer = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -144,53 +122,6 @@ abstract class memory extends \phpbb\cache\driver\base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function purge()
|
|
||||||
{
|
|
||||||
// Purge all phpbb cache files
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$iterator = new \DirectoryIterator($this->cache_dir);
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($iterator as $fileInfo)
|
|
||||||
{
|
|
||||||
if ($fileInfo->isDot())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$filename = $fileInfo->getFilename();
|
|
||||||
if ($fileInfo->isDir())
|
|
||||||
{
|
|
||||||
$this->remove_dir($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
else if (strpos($filename, 'container_') !== 0 &&
|
|
||||||
strpos($filename, 'url_matcher') !== 0 &&
|
|
||||||
strpos($filename, 'sql_') !== 0 &&
|
|
||||||
strpos($filename, 'data_') !== 0)
|
|
||||||
{
|
|
||||||
$this->remove_file($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($this->vars);
|
|
||||||
unset($this->sql_rowset);
|
|
||||||
unset($this->sql_row_pointer);
|
|
||||||
|
|
||||||
$this->vars = array();
|
|
||||||
$this->sql_rowset = array();
|
|
||||||
$this->sql_row_pointer = array();
|
|
||||||
|
|
||||||
$this->is_modified = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -265,26 +196,6 @@ abstract class memory extends \phpbb\cache\driver\base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_load($query)
|
|
||||||
{
|
|
||||||
// Remove extra spaces and tabs
|
|
||||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
|
||||||
$query_id = sizeof($this->sql_rowset);
|
|
||||||
|
|
||||||
if (($result = $this->_read('sql_' . md5($query))) === false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->sql_rowset[$query_id] = $result;
|
|
||||||
$this->sql_row_pointer[$query_id] = 0;
|
|
||||||
|
|
||||||
return $query_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -343,132 +254,6 @@ abstract class memory extends \phpbb\cache\driver\base
|
||||||
return $query_id;
|
return $query_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_exists($query_id)
|
|
||||||
{
|
|
||||||
return isset($this->sql_rowset[$query_id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_fetchrow($query_id)
|
|
||||||
{
|
|
||||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
|
||||||
{
|
|
||||||
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_fetchfield($query_id, $field)
|
|
||||||
{
|
|
||||||
if ($this->sql_row_pointer[$query_id] < sizeof($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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_rowseek($rownum, $query_id)
|
|
||||||
{
|
|
||||||
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->sql_row_pointer[$query_id] = $rownum;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
function sql_freeresult($query_id)
|
|
||||||
{
|
|
||||||
if (!isset($this->sql_rowset[$query_id]))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($this->sql_rowset[$query_id]);
|
|
||||||
unset($this->sql_row_pointer[$query_id]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes/unlinks file
|
|
||||||
*
|
|
||||||
* @param string $filename Filename to remove
|
|
||||||
* @param bool $check Check file permissions
|
|
||||||
* @return bool True if the file was successfully removed, otherwise false
|
|
||||||
*/
|
|
||||||
function remove_file($filename, $check = false)
|
|
||||||
{
|
|
||||||
if (!function_exists('phpbb_is_writable'))
|
|
||||||
{
|
|
||||||
global $phpbb_root_path, $phpEx;
|
|
||||||
include($phpbb_root_path . 'includes/functions.' . $phpEx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($check && !phpbb_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return @unlink($filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove directory
|
|
||||||
*
|
|
||||||
* @param string $dir Directory to remove
|
|
||||||
*
|
|
||||||
* @return null
|
|
||||||
*/
|
|
||||||
protected function remove_dir($dir)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$iterator = new \DirectoryIterator($dir);
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($iterator as $fileInfo)
|
|
||||||
{
|
|
||||||
if ($fileInfo->isDot())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($fileInfo->isDir())
|
|
||||||
{
|
|
||||||
$this->remove_dir($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->remove_file($fileInfo->getPathname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@rmdir($dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a cache var exists
|
* Check if a cache var exists
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue