diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-15 11:31:39 -0600 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-15 11:31:39 -0600 |
commit | 51e0f002eeaf2d55a63feee66ccb37d689f46f55 (patch) | |
tree | 21590506df83029d97a02ccaafa86c085f8c568f /phpBB/includes/cache/service.php | |
parent | 44fcec520f785d18d3cd3b19e26db977f23b844c (diff) | |
parent | a2f6e494f37914352b0bb72d5a84904d3f2c51a3 (diff) | |
download | forums-51e0f002eeaf2d55a63feee66ccb37d689f46f55.tar forums-51e0f002eeaf2d55a63feee66ccb37d689f46f55.tar.gz forums-51e0f002eeaf2d55a63feee66ccb37d689f46f55.tar.bz2 forums-51e0f002eeaf2d55a63feee66ccb37d689f46f55.tar.xz forums-51e0f002eeaf2d55a63feee66ccb37d689f46f55.zip |
Merge branch 'develop' of github.com:phpbb/phpbb3 into ticket/11103
# By Oleg Pudeyev (37) and others
# Via Oleg Pudeyev (24) and others
* 'develop' of github.com:phpbb/phpbb3: (179 commits)
[ticket/11323] Add tests for inclusion of defined variables
[ticket/11324] Add PHP 5.5 environment to travis and allow it to fail.
[ticket/11321] Recreate schema files with develop/create_schema_files.php
[ticket/11320] Include functions file as we need phpbb_convert_30_dbms_to_31
[ticket/11313] Use correct object el instead of eel in alt_text callback
[ticket/11301] Guidelines: Add spaces in front and after the / operator.
[ticket/11301] Explicitly cast str offset to int to prevent E_NOTICE on 5.4.
[ticket/11311] Include asset core.js in subsilver2 overall_footer.html
[ticket/10949] Remove not needed comma
[ticket/11309] phpbb_extension_interface::disable_step correct docblock.
[ticket/10949] Converted missing code to new JS coding guidelines
[ticket/11302] Correctly select first timezone or selected timezone
[ticket/11305] Mock container for cache driver in functional create_user()
[ticket/11305] Check for $cache being null before using it in db drivers.
[ticket/10805] Compare phpbbAlertTimer against null
[ticket/11305] Define hook finder as a service on the container.
[ticket/11305] Adjust comment.
[ticket/11305] Use phpbb_create_default_container.
[ticket/11305] Create a normal container during final installation step.
[ticket/11305] Retrieve cache driver from container rather than cache service.
...
Conflicts:
phpBB/install/schemas/firebird_schema.sql
phpBB/install/schemas/mssql_schema.sql
phpBB/install/schemas/mysql_40_schema.sql
phpBB/install/schemas/mysql_41_schema.sql
phpBB/install/schemas/oracle_schema.sql
phpBB/install/schemas/postgres_schema.sql
phpBB/install/schemas/sqlite_schema.sql
phpBB/styles/subsilver2/template/overall_footer.html
Diffstat (limited to 'phpBB/includes/cache/service.php')
-rw-r--r-- | phpBB/includes/cache/service.php | 133 |
1 files changed, 64 insertions, 69 deletions
diff --git a/phpBB/includes/cache/service.php b/phpBB/includes/cache/service.php index e63ec6e33a..69c5e0fdd0 100644 --- a/phpBB/includes/cache/service.php +++ b/phpBB/includes/cache/service.php @@ -21,16 +21,57 @@ if (!defined('IN_PHPBB')) */ class phpbb_cache_service { - private $driver; + /** + * Cache driver. + * + * @var phpbb_cache_driver_interface + */ + protected $driver; + + /** + * The config. + * + * @var phpbb_config + */ + protected $config; + + /** + * Database connection. + * + * @var phpbb_db_driver + */ + protected $db; + + /** + * Root path. + * + * @var string + */ + protected $phpbb_root_path; + + /** + * PHP extension. + * + * @var string + */ + protected $php_ext; /** * Creates a cache service around a cache driver * * @param phpbb_cache_driver_interface $driver The cache driver + * @param phpbb_config $config The config + * @param phpbb_db_driver $db Database connection + * @param string $phpbb_root_path Root path + * @param string $php_ext PHP extension */ - public function __construct(phpbb_cache_driver_interface $driver = null) + public function __construct(phpbb_cache_driver_interface $driver, phpbb_config $config, phpbb_db_driver $db, $phpbb_root_path, $php_ext) { $this->set_driver($driver); + $this->config = $config; + $this->db = $db; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; } /** @@ -64,21 +105,19 @@ class phpbb_cache_service */ function obtain_word_list() { - global $db; - if (($censors = $this->driver->get('_word_censors')) === false) { $sql = 'SELECT word, replacement FROM ' . WORDS_TABLE; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $censors = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $censors['match'][] = get_censor_preg_expression($row['word']); $censors['replace'][] = $row['replacement']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); $this->driver->put('_word_censors', $censors); } @@ -93,23 +132,21 @@ class phpbb_cache_service { if (($icons = $this->driver->get('_icons')) === false) { - global $db; - // Topic icons $sql = 'SELECT * FROM ' . ICONS_TABLE . ' ORDER BY icons_order'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $icons = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $icons[$row['icons_id']]['img'] = $row['icons_url']; $icons[$row['icons_id']]['width'] = (int) $row['icons_width']; $icons[$row['icons_id']]['height'] = (int) $row['icons_height']; $icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); $this->driver->put('_icons', $icons); } @@ -124,15 +161,13 @@ class phpbb_cache_service { if (($ranks = $this->driver->get('_ranks')) === false) { - global $db; - $sql = 'SELECT * FROM ' . RANKS_TABLE . ' ORDER BY rank_min DESC'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $ranks = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { if ($row['rank_special']) { @@ -150,7 +185,7 @@ class phpbb_cache_service ); } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); $this->driver->put('_ranks', $ranks); } @@ -169,8 +204,6 @@ class phpbb_cache_service { if (($extensions = $this->driver->get('_extensions')) === false) { - global $db; - $extensions = array( '_allowed_post' => array(), '_allowed_pm' => array(), @@ -181,9 +214,9 @@ class phpbb_cache_service FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g WHERE e.group_id = g.group_id AND (g.allow_group = 1 OR g.allow_in_pm = 1)'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $extension = strtolower(trim($row['extension'])); @@ -210,7 +243,7 @@ class phpbb_cache_service $extensions['_allowed_pm'][$extension] = 0; } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); $this->driver->put('_extensions', $extensions); } @@ -275,9 +308,7 @@ class phpbb_cache_service { if (($bots = $this->driver->get('_bots')) === false) { - global $db; - - switch ($db->sql_layer) + switch ($this->db->sql_layer) { case 'mssql': case 'mssql_odbc': @@ -303,14 +334,14 @@ class phpbb_cache_service ORDER BY LENGTH(bot_agent) DESC'; break; } - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $bots = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $bots[] = $row; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); $this->driver->put('_bots', $bots); } @@ -323,8 +354,6 @@ class phpbb_cache_service */ function obtain_cfg_items($style) { - global $config, $phpbb_root_path; - $parsed_array = $this->driver->get('_cfg_' . $style['style_path']); if ($parsed_array === false) @@ -332,14 +361,14 @@ class phpbb_cache_service $parsed_array = array(); } - $filename = $phpbb_root_path . 'styles/' . $style['style_path'] . '/style.cfg'; + $filename = $this->phpbb_root_path . 'styles/' . $style['style_path'] . '/style.cfg'; if (!file_exists($filename)) { return $parsed_array; } - if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime']))) + if (!isset($parsed_array['filetime']) || (($this->config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime']))) { // Re-parse cfg file $parsed_array = parse_cfg_file($filename); @@ -358,54 +387,20 @@ class phpbb_cache_service { if (($usernames = $this->driver->get('_disallowed_usernames')) === false) { - global $db; - $sql = 'SELECT disallow_username FROM ' . DISALLOW_TABLE; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $usernames = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $usernames[] = str_replace('%', '.*?', preg_quote(utf8_clean_string($row['disallow_username']), '#')); } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); $this->driver->put('_disallowed_usernames', $usernames); } return $usernames; } - - /** - * Obtain hooks... - */ - function obtain_hooks() - { - global $phpbb_root_path, $phpEx; - - if (($hook_files = $this->driver->get('_hooks')) === false) - { - $hook_files = array(); - - // Now search for hooks... - $dh = @opendir($phpbb_root_path . 'includes/hooks/'); - - if ($dh) - { - while (($file = readdir($dh)) !== false) - { - if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) - { - $hook_files[] = substr($file, 0, -(strlen($phpEx) + 1)); - } - } - closedir($dh); - } - - $this->driver->put('_hooks', $hook_files); - } - - return $hook_files; - } } |