mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:38:53 +00:00
Merge remote-tracking branch 'p/ticket/11305' into develop
* p/ticket/11305: [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/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. [ticket/11305] Extract hook finder from cache service.
This commit is contained in:
commit
208770d7fd
20 changed files with 163 additions and 87 deletions
|
@ -120,8 +120,9 @@ $phpbb_style = $phpbb_container->get('style');
|
|||
// Add own hook handler
|
||||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display')));
|
||||
$phpbb_hook_finder = $phpbb_container->get('hook_finder');
|
||||
|
||||
foreach ($cache->obtain_hooks() as $hook)
|
||||
foreach ($phpbb_hook_finder->find() as $hook)
|
||||
{
|
||||
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
||||
}
|
||||
|
|
|
@ -127,6 +127,13 @@ services:
|
|||
- @dispatcher
|
||||
- @controller.resolver
|
||||
|
||||
hook_finder:
|
||||
class: phpbb_hook_finder
|
||||
arguments:
|
||||
- %core.root_path%
|
||||
- .%core.php_ext%
|
||||
- @cache.driver
|
||||
|
||||
kernel_request_subscriber:
|
||||
class: phpbb_event_kernel_request_subscriber
|
||||
arguments:
|
||||
|
|
|
@ -740,15 +740,15 @@ class acp_modules
|
|||
*/
|
||||
function remove_cache_file()
|
||||
{
|
||||
global $cache;
|
||||
global $phpbb_container;
|
||||
|
||||
// Sanitise for future path use, it's escaped as appropriate for queries
|
||||
$p_class = str_replace(array('.', '/', '\\'), '', basename($this->module_class));
|
||||
|
||||
$cache->destroy('_modules_' . $p_class);
|
||||
$phpbb_container->get('cache.driver')->destroy('_modules_' . $p_class);
|
||||
|
||||
// Additionally remove sql cache
|
||||
$cache->destroy('sql', MODULES_TABLE);
|
||||
$phpbb_container->get('cache.driver')->destroy('sql', MODULES_TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
30
phpBB/includes/cache/service.php
vendored
30
phpBB/includes/cache/service.php
vendored
|
@ -403,34 +403,4 @@ class phpbb_cache_service
|
|||
|
||||
return $usernames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain hooks...
|
||||
*/
|
||||
function obtain_hooks()
|
||||
{
|
||||
if (($hook_files = $this->driver->get('_hooks')) === false)
|
||||
{
|
||||
$hook_files = array();
|
||||
|
||||
// Now search for hooks...
|
||||
$dh = @opendir($this->phpbb_root_path . 'includes/hooks/');
|
||||
|
||||
if ($dh)
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($this->php_ext) + 1)) === '.' . $this->php_ext)
|
||||
{
|
||||
$hook_files[] = substr($file, 0, -(strlen($this->php_ext) + 1));
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
$this->driver->put('_hooks', $hook_files);
|
||||
}
|
||||
|
||||
return $hook_files;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ class phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class phpbb_db_driver
|
|||
$this->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchfield($query_id, $field);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
|
|||
}
|
||||
|
||||
$this->last_query_text = $query;
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -267,7 +267,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
|
|||
}
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -330,7 +330,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
|
|||
$this->sql_report('start', $query);
|
||||
}
|
||||
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -165,7 +165,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -240,7 +240,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
|||
}
|
||||
|
||||
$this->last_query_text = $query;
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -194,7 +194,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -270,7 +270,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
|||
}
|
||||
|
||||
$this->last_query_text = $query;
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
|
|
@ -188,7 +188,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
|||
$this->sql_report('start', $query);
|
||||
}
|
||||
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -203,7 +203,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -265,7 +265,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
|||
$this->sql_report('start', $query);
|
||||
}
|
||||
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -199,7 +199,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
|
|||
}
|
||||
|
||||
$this->last_query_text = $query;
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -443,7 +443,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -498,7 +498,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
|
|||
}
|
||||
|
||||
$this->last_query_text = $query;
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -208,7 +208,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -278,7 +278,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
|
|||
$this->sql_report('start', $query);
|
||||
}
|
||||
|
||||
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
|
||||
$this->sql_add_num_queries($this->query_result);
|
||||
|
||||
if ($this->query_result === false)
|
||||
|
@ -149,7 +149,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -210,7 +210,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
|
|
@ -3463,7 +3463,7 @@ function group_validate_groupname($group_id, $group_name)
|
|||
*/
|
||||
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
|
||||
{
|
||||
global $cache, $db, $phpbb_dispatcher;
|
||||
global $phpbb_container, $db, $phpbb_dispatcher;
|
||||
|
||||
if (empty($user_id_ary))
|
||||
{
|
||||
|
@ -3579,7 +3579,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
|
|||
}
|
||||
|
||||
// Because some tables/caches use usercolour-specific data we need to purge this here.
|
||||
$cache->destroy('sql', MODERATOR_CACHE_TABLE);
|
||||
$phpbb_container->get('cache.driver')->destroy('sql', MODERATOR_CACHE_TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
84
phpBB/includes/hook/finder.php
Normal file
84
phpBB/includes/hook/finder.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package extension
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hook finder locates installed hooks.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_hook_finder
|
||||
{
|
||||
protected $phpbb_root_path;
|
||||
protected $cache;
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Creates a new finder instance.
|
||||
*
|
||||
* @param string $phpbb_root_path Path to the phpbb root directory
|
||||
* @param string $php_ext php file extension
|
||||
* @param phpbb_cache_driver_interface $cache A cache instance or null
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, phpbb_cache_driver_interface $cache = null)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->cache = $cache;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all hook files.
|
||||
*
|
||||
* @param bool $cache Whether the result should be cached
|
||||
* @return array An array of paths to found hook files
|
||||
*/
|
||||
public function find($cache = true)
|
||||
{
|
||||
if (!defined('DEBUG') && $cache && $this->cache)
|
||||
{
|
||||
$hook_files = $this->cache->get('_hooks');
|
||||
if ($hook_files !== false)
|
||||
{
|
||||
return $hook_files;
|
||||
}
|
||||
}
|
||||
|
||||
$hook_files = array();
|
||||
|
||||
// Now search for hooks...
|
||||
$dh = @opendir($this->phpbb_root_path . 'includes/hooks/');
|
||||
|
||||
if ($dh)
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($this->php_ext) + 1)) === '.' . $this->php_ext)
|
||||
{
|
||||
$hook_files[] = substr($file, 0, -(strlen($this->php_ext) + 1));
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
if ($cache && $this->cache)
|
||||
{
|
||||
$this->cache->put('_hooks', $hook_files);
|
||||
}
|
||||
|
||||
return $hook_files;
|
||||
}
|
||||
}
|
|
@ -133,7 +133,8 @@ if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
|
|||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
|
||||
|
||||
foreach ($cache->obtain_hooks() as $hook)
|
||||
$phpbb_hook_finder = $phpbb_container->get('hook_finder');
|
||||
foreach ($phpbb_hook_finder->find() as $hook)
|
||||
{
|
||||
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
||||
}
|
||||
|
@ -186,7 +187,7 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);
|
|||
$inline_update = (request_var('type', 0)) ? true : false;
|
||||
|
||||
// To let set_config() calls succeed, we need to make the config array available globally
|
||||
$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
|
||||
$config = new phpbb_config_db($db, $phpbb_container->get('cache.driver'), CONFIG_TABLE);
|
||||
set_config(null, null, null, $config);
|
||||
set_config_count(null, null, null, $config);
|
||||
|
||||
|
@ -573,7 +574,7 @@ else
|
|||
add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $updates_to_version);
|
||||
|
||||
// Now we purge the session table as well as all cache files
|
||||
$cache->purge();
|
||||
$phpbb_container->get('cache.driver')->purge();
|
||||
|
||||
_print_footer();
|
||||
|
||||
|
|
|
@ -101,9 +101,6 @@ $phpbb_container = phpbb_create_install_container($phpbb_root_path, $phpEx);
|
|||
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
|
||||
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
|
||||
|
||||
// set up caching
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
|
||||
$request = $phpbb_container->get('request');
|
||||
|
||||
|
@ -199,7 +196,8 @@ if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
|
|||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
|
||||
|
||||
foreach ($cache->obtain_hooks() as $hook)
|
||||
$phpbb_hook_finder = $phpbb_container->get('hook_finder');
|
||||
foreach ($phpbb_hook_finder->find() as $hook)
|
||||
{
|
||||
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
||||
}
|
||||
|
|
|
@ -52,12 +52,13 @@ class install_install extends module
|
|||
|
||||
function main($mode, $sub)
|
||||
{
|
||||
global $lang, $template, $language, $phpbb_root_path, $cache;
|
||||
global $lang, $template, $language, $phpbb_root_path, $phpEx;
|
||||
global $phpbb_container, $cache;
|
||||
|
||||
switch ($sub)
|
||||
{
|
||||
case 'intro':
|
||||
$cache->purge();
|
||||
$phpbb_container->get('cache.driver')->purge();
|
||||
|
||||
$this->page_title = $lang['SUB_INTRO'];
|
||||
|
||||
|
@ -101,6 +102,12 @@ class install_install extends module
|
|||
break;
|
||||
|
||||
case 'final':
|
||||
// Create a normal container now
|
||||
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||
|
||||
// Sets the global $cache variable
|
||||
$cache = $phpbb_container->get('cache');
|
||||
|
||||
$this->build_search_index($mode, $sub);
|
||||
$this->add_modules($mode, $sub);
|
||||
$this->add_language($mode, $sub);
|
||||
|
|
|
@ -262,7 +262,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
$config['rand_seed_last_update'] = time() + 600;
|
||||
|
||||
// Required by user_add
|
||||
global $db, $cache, $phpbb_dispatcher;
|
||||
global $db, $cache, $phpbb_dispatcher, $phpbb_container;
|
||||
$db = $this->get_db();
|
||||
if (!function_exists('phpbb_mock_null_cache'))
|
||||
{
|
||||
|
@ -270,6 +270,14 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
}
|
||||
$cache = new phpbb_mock_null_cache;
|
||||
|
||||
$cache_driver = new phpbb_cache_driver_null();
|
||||
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$phpbb_container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->with('cache.driver')
|
||||
->will($this->returnValue($cache_driver));
|
||||
|
||||
if (!function_exists('utf_clean_string'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
|
||||
|
|
Loading…
Add table
Reference in a new issue