mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge branch 'task/acm-refactor' into develop
Conflicts: tests/bootstrap.php
This commit is contained in:
commit
95c683056b
25 changed files with 399 additions and 127 deletions
|
@ -187,8 +187,6 @@ if (!empty($load_extensions) && function_exists('dl'))
|
|||
|
||||
// Include files
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/cache.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/template.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/session.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/auth.' . $phpEx);
|
||||
|
@ -203,13 +201,15 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
|||
// Set PHP error handler to ours
|
||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
||||
|
||||
// Cache must be loaded before class loader
|
||||
$cache = new cache();
|
||||
|
||||
// Setup class loader first
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache);
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx);
|
||||
$class_loader->register();
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory($acm_type);
|
||||
$class_loader->set_cache($cache_factory->get_driver());
|
||||
$cache = $cache_factory->get_service();
|
||||
|
||||
// Instantiate some basic classes
|
||||
$request = new phpbb_request();
|
||||
$user = new user();
|
||||
|
|
|
@ -203,7 +203,7 @@ class ...
|
|||
|
||||
<ul>
|
||||
<li><strong>phpBB3</strong><br />Core files and all files not assigned to a separate package</li>
|
||||
<li><strong>acm</strong><br /><code>/includes/acm</code>, <code>/includes/cache.php</code><br />Cache System</li>
|
||||
<li><strong>acm</strong><br /><code>/includes/cache</code>, <code>/includes/cache.php</code><br />Cache System</li>
|
||||
<li><strong>acp</strong><br /><code>/adm</code>, <code>/includes/acp</code>, <code>/includes/functions_admin.php</code><br />Administration Control Panel</li>
|
||||
<li><strong>dbal</strong><br /><code>/includes/db</code><br />Database Abstraction Layer.<br />Base class is <code>dbal</code>
|
||||
<ul>
|
||||
|
|
|
@ -44,15 +44,21 @@ if (isset($_GET['avatar']))
|
|||
exit;
|
||||
}
|
||||
|
||||
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/cache.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx);
|
||||
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx);
|
||||
$class_loader->register();
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory($acm_type);
|
||||
$class_loader->set_cache($cache_factory->get_driver());
|
||||
$cache = $cache_factory->get_service();
|
||||
|
||||
$db = new $sql_db();
|
||||
$cache = new cache();
|
||||
|
||||
// Connect to DB
|
||||
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
|
||||
|
|
|
@ -16,17 +16,11 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
// Include the abstract base
|
||||
if (!class_exists('acm_memory'))
|
||||
{
|
||||
require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
|
||||
}
|
||||
|
||||
/**
|
||||
* ACM for APC
|
||||
* @package acm
|
||||
*/
|
||||
class acm extends acm_memory
|
||||
class phpbb_cache_driver_apc extends phpbb_cache_driver_memory
|
||||
{
|
||||
var $extension = 'apc';
|
||||
|
24
phpBB/includes/cache/driver/base.php
vendored
Normal file
24
phpBB/includes/cache/driver/base.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @version $Id$
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package acm
|
||||
*/
|
||||
abstract class phpbb_cache_driver_base implements phpbb_cache_driver_interface
|
||||
{
|
||||
}
|
|
@ -16,18 +16,12 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
// Include the abstract base
|
||||
if (!class_exists('acm_memory'))
|
||||
{
|
||||
require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
|
||||
}
|
||||
|
||||
/**
|
||||
* ACM for eAccelerator
|
||||
* @package acm
|
||||
* @todo Missing locks from destroy() talk with David
|
||||
*/
|
||||
class acm extends acm_memory
|
||||
class phpbb_cache_driver_eaccelerator extends phpbb_cache_driver_memory
|
||||
{
|
||||
var $extension = 'eaccelerator';
|
||||
var $function = 'eaccelerator_get';
|
|
@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
|
|||
* ACM File Based Caching
|
||||
* @package acm
|
||||
*/
|
||||
class acm
|
||||
class phpbb_cache_driver_file extends phpbb_cache_driver_base
|
||||
{
|
||||
var $vars = array();
|
||||
var $var_expires = array();
|
||||
|
@ -33,10 +33,10 @@ class acm
|
|||
/**
|
||||
* Set cache path
|
||||
*/
|
||||
function acm()
|
||||
function __construct($cache_dir = null)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
$this->cache_dir = $phpbb_root_path . 'cache/';
|
||||
$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/';
|
||||
}
|
||||
|
||||
/**
|
104
phpBB/includes/cache/driver/interface.php
vendored
Normal file
104
phpBB/includes/cache/driver/interface.php
vendored
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface that all cache drivers must implement
|
||||
*
|
||||
* @package acm
|
||||
*/
|
||||
interface phpbb_cache_driver_interface
|
||||
{
|
||||
/**
|
||||
* Load global cache
|
||||
*/
|
||||
public function load();
|
||||
|
||||
/**
|
||||
* Unload cache object
|
||||
*/
|
||||
public function unload();
|
||||
|
||||
/**
|
||||
* Save modified objects
|
||||
*/
|
||||
public function save();
|
||||
|
||||
/**
|
||||
* Tidy cache
|
||||
*/
|
||||
public function tidy();
|
||||
|
||||
/**
|
||||
* Get saved cache object
|
||||
*/
|
||||
public function get($var_name);
|
||||
|
||||
/**
|
||||
* Put data into cache
|
||||
*/
|
||||
public function put($var_name, $var, $ttl = 0);
|
||||
|
||||
/**
|
||||
* Purge cache data
|
||||
*/
|
||||
public function purge();
|
||||
|
||||
/**
|
||||
* Destroy cache data
|
||||
*/
|
||||
public function destroy($var_name, $table = '');
|
||||
|
||||
/**
|
||||
* Check if a given cache entry exist
|
||||
*/
|
||||
public function _exists($var_name);
|
||||
|
||||
/**
|
||||
* Load cached sql query
|
||||
*/
|
||||
public function sql_load($query);
|
||||
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
public function sql_save($query, &$query_result, $ttl);
|
||||
|
||||
/**
|
||||
* Ceck if a given sql query exist in cache
|
||||
*/
|
||||
public function sql_exists($query_id);
|
||||
|
||||
/**
|
||||
* Fetch row from cache (database)
|
||||
*/
|
||||
public function sql_fetchrow($query_id);
|
||||
|
||||
/**
|
||||
* Fetch a field from the current row of a cached database result (database)
|
||||
*/
|
||||
public function sql_fetchfield($query_id, $field);
|
||||
|
||||
/**
|
||||
* Seek a specific row in an a cached database result (database)
|
||||
*/
|
||||
public function sql_rowseek($rownum, $query_id);
|
||||
|
||||
/**
|
||||
* Free memory used for a cached database result (database)
|
||||
*/
|
||||
public function sql_freeresult($query_id);
|
||||
}
|
|
@ -16,12 +16,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
// Include the abstract base
|
||||
if (!class_exists('acm_memory'))
|
||||
{
|
||||
require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
|
||||
}
|
||||
|
||||
if (!defined('PHPBB_ACM_MEMCACHE_PORT'))
|
||||
{
|
||||
define('PHPBB_ACM_MEMCACHE_PORT', 11211);
|
||||
|
@ -47,17 +41,17 @@ if (!defined('PHPBB_ACM_MEMCACHE'))
|
|||
* ACM for Memcached
|
||||
* @package acm
|
||||
*/
|
||||
class acm extends acm_memory
|
||||
class phpbb_cache_driver_memcache extends phpbb_cache_driver_memory
|
||||
{
|
||||
var $extension = 'memcache';
|
||||
|
||||
var $memcache;
|
||||
var $flags = 0;
|
||||
|
||||
function acm()
|
||||
function __construct()
|
||||
{
|
||||
// Call the parent constructor
|
||||
parent::acm_memory();
|
||||
parent::__construct();
|
||||
|
||||
$this->memcache = new Memcache;
|
||||
foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u)
|
|
@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
|
|||
* ACM Abstract Memory Class
|
||||
* @package acm
|
||||
*/
|
||||
class acm_memory
|
||||
class phpbb_cache_driver_memory extends phpbb_cache_driver_base
|
||||
{
|
||||
var $key_prefix;
|
||||
|
||||
|
@ -34,7 +34,7 @@ class acm_memory
|
|||
/**
|
||||
* Set cache path
|
||||
*/
|
||||
function acm_memory()
|
||||
function __construct()
|
||||
{
|
||||
global $phpbb_root_path, $dbname, $table_prefix;
|
||||
|
|
@ -20,12 +20,12 @@ if (!defined('IN_PHPBB'))
|
|||
* ACM Null Caching
|
||||
* @package acm
|
||||
*/
|
||||
class acm
|
||||
class phpbb_cache_driver_null extends phpbb_cache_driver_base
|
||||
{
|
||||
/**
|
||||
* Set cache path
|
||||
*/
|
||||
function acm()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
|
@ -16,12 +16,6 @@ if (!defined('IN_PHPBB'))
|
|||
exit;
|
||||
}
|
||||
|
||||
// Include the abstract base
|
||||
if (!class_exists('acm_memory'))
|
||||
{
|
||||
require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
|
||||
}
|
||||
|
||||
/**
|
||||
* ACM for XCache
|
||||
* @package acm
|
||||
|
@ -31,13 +25,13 @@ if (!class_exists('acm_memory'))
|
|||
* - xcache.admin.enable_auth = off (or xcache.admin.user and xcache.admin.password set)
|
||||
*
|
||||
*/
|
||||
class acm extends acm_memory
|
||||
class phpbb_cache_driver_xcache extends phpbb_cache_driver_memory
|
||||
{
|
||||
var $extension = 'XCache';
|
||||
|
||||
function acm()
|
||||
function __construct()
|
||||
{
|
||||
parent::acm_memory();
|
||||
parent::__construct();
|
||||
|
||||
if (!function_exists('ini_get') || (int) ini_get('xcache.var_size') <= 0)
|
||||
{
|
43
phpBB/includes/cache/factory.php
vendored
Normal file
43
phpBB/includes/cache/factory.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @version $Id$
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package acm
|
||||
*/
|
||||
class phpbb_cache_factory
|
||||
{
|
||||
private $acm_type;
|
||||
|
||||
public function __construct($acm_type)
|
||||
{
|
||||
$this->acm_type = $acm_type;
|
||||
}
|
||||
|
||||
public function get_driver()
|
||||
{
|
||||
$class_name = 'phpbb_cache_driver_' . $this->acm_type;
|
||||
return new $class_name();
|
||||
}
|
||||
|
||||
public function get_service()
|
||||
{
|
||||
$driver = $this->get_driver();
|
||||
$service = new phpbb_cache_service($driver);
|
||||
return $service;
|
||||
}
|
||||
}
|
|
@ -17,11 +17,28 @@ if (!defined('IN_PHPBB'))
|
|||
}
|
||||
|
||||
/**
|
||||
* Class for grabbing/handling cached entries, extends acm_file or acm_db depending on the setup
|
||||
* Class for grabbing/handling cached entries
|
||||
* @package acm
|
||||
*/
|
||||
class cache extends acm
|
||||
class phpbb_cache_service
|
||||
{
|
||||
private $acm;
|
||||
|
||||
public function __construct(phpbb_cache_driver_interface $acm = null)
|
||||
{
|
||||
$this->set_acm($acm);
|
||||
}
|
||||
|
||||
public function set_acm(phpbb_cache_driver_interface $acm)
|
||||
{
|
||||
$this->acm = $acm;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
return call_user_func_array(array($this->acm, $method), $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get config values
|
||||
*/
|
||||
|
@ -29,7 +46,7 @@ class cache extends acm
|
|||
{
|
||||
global $db;
|
||||
|
||||
if (($config = $this->get('config')) !== false)
|
||||
if (($config = $this->acm->get('config')) !== false)
|
||||
{
|
||||
$sql = 'SELECT config_name, config_value
|
||||
FROM ' . CONFIG_TABLE . '
|
||||
|
@ -61,7 +78,7 @@ class cache extends acm
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->put('config', $cached_config);
|
||||
$this->acm->put('config', $cached_config);
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
@ -75,7 +92,7 @@ class cache extends acm
|
|||
{
|
||||
global $db;
|
||||
|
||||
if (($censors = $this->get('_word_censors')) === false)
|
||||
if (($censors = $this->acm->get('_word_censors')) === false)
|
||||
{
|
||||
$sql = 'SELECT word, replacement
|
||||
FROM ' . WORDS_TABLE;
|
||||
|
@ -89,7 +106,7 @@ class cache extends acm
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->put('_word_censors', $censors);
|
||||
$this->acm->put('_word_censors', $censors);
|
||||
}
|
||||
|
||||
return $censors;
|
||||
|
@ -100,7 +117,7 @@ class cache extends acm
|
|||
*/
|
||||
function obtain_icons()
|
||||
{
|
||||
if (($icons = $this->get('_icons')) === false)
|
||||
if (($icons = $this->acm->get('_icons')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -120,7 +137,7 @@ class cache extends acm
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->put('_icons', $icons);
|
||||
$this->acm->put('_icons', $icons);
|
||||
}
|
||||
|
||||
return $icons;
|
||||
|
@ -131,7 +148,7 @@ class cache extends acm
|
|||
*/
|
||||
function obtain_ranks()
|
||||
{
|
||||
if (($ranks = $this->get('_ranks')) === false)
|
||||
if (($ranks = $this->acm->get('_ranks')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -161,7 +178,7 @@ class cache extends acm
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->put('_ranks', $ranks);
|
||||
$this->acm->put('_ranks', $ranks);
|
||||
}
|
||||
|
||||
return $ranks;
|
||||
|
@ -176,7 +193,7 @@ class cache extends acm
|
|||
*/
|
||||
function obtain_attach_extensions($forum_id)
|
||||
{
|
||||
if (($extensions = $this->get('_extensions')) === false)
|
||||
if (($extensions = $this->acm->get('_extensions')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -220,7 +237,7 @@ class cache extends acm
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->put('_extensions', $extensions);
|
||||
$this->acm->put('_extensions', $extensions);
|
||||
}
|
||||
|
||||
// Forum post
|
||||
|
@ -281,7 +298,7 @@ class cache extends acm
|
|||
*/
|
||||
function obtain_bots()
|
||||
{
|
||||
if (($bots = $this->get('_bots')) === false)
|
||||
if (($bots = $this->acm->get('_bots')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -320,7 +337,7 @@ class cache extends acm
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->put('_bots', $bots);
|
||||
$this->acm->put('_bots', $bots);
|
||||
}
|
||||
|
||||
return $bots;
|
||||
|
@ -341,7 +358,7 @@ class cache extends acm
|
|||
|
||||
foreach ($parsed_items as $key => $parsed_array)
|
||||
{
|
||||
$parsed_array = $this->get('_cfg_' . $key . '_' . $theme[$key . '_path']);
|
||||
$parsed_array = $this->acm->get('_cfg_' . $key . '_' . $theme[$key . '_path']);
|
||||
|
||||
if ($parsed_array === false)
|
||||
{
|
||||
|
@ -367,7 +384,7 @@ class cache extends acm
|
|||
$parsed_array = parse_cfg_file($filename);
|
||||
$parsed_array['filetime'] = @filemtime($filename);
|
||||
|
||||
$this->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array);
|
||||
$this->acm->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array);
|
||||
}
|
||||
$parsed_items[$key] = $parsed_array;
|
||||
}
|
||||
|
@ -380,7 +397,7 @@ class cache extends acm
|
|||
*/
|
||||
function obtain_disallowed_usernames()
|
||||
{
|
||||
if (($usernames = $this->get('_disallowed_usernames')) === false)
|
||||
if (($usernames = $this->acm->get('_disallowed_usernames')) === false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -395,7 +412,7 @@ class cache extends acm
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->put('_disallowed_usernames', $usernames);
|
||||
$this->acm->put('_disallowed_usernames', $usernames);
|
||||
}
|
||||
|
||||
return $usernames;
|
||||
|
@ -408,7 +425,7 @@ class cache extends acm
|
|||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
if (($hook_files = $this->get('_hooks')) === false)
|
||||
if (($hook_files = $this->acm->get('_hooks')) === false)
|
||||
{
|
||||
$hook_files = array();
|
||||
|
||||
|
@ -427,7 +444,7 @@ class cache extends acm
|
|||
closedir($dh);
|
||||
}
|
||||
|
||||
$this->put('_hooks', $hook_files);
|
||||
$this->acm->put('_hooks', $hook_files);
|
||||
}
|
||||
|
||||
return $hook_files;
|
|
@ -42,8 +42,9 @@ class phpbb_class_loader
|
|||
*
|
||||
* @param string $phpbb_root_path phpBB's root directory containing includes/
|
||||
* @param string $php_ext The file extension for PHP files
|
||||
* @param phpbb_cache_driver_interface $cache An implementation of the phpBB cache interface.
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext = '.php', $cache = null)
|
||||
public function __construct($phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
@ -56,9 +57,9 @@ class phpbb_class_loader
|
|||
* the class loader will resolve paths by checking for the existance of every
|
||||
* directory in the class name every time.
|
||||
*
|
||||
* @param acm $cache An implementation of the phpBB cache interface.
|
||||
* @param phpbb_cache_driver_interface $cache An implementation of the phpBB cache interface.
|
||||
*/
|
||||
public function set_cache($cache = null)
|
||||
public function set_cache(phpbb_cache_driver_interface $cache = null)
|
||||
{
|
||||
if ($cache)
|
||||
{
|
||||
|
|
|
@ -61,8 +61,6 @@ if (!empty($load_extensions) && function_exists('dl'))
|
|||
|
||||
// Include files
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/cache.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/template.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/session.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/auth.' . $phpEx);
|
||||
|
@ -93,11 +91,14 @@ else
|
|||
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
|
||||
}
|
||||
|
||||
$cache = new cache();
|
||||
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache);
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx);
|
||||
$class_loader->register();
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory($acm_type);
|
||||
$class_loader->set_cache($cache_factory->get_driver());
|
||||
$cache = $cache_factory->get_service();
|
||||
|
||||
$request = new phpbb_request();
|
||||
$user = new user();
|
||||
$db = new $sql_db();
|
||||
|
|
|
@ -163,8 +163,6 @@ if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx))
|
|||
include($phpbb_root_path . 'includes/auth.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/session.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/template.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/acm/acm_file.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/cache.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
|
||||
|
@ -172,6 +170,11 @@ require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
|
|||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx);
|
||||
$class_loader->register();
|
||||
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory('file');
|
||||
$class_loader->set_cache($cache_factory->get_driver());
|
||||
$cache = $cache_factory->get_service();
|
||||
|
||||
$request = new phpbb_request();
|
||||
|
||||
// make sure request_var uses this request instance
|
||||
|
@ -259,7 +262,6 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle
|
|||
|
||||
$user = new user();
|
||||
$auth = new auth();
|
||||
$cache = new cache();
|
||||
$template = new template();
|
||||
|
||||
// Add own hook handler, if present. :o
|
||||
|
|
|
@ -57,18 +57,19 @@ if ($id)
|
|||
{
|
||||
// Include files
|
||||
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/cache.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions.' . $phpEx);
|
||||
|
||||
$cache = new cache();
|
||||
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache);
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx);
|
||||
$class_loader->register();
|
||||
|
||||
$request = new phpbb_request();
|
||||
// set up caching
|
||||
$cache_factory = new phpbb_cache_factory($acm_type);
|
||||
$class_loader->set_cache($cache_factory->get_driver());
|
||||
$cache = $cache_factory->get_service();
|
||||
|
||||
$request = new phpbb_request();
|
||||
$db = new $sql_db();
|
||||
|
||||
// make sure request_var uses this request instance
|
||||
|
@ -308,5 +309,3 @@ if ($id)
|
|||
}
|
||||
$db->sql_close();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
|
|
@ -28,7 +28,7 @@ else
|
|||
require_once $phpbb_root_path . 'includes/constants.php';
|
||||
require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx;
|
||||
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx);
|
||||
$class_loader = new phpbb_class_loader($phpbb_root_path, '.php');
|
||||
$class_loader->register();
|
||||
|
||||
require_once 'test_framework/phpbb_test_case_helpers.php';
|
||||
|
|
41
tests/cache/cache_test.php
vendored
Normal file
41
tests/cache/cache_test.php
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_cache_test extends phpbb_test_case
|
||||
{
|
||||
protected function tearDown()
|
||||
{
|
||||
$iterator = new DirectoryIterator(__DIR__ . '/tmp');
|
||||
foreach ($iterator as $file)
|
||||
{
|
||||
if (is_file(__DIR__ . '/tmp/' . $file) && $file != '.gitkeep')
|
||||
{
|
||||
unlink(__DIR__ . '/tmp/' . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_cache_driver_file()
|
||||
{
|
||||
global $phpEx;
|
||||
$phpEx = 'txt'; // do not store files as .php
|
||||
|
||||
$driver = new phpbb_cache_driver_file(__DIR__ . '/tmp/');
|
||||
$driver->put('test_key', 'test_value');
|
||||
$driver->save();
|
||||
|
||||
$this->assertEquals(
|
||||
'test_value',
|
||||
$driver->get('test_key'),
|
||||
'File ACM put and get'
|
||||
);
|
||||
}
|
||||
}
|
0
tests/cache/tmp/.gitkeep
vendored
Normal file
0
tests/cache/tmp/.gitkeep
vendored
Normal file
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @version $Id$
|
||||
* @copyright (c) 2008 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_cache_mock
|
||||
{
|
||||
private $variables = array();
|
||||
|
||||
function get($var_name)
|
||||
{
|
||||
if (isset($this->variables[$var_name]))
|
||||
{
|
||||
return $this->variables[$var_name];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function put($var_name, $value)
|
||||
{
|
||||
$this->variables[$var_name] = $value;
|
||||
}
|
||||
}
|
|
@ -2,15 +2,12 @@
|
|||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @version $Id$
|
||||
* @copyright (c) 2008 phpBB Group
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/cache_mock.php';
|
||||
|
||||
require_once __DIR__ . '/../../phpBB/includes/class_loader.php';
|
||||
require_once __DIR__ . '/../mock/cache.php';
|
||||
|
||||
class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -63,8 +60,8 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
|
|||
|
||||
public function test_resolve_cached()
|
||||
{
|
||||
$cache = new phpbb_cache_mock;
|
||||
$cache->put('class_loader', array('phpbb_a_cached_name' => 'a/cached_name'));
|
||||
$cacheMap = array('class_loader' => array('phpbb_a_cached_name' => 'a/cached_name'));
|
||||
$cache = new phpbb_mock_cache($cacheMap);
|
||||
|
||||
$prefix = __DIR__ . '/';
|
||||
$class_loader = new phpbb_class_loader($prefix, '.php', $cache);
|
||||
|
@ -82,5 +79,8 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
|
|||
$class_loader->resolve_path('phpbb_a_cached_name'),
|
||||
'Class in a directory'
|
||||
);
|
||||
|
||||
$cacheMap['class_loader']['phpbb_dir_class_name'] = 'dir/class_name';
|
||||
$cache->check($this, $cacheMap);
|
||||
}
|
||||
}
|
||||
|
|
87
tests/mock/cache.php
Normal file
87
tests/mock/cache.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_mock_cache implements phpbb_cache_driver_interface
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($data = array())
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function get($var_name)
|
||||
{
|
||||
if (isset($this->data[$var_name]))
|
||||
{
|
||||
return $this->data[$var_name];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function put($var_name, $var, $ttl = 0)
|
||||
{
|
||||
$this->data[$var_name] = $var;
|
||||
}
|
||||
|
||||
public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data)
|
||||
{
|
||||
$test->assertTrue(isset($this->data[$var_name]));
|
||||
$test->assertEquals($data, $this->data[$var_name]);
|
||||
}
|
||||
|
||||
public function check(PHPUnit_Framework_Assert $test, $data)
|
||||
{
|
||||
$test->assertEquals($data, $this->data);
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
}
|
||||
function unload()
|
||||
{
|
||||
}
|
||||
function save()
|
||||
{
|
||||
}
|
||||
function tidy()
|
||||
{
|
||||
}
|
||||
function purge()
|
||||
{
|
||||
}
|
||||
function destroy($var_name, $table = '')
|
||||
{
|
||||
}
|
||||
public function _exists($var_name)
|
||||
{
|
||||
}
|
||||
public function sql_load($query)
|
||||
{
|
||||
}
|
||||
public function sql_save($query, &$query_result, $ttl)
|
||||
{
|
||||
}
|
||||
public function sql_exists($query_id)
|
||||
{
|
||||
}
|
||||
public function sql_fetchrow($query_id)
|
||||
{
|
||||
}
|
||||
public function sql_fetchfield($query_id, $field)
|
||||
{
|
||||
}
|
||||
public function sql_rowseek($rownum, $query_id)
|
||||
{
|
||||
}
|
||||
public function sql_freeresult($query_id)
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue