From d5896239068e1063970f398a12ffb5a0707fb286 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sat, 7 Jul 2012 22:43:52 +0100 Subject: [PATCH 001/544] [ticket/10970] Paths of the form {FOO}/a/{BAR}/b parsed correctly A new method to handle this type of path was added and compile_tag_include, compile_tag_include_php and compile_tag_include_js were modified to use it appropriately. Tests were added for these three macros also. PHPBB3-10970 --- phpBB/includes/template/filter.php | 70 +++++++++++++++---- tests/template/includephp_test.php | 12 ++++ tests/template/template_includejs_test.php | 6 +- tests/template/template_test.php | 7 ++ .../template/templates/include_variables.html | 1 + tests/template/templates/includejs.html | 4 +- .../templates/includephp_variables.html | 2 + .../template/templates/subdir/parent_only.js | 0 .../templates/subdir/subsubdir/parent_only.js | 0 tests/template/templates/subdir/variable.html | 1 + 10 files changed, 85 insertions(+), 18 deletions(-) create mode 100644 tests/template/templates/include_variables.html create mode 100644 tests/template/templates/includephp_variables.html create mode 100644 tests/template/templates/subdir/parent_only.js create mode 100644 tests/template/templates/subdir/subsubdir/parent_only.js create mode 100644 tests/template/templates/subdir/variable.html diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index ad2e35de6a..a8985a771c 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -361,6 +361,52 @@ class phpbb_template_filter extends php_user_filter return $text_blocks; } + /** + * Parse paths of the form {FOO}/a/{BAR}/b + * Note: this method assumes at least one variable in the path, this should + * be checked before this method is called. + * + * @param string $path The path to parse + * @param string $include_type The type of template function to call + * @return string An appropriately formatted string to include in the + * template + */ + private function parse_dynamic_path($path, $include_type) + { + $segments = explode('/', $path); + $is_expr = true; + $str = array(); + $vars = array(); + + foreach ($segments as $segment) + { + if ($segment[0] === '{') + { + $var = $this->get_varref($segment, $tmp_is_expr); + $is_expr = $is_expr && $tmp_is_expr; + $vars[] = "isset($var)"; + $str[] = "$var . '/'"; + } + else + { + $str[] = "'$segment/'"; + } + } + + // Remove trailing slash from last element + $last = array_pop($str); + $str[] = str_replace('/', '', $last); + + if (!$is_expr) + { + return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type(" . implode(' . ', $str) . ', true); }'; + } + else + { + return ''; + } + } + /** * Compile variables * @@ -774,15 +820,9 @@ class phpbb_template_filter extends php_user_filter private function compile_tag_include($tag_args) { // Process dynamic includes - if ($tag_args[0] == '{') + if (strpos($tag_args, '{') !== false) { - $var = $this->get_varref($tag_args, $is_expr); - - // Make sure someone didn't try to include S_FIRST_ROW or similar - if (!$is_expr) - { - return "if (isset($var)) { \$_template->_tpl_include($var); }"; - } + return $this->parse_dynamic_path($tag_args, '_tpl_include'); } return "\$_template->_tpl_include('$tag_args');"; @@ -796,6 +836,11 @@ class phpbb_template_filter extends php_user_filter */ private function compile_tag_include_php($tag_args) { + if (strpos($tag_args, '{') !== false) + { + return $this->parse_dynamic_path($tag_args, '_php_include'); + } + return "\$_template->_php_include('$tag_args');"; } @@ -883,14 +928,9 @@ class phpbb_template_filter extends php_user_filter private function compile_tag_include_js($tag_args) { // Process dynamic includes - if ($tag_args[0] == '{') + if (strpos($tag_args, '{') !== false) { - $var = $this->get_varref($tag_args, $is_expr); - if (!$is_expr) - { - return " \$_template->_js_include($var, true);"; - } - return ''; + return $this->parse_dynamic_path($tag_args, '_js_include'); } // Locate file diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index 626735f15f..236621adec 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -23,6 +23,18 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case $this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP"); } + public function test_includephp_variables() + { + $this->setup_engine(array('tpl_allow_php' => true)); + + $cache_file = $this->template->cachepath . 'includephp_variables.html.php'; + + $this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php", $cache_file); + + $this->template->set_filenames(array('test' => 'includephp_variables.html')); + $this->assertEquals("Path includes variables.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP"); + } + public function test_includephp_absolute() { $path_to_php = dirname(__FILE__) . '/templates/_dummy_include.php.inc'; diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index a8f9a9037f..d8c7170e94 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -20,11 +20,13 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes $scripts = array( '', '', - '' + '', + '', + '', ); // Run test $cache_file = $this->template->cachepath . 'includejs.html.php'; - $this->run_template('includejs.html', array('PARENT' => 'parent_only.js'), array(), array(), implode('', $scripts), $cache_file); + $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir'), array(), array(), implode('', $scripts), $cache_file); } } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index f8677ed913..83995cb4ac 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -183,6 +183,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), 'value', ), + array( + 'include_variables.html', + array('SUBDIR' => 'subdir', 'VARIABLE' => 'value'), + array(), + array(), + 'value', + ), array( 'loop_vars.html', array(), diff --git a/tests/template/templates/include_variables.html b/tests/template/templates/include_variables.html new file mode 100644 index 0000000000..8371a061b5 --- /dev/null +++ b/tests/template/templates/include_variables.html @@ -0,0 +1 @@ + diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index 8a2587d76b..dbcf6e04a8 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -2,4 +2,6 @@ -{SCRIPTS} \ No newline at end of file + + +{SCRIPTS} diff --git a/tests/template/templates/includephp_variables.html b/tests/template/templates/includephp_variables.html new file mode 100644 index 0000000000..6106efc86a --- /dev/null +++ b/tests/template/templates/includephp_variables.html @@ -0,0 +1,2 @@ +Path includes variables. + diff --git a/tests/template/templates/subdir/parent_only.js b/tests/template/templates/subdir/parent_only.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/template/templates/subdir/subsubdir/parent_only.js b/tests/template/templates/subdir/subsubdir/parent_only.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/template/templates/subdir/variable.html b/tests/template/templates/subdir/variable.html new file mode 100644 index 0000000000..f68f91597c --- /dev/null +++ b/tests/template/templates/subdir/variable.html @@ -0,0 +1 @@ +{VARIABLE} From d0cb5bb093d09a15f422f84e19d781a8260512a0 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sun, 8 Jul 2012 15:12:08 +0100 Subject: [PATCH 002/544] [ticket/10970] Added support for forms such as {FOO}bar.{EXT} PHPBB3-10970 --- phpBB/includes/template/filter.php | 30 +++++++--------------- tests/template/template_includejs_test.php | 3 ++- tests/template/templates/includejs.html | 1 + 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index a8985a771c..568727be82 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -373,33 +373,21 @@ class phpbb_template_filter extends php_user_filter */ private function parse_dynamic_path($path, $include_type) { - $segments = explode('/', $path); - $is_expr = true; - $str = array(); - $vars = array(); + $matches = array(); + $replace = array(); - foreach ($segments as $segment) + preg_match_all('/{[^}]+}/', $path, $matches); + foreach ($matches[0] as $var_str) { - if ($segment[0] === '{') - { - $var = $this->get_varref($segment, $tmp_is_expr); - $is_expr = $is_expr && $tmp_is_expr; - $vars[] = "isset($var)"; - $str[] = "$var . '/'"; - } - else - { - $str[] = "'$segment/'"; - } + $var = $this->get_varref($var_str, $tmp_is_expr); + $is_expr = $is_expr && $tmp_is_expr; + $vars[] = "isset($var)"; + $replace[] = "' . $var . '"; } - // Remove trailing slash from last element - $last = array_pop($str); - $str[] = str_replace('/', '', $last); - if (!$is_expr) { - return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type(" . implode(' . ', $str) . ', true); }'; + return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type('" . str_replace($matches[0], $replace, $path) . "', true); }"; } else { diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index d8c7170e94..22b020208b 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -23,10 +23,11 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes '', '', '', + '', ); // Run test $cache_file = $this->template->cachepath . 'includejs.html.php'; - $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir'), array(), array(), implode('', $scripts), $cache_file); + $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts), $cache_file); } } diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index dbcf6e04a8..ef73700eeb 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -4,4 +4,5 @@ + {SCRIPTS} From 90a957ad26f52e26c3979464c5ac15b1fd0fcc28 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 17:43:43 +0200 Subject: [PATCH 003/544] [ticket/11015] Make DBAL classes autoloadable PHPBB3-11015 This allows us to just create the object without having to include the driver first. However, it also means that users must specify the full class name in config.php --- phpBB/common.php | 3 +- phpBB/download/file.php | 3 +- phpBB/includes/config/db.php | 2 +- phpBB/includes/db/dbal.php | 1049 ----------------- phpBB/includes/db/driver/driver.php | 1044 ++++++++++++++++ phpBB/includes/db/{ => driver}/firebird.php | 4 +- phpBB/includes/db/{ => driver}/mssql.php | 6 +- phpBB/includes/db/{ => driver}/mssql_odbc.php | 4 +- .../includes/db/{ => driver}/mssqlnative.php | 4 +- phpBB/includes/db/{ => driver}/mysql.php | 4 +- phpBB/includes/db/{ => driver}/mysqli.php | 4 +- phpBB/includes/db/{ => driver}/oracle.php | 4 +- phpBB/includes/db/{ => driver}/postgres.php | 9 +- phpBB/includes/db/{ => driver}/sqlite.php | 4 +- phpBB/includes/extension/manager.php | 4 +- phpBB/includes/functions_install.php | 59 +- phpBB/install/database_update.php | 7 +- phpBB/install/install_convert.php | 24 +- phpBB/install/install_install.php | 12 +- phpBB/install/install_update.php | 3 +- tests/RUNNING_TESTS.txt | 2 +- tests/session/testable_factory.php | 2 +- .../phpbb_database_test_case.php | 7 +- ...phpbb_database_test_connection_manager.php | 44 +- .../phpbb_functional_test_case.php | 8 +- .../phpbb_test_case_helpers.php | 2 +- 26 files changed, 1129 insertions(+), 1189 deletions(-) delete mode 100644 phpBB/includes/db/dbal.php create mode 100644 phpBB/includes/db/driver/driver.php rename phpBB/includes/db/{ => driver}/firebird.php (99%) rename phpBB/includes/db/{ => driver}/mssql.php (99%) rename phpBB/includes/db/{ => driver}/mssql_odbc.php (98%) rename phpBB/includes/db/{ => driver}/mssqlnative.php (99%) rename phpBB/includes/db/{ => driver}/mysql.php (99%) rename phpBB/includes/db/{ => driver}/mysqli.php (99%) rename phpBB/includes/db/{ => driver}/oracle.php (99%) rename phpBB/includes/db/{ => driver}/postgres.php (98%) rename phpBB/includes/db/{ => driver}/sqlite.php (98%) diff --git a/phpBB/common.php b/phpBB/common.php index 81fe275008..9862fcf4c3 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -79,7 +79,6 @@ require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours @@ -102,7 +101,7 @@ $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new phpbb_user(); $auth = new phpbb_auth(); -$db = new $sql_db(); +$db = new $dbms(); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function diff --git a/phpBB/download/file.php b/phpBB/download/file.php index c01b0789de..72c2d3ba3f 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -39,7 +39,6 @@ if (isset($_GET['avatar'])) } 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); @@ -58,7 +57,7 @@ if (isset($_GET['avatar'])) $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); - $db = new $sql_db(); + $db = new $dbms(); // Connect to DB if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index 993a764a7f..4293498d97 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -46,7 +46,7 @@ class phpbb_config_db extends phpbb_config * @param phpbb_cache_driver_interface $cache Cache instance * @param string $table Configuration table name */ - public function __construct(dbal $db, phpbb_cache_driver_interface $cache, $table) + public function __construct(phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $table) { $this->db = $db; $this->cache = $cache; diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php deleted file mode 100644 index 159703d3be..0000000000 --- a/phpBB/includes/db/dbal.php +++ /dev/null @@ -1,1049 +0,0 @@ -num_queries = array( - 'cached' => 0, - 'normal' => 0, - 'total' => 0, - ); - - // Fill default sql layer based on the class being called. - // This can be changed by the specified layer itself later if needed. - $this->sql_layer = substr(get_class($this), 5); - - // Do not change this please! This variable is used to easy the use of it - and is hardcoded. - $this->any_char = chr(0) . '%'; - $this->one_char = chr(0) . '_'; - } - - /** - * return on error or display error message - */ - function sql_return_on_error($fail = false) - { - $this->sql_error_triggered = false; - $this->sql_error_sql = ''; - - $this->return_on_error = $fail; - } - - /** - * Return number of sql queries and cached sql queries used - */ - function sql_num_queries($cached = false) - { - return ($cached) ? $this->num_queries['cached'] : $this->num_queries['normal']; - } - - /** - * Add to query count - */ - function sql_add_num_queries($cached = false) - { - $this->num_queries['cached'] += ($cached !== false) ? 1 : 0; - $this->num_queries['normal'] += ($cached !== false) ? 0 : 1; - $this->num_queries['total'] += 1; - } - - /** - * DBAL garbage collection, close sql connection - */ - function sql_close() - { - if (!$this->db_connect_id) - { - return false; - } - - if ($this->transaction) - { - do - { - $this->sql_transaction('commit'); - } - while ($this->transaction); - } - - foreach ($this->open_queries as $query_id) - { - $this->sql_freeresult($query_id); - } - - // Connection closed correctly. Set db_connect_id to false to prevent errors - if ($result = $this->_sql_close()) - { - $this->db_connect_id = false; - } - - return $result; - } - - /** - * Build LIMIT query - * Doing some validation here. - */ - function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if (empty($query)) - { - return false; - } - - // Never use a negative total or offset - $total = ($total < 0) ? 0 : $total; - $offset = ($offset < 0) ? 0 : $offset; - - return $this->_sql_query_limit($query, $total, $offset, $cache_ttl); - } - - /** - * Fetch all rows - */ - function sql_fetchrowset($query_id = false) - { - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id !== false) - { - $result = array(); - while ($row = $this->sql_fetchrow($query_id)) - { - $result[] = $row; - } - - return $result; - } - - return false; - } - - /** - * Seek to given row number - * rownum is zero-based - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if (isset($cache->sql_rowset[$query_id])) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if ($query_id === false) - { - return false; - } - - $this->sql_freeresult($query_id); - $query_id = $this->sql_query($this->last_query_text); - - if ($query_id === false) - { - return false; - } - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** - * Fetch field - * if rownum is false, the current row is used, else it is pointing to the row (zero-based) - */ - function sql_fetchfield($field, $rownum = false, $query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id !== false) - { - if ($rownum !== false) - { - $this->sql_rowseek($rownum, $query_id); - } - - if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) - { - return $cache->sql_fetchfield($query_id, $field); - } - - $row = $this->sql_fetchrow($query_id); - return (isset($row[$field])) ? $row[$field] : false; - } - - return false; - } - - /** - * Correctly adjust LIKE expression for special characters - * Some DBMS are handling them in a different way - * - * @param string $expression The expression to use. Every wildcard is escaped, except $this->any_char and $this->one_char - * @return string LIKE expression including the keyword! - */ - function sql_like_expression($expression) - { - $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression); - $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); - - return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); - } - - /** - * Build a case expression - * - * Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database! - * - * @param string $condition The condition which must be true, to use action_true rather then action_else - * @param string $action_true SQL expression that is used, if the condition is true - * @param string $action_else SQL expression that is used, if the condition is false, optional - * @return string CASE expression including the condition and statements - */ - public function sql_case($condition, $action_true, $action_false = false) - { - $sql_case = 'CASE WHEN ' . $condition; - $sql_case .= ' THEN ' . $action_true; - $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; - $sql_case .= ' END'; - return $sql_case; - } - - /** - * Build a concatenated expression - * - * @param string $expr1 Base SQL expression where we append the second one - * @param string $expr2 SQL expression that is appended to the first expression - * @return string Concatenated string - */ - public function sql_concatenate($expr1, $expr2) - { - return $expr1 . ' || ' . $expr2; - } - - /** - * Returns whether results of a query need to be buffered to run a transaction while iterating over them. - * - * @return bool Whether buffering is required. - */ - function sql_buffer_nested_transactions() - { - return false; - } - - /** - * SQL Transaction - * @access private - */ - function sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - // If we are within a transaction we will not open another one, but enclose the current one to not loose data (prevening auto commit) - if ($this->transaction) - { - $this->transactions++; - return true; - } - - $result = $this->_sql_transaction('begin'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = true; - break; - - case 'commit': - // If there was a previously opened transaction we do not commit yet... but count back the number of inner transactions - if ($this->transaction && $this->transactions) - { - $this->transactions--; - return true; - } - - // Check if there is a transaction (no transaction can happen if there was an error, with a combined rollback and error returning enabled) - // This implies we have transaction always set for autocommit db's - if (!$this->transaction) - { - return false; - } - - $result = $this->_sql_transaction('commit'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = false; - $this->transactions = 0; - break; - - case 'rollback': - $result = $this->_sql_transaction('rollback'); - $this->transaction = false; - $this->transactions = 0; - break; - - default: - $result = $this->_sql_transaction($status); - break; - } - - return $result; - } - - /** - * Build sql statement from array for insert/update/select statements - * - * Idea for this from Ikonboard - * Possible query values: INSERT, INSERT_SELECT, UPDATE, SELECT - * - */ - function sql_build_array($query, $assoc_ary = false) - { - if (!is_array($assoc_ary)) - { - return false; - } - - $fields = $values = array(); - - if ($query == 'INSERT' || $query == 'INSERT_SELECT') - { - foreach ($assoc_ary as $key => $var) - { - $fields[] = $key; - - if (is_array($var) && is_string($var[0])) - { - // This is used for INSERT_SELECT(s) - $values[] = $var[0]; - } - else - { - $values[] = $this->_sql_validate_value($var); - } - } - - $query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' '; - } - else if ($query == 'MULTI_INSERT') - { - trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR); - } - else if ($query == 'UPDATE' || $query == 'SELECT') - { - $values = array(); - foreach ($assoc_ary as $key => $var) - { - $values[] = "$key = " . $this->_sql_validate_value($var); - } - $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); - } - - return $query; - } - - /** - * Build IN or NOT IN sql comparison string, uses <> or = on single element - * arrays to improve comparison speed - * - * @access public - * @param string $field name of the sql column that shall be compared - * @param array $array array of values that are allowed (IN) or not allowed (NOT IN) - * @param bool $negate true for NOT IN (), false for IN () (default) - * @param bool $allow_empty_set If true, allow $array to be empty, this function will return 1=1 or 1=0 then. Default to false. - */ - function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) - { - if (!sizeof($array)) - { - if (!$allow_empty_set) - { - // Print the backtrace to help identifying the location of the problematic code - $this->sql_error('No values specified for SQL IN comparison'); - } - else - { - // NOT IN () actually means everything so use a tautology - if ($negate) - { - return '1=1'; - } - // IN () actually means nothing so use a contradiction - else - { - return '1=0'; - } - } - } - - if (!is_array($array)) - { - $array = array($array); - } - - if (sizeof($array) == 1) - { - @reset($array); - $var = current($array); - - return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var); - } - else - { - return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')'; - } - } - - /** - * Run binary AND operator on DB column. - * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (for example "= 0") - */ - function sql_bit_and($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_and')) - { - return $this->_sql_bit_and($column_name, $bit, $compare); - } - - return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * Run binary OR operator on DB column. - * Results in sql statement: "{$column_name} | (1 << {$bit}) {$compare}" - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the OR operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (for example "= 0") - */ - function sql_bit_or($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_or')) - { - return $this->_sql_bit_or($column_name, $bit, $compare); - } - - return $column_name . ' | ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * Returns SQL string to cast a string expression to an int. - * - * @param string $expression An expression evaluating to string - * @return string Expression returning an int - */ - function cast_expr_to_bigint($expression) - { - return $expression; - } - - /** - * Returns SQL string to cast an integer expression to a string. - * - * @param string $expression An expression evaluating to int - * @return string Expression returning a string - */ - function cast_expr_to_string($expression) - { - return $expression; - } - - /** - * Run LOWER() on DB column of type text (i.e. neither varchar nor char). - * - * @param string $column_name The column name to use - * - * @return string A SQL statement like "LOWER($column_name)" - */ - function sql_lower_text($column_name) - { - return "LOWER($column_name)"; - } - - /** - * Run more than one insert statement. - * - * @param string $table table name to run the statements on - * @param array &$sql_ary multi-dimensional array holding the statement data. - * - * @return bool false if no statements were executed. - * @access public - */ - function sql_multi_insert($table, &$sql_ary) - { - if (!sizeof($sql_ary)) - { - return false; - } - - if ($this->multi_insert) - { - $ary = array(); - foreach ($sql_ary as $id => $_sql_ary) - { - // If by accident the sql array is only one-dimensional we build a normal insert statement - if (!is_array($_sql_ary)) - { - return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); - } - - $values = array(); - foreach ($_sql_ary as $key => $var) - { - $values[] = $this->_sql_validate_value($var); - } - $ary[] = '(' . implode(', ', $values) . ')'; - } - - return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); - } - else - { - foreach ($sql_ary as $ary) - { - if (!is_array($ary)) - { - return false; - } - - $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); - - if (!$result) - { - return false; - } - } - } - - return true; - } - - /** - * Function for validating values - * @access private - */ - function _sql_validate_value($var) - { - if (is_null($var)) - { - return 'NULL'; - } - else if (is_string($var)) - { - return "'" . $this->sql_escape($var) . "'"; - } - else - { - return (is_bool($var)) ? intval($var) : $var; - } - } - - /** - * Build sql statement from array for select and select distinct statements - * - * Possible query values: SELECT, SELECT_DISTINCT - */ - function sql_build_query($query, $array) - { - $sql = ''; - switch ($query) - { - case 'SELECT': - case 'SELECT_DISTINCT'; - - $sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM '; - - // Build table array. We also build an alias array for later checks. - $table_array = $aliases = array(); - $used_multi_alias = false; - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - $used_multi_alias = true; - - foreach ($alias as $multi_alias) - { - $table_array[] = $table_name . ' ' . $multi_alias; - $aliases[] = $multi_alias; - } - } - else - { - $table_array[] = $table_name . ' ' . $alias; - $aliases[] = $alias; - } - } - - // We run the following code to determine if we need to re-order the table array. ;) - // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. - // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. - if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false) - { - // Take first LEFT JOIN - $join = current($array['LEFT_JOIN']); - - // Determine the table used there (even if there are more than one used, we only want to have one - preg_match('/(' . implode('|', $aliases) . ')\.[^\s]+/U', str_replace(array('(', ')', 'AND', 'OR', ' '), '', $join['ON']), $matches); - - // If there is a first join match, we need to make sure the table order is correct - if (!empty($matches[1])) - { - $first_join_match = trim($matches[1]); - $table_array = $last = array(); - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - foreach ($alias as $multi_alias) - { - ($multi_alias === $first_join_match) ? $last[] = $table_name . ' ' . $multi_alias : $table_array[] = $table_name . ' ' . $multi_alias; - } - } - else - { - ($alias === $first_join_match) ? $last[] = $table_name . ' ' . $alias : $table_array[] = $table_name . ' ' . $alias; - } - } - - $table_array = array_merge($table_array, $last); - } - } - - $sql .= $this->_sql_custom_build('FROM', implode(' CROSS JOIN ', $table_array)); - - if (!empty($array['LEFT_JOIN'])) - { - foreach ($array['LEFT_JOIN'] as $join) - { - $sql .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')'; - } - } - - if (!empty($array['WHERE'])) - { - $sql .= ' WHERE ' . $this->_sql_custom_build('WHERE', $array['WHERE']); - } - - if (!empty($array['GROUP_BY'])) - { - $sql .= ' GROUP BY ' . $array['GROUP_BY']; - } - - if (!empty($array['ORDER_BY'])) - { - $sql .= ' ORDER BY ' . $array['ORDER_BY']; - } - - break; - } - - return $sql; - } - - /** - * display sql error page - */ - function sql_error($sql = '') - { - global $auth, $user, $config; - - // Set var to retrieve errored status - $this->sql_error_triggered = true; - $this->sql_error_sql = $sql; - - $this->sql_error_returned = $this->_sql_error(); - - if (!$this->return_on_error) - { - $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]

' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']'; - - // Show complete SQL error and path to administrators only - // Additionally show complete error on installation or if extended debug mode is enabled - // The DEBUG_EXTRA constant is for development only! - if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) - { - $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; - } - else - { - // If error occurs in initiating the session we need to use a pre-defined language string - // This could happen if the connection could not be established for example (then we are not able to grab the default language) - if (!isset($user->lang['SQL_ERROR_OCCURRED'])) - { - $message .= '

An sql error occurred while fetching this page. Please contact an administrator if this problem persists.'; - } - else - { - if (!empty($config['board_contact'])) - { - $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - else - { - $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - } - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - if (strlen($message) > 1024) - { - // We need to define $msg_long_text here to circumvent text stripping. - global $msg_long_text; - $msg_long_text = $message; - - trigger_error(false, E_USER_ERROR); - } - - trigger_error($message, E_USER_ERROR); - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - return $this->sql_error_returned; - } - - /** - * Explain queries - */ - function sql_report($mode, $query = '') - { - global $cache, $starttime, $phpbb_root_path, $user; - global $request; - - if (is_object($request) && !$request->variable('explain', false)) - { - return false; - } - - if (!$query && $this->query_hold != '') - { - $query = $this->query_hold; - } - - switch ($mode) - { - case 'display': - if (!empty($cache)) - { - $cache->unload(); - } - $this->sql_close(); - - $mtime = explode(' ', microtime()); - $totaltime = $mtime[0] + $mtime[1] - $starttime; - - echo ' - - - - SQL Report - - - -
- -
-
-
- -
-

SQL Report

-
-

Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . (($this->num_queries['cached']) ? " + {$this->num_queries['cached']} " . (($this->num_queries['cached'] == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '

- -

Time spent on ' . $this->sql_layer . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's

- -

- ' . $this->sql_report . ' -
- -
-
-
- -
- - '; - - exit_handler(); - - break; - - case 'stop': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $this->sql_report .= ' - - - - - - - - - - - - -
Query #' . $this->num_queries['total'] . '
- - ' . $this->html_hold . ' - -

- '; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $this->sql_report .= 'Affected rows: ' . $this->sql_affectedrows($this->query_result) . ' | '; - } - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $this->curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $this->sql_report .= 'FAILED - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $this->sql_report .= '



'; - - $this->sql_time += $endtime - $this->curtime; - break; - - case 'start': - $this->query_hold = $query; - $this->html_hold = ''; - - $this->_sql_report($mode, $query); - - $this->curtime = explode(' ', microtime()); - $this->curtime = $this->curtime[0] + $this->curtime[1]; - - break; - - case 'add_select_row': - - $html_table = func_get_arg(2); - $row = func_get_arg(3); - - if (!$html_table && sizeof($row)) - { - $html_table = true; - $this->html_hold .= ''; - - foreach (array_keys($row) as $val) - { - $this->html_hold .= ''; - } - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - $class = 'row1'; - foreach (array_values($row) as $val) - { - $class = ($class == 'row1') ? 'row2' : 'row1'; - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - return $html_table; - - break; - - case 'fromcache': - - $this->_sql_report($mode, $query); - - break; - - case 'record_fromcache': - - $endtime = func_get_arg(2); - $splittime = func_get_arg(3); - - $time_cache = $endtime - $this->curtime; - $time_db = $splittime - $endtime; - $color = ($time_db > $time_cache) ? 'green' : 'red'; - - $this->sql_report .= '
' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '
' . (($val) ? $val : ' ') . '
'; - $this->sql_report .= '
Query results obtained from the cache
'; - $this->sql_report .= '

'; - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: ' . sprintf('%.5f', ($time_cache)) . 's | Elapsed [db]: ' . sprintf('%.5f', $time_db) . 's



'; - - // Pad the start time to not interfere with page timing - $starttime += $time_db; - - break; - - default: - - $this->_sql_report($mode, $query); - - break; - } - - return true; - } - - /** - * Gets the estimated number of rows in a specified table. - * - * @param string $table_name Table name - * - * @return string Number of rows in $table_name. - * Prefixed with ~ if estimated (otherwise exact). - * - * @access public - */ - function get_estimated_row_count($table_name) - { - return $this->get_row_count($table_name); - } - - /** - * Gets the exact number of rows in a specified table. - * - * @param string $table_name Table name - * - * @return string Exact number of rows in $table_name. - * - * @access public - */ - function get_row_count($table_name) - { - $sql = 'SELECT COUNT(*) AS rows_total - FROM ' . $this->sql_escape($table_name); - $result = $this->sql_query($sql); - $rows_total = $this->sql_fetchfield('rows_total'); - $this->sql_freeresult($result); - - return $rows_total; - } -} - -/** -* This variable holds the class name to use later -*/ -$sql_db = (!empty($dbms)) ? 'dbal_' . basename($dbms) : 'dbal'; diff --git a/phpBB/includes/db/driver/driver.php b/phpBB/includes/db/driver/driver.php new file mode 100644 index 0000000000..39211a5af4 --- /dev/null +++ b/phpBB/includes/db/driver/driver.php @@ -0,0 +1,1044 @@ +num_queries = array( + 'cached' => 0, + 'normal' => 0, + 'total' => 0, + ); + + // Fill default sql layer based on the class being called. + // This can be changed by the specified layer itself later if needed. + $this->sql_layer = substr(get_class($this), 5); + + // Do not change this please! This variable is used to easy the use of it - and is hardcoded. + $this->any_char = chr(0) . '%'; + $this->one_char = chr(0) . '_'; + } + + /** + * return on error or display error message + */ + function sql_return_on_error($fail = false) + { + $this->sql_error_triggered = false; + $this->sql_error_sql = ''; + + $this->return_on_error = $fail; + } + + /** + * Return number of sql queries and cached sql queries used + */ + function sql_num_queries($cached = false) + { + return ($cached) ? $this->num_queries['cached'] : $this->num_queries['normal']; + } + + /** + * Add to query count + */ + function sql_add_num_queries($cached = false) + { + $this->num_queries['cached'] += ($cached !== false) ? 1 : 0; + $this->num_queries['normal'] += ($cached !== false) ? 0 : 1; + $this->num_queries['total'] += 1; + } + + /** + * DBAL garbage collection, close sql connection + */ + function sql_close() + { + if (!$this->db_connect_id) + { + return false; + } + + if ($this->transaction) + { + do + { + $this->sql_transaction('commit'); + } + while ($this->transaction); + } + + foreach ($this->open_queries as $query_id) + { + $this->sql_freeresult($query_id); + } + + // Connection closed correctly. Set db_connect_id to false to prevent errors + if ($result = $this->_sql_close()) + { + $this->db_connect_id = false; + } + + return $result; + } + + /** + * Build LIMIT query + * Doing some validation here. + */ + function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) + { + if (empty($query)) + { + return false; + } + + // Never use a negative total or offset + $total = ($total < 0) ? 0 : $total; + $offset = ($offset < 0) ? 0 : $offset; + + return $this->_sql_query_limit($query, $total, $offset, $cache_ttl); + } + + /** + * Fetch all rows + */ + function sql_fetchrowset($query_id = false) + { + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if ($query_id !== false) + { + $result = array(); + while ($row = $this->sql_fetchrow($query_id)) + { + $result[] = $row; + } + + return $result; + } + + return false; + } + + /** + * Seek to given row number + * rownum is zero-based + */ + function sql_rowseek($rownum, &$query_id) + { + global $cache; + + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_rowseek($rownum, $query_id); + } + + if ($query_id === false) + { + return false; + } + + $this->sql_freeresult($query_id); + $query_id = $this->sql_query($this->last_query_text); + + if ($query_id === false) + { + return false; + } + + // We do not fetch the row for rownum == 0 because then the next resultset would be the second row + for ($i = 0; $i < $rownum; $i++) + { + if (!$this->sql_fetchrow($query_id)) + { + return false; + } + } + + return true; + } + + /** + * Fetch field + * if rownum is false, the current row is used, else it is pointing to the row (zero-based) + */ + function sql_fetchfield($field, $rownum = false, $query_id = false) + { + global $cache; + + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if ($query_id !== false) + { + if ($rownum !== false) + { + $this->sql_rowseek($rownum, $query_id); + } + + if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_fetchfield($query_id, $field); + } + + $row = $this->sql_fetchrow($query_id); + return (isset($row[$field])) ? $row[$field] : false; + } + + return false; + } + + /** + * Correctly adjust LIKE expression for special characters + * Some DBMS are handling them in a different way + * + * @param string $expression The expression to use. Every wildcard is escaped, except $this->any_char and $this->one_char + * @return string LIKE expression including the keyword! + */ + function sql_like_expression($expression) + { + $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression); + $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); + + return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); + } + + /** + * Build a case expression + * + * Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database! + * + * @param string $condition The condition which must be true, to use action_true rather then action_else + * @param string $action_true SQL expression that is used, if the condition is true + * @param string $action_else SQL expression that is used, if the condition is false, optional + * @return string CASE expression including the condition and statements + */ + public function sql_case($condition, $action_true, $action_false = false) + { + $sql_case = 'CASE WHEN ' . $condition; + $sql_case .= ' THEN ' . $action_true; + $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; + $sql_case .= ' END'; + return $sql_case; + } + + /** + * Build a concatenated expression + * + * @param string $expr1 Base SQL expression where we append the second one + * @param string $expr2 SQL expression that is appended to the first expression + * @return string Concatenated string + */ + public function sql_concatenate($expr1, $expr2) + { + return $expr1 . ' || ' . $expr2; + } + + /** + * Returns whether results of a query need to be buffered to run a transaction while iterating over them. + * + * @return bool Whether buffering is required. + */ + function sql_buffer_nested_transactions() + { + return false; + } + + /** + * SQL Transaction + * @access private + */ + function sql_transaction($status = 'begin') + { + switch ($status) + { + case 'begin': + // If we are within a transaction we will not open another one, but enclose the current one to not loose data (prevening auto commit) + if ($this->transaction) + { + $this->transactions++; + return true; + } + + $result = $this->_sql_transaction('begin'); + + if (!$result) + { + $this->sql_error(); + } + + $this->transaction = true; + break; + + case 'commit': + // If there was a previously opened transaction we do not commit yet... but count back the number of inner transactions + if ($this->transaction && $this->transactions) + { + $this->transactions--; + return true; + } + + // Check if there is a transaction (no transaction can happen if there was an error, with a combined rollback and error returning enabled) + // This implies we have transaction always set for autocommit db's + if (!$this->transaction) + { + return false; + } + + $result = $this->_sql_transaction('commit'); + + if (!$result) + { + $this->sql_error(); + } + + $this->transaction = false; + $this->transactions = 0; + break; + + case 'rollback': + $result = $this->_sql_transaction('rollback'); + $this->transaction = false; + $this->transactions = 0; + break; + + default: + $result = $this->_sql_transaction($status); + break; + } + + return $result; + } + + /** + * Build sql statement from array for insert/update/select statements + * + * Idea for this from Ikonboard + * Possible query values: INSERT, INSERT_SELECT, UPDATE, SELECT + * + */ + function sql_build_array($query, $assoc_ary = false) + { + if (!is_array($assoc_ary)) + { + return false; + } + + $fields = $values = array(); + + if ($query == 'INSERT' || $query == 'INSERT_SELECT') + { + foreach ($assoc_ary as $key => $var) + { + $fields[] = $key; + + if (is_array($var) && is_string($var[0])) + { + // This is used for INSERT_SELECT(s) + $values[] = $var[0]; + } + else + { + $values[] = $this->_sql_validate_value($var); + } + } + + $query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' '; + } + else if ($query == 'MULTI_INSERT') + { + trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR); + } + else if ($query == 'UPDATE' || $query == 'SELECT') + { + $values = array(); + foreach ($assoc_ary as $key => $var) + { + $values[] = "$key = " . $this->_sql_validate_value($var); + } + $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); + } + + return $query; + } + + /** + * Build IN or NOT IN sql comparison string, uses <> or = on single element + * arrays to improve comparison speed + * + * @access public + * @param string $field name of the sql column that shall be compared + * @param array $array array of values that are allowed (IN) or not allowed (NOT IN) + * @param bool $negate true for NOT IN (), false for IN () (default) + * @param bool $allow_empty_set If true, allow $array to be empty, this function will return 1=1 or 1=0 then. Default to false. + */ + function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) + { + if (!sizeof($array)) + { + if (!$allow_empty_set) + { + // Print the backtrace to help identifying the location of the problematic code + $this->sql_error('No values specified for SQL IN comparison'); + } + else + { + // NOT IN () actually means everything so use a tautology + if ($negate) + { + return '1=1'; + } + // IN () actually means nothing so use a contradiction + else + { + return '1=0'; + } + } + } + + if (!is_array($array)) + { + $array = array($array); + } + + if (sizeof($array) == 1) + { + @reset($array); + $var = current($array); + + return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var); + } + else + { + return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')'; + } + } + + /** + * Run binary AND operator on DB column. + * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" + * + * @param string $column_name The column name to use + * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 + * @param string $compare Any custom SQL code after the check (for example "= 0") + */ + function sql_bit_and($column_name, $bit, $compare = '') + { + if (method_exists($this, '_sql_bit_and')) + { + return $this->_sql_bit_and($column_name, $bit, $compare); + } + + return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); + } + + /** + * Run binary OR operator on DB column. + * Results in sql statement: "{$column_name} | (1 << {$bit}) {$compare}" + * + * @param string $column_name The column name to use + * @param int $bit The value to use for the OR operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 + * @param string $compare Any custom SQL code after the check (for example "= 0") + */ + function sql_bit_or($column_name, $bit, $compare = '') + { + if (method_exists($this, '_sql_bit_or')) + { + return $this->_sql_bit_or($column_name, $bit, $compare); + } + + return $column_name . ' | ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); + } + + /** + * Returns SQL string to cast a string expression to an int. + * + * @param string $expression An expression evaluating to string + * @return string Expression returning an int + */ + function cast_expr_to_bigint($expression) + { + return $expression; + } + + /** + * Returns SQL string to cast an integer expression to a string. + * + * @param string $expression An expression evaluating to int + * @return string Expression returning a string + */ + function cast_expr_to_string($expression) + { + return $expression; + } + + /** + * Run LOWER() on DB column of type text (i.e. neither varchar nor char). + * + * @param string $column_name The column name to use + * + * @return string A SQL statement like "LOWER($column_name)" + */ + function sql_lower_text($column_name) + { + return "LOWER($column_name)"; + } + + /** + * Run more than one insert statement. + * + * @param string $table table name to run the statements on + * @param array &$sql_ary multi-dimensional array holding the statement data. + * + * @return bool false if no statements were executed. + * @access public + */ + function sql_multi_insert($table, &$sql_ary) + { + if (!sizeof($sql_ary)) + { + return false; + } + + if ($this->multi_insert) + { + $ary = array(); + foreach ($sql_ary as $id => $_sql_ary) + { + // If by accident the sql array is only one-dimensional we build a normal insert statement + if (!is_array($_sql_ary)) + { + return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); + } + + $values = array(); + foreach ($_sql_ary as $key => $var) + { + $values[] = $this->_sql_validate_value($var); + } + $ary[] = '(' . implode(', ', $values) . ')'; + } + + return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); + } + else + { + foreach ($sql_ary as $ary) + { + if (!is_array($ary)) + { + return false; + } + + $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); + + if (!$result) + { + return false; + } + } + } + + return true; + } + + /** + * Function for validating values + * @access private + */ + function _sql_validate_value($var) + { + if (is_null($var)) + { + return 'NULL'; + } + else if (is_string($var)) + { + return "'" . $this->sql_escape($var) . "'"; + } + else + { + return (is_bool($var)) ? intval($var) : $var; + } + } + + /** + * Build sql statement from array for select and select distinct statements + * + * Possible query values: SELECT, SELECT_DISTINCT + */ + function sql_build_query($query, $array) + { + $sql = ''; + switch ($query) + { + case 'SELECT': + case 'SELECT_DISTINCT'; + + $sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM '; + + // Build table array. We also build an alias array for later checks. + $table_array = $aliases = array(); + $used_multi_alias = false; + + foreach ($array['FROM'] as $table_name => $alias) + { + if (is_array($alias)) + { + $used_multi_alias = true; + + foreach ($alias as $multi_alias) + { + $table_array[] = $table_name . ' ' . $multi_alias; + $aliases[] = $multi_alias; + } + } + else + { + $table_array[] = $table_name . ' ' . $alias; + $aliases[] = $alias; + } + } + + // We run the following code to determine if we need to re-order the table array. ;) + // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. + // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. + if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false) + { + // Take first LEFT JOIN + $join = current($array['LEFT_JOIN']); + + // Determine the table used there (even if there are more than one used, we only want to have one + preg_match('/(' . implode('|', $aliases) . ')\.[^\s]+/U', str_replace(array('(', ')', 'AND', 'OR', ' '), '', $join['ON']), $matches); + + // If there is a first join match, we need to make sure the table order is correct + if (!empty($matches[1])) + { + $first_join_match = trim($matches[1]); + $table_array = $last = array(); + + foreach ($array['FROM'] as $table_name => $alias) + { + if (is_array($alias)) + { + foreach ($alias as $multi_alias) + { + ($multi_alias === $first_join_match) ? $last[] = $table_name . ' ' . $multi_alias : $table_array[] = $table_name . ' ' . $multi_alias; + } + } + else + { + ($alias === $first_join_match) ? $last[] = $table_name . ' ' . $alias : $table_array[] = $table_name . ' ' . $alias; + } + } + + $table_array = array_merge($table_array, $last); + } + } + + $sql .= $this->_sql_custom_build('FROM', implode(' CROSS JOIN ', $table_array)); + + if (!empty($array['LEFT_JOIN'])) + { + foreach ($array['LEFT_JOIN'] as $join) + { + $sql .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')'; + } + } + + if (!empty($array['WHERE'])) + { + $sql .= ' WHERE ' . $this->_sql_custom_build('WHERE', $array['WHERE']); + } + + if (!empty($array['GROUP_BY'])) + { + $sql .= ' GROUP BY ' . $array['GROUP_BY']; + } + + if (!empty($array['ORDER_BY'])) + { + $sql .= ' ORDER BY ' . $array['ORDER_BY']; + } + + break; + } + + return $sql; + } + + /** + * display sql error page + */ + function sql_error($sql = '') + { + global $auth, $user, $config; + + // Set var to retrieve errored status + $this->sql_error_triggered = true; + $this->sql_error_sql = $sql; + + $this->sql_error_returned = $this->_sql_error(); + + if (!$this->return_on_error) + { + $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]

' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']'; + + // Show complete SQL error and path to administrators only + // Additionally show complete error on installation or if extended debug mode is enabled + // The DEBUG_EXTRA constant is for development only! + if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) + { + $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; + } + else + { + // If error occurs in initiating the session we need to use a pre-defined language string + // This could happen if the connection could not be established for example (then we are not able to grab the default language) + if (!isset($user->lang['SQL_ERROR_OCCURRED'])) + { + $message .= '

An sql error occurred while fetching this page. Please contact an administrator if this problem persists.'; + } + else + { + if (!empty($config['board_contact'])) + { + $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); + } + else + { + $message .= '

' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); + } + } + } + + if ($this->transaction) + { + $this->sql_transaction('rollback'); + } + + if (strlen($message) > 1024) + { + // We need to define $msg_long_text here to circumvent text stripping. + global $msg_long_text; + $msg_long_text = $message; + + trigger_error(false, E_USER_ERROR); + } + + trigger_error($message, E_USER_ERROR); + } + + if ($this->transaction) + { + $this->sql_transaction('rollback'); + } + + return $this->sql_error_returned; + } + + /** + * Explain queries + */ + function sql_report($mode, $query = '') + { + global $cache, $starttime, $phpbb_root_path, $user; + global $request; + + if (is_object($request) && !$request->variable('explain', false)) + { + return false; + } + + if (!$query && $this->query_hold != '') + { + $query = $this->query_hold; + } + + switch ($mode) + { + case 'display': + if (!empty($cache)) + { + $cache->unload(); + } + $this->sql_close(); + + $mtime = explode(' ', microtime()); + $totaltime = $mtime[0] + $mtime[1] - $starttime; + + echo ' + + + + SQL Report + + + +
+ +
+
+
+ +
+

SQL Report

+
+

Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . (($this->num_queries['cached']) ? " + {$this->num_queries['cached']} " . (($this->num_queries['cached'] == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '

+ +

Time spent on ' . $this->sql_layer . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's

+ +

+ ' . $this->sql_report . ' +
+ +
+
+
+ +
+ + '; + + exit_handler(); + + break; + + case 'stop': + $endtime = explode(' ', microtime()); + $endtime = $endtime[0] + $endtime[1]; + + $this->sql_report .= ' + + + + + + + + + + + + +
Query #' . $this->num_queries['total'] . '
+ + ' . $this->html_hold . ' + +

+ '; + + if ($this->query_result) + { + if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) + { + $this->sql_report .= 'Affected rows: ' . $this->sql_affectedrows($this->query_result) . ' | '; + } + $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $this->curtime) . 's'; + } + else + { + $error = $this->sql_error(); + $this->sql_report .= 'FAILED - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); + } + + $this->sql_report .= '



'; + + $this->sql_time += $endtime - $this->curtime; + break; + + case 'start': + $this->query_hold = $query; + $this->html_hold = ''; + + $this->_sql_report($mode, $query); + + $this->curtime = explode(' ', microtime()); + $this->curtime = $this->curtime[0] + $this->curtime[1]; + + break; + + case 'add_select_row': + + $html_table = func_get_arg(2); + $row = func_get_arg(3); + + if (!$html_table && sizeof($row)) + { + $html_table = true; + $this->html_hold .= ''; + + foreach (array_keys($row) as $val) + { + $this->html_hold .= ''; + } + $this->html_hold .= ''; + } + $this->html_hold .= ''; + + $class = 'row1'; + foreach (array_values($row) as $val) + { + $class = ($class == 'row1') ? 'row2' : 'row1'; + $this->html_hold .= ''; + } + $this->html_hold .= ''; + + return $html_table; + + break; + + case 'fromcache': + + $this->_sql_report($mode, $query); + + break; + + case 'record_fromcache': + + $endtime = func_get_arg(2); + $splittime = func_get_arg(3); + + $time_cache = $endtime - $this->curtime; + $time_db = $splittime - $endtime; + $color = ($time_db > $time_cache) ? 'green' : 'red'; + + $this->sql_report .= '
' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '
' . (($val) ? $val : ' ') . '
'; + $this->sql_report .= '
Query results obtained from the cache
'; + $this->sql_report .= '

'; + $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: ' . sprintf('%.5f', ($time_cache)) . 's | Elapsed [db]: ' . sprintf('%.5f', $time_db) . 's



'; + + // Pad the start time to not interfere with page timing + $starttime += $time_db; + + break; + + default: + + $this->_sql_report($mode, $query); + + break; + } + + return true; + } + + /** + * Gets the estimated number of rows in a specified table. + * + * @param string $table_name Table name + * + * @return string Number of rows in $table_name. + * Prefixed with ~ if estimated (otherwise exact). + * + * @access public + */ + function get_estimated_row_count($table_name) + { + return $this->get_row_count($table_name); + } + + /** + * Gets the exact number of rows in a specified table. + * + * @param string $table_name Table name + * + * @return string Exact number of rows in $table_name. + * + * @access public + */ + function get_row_count($table_name) + { + $sql = 'SELECT COUNT(*) AS rows_total + FROM ' . $this->sql_escape($table_name); + $result = $this->sql_query($sql); + $rows_total = $this->sql_fetchfield('rows_total'); + $this->sql_freeresult($result); + + return $rows_total; + } +} diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/driver/firebird.php similarity index 99% rename from phpBB/includes/db/firebird.php rename to phpBB/includes/db/driver/firebird.php index 7709e8fdf5..c793e0a51f 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/driver/firebird.php @@ -15,14 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Firebird/Interbase Database Abstraction Layer * Minimum Requirement is Firebird 2.1 * @package dbal */ -class dbal_firebird extends dbal +class phpbb_db_driver_firebird extends phpbb_db_driver { var $last_query_text = ''; var $service_handle = false; diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/driver/mssql.php similarity index 99% rename from phpBB/includes/db/mssql.php rename to phpBB/includes/db/driver/mssql.php index fb044b492f..e68738f918 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/driver/mssql.php @@ -15,14 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * MSSQL Database Abstraction Layer * Minimum Requirement is MSSQL 2000+ * @package dbal */ -class dbal_mssql extends dbal +class phpbb_db_driver_mssql extends phpbb_db_driver { /** * Connect to server @@ -374,7 +372,7 @@ class dbal_mssql extends dbal FROM master.dbo.sysmessages WHERE error = ' . $error['code']; $result_id = @mssql_query($sql); - + if ($result_id) { $row = @mssql_fetch_assoc($result_id); diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/driver/mssql_odbc.php similarity index 98% rename from phpBB/includes/db/mssql_odbc.php rename to phpBB/includes/db/driver/mssql_odbc.php index 64fa9634d1..7b35ce3d11 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/driver/mssql_odbc.php @@ -15,8 +15,6 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Unified ODBC functions * Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere... @@ -28,7 +26,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); * * @package dbal */ -class dbal_mssql_odbc extends dbal +class phpbb_db_driver_mssql_odbc extends phpbb_db_driver { var $last_query_text = ''; diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/driver/mssqlnative.php similarity index 99% rename from phpBB/includes/db/mssqlnative.php rename to phpBB/includes/db/driver/mssqlnative.php index 1f37d54ecb..99b9d7975a 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/driver/mssqlnative.php @@ -19,8 +19,6 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Prior to version 1.1 the SQL Server Native PHP driver didn't support sqlsrv_num_rows, or cursor based seeking so we recall all rows into an array * and maintain our own cursor index into that array. @@ -193,7 +191,7 @@ class result_mssqlnative /** * @package dbal */ -class dbal_mssqlnative extends dbal +class phpbb_db_driver_mssqlnative extends phpbb_db_driver { var $m_insert_id = NULL; var $last_query_text = ''; diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/driver/mysql.php similarity index 99% rename from phpBB/includes/db/mysql.php rename to phpBB/includes/db/driver/mysql.php index 8d1f805870..987691341a 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/driver/mysql.php @@ -15,8 +15,6 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * MySQL4 Database Abstraction Layer * Compatible with: @@ -26,7 +24,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); * MySQL 5.0+ * @package dbal */ -class dbal_mysql extends dbal +class phpbb_db_driver_mysql extends phpbb_db_driver { var $multi_insert = true; diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/driver/mysqli.php similarity index 99% rename from phpBB/includes/db/mysqli.php rename to phpBB/includes/db/driver/mysqli.php index e07cd35e24..c473c7fe99 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/driver/mysqli.php @@ -15,15 +15,13 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * MySQLi Database Abstraction Layer * mysqli-extension has to be compiled with: * MySQL 4.1+ or MySQL 5.0+ * @package dbal */ -class dbal_mysqli extends dbal +class phpbb_db_driver_mysqli extends phpbb_db_driver { var $multi_insert = true; diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/driver/oracle.php similarity index 99% rename from phpBB/includes/db/oracle.php rename to phpBB/includes/db/driver/oracle.php index 2e801532f0..25803e57bd 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/driver/oracle.php @@ -15,13 +15,11 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Oracle Database Abstraction Layer * @package dbal */ -class dbal_oracle extends dbal +class phpbb_db_driver_oracle extends phpbb_db_driver { var $last_query_text = ''; diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/driver/postgres.php similarity index 98% rename from phpBB/includes/db/postgres.php rename to phpBB/includes/db/driver/postgres.php index bf22cffafa..3f54936d23 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/driver/postgres.php @@ -15,19 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - -if (!class_exists('phpbb_error_collector')) -{ - include($phpbb_root_path . 'includes/error_collector.' . $phpEx); -} - /** * PostgreSQL Database Abstraction Layer * Minimum Requirement is Version 7.3+ * @package dbal */ -class dbal_postgres extends dbal +class phpbb_db_driver_postgres extends phpbb_db_driver { var $last_query_text = ''; var $connect_error = ''; diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/driver/sqlite.php similarity index 98% rename from phpBB/includes/db/sqlite.php rename to phpBB/includes/db/driver/sqlite.php index 86bfa75a13..363f26da2b 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/driver/sqlite.php @@ -15,14 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Sqlite Database Abstraction Layer * Minimum Requirement: 2.8.2+ * @package dbal */ -class dbal_sqlite extends dbal +class phpbb_db_driver_sqlite extends phpbb_db_driver { /** * Connect to server diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 537c19aff8..c3d1f58893 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -39,7 +39,7 @@ class phpbb_extension_manager * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(dbal $db, $extension_table, $phpbb_root_path, $phpEx = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(phpbb_db_driver $db, $extension_table, $phpbb_root_path, $phpEx = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; @@ -432,7 +432,7 @@ class phpbb_extension_manager } return $disabled; } - + /** * Check to see if a given extension is available on the filesystem * diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 46541acd44..413d8481b0 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -49,7 +49,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'firebird', 'MODULE' => 'interbase', 'DELIM' => ';;', - 'DRIVER' => 'firebird', + 'DRIVER' => 'phpbb_db_driver_firebird', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -58,7 +58,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mysql_41', 'MODULE' => 'mysqli', 'DELIM' => ';', - 'DRIVER' => 'mysqli', + 'DRIVER' => 'phpbb_db_driver_mysqli', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -67,7 +67,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', - 'DRIVER' => 'mysql', + 'DRIVER' => 'phpbb_db_driver_mysql', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -76,7 +76,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mssql', 'MODULE' => 'mssql', 'DELIM' => 'GO', - 'DRIVER' => 'mssql', + 'DRIVER' => 'phpbb_db_driver_mssql', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -85,7 +85,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mssql', 'MODULE' => 'odbc', 'DELIM' => 'GO', - 'DRIVER' => 'mssql_odbc', + 'DRIVER' => 'phpbb_db_driver_mssql_odbc', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -94,7 +94,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mssql', 'MODULE' => 'sqlsrv', 'DELIM' => 'GO', - 'DRIVER' => 'mssqlnative', + 'DRIVER' => 'phpbb_db_driver_mssqlnative', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -103,7 +103,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'oracle', 'MODULE' => 'oci8', 'DELIM' => '/', - 'DRIVER' => 'oracle', + 'DRIVER' => 'phpbb_db_driver_oracle', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -112,7 +112,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'postgres', 'MODULE' => 'pgsql', 'DELIM' => ';', - 'DRIVER' => 'postgres', + 'DRIVER' => 'phpbb_db_driver_postgres', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -121,7 +121,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'sqlite', 'MODULE' => 'sqlite', 'DELIM' => ';', - 'DRIVER' => 'sqlite', + 'DRIVER' => 'phpbb_db_driver_sqlite', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -229,26 +229,19 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbms = $dbms_details['DRIVER']; - if ($load_dbal) - { - // Include the DB layer - include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - } - // Instantiate it and set return on error true - $sql_db = 'dbal_' . $dbms; - $db = new $sql_db(); + $db = new $dbms(); $db->sql_return_on_error(true); // Check that we actually have a database name before going any further..... - if ($dbms_details['DRIVER'] != 'sqlite' && $dbms_details['DRIVER'] != 'oracle' && $dbname === '') + if ($dbms_details['DRIVER'] != 'phpbb_db_driver_sqlite' && $dbms_details['DRIVER'] != 'phpbb_db_driver_oracle' && $dbname === '') { $error[] = $lang['INST_ERR_DB_NO_NAME']; return false; } // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea - if ($dbms_details['DRIVER'] == 'sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) + if ($dbms_details['DRIVER'] == 'phpbb_db_driver_sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) { $error[] = $lang['INST_ERR_DB_FORUM_PATH']; return false; @@ -257,8 +250,8 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, // Check the prefix length to ensure that index names are not too long and does not contain invalid characters switch ($dbms_details['DRIVER']) { - case 'mysql': - case 'mysqli': + case 'phpbb_db_driver_mysql': + case 'phpbb_db_driver_mysqli': if (strspn($table_prefix, '-./\\') !== 0) { $error[] = $lang['INST_ERR_PREFIX_INVALID']; @@ -267,22 +260,22 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, // no break; - case 'postgres': + case 'phpbb_db_driver_postgres': $prefix_length = 36; break; - case 'mssql': - case 'mssql_odbc': - case 'mssqlnative': + case 'phpbb_db_driver_mssql': + case 'phpbb_db_driver_mssql_odbc': + case 'phpbb_db_driver_mssqlnative': $prefix_length = 90; break; - case 'sqlite': + case 'phpbb_db_driver_sqlite': $prefix_length = 200; break; - case 'firebird': - case 'oracle': + case 'phpbb_db_driver_firebird': + case 'phpbb_db_driver_oracle': $prefix_length = 6; break; } @@ -320,21 +313,21 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, // Make sure that the user has selected a sensible DBAL for the DBMS actually installed switch ($dbms_details['DRIVER']) { - case 'mysqli': + case 'phpbb_db_driver_mysqli': if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<')) { $error[] = $lang['INST_ERR_DB_NO_MYSQLI']; } break; - case 'sqlite': + case 'phpbb_db_driver_sqlite': if (version_compare(sqlite_libversion(), '2.8.2', '<')) { $error[] = $lang['INST_ERR_DB_NO_SQLITE']; } break; - case 'firebird': + case 'phpbb_db_driver_firebird': // check the version of FB, use some hackery if we can't get access to the server info if ($db->service_handle !== false && function_exists('ibase_server_info')) { @@ -415,7 +408,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, } break; - case 'oracle': + case 'phpbb_db_driver_oracle': if ($unicode_check) { $sql = "SELECT * @@ -437,7 +430,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, } break; - case 'postgres': + case 'phpbb_db_driver_postgres': if ($unicode_check) { $sql = "SHOW server_encoding;"; diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 6e99fd56a0..63a949762b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -91,7 +91,6 @@ phpbb_require_updated('includes/functions_content.' . $phpEx, true); require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); phpbb_require_updated('includes/db/db_tools.' . $phpEx); @@ -121,7 +120,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new phpbb_user(); -$db = new $sql_db(); +$db = new $dbms(); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function @@ -2601,10 +2600,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index db974f9903..8f648066ba 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -121,10 +121,9 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -209,10 +208,8 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -332,10 +329,9 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -425,8 +421,7 @@ class install_convert extends module if ($src_dbms != $dbms || $src_dbhost != $dbhost || $src_dbport != $dbport || $src_dbname != $dbname || $src_dbuser != $dbuser) { - $sql_db = 'dbal_' . $src_dbms; - $src_db = new $sql_db(); + $src_db = new $src_dbms(); $src_db->sql_connect($src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd), $src_dbname, $src_dbport, false, true); $same_db = false; } @@ -575,10 +570,9 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -639,12 +633,8 @@ class install_convert extends module $src_db = $same_db = null; if ($convert->src_dbms != $dbms || $convert->src_dbhost != $dbhost || $convert->src_dbport != $dbport || $convert->src_dbname != $dbname || $convert->src_dbuser != $dbuser) { - if ($convert->src_dbms != $dbms) - { - require($phpbb_root_path . 'includes/db/' . $convert->src_dbms . '.' . $phpEx); - } - $sql_db = 'dbal_' . $convert->src_dbms; - $src_db = new $sql_db(); + $dbms = $convert->src_dbms; + $src_db = new $dbms(); $src_db->sql_connect($convert->src_dbhost, $convert->src_dbuser, htmlspecialchars_decode($convert->src_dbpasswd), $convert->src_dbname, $convert->src_dbport, false, true); $same_db = false; } diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 40dee7b3d7..520163ef9d 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -250,7 +250,7 @@ class install_install extends module 'S_EXPLAIN' => true, 'S_LEGEND' => false, )); - + // Check for php json support if (@extension_loaded('json')) { @@ -1144,11 +1144,8 @@ class install_install extends module $dbms = $available_dbms[$data['dbms']]['DRIVER']; - // Load the appropriate database class if not already loaded - include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - // Instantiate the database - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); // NOTE: trigger_error does not work here. @@ -1444,11 +1441,8 @@ class install_install extends module $dbms = $available_dbms[$data['dbms']]['DRIVER']; - // Load the appropriate database class if not already loaded - include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - // Instantiate the database - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); // NOTE: trigger_error does not work here. diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index c2feaa086a..fb76420033 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -83,7 +83,6 @@ class install_update extends module // Init DB require($phpbb_root_path . 'config.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); // Special options for conflicts/modified files @@ -92,7 +91,7 @@ class install_update extends module define('MERGE_NEW_FILE', 3); define('MERGE_MOD_FILE', 4); - $db = new $sql_db(); + $db = new $dbms(); // Connect to DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index 7c2a7c3fce..0342179a6e 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -30,7 +30,7 @@ example for mysqli can be found below. More information on configuration options can be found on the wiki (see below). get_database_config(); // Firebird requires table and column names to be uppercase - if ($db_config['dbms'] == 'firebird') + if ($db_config['dbms'] == 'phpbb_db_driver_firebird') { $xml_data = file_get_contents($path); $xml_data = preg_replace_callback('/(?:())/', 'phpbb_database_test_case::to_upper', $xml_data); @@ -100,9 +100,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $config = $this->get_database_config(); - require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php'; - $dbal = 'dbal_' . $config['dbms']; - $db = new $dbal(); + $dbms = $config['dbms']; + $db = new $dbms(); $db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']); return $db; diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 25e0972f42..db772496a0 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -108,7 +108,7 @@ class phpbb_database_test_connection_manager // These require different connection strings on the phpBB side than they do in PDO // so you must provide a DSN string for ODBC separately - if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird')) + if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'phpbb_db_driver_mssql' || $this->config['dbms'] == 'phpbb_db_driver_firebird')) { $dsn = 'odbc:' . $this->config['custom_dsn']; } @@ -117,12 +117,12 @@ class phpbb_database_test_connection_manager { switch ($this->config['dbms']) { - case 'mssql': - case 'mssql_odbc': + case 'phpbb_db_driver_mssql': + case 'phpbb_db_driver_mssql_odbc': $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); break; - case 'firebird': + case 'phpbb_db_driver_firebird': if (!empty($this->config['custom_dsn'])) { $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); @@ -165,14 +165,14 @@ class phpbb_database_test_connection_manager { switch ($this->config['dbms']) { - case 'sqlite': + case 'phpbb_db_driver_sqlite': if (file_exists($this->config['dbhost'])) { unlink($this->config['dbhost']); } break; - case 'firebird': + case 'phpbb_db_driver_firebird': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -182,7 +182,7 @@ class phpbb_database_test_connection_manager $this->purge_extras(); break; - case 'oracle': + case 'phpbb_db_driver_oracle': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -232,39 +232,39 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'mysql': - case 'mysql4': - case 'mysqli': + case 'phpbb_db_driver_mysql': + case 'phpbb_db_driver_mysql4': + case 'phpbb_db_driver_mysqli': $sql = 'SHOW TABLES'; break; - case 'sqlite': + case 'phpbb_db_driver_sqlite': $sql = 'SELECT name FROM sqlite_master WHERE type = "table"'; break; - case 'mssql': - case 'mssql_odbc': - case 'mssqlnative': + case 'phpbb_db_driver_mssql': + case 'phpbb_db_driver_mssql_odbc': + case 'phpbb_db_driver_mssqlnative': $sql = "SELECT name FROM sysobjects WHERE type='U'"; break; - case 'postgres': + case 'phpbb_db_driver_postgres': $sql = 'SELECT relname FROM pg_stat_user_tables'; break; - case 'firebird': + case 'phpbb_db_driver_firebird': $sql = 'SELECT rdb$relation_name FROM rdb$relations WHERE rdb$view_source is null AND rdb$system_flag = 0'; break; - case 'oracle': + case 'phpbb_db_driver_oracle': $sql = 'SELECT table_name FROM USER_TABLES'; break; @@ -299,8 +299,8 @@ class phpbb_database_test_connection_manager protected function load_schema_from_file($directory) { $schema = $this->dbms['SCHEMA']; - - if ($this->config['dbms'] == 'mysql') + + if ($this->config['dbms'] == 'phpbb_db_driver_mysql') { $sth = $this->pdo->query('SELECT VERSION() AS version'); $row = $sth->fetch(PDO::FETCH_ASSOC); @@ -319,7 +319,7 @@ class phpbb_database_test_connection_manager $queries = file_get_contents($filename); $sql = phpbb_remove_comments($queries); - + $sql = split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) @@ -403,7 +403,7 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'firebird': + case 'phpbb_db_driver_firebird': $sql = 'SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS WHERE RDB$SYSTEM_FLAG = 0'; @@ -415,7 +415,7 @@ class phpbb_database_test_connection_manager } break; - case 'oracle': + case 'phpbb_db_driver_oracle': $sql = 'SELECT sequence_name FROM USER_SEQUENCES'; $result = $this->pdo->query($sql); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c042d75811..ce0042d538 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -87,12 +87,8 @@ class phpbb_functional_test_case extends phpbb_test_case // so we don't reopen an open connection if (!($this->db instanceof dbal)) { - if (!class_exists('dbal_' . self::$config['dbms'])) - { - include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); - } - $sql_db = 'dbal_' . self::$config['dbms']; - $this->db = new $sql_db(); + $dbms = self::$config['dbms']; + $this->db = new $dbms(); $this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); } return $this->db; diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 46feef550a..5667aa6ca2 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -54,7 +54,7 @@ class phpbb_test_case_helpers if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) { $config = array_merge($config, array( - 'dbms' => 'sqlite', + 'dbms' => 'phpbb_db_driver_sqlite', 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename 'dbport' => '', 'dbname' => '', From 65bafb22810038fd51e22fd8168775afd86c2e74 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 18:08:40 +0200 Subject: [PATCH 004/544] [ticket/11015] Add BC files for the drivers PHPBB3-11015 --- phpBB/includes/db/firebird.php | 19 +++++++++++++++++++ phpBB/includes/db/mssql.php | 19 +++++++++++++++++++ phpBB/includes/db/mssql_odbc.php | 19 +++++++++++++++++++ phpBB/includes/db/mssqlnative.php | 19 +++++++++++++++++++ phpBB/includes/db/mysql.php | 19 +++++++++++++++++++ phpBB/includes/db/mysqli.php | 19 +++++++++++++++++++ phpBB/includes/db/oracle.php | 19 +++++++++++++++++++ phpBB/includes/db/postgres.php | 19 +++++++++++++++++++ phpBB/includes/db/sqlite.php | 19 +++++++++++++++++++ 9 files changed, 171 insertions(+) create mode 100644 phpBB/includes/db/firebird.php create mode 100644 phpBB/includes/db/mssql.php create mode 100644 phpBB/includes/db/mssql_odbc.php create mode 100644 phpBB/includes/db/mssqlnative.php create mode 100644 phpBB/includes/db/mysql.php create mode 100644 phpBB/includes/db/mysqli.php create mode 100644 phpBB/includes/db/oracle.php create mode 100644 phpBB/includes/db/postgres.php create mode 100644 phpBB/includes/db/sqlite.php diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php new file mode 100644 index 0000000000..33f4e2ea48 --- /dev/null +++ b/phpBB/includes/db/firebird.php @@ -0,0 +1,19 @@ + Date: Sat, 21 Jul 2012 18:24:24 +0200 Subject: [PATCH 005/544] [ticket/11015] Correctly set sql_layer in driver base class PHPBB3-11015 --- phpBB/includes/db/driver/driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/driver/driver.php b/phpBB/includes/db/driver/driver.php index 39211a5af4..9692ee71b9 100644 --- a/phpBB/includes/db/driver/driver.php +++ b/phpBB/includes/db/driver/driver.php @@ -82,7 +82,7 @@ class phpbb_db_driver // Fill default sql layer based on the class being called. // This can be changed by the specified layer itself later if needed. - $this->sql_layer = substr(get_class($this), 5); + $this->sql_layer = substr(get_class($this), strlen('phpbb_db_driver_')); // Do not change this please! This variable is used to easy the use of it - and is hardcoded. $this->any_char = chr(0) . '%'; From d6cca4e2c0719da35c75d3fff68f4a46255fe352 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 19:35:39 +0200 Subject: [PATCH 006/544] [ticket/11015] Fix connection manager db driver selection PHPBB3-11015 --- .../phpbb_database_test_connection_manager.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index db772496a0..82da5fe4c3 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -334,47 +334,47 @@ class phpbb_database_test_connection_manager protected function get_dbms_data($dbms) { $available_dbms = array( - 'firebird' => array( + 'phpbb_db_driver_firebird' => array( 'SCHEMA' => 'firebird', 'DELIM' => ';;', 'PDO' => 'firebird', ), - 'mysqli' => array( + 'phpbb_db_driver_mysqli' => array( 'SCHEMA' => 'mysql_41', 'DELIM' => ';', 'PDO' => 'mysql', ), - 'mysql' => array( + 'phpbb_db_driver_mysql' => array( 'SCHEMA' => 'mysql', 'DELIM' => ';', 'PDO' => 'mysql', ), - 'mssql' => array( + 'phpbb_db_driver_mssql' => array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'odbc', ), - 'mssql_odbc'=> array( + 'phpbb_db_driver_mssql_odbc'=> array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'odbc', ), - 'mssqlnative' => array( + 'phpbb_db_driver_mssqlnative' => array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'sqlsrv', ), - 'oracle' => array( + 'phpbb_db_driver_oracle' => array( 'SCHEMA' => 'oracle', 'DELIM' => '/', 'PDO' => 'oci', ), - 'postgres' => array( + 'phpbb_db_driver_postgres' => array( 'SCHEMA' => 'postgres', 'DELIM' => ';', 'PDO' => 'pgsql', ), - 'sqlite' => array( + 'phpbb_db_driver_sqlite' => array( 'SCHEMA' => 'sqlite', 'DELIM' => ';', 'PDO' => 'sqlite2', From c34ca32795f29c944c840f8282c025e4b322c891 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 19:35:45 +0200 Subject: [PATCH 007/544] [ticket/11015] Fix db connection type hint in lock_db PHPBB3-11015 --- phpBB/includes/lock/db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/lock/db.php b/phpBB/includes/lock/db.php index fa559d6887..40690144b1 100644 --- a/phpBB/includes/lock/db.php +++ b/phpBB/includes/lock/db.php @@ -61,7 +61,7 @@ class phpbb_lock_db * @param array $config The phpBB configuration * @param dbal $db A database connection */ - public function __construct($config_name, phpbb_config $config, dbal $db) + public function __construct($config_name, phpbb_config $config, phpbb_db_driver $db) { $this->config_name = $config_name; $this->config = $config; From 0971d3f975ebaa8c2874115bd82b308b244783f2 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 19:57:00 +0200 Subject: [PATCH 008/544] [ticket/11015] Fix configuration for travis PHPBB3-11015 --- travis/phpunit-mysql-travis.xml | 2 +- travis/phpunit-postgres-travis.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index e54b2bb77b..6eeffeff15 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -27,7 +27,7 @@ - + diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 55ba996548..3a09c4a826 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -29,7 +29,7 @@ - + From 47c67b6d021c6488106bb0d327600b35e08bf94b Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 24 Jul 2012 11:54:46 +0100 Subject: [PATCH 009/544] [ticket/10970] Added missing initialisations and modified the regex Non-existent variables now become empty strings. PHPBB3-10970 --- phpBB/includes/template/filter.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index 568727be82..596b83cc75 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -375,10 +375,13 @@ class phpbb_template_filter extends php_user_filter { $matches = array(); $replace = array(); + $vars = array(); + $is_expr = true; - preg_match_all('/{[^}]+}/', $path, $matches); + preg_match_all('#\{((?:' . self::REGEX_NS . '\.)*)(\$)?(' . self::REGEX_VAR . ')\}#', $path, $matches); foreach ($matches[0] as $var_str) { + $tmp_is_expr = false; $var = $this->get_varref($var_str, $tmp_is_expr); $is_expr = $is_expr && $tmp_is_expr; $vars[] = "isset($var)"; @@ -387,7 +390,7 @@ class phpbb_template_filter extends php_user_filter if (!$is_expr) { - return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type('" . str_replace($matches[0], $replace, $path) . "', true); }"; + return " \$_template->$include_type('" . str_replace($matches[0], $replace, $path) . "', true);"; } else { From 003220dc7c781df38fde75f0007c3b3e48803162 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 24 Jul 2012 11:55:38 +0100 Subject: [PATCH 010/544] [ticket/10970] Fixed a problem with prepending root paths PHPBB3-10970 --- phpBB/includes/template/template.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 8ab3c44be3..861a5e28e7 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -503,7 +503,11 @@ class phpbb_template // Locate file if ($locate) { - $file = $this->locator->get_first_file_location(array($file), true, true); + $located = $this->locator->get_first_file_location(array($file), false, true); + if ($located) + { + $file = $located; + } } else if ($relative) { From 02ccf392fa11c7c2210f5ba1e8923e82e62a66cf Mon Sep 17 00:00:00 2001 From: Fyorl Date: Fri, 10 Aug 2012 13:42:38 +0100 Subject: [PATCH 011/544] [ticket/10970] Removed unused $vars PHPBB3-10970 --- phpBB/includes/template/filter.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index 596b83cc75..e4c3184565 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -375,7 +375,6 @@ class phpbb_template_filter extends php_user_filter { $matches = array(); $replace = array(); - $vars = array(); $is_expr = true; preg_match_all('#\{((?:' . self::REGEX_NS . '\.)*)(\$)?(' . self::REGEX_VAR . ')\}#', $path, $matches); @@ -384,7 +383,6 @@ class phpbb_template_filter extends php_user_filter $tmp_is_expr = false; $var = $this->get_varref($var_str, $tmp_is_expr); $is_expr = $is_expr && $tmp_is_expr; - $vars[] = "isset($var)"; $replace[] = "' . $var . '"; } From 74423eaf126ea719df3ed102e459edad6be864da Mon Sep 17 00:00:00 2001 From: Fyorl Date: Thu, 9 Aug 2012 12:31:49 +0100 Subject: [PATCH 012/544] [ticket/10939] Added $_FILES handling to phpbb_request PHPBB3-10939 --- phpBB/includes/request/interface.php | 1 + phpBB/includes/request/request.php | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/phpBB/includes/request/interface.php b/phpBB/includes/request/interface.php index afd53002e3..741db35917 100644 --- a/phpBB/includes/request/interface.php +++ b/phpBB/includes/request/interface.php @@ -30,6 +30,7 @@ interface phpbb_request_interface const REQUEST = 2; const COOKIE = 3; const SERVER = 4; + const FILES = 5; /**#@-*/ /** diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php index 4e425dbd27..4fc9e67314 100644 --- a/phpBB/includes/request/request.php +++ b/phpBB/includes/request/request.php @@ -34,6 +34,7 @@ class phpbb_request implements phpbb_request_interface phpbb_request_interface::REQUEST => '_REQUEST', phpbb_request_interface::COOKIE => '_COOKIE', phpbb_request_interface::SERVER => '_SERVER', + phpbb_request_interface::FILES => '_FILES', ); /** @@ -283,6 +284,18 @@ class phpbb_request implements phpbb_request_interface return $this->server($var_name, $default); } + /** + * Shortcut method to retrieve $_FILES variables + * + * @param string $form_name The name of the file input form element + * + * @return array The uploaded file's information + */ + public function file($form_name) + { + return $this->variable($form_name, array(), false, phpbb_request_interface::FILES); + } + /** * Checks whether a certain variable was sent via POST. * To make sure that a request was sent using POST you should call this function From 48a0810ea593fc3ed84762ccd9076ea756cda41c Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 14:20:40 +0100 Subject: [PATCH 013/544] [ticket/10939] Modified request test slightly to include $_FILES PHPBB3-10939 --- tests/request/request_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/request/request_test.php b/tests/request/request_test.php index bca5125b7a..c02fcf829f 100644 --- a/tests/request/request_test.php +++ b/tests/request/request_test.php @@ -21,6 +21,13 @@ class phpbb_request_test extends phpbb_test_case $_COOKIE['test'] = 3; $_REQUEST['test'] = 3; $_GET['unset'] = ''; + $_FILES['test'] = array( + 'name' => 'file', + 'tmp_name' => 'tmp', + 'size' => 256, + 'type' => 'application/octet-stream', + 'error' => UPLOAD_ERR_OK, + ); $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['HTTP_ACCEPT'] = 'application/json'; @@ -42,6 +49,7 @@ class phpbb_request_test extends phpbb_test_case $this->assertEquals(2, $_GET['test'], 'Checking $_GET after enable_super_globals'); $this->assertEquals(3, $_COOKIE['test'], 'Checking $_COOKIE after enable_super_globals'); $this->assertEquals(3, $_REQUEST['test'], 'Checking $_REQUEST after enable_super_globals'); + $this->assertEquals(256, $_FILES['test']['size']); $_POST['x'] = 2; $this->assertEquals($_POST, $GLOBALS['_POST'], 'Checking whether $_POST can still be accessed via $GLOBALS[\'_POST\']'); From 91b9cc90dd078fda135d975f0e5af798535d9014 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 15:00:03 +0100 Subject: [PATCH 014/544] [ticket/10939] Modified functions_upload to not use $_FILES PHPBB3-10939 --- phpBB/includes/functions_upload.php | 45 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index d4c6b42cf4..b467aa93d1 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -566,10 +566,11 @@ class fileupload */ function form_upload($form_name) { - global $user; + global $user, $request; - unset($_FILES[$form_name]['local_mode']); - $file = new filespec($_FILES[$form_name], $this); + $upload = $request->file($form_name); + unset($upload['local_mode']); + $file = new filespec($upload, $this); if ($file->init_error) { @@ -578,9 +579,9 @@ class fileupload } // Error array filled? - if (isset($_FILES[$form_name]['error'])) + if (isset($upload['error'])) { - $error = $this->assign_internal_error($_FILES[$form_name]['error']); + $error = $this->assign_internal_error($upload['error']); if ($error !== false) { @@ -590,7 +591,7 @@ class fileupload } // Check if empty file got uploaded (not catched by is_uploaded_file) - if (isset($_FILES[$form_name]['size']) && $_FILES[$form_name]['size'] == 0) + if (isset($upload['size']) && $upload['size'] == 0) { $file->error[] = $user->lang[$this->error_prefix . 'EMPTY_FILEUPLOAD']; return $file; @@ -631,17 +632,17 @@ class fileupload */ function local_upload($source_file, $filedata = false) { - global $user; + global $user, $request; - $form_name = 'local'; + $upload = array(); - $_FILES[$form_name]['local_mode'] = true; - $_FILES[$form_name]['tmp_name'] = $source_file; + $upload['local_mode'] = true; + $upload['tmp_name'] = $source_file; if ($filedata === false) { - $_FILES[$form_name]['name'] = utf8_basename($source_file); - $_FILES[$form_name]['size'] = 0; + $upload['name'] = utf8_basename($source_file); + $upload['size'] = 0; $mimetype = ''; if (function_exists('mime_content_type')) @@ -655,16 +656,16 @@ class fileupload $mimetype = 'application/octetstream'; } - $_FILES[$form_name]['type'] = $mimetype; + $upload['type'] = $mimetype; } else { - $_FILES[$form_name]['name'] = $filedata['realname']; - $_FILES[$form_name]['size'] = $filedata['size']; - $_FILES[$form_name]['type'] = $filedata['type']; + $upload['name'] = $filedata['realname']; + $upload['size'] = $filedata['size']; + $upload['type'] = $filedata['type']; } - $file = new filespec($_FILES[$form_name], $this); + $file = new filespec($upload, $this); if ($file->init_error) { @@ -672,9 +673,9 @@ class fileupload return $file; } - if (isset($_FILES[$form_name]['error'])) + if (isset($upload['error'])) { - $error = $this->assign_internal_error($_FILES[$form_name]['error']); + $error = $this->assign_internal_error($upload['error']); if ($error !== false) { @@ -709,6 +710,7 @@ class fileupload } $this->common_checks($file); + $request->overwrite('local', $upload, phpbb_request_interface::FILES); return $file; } @@ -1001,7 +1003,10 @@ class fileupload */ function is_valid($form_name) { - return (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none') ? true : false; + global $request; + $upload = $request->file($form_name); + + return (!empty($upload) && $upload['name'] !== 'none'); } From 3eb88b026752512a79b641e3b55193972f221a45 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 15:06:37 +0100 Subject: [PATCH 015/544] [ticket/10939] Modified message_parser.php to not use $_FILES PHPBB3-10939 --- phpBB/includes/message_parser.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 6695047b56..1cd2a46fa1 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1363,13 +1363,14 @@ class parse_message extends bbcode_firstpass */ function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false) { - global $config, $auth, $user, $phpbb_root_path, $phpEx, $db; + global $config, $auth, $user, $phpbb_root_path, $phpEx, $db, $request; $error = array(); $num_attachments = sizeof($this->attachment_data); $this->filename_data['filecomment'] = utf8_normalize_nfc(request_var('filecomment', '', true)); - $upload_file = (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none' && trim($_FILES[$form_name]['name'])) ? true : false; + $upload = $request->file($form_name); + $upload_file = (!empty($upload) && $upload['name'] !== 'none' && trim($upload['name'])); $add_file = (isset($_POST['add_file'])) ? true : false; $delete_file = (isset($_POST['delete_file'])) ? true : false; From a3b87f1e953e4f79478d8e7eb65ca9855140243a Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 15:07:42 +0100 Subject: [PATCH 016/544] [ticket/10939] Modified functions_user.php to not use $_FILES PHPBB3-10939 --- phpBB/includes/functions_user.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6e658b4ef4..405c5ef5d1 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2059,13 +2059,14 @@ function avatar_remote($data, &$error) */ function avatar_upload($data, &$error) { - global $phpbb_root_path, $config, $db, $user, $phpEx; + global $phpbb_root_path, $config, $db, $user, $phpEx, $request; // Init upload class include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx); $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], (isset($config['mime_triggers']) ? explode('|', $config['mime_triggers']) : false)); - if (!empty($_FILES['uploadfile']['name'])) + $uploadfile = $request->file('uploadfile'); + if (!empty($uploadfile['name'])) { $file = $upload->form_upload('uploadfile'); } @@ -2288,7 +2289,7 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $ */ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = null) { - global $config, $phpbb_root_path, $auth, $user, $db; + global $config, $phpbb_root_path, $auth, $user, $db, $request; $data = array( 'uploadurl' => request_var('uploadurl', ''), @@ -2330,7 +2331,8 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; } - if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) + $uploadfile = $request->file('uploadfile'); + if ((!empty($uploadfile['name']) || $data['uploadurl']) && $can_upload) { list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_upload($data, $error); } From 83a53eb985d17f203d8ef0d33291c1ad1c4db84c Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 15:11:33 +0100 Subject: [PATCH 017/544] [ticket/10939] Modified ucp_groups.php to not use $_FILES PHPBB3-10939 --- phpBB/includes/ucp/ucp_groups.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 65ab92e78e..9652986cf2 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -513,7 +513,8 @@ class ucp_groups $data['height'] = request_var('height', ''); $delete = request_var('delete', ''); - if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) + $uploadfile = $request->file('uploadfile'); + if (!empty($uploadfile['tmp_name']) || $data['uploadurl'] || $data['remotelink']) { // Avatar stuff $var_ary = array( @@ -527,7 +528,7 @@ class ucp_groups { $data['user_id'] = "g$group_id"; - if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) + if ((!empty($uploadfile['tmp_name']) || $data['uploadurl']) && $can_upload) { list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); } From 94ed66c777d22e16ba73d317889707b90f755878 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 15:14:52 +0100 Subject: [PATCH 018/544] [ticket/10939] Modified acp_groups.php to not use $_FILES PHPBB3-10939 --- phpBB/includes/acp/acp_groups.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index f88fa76df1..b018faf968 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -26,6 +26,7 @@ class acp_groups { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; + global $request; $user->add_lang('acp/groups'); $this->tpl_name = 'acp_groups'; @@ -323,7 +324,8 @@ class acp_groups $submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0; } - if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) + $uploadfile = $request->file('uploadfile'); + if (!empty($uploadfile['tmp_name']) || $data['uploadurl'] || $data['remotelink']) { // Avatar stuff $var_ary = array( @@ -337,7 +339,7 @@ class acp_groups { $data['user_id'] = "g$group_id"; - if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) + if ((!empty($uploadfile['tmp_name']) || $data['uploadurl']) && $can_upload) { list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); } From 348554cc297bf906a0510894986bb60041a5db9a Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 15:36:41 +0100 Subject: [PATCH 019/544] [ticket/10939] Modified mock request class to handle deactivated $_FILES PHPBB3-10939 --- tests/mock/request.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/mock/request.php b/tests/mock/request.php index 946dfdada9..2a272fc03b 100644 --- a/tests/mock/request.php +++ b/tests/mock/request.php @@ -11,13 +11,14 @@ class phpbb_mock_request implements phpbb_request_interface { protected $data; - public function __construct($get = array(), $post = array(), $cookie = array(), $server = array(), $request = false) + public function __construct($get = array(), $post = array(), $cookie = array(), $server = array(), $request = false, $files = array()) { $this->data[phpbb_request_interface::GET] = $get; $this->data[phpbb_request_interface::POST] = $post; $this->data[phpbb_request_interface::COOKIE] = $cookie; $this->data[phpbb_request_interface::REQUEST] = ($request === false) ? $post + $get : $request; $this->data[phpbb_request_interface::SERVER] = $server; + $this->data[phpbb_request_interface::FILES] = $files; } public function overwrite($var_name, $value, $super_global = phpbb_request_interface::REQUEST) @@ -42,6 +43,12 @@ class phpbb_mock_request implements phpbb_request_interface return $this->server($var_name, $default); } + public function file($form_name) + { + $super_global = phpbb_request_interface::FILES; + return isset($this->data[$super_global][$form_name]) ? $this->data[$super_global][$form_name] : array(); + } + public function is_set_post($name) { return $this->is_set($name, phpbb_request_interface::POST); From df86f466e0245669e5cf97a162378fb653c72422 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 15:56:43 +0100 Subject: [PATCH 020/544] [ticket/10939] Modified fileupload tests to deal with new behaviour PHPBB3-10939 --- tests/upload/fileupload_test.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 076855ab56..1665c493be 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -19,7 +19,8 @@ class phpbb_fileupload_test extends phpbb_test_case { // Global $config required by unique_id // Global $user required by several functions dealing with translations - global $config, $user; + // Global $request required by form_upload, local_upload and is_valid + global $config, $user, $request; if (!is_array($config)) { @@ -31,6 +32,9 @@ class phpbb_fileupload_test extends phpbb_test_case $user = new phpbb_mock_user(); $user->lang = new phpbb_mock_lang(); + + $request = new phpbb_mock_request(); + $this->path = __DIR__ . '/fixture/'; } From 935e717762ccf9cad47058157933b4d372a57320 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Wed, 15 Aug 2012 17:03:15 +0100 Subject: [PATCH 021/544] [ticket/10939] Modified the default return for $request->file PHPBB3-10939 --- phpBB/includes/request/request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php index 4fc9e67314..25410c27c4 100644 --- a/phpBB/includes/request/request.php +++ b/phpBB/includes/request/request.php @@ -293,7 +293,7 @@ class phpbb_request implements phpbb_request_interface */ public function file($form_name) { - return $this->variable($form_name, array(), false, phpbb_request_interface::FILES); + return $this->variable($form_name, array('name' => 'none'), false, phpbb_request_interface::FILES); } /** From e9bdca7a8bc8c36b6d55806b1337e5d32409cb9d Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sun, 19 Aug 2012 17:12:08 +0800 Subject: [PATCH 022/544] [ticket/10970] Added newline in docblock PHPBB3-10970 --- phpBB/includes/template/filter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index e4c3184565..471ca0c777 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -363,6 +363,7 @@ class phpbb_template_filter extends php_user_filter /** * Parse paths of the form {FOO}/a/{BAR}/b + * * Note: this method assumes at least one variable in the path, this should * be checked before this method is called. * From aa5f6dffa5ad7e8c357006ba539885bf9814d8f5 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 20 Aug 2012 21:40:53 +0100 Subject: [PATCH 023/544] [ticket/10939] Added tests for phpbb_request::file PHPBB3-10939 --- tests/request/request_test.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/request/request_test.php b/tests/request/request_test.php index c02fcf829f..52c21abd2a 100644 --- a/tests/request/request_test.php +++ b/tests/request/request_test.php @@ -93,6 +93,23 @@ class phpbb_request_test extends phpbb_test_case $this->request->header('SOMEVAR'); } + public function test_file() + { + $file = $this->request->file('test'); + $this->assertEquals('file', $file['name']); + $this->assertEquals('tmp', $file['tmp_name']); + $this->assertEquals(256, $file['size']); + $this->assertEquals('application/octet-stream', $file['type']); + $this->assertEquals(UPLOAD_ERR_OK, $file['error']); + } + + public function test_file_not_exists() + { + $file = $this->request->file('404'); + $this->assertTrue(is_array($file)); + $this->assertTrue(empty($file)); + } + /** * Checks that directly accessing $_POST will trigger * an error. From 4f65a003344a3aeec0c5f608e990c2860146d39e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 26 Aug 2012 18:40:23 +0200 Subject: [PATCH 024/544] [ticket/10875] Remove useless assignment from phpbb_cache_driver_memory. sql_save() no longer takes $query_result as a reference, thus this assignment is a no-op. PHPBB3-10875 --- phpBB/includes/cache/driver/memory.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php index e0771ab1d3..bc08494c0c 100644 --- a/phpBB/includes/cache/driver/memory.php +++ b/phpBB/includes/cache/driver/memory.php @@ -334,8 +334,6 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base $this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); - $query_result = $query_id; - return $query_id; } From e28f0aa336e4b4d8965d1025d6e0d28e6b1fcde9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 26 Aug 2012 18:42:21 +0200 Subject: [PATCH 025/544] [ticket/10875] Fix return value of phpbb_cache_driver_null::sql_save(). phpbb_cache_driver_null::sql_save() has to return $query_result as is instead of null. PHPBB3-10875 --- phpBB/includes/cache/driver/null.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/cache/driver/null.php b/phpBB/includes/cache/driver/null.php index df2c6c026f..687604d14f 100644 --- a/phpBB/includes/cache/driver/null.php +++ b/phpBB/includes/cache/driver/null.php @@ -109,6 +109,7 @@ class phpbb_cache_driver_null extends phpbb_cache_driver_base */ function sql_save($query, $query_result, $ttl) { + return $query_result; } /** From 59af4d68fc6f5455e156c5a192b35ca1ffe6872b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 26 Aug 2012 18:45:20 +0200 Subject: [PATCH 026/544] [ticket/10875] Fix phpbb_mock_cache::sql_save() to return $query_result. PHPBB3-10875 --- tests/mock/cache.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/mock/cache.php b/tests/mock/cache.php index b64c92ea89..bc18ca066b 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -123,6 +123,7 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface } public function sql_save($query, $query_result, $ttl) { + return $query_result; } public function sql_exists($query_id) { From 4e83cd461ce2adb008889593abf352745d9adff6 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 26 Aug 2012 18:46:08 +0200 Subject: [PATCH 027/544] [ticket/10875] Fix logic in phpbb_cache_driver_file::sql_save(). Previously (develop-olympus) $query_result was passed via reference into sql_save(). Now the (possibly changed) result is returned by value. Adjust logic to take this change into account correctly. PHPBB3-10875 --- phpBB/includes/cache/driver/file.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php index f64a9e3ea8..d45497af56 100644 --- a/phpBB/includes/cache/driver/file.php +++ b/phpBB/includes/cache/driver/file.php @@ -383,10 +383,10 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base if ($this->_write('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl + time(), $query)) { - $query_result = $query_id; + return $query_id; } - return $query_id; + return $query_result; } /** From 969369254f8860c7ab4cc5a1185f1e8ebf043b63 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 31 Oct 2012 18:14:24 -0400 Subject: [PATCH 028/544] [ticket/10875] Add comment about cache's sql_load() method. PHPBB3-10875 --- phpBB/includes/cache/driver/interface.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/includes/cache/driver/interface.php b/phpBB/includes/cache/driver/interface.php index 847ba97262..669eb75f63 100644 --- a/phpBB/includes/cache/driver/interface.php +++ b/phpBB/includes/cache/driver/interface.php @@ -69,6 +69,12 @@ interface phpbb_cache_driver_interface /** * Load cached sql query + * + * @param string $query SQL query + * + * @return int|bool Query ID (integer) if cache contains a rowset + * for the specified query. + * False otherwise. */ public function sql_load($query); From fd6ee50e06cb48c9e3a476bf23285875484ff5f7 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 2 Nov 2012 16:05:53 -0400 Subject: [PATCH 029/544] [ticket/11162] Extract existing behavior into a function and add a test. PHPBB3-11162 --- phpBB/includes/functions.php | 24 ++++++- tests/functions/fixtures/duplicates.xml | 56 +++++++++++++++ .../update_rows_avoiding_duplicates_test.php | 71 +++++++++++++++++++ 3 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 tests/functions/fixtures/duplicates.xml create mode 100644 tests/functions/update_rows_avoiding_duplicates_test.php diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 65d8be32ad..8608c6ca4f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1297,6 +1297,28 @@ function tz_select($default = '', $truncate = false) return $tz_select; } +/** +* Updates rows in given table from a set of values to a new value. +* If this results in rows violating uniqueness constraints, the duplicate +* rows are eliminated. +* +* @param dbal $db Database object +* @param string $table Table on which to perform the update +* @param string $column Column whose values to change +* @param array $from_values An array of values that should be changed +* @param int $to_value The new value +* @return null +*/ +function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_values, $to_value) +{ + $db->sql_return_on_error(true); + $condition = $db->sql_in_set($column, $from_values); + $db->sql_query('UPDATE ' . $table . ' SET ' . $column . ' = ' . (int) $to_value. ' WHERE ' . $condition); + $db->sql_return_on_error(false); + + $db->sql_query('DELETE FROM ' . $table . ' WHERE ' . $condition); +} + // Functions handling topic/post tracking/marking /** @@ -3355,7 +3377,7 @@ function parse_cfg_file($filename, $lines = false) $parsed_items[$key] = $value; } - + if (isset($parsed_items['inherit_from']) && isset($parsed_items['name']) && $parsed_items['inherit_from'] == $parsed_items['name']) { unset($parsed_items['inherit_from']); diff --git a/tests/functions/fixtures/duplicates.xml b/tests/functions/fixtures/duplicates.xml new file mode 100644 index 0000000000..bc08016a8f --- /dev/null +++ b/tests/functions/fixtures/duplicates.xml @@ -0,0 +1,56 @@ + + +
+ user_id + topic_id + notify_status + + + + 1 + 1 + 1 + + + + + 2 + 2 + 1 + + + 3 + 3 + 1 + + + + + 1 + 4 + 1 + + + 1 + 5 + 1 + + + + + 1 + 6 + 1 + + + 1 + 7 + 1 + + + 2 + 6 + 1 + +
+ diff --git a/tests/functions/update_rows_avoiding_duplicates_test.php b/tests/functions/update_rows_avoiding_duplicates_test.php new file mode 100644 index 0000000000..0e949717d2 --- /dev/null +++ b/tests/functions/update_rows_avoiding_duplicates_test.php @@ -0,0 +1,71 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/duplicates.xml'); + } + + public static function fixture_data() + { + return array( + // description + // from array + // to value + // expected count with to value post update + array( + 'trivial', + array(1), + 10, + 1, + ), + array( + 'no conflict', + array(2), + 3, + 2, + ), + array( + 'conflict', + array(4), + 5, + 1, + ), + array( + 'conflict and no conflict', + array(6), + 7, + 2, + ), + ); + } + + /** + * @dataProvider fixture_data + */ + public function test_trivial_update($description, $from, $to, $expected_result_count) + { + $db = $this->new_dbal(); + + phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $from, $to); + + $sql = 'SELECT count(*) AS count + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . $db->sql_escape($to); + $result = $db->sql_query($sql); + $result_count = $db->sql_fetchfield('count'); + $db->sql_freeresult($result); + + $this->assertEquals($expected_result_count, $result_count); + } +} From 615d5ef628767ec127735fb4797171de3f886de2 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 11 Jun 2012 23:43:00 -0400 Subject: [PATCH 030/544] [ticket/10933] Add get_first_template_location. This localizes template_path to style resource locator. locate function on template will be removed in a subsequent commit. PHPBB3-10933 --- phpBB/includes/style/resource_locator.php | 27 +++++++++++++++++++++++ phpBB/includes/template/template.php | 16 +------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 8658fe4a36..e3bcf4d9c4 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -229,4 +229,31 @@ class phpbb_style_resource_locator implements phpbb_template_locator // search failed return $default_result; } + + /** + * Just like get_first_file_location but works on a list of templates, + * not files. + * + * The templates given in the first argument first are prepended with + * the template path (property in this class), then given to + * get_first_file_location for the rest of the processing. + */ + public function get_first_template_location($templates, $return_default = false, $return_full_path = true) + { + // add template path prefix + $files = array(); + if (is_string($templates)) + { + $files[] = $this->template_path . $templates; + } + else + { + foreach ($templates as $template) + { + $files[] = $this->template_path . $template; + } + } + + return $this->get_first_file_location($files, $return_default, $return_full_path); + } } diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 5d3ce4c82b..9e44c5609b 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -508,22 +508,8 @@ class phpbb_template */ public function locate($files, $return_default = false, $return_full_path = true) { - // add template path prefix - $templates = array(); - if (is_string($files)) - { - $templates[] = $this->template_path . $files; - } - else - { - foreach ($files as $file) - { - $templates[] = $this->template_path . $file; - } - } - // use resource locator to find files - return $this->locator->get_first_file_location($templates, $return_default, $return_full_path); + return $this->locator->get_first_template_location($files, $return_default, $return_full_path); } /** From 97e53103c3bb873389ea3046a3cd451ab5542ae1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 11 Jun 2012 23:49:10 -0400 Subject: [PATCH 031/544] [ticket/10933] Delete template_path from template class. template_path is now only present in style resource locator. PHPBB3-10933 --- phpBB/includes/template/template.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 9e44c5609b..6a4db1cf41 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -74,12 +74,6 @@ class phpbb_template */ private $locator; - /** - * Location of templates directory within style directories - * @var string - */ - public $template_path = 'template/'; - /** * Constructor. * @@ -95,7 +89,6 @@ class phpbb_template $this->config = $config; $this->user = $user; $this->locator = $locator; - $this->template_path = $this->locator->template_path; $this->context = $context; } From 6295b014d35890d60ccf422f5bb8228569e8ca3a Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 11 Jun 2012 23:50:33 -0400 Subject: [PATCH 032/544] [ticket/10933] Delete template_path assignment. template_path is now only present in style resource locator and should not be assigned to. PHPBB3-10933 --- phpBB/includes/style/style.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 36298b49ec..d8974bc516 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -126,7 +126,7 @@ class phpbb_style if ($template_path !== false) { - $this->template->template_path = $this->locator->template_path = $template_path; + $this->locator->template_path = $template_path; } return true; From 09794c6821a93023c19d6b74e8e5d0e835e37be6 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 12 Jun 2012 00:02:30 -0400 Subject: [PATCH 033/544] [ticket/10933] Add mutators for template_path to style resource locator. template_path is now private. Change semantics of passing false for template path - now this resets template path to default which I think makes sense. PHPBB3-10933 --- phpBB/includes/style/resource_locator.php | 20 +++++++++++++++++++- phpBB/includes/style/style.php | 12 ++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index e3bcf4d9c4..a5bf595671 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -44,7 +44,7 @@ class phpbb_style_resource_locator implements phpbb_template_locator * style directory, such as admin control panel templates. * @var string */ - public $template_path = 'template/'; + private $template_path; /** * Map from root index to handles to source template file paths. @@ -63,6 +63,11 @@ class phpbb_style_resource_locator implements phpbb_template_locator */ private $filenames = array(); + public function __construct() + { + $this->set_default_template_path(); + } + /** * Sets the list of style paths * @@ -93,6 +98,19 @@ class phpbb_style_resource_locator implements phpbb_template_locator } } + /** + * Sets the location of templates directory within style directories. + */ + public function set_template_path($template_path) + { + $this->template_path = $template_path; + } + + public function set_default_template_path() + { + $this->template_path = 'template/'; + } + /** * {@inheritDoc} */ diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index d8974bc516..effd496fb9 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -110,7 +110,7 @@ class phpbb_style * * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. False if path should not be changed. + * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). */ public function set_custom_style($name, $paths, $template_path = false) { @@ -122,12 +122,16 @@ class phpbb_style $this->provider->set_styles($paths); $this->locator->set_paths($this->provider); - $this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_'; - if ($template_path !== false) { - $this->locator->template_path = $template_path; + $this->locator->set_template_path($template_path); } + else + { + $this->locator->set_default_template_path(); + } + + $this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_'; return true; } From 0dd981071bd4a39480759db130ea9c6d80c37065 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 12 Jun 2012 00:06:13 -0400 Subject: [PATCH 034/544] [ticket/10933] Dispose of locate function in template class. It had no callers other than the test suite. PHPBB3-10933 --- phpBB/includes/style/resource_locator.php | 47 ++++++++++++++++++++ phpBB/includes/template/template.php | 54 ----------------------- 2 files changed, 47 insertions(+), 54 deletions(-) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index a5bf595671..37ea2fed40 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -249,12 +249,59 @@ class phpbb_style_resource_locator implements phpbb_template_locator } /** + * Obtains filesystem path for a template file. + * + * The simplest use is specifying a single template file as a string + * in the first argument. This template file should be a basename + * of a template file in the selected style, or its parent styles + * if template inheritance is being utilized. + * + * Note: "selected style" is whatever style the style resource locator + * is configured for. + * + * The return value then will be a path, relative to the current + * directory or absolute, to the template file in the selected style + * or its closest parent. + * + * If the selected style does not have the template file being searched, + * (and if inheritance is involved, none of the parents have it either), + * false will be returned. + * + * Specifying true for $return_default will cause the function to + * return the first path which was checked for existence in the event + * that the template file was not found, instead of false. + * This is the path in the selected style itself, not any of its + * parents. + * + * $files can be given an array of templates instead of a single + * template. When given an array, the function will try to resolve + * each template in the array to a path, and will return the first + * path that exists, or false if none exist. + * + * If $return_full_path is false, then instead of returning a usable + * path (when the template is found) only the template's basename + * will be returned. This can be used to check which of the templates + * specified in $files exists, provided different file names are + * used for different templates. + * * Just like get_first_file_location but works on a list of templates, * not files. * * The templates given in the first argument first are prepended with * the template path (property in this class), then given to * get_first_file_location for the rest of the processing. + * + * @param string or array $files List of templates to locate. If there is only + * one template, $files can be a string to make code easier to read. + * @param bool $return_default Determines what to return if template does not + * exist. If true, function will return location where template is + * supposed to be. If false, function will return false. + * @param bool $return_full_path If true, function will return full path + * to template. If false, function will return template file name. + * This parameter can be used to check which one of set of template + * files is available. + * @return string or boolean Source template path if template exists or $return_default is + * true. False if template does not exist and $return_default is false */ public function get_first_template_location($templates, $return_default = false, $return_full_path = true) { diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 6a4db1cf41..f79c565e5c 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -451,60 +451,6 @@ class phpbb_template include($file); } - /** - * Obtains filesystem path for a template file. - * - * The simplest use is specifying a single template file as a string - * in the first argument. This template file should be a basename - * of a template file in the selected style, or its parent styles - * if template inheritance is being utilized. - * - * Note: "selected style" is whatever style the style resource locator - * is configured for. - * - * The return value then will be a path, relative to the current - * directory or absolute, to the template file in the selected style - * or its closest parent. - * - * If the selected style does not have the template file being searched, - * (and if inheritance is involved, none of the parents have it either), - * false will be returned. - * - * Specifying true for $return_default will cause the function to - * return the first path which was checked for existence in the event - * that the template file was not found, instead of false. - * This is the path in the selected style itself, not any of its - * parents. - * - * $files can be given an array of templates instead of a single - * template. When given an array, the function will try to resolve - * each template in the array to a path, and will return the first - * path that exists, or false if none exist. - * - * If $return_full_path is false, then instead of returning a usable - * path (when the template is found) only the template's basename - * will be returned. This can be used to check which of the templates - * specified in $files exists, provided different file names are - * used for different templates. - * - * @param string or array $files List of templates to locate. If there is only - * one template, $files can be a string to make code easier to read. - * @param bool $return_default Determines what to return if template does not - * exist. If true, function will return location where template is - * supposed to be. If false, function will return false. - * @param bool $return_full_path If true, function will return full path - * to template. If false, function will return template file name. - * This parameter can be used to check which one of set of template - * files is available. - * @return string or boolean Source template path if template exists or $return_default is - * true. False if template does not exist and $return_default is false - */ - public function locate($files, $return_default = false, $return_full_path = true) - { - // use resource locator to find files - return $this->locator->get_first_template_location($files, $return_default, $return_full_path); - } - /** * Include JS file * From b878d5daa9e7210c35b2d06e1680f22eb6701c6f Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 12 Jun 2012 00:35:45 -0400 Subject: [PATCH 035/544] [ticket/10933] Update template locator test to use style resource locator. There is no reason for it to go through a template instance to test resource locator functionality. PHPBB3-10933 --- tests/template/template_locate_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/template/template_locate_test.php b/tests/template/template_locate_test.php index be9ae06809..851dcae8ea 100644 --- a/tests/template/template_locate_test.php +++ b/tests/template/template_locate_test.php @@ -62,7 +62,7 @@ class phpbb_template_template_locate_test extends phpbb_template_template_test_c $this->setup_engine(); // Locate template - $result = $this->template->locate($files, $return_default, $return_full_path); + $result = $this->style_resource_locator->get_first_template_location($files, $return_default, $return_full_path); $this->assertSame($expected, $result); } } From bf66c47650682331454487c9db3999265f06df78 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 12 Jun 2012 01:32:49 -0400 Subject: [PATCH 036/544] [ticket/10933] Remaining documentation for added functions in resource locator PHPBB3-10933 --- phpBB/includes/style/resource_locator.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 37ea2fed40..6181653d4e 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -63,6 +63,11 @@ class phpbb_style_resource_locator implements phpbb_template_locator */ private $filenames = array(); + /** + * Constructor. + * + * Sets default template path to template/. + */ public function __construct() { $this->set_default_template_path(); @@ -100,12 +105,24 @@ class phpbb_style_resource_locator implements phpbb_template_locator /** * Sets the location of templates directory within style directories. + * + * The location must be a relative path, with a trailing slash. + * Typically it is one directory level deep, e.g. "template/". + * + * @param string $template_path Relative path to templates directory within style directories + * @return void */ public function set_template_path($template_path) { $this->template_path = $template_path; } + /** + * Sets the location of templates directory within style directories + * to the default, which is "template/". + * + * @return void + */ public function set_default_template_path() { $this->template_path = 'template/'; From 7fdab9c5d7d212f206cfdd79f5ccef097070a7f5 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 12 Jun 2012 01:50:22 -0400 Subject: [PATCH 037/544] [ticket/10933] Prose for get_first_file_location. Also rewrite get_first_template_location prose a little to be less repetitive with get_first_file_location. PHPBB3-10933 --- phpBB/includes/style/resource_locator.php | 19 ++++++--- phpBB/includes/template/locator.php | 52 ++++++++++++++++++++--- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 6181653d4e..04beddb434 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -295,19 +295,26 @@ class phpbb_style_resource_locator implements phpbb_template_locator * each template in the array to a path, and will return the first * path that exists, or false if none exist. * + * If $files is an array and template inheritance is involved, first + * each of the files will be checked in the selected style, then each + * of the files will be checked in the immediate parent, and so on. + * * If $return_full_path is false, then instead of returning a usable * path (when the template is found) only the template's basename * will be returned. This can be used to check which of the templates - * specified in $files exists, provided different file names are - * used for different templates. + * specified in $files exists. Naturally more than one template must + * be given in $files. * - * Just like get_first_file_location but works on a list of templates, - * not files. - * - * The templates given in the first argument first are prepended with + * This function works identically to get_first_file_location except + * it operates on a list of templates, not files. Practically speaking, + * the templates given in the first argument first are prepended with * the template path (property in this class), then given to * get_first_file_location for the rest of the processing. * + * Templates given to this function can be relative paths for templates + * located in subdirectories of the template directories. The paths + * should be relative to the templates directory (template/ by default). + * * @param string or array $files List of templates to locate. If there is only * one template, $files can be a string to make code easier to read. * @param bool $return_default Determines what to return if template does not diff --git a/phpBB/includes/template/locator.php b/phpBB/includes/template/locator.php index 01c79eec4e..42db91efb2 100644 --- a/phpBB/includes/template/locator.php +++ b/phpBB/includes/template/locator.php @@ -99,12 +99,54 @@ interface phpbb_template_locator public function get_source_file_for_handle($handle, $find_all = false); /** - * Locates source file path, accounting for styles tree and verifying that - * the path exists. + * Obtains a complete filesystem path for a file in a style. * - * Unlike previous functions, this function works without template handle - * and it can search for more than one file. If more than one file name is - * specified, it will return location of file that it finds first. + * This function traverses the style tree (selected style and + * its parents in order, if inheritance is being used) and finds + * the first file on the filesystem matching specified relative path, + * or the first of the specified paths if more than one path is given. + * + * This function can be used to determine filesystem path of any + * file under any style, with the consequence being that complete + * relative to the style directory path must be provided as an argument. + * + * In particular, this function can be used to locate templates + * and javascript files. + * + * For locating templates get_first_template_location should be used + * as it prepends the configured template path to the template basename. + * + * Note: "selected style" is whatever style the style resource locator + * is configured for. + * + * The return value then will be a path, relative to the current + * directory or absolute, to the first existing file in the selected + * style or its closest parent. + * + * If the selected style does not have the file being searched, + * (and if inheritance is involved, none of the parents have it either), + * false will be returned. + * + * Multiple files can be specified, in which case the first file in + * the list that can be found on the filesystem is returned. + * + * If multiple files are specified and inheritance is involved, + * first each of the specified files is checked in the selected style, + * then each of the specified files is checked in the immediate parent, + * etc. + * + * Specifying true for $return_default will cause the function to + * return the first path which was checked for existence in the event + * that the template file was not found, instead of false. + * This is always a path in the selected style itself, not any of its + * parents. + * + * If $return_full_path is false, then instead of returning a usable + * path (when the file is found) the file's path relative to the style + * directory will be returned. This is the same path as was given to + * the function as a parameter. This can be used to check which of the + * files specified in $files exists. Naturally this requires passing + * more than one file in $files. * * @param array $files List of files to locate. * @param bool $return_default Determines what to return if file does not From 1f9bff2126bbec514c4a7b675723bfe7f26c432e Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sat, 10 Nov 2012 08:51:12 +0000 Subject: [PATCH 038/544] [ticket/10939] Added documentation for phpbb_request::file PHPBB3-10939 --- phpBB/includes/request/request.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php index 25410c27c4..94445f232c 100644 --- a/phpBB/includes/request/request.php +++ b/phpBB/includes/request/request.php @@ -289,7 +289,8 @@ class phpbb_request implements phpbb_request_interface * * @param string $form_name The name of the file input form element * - * @return array The uploaded file's information + * @return array The uploaded file's information or an empty array if the + * variable does not exist in _FILES. */ public function file($form_name) { From a05f354fdf903d00e85d8e4ad1d50f9ef906534d Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sat, 10 Nov 2012 09:36:02 +0000 Subject: [PATCH 039/544] [ticket/10970] Added extra documentation to parse_dynamic_path. PHPBB3-10970 --- phpBB/includes/template/filter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index 471ca0c777..3e90190db7 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -370,7 +370,8 @@ class phpbb_template_filter extends php_user_filter * @param string $path The path to parse * @param string $include_type The type of template function to call * @return string An appropriately formatted string to include in the - * template + * template or an empty string if an expression like S_FIRST_ROW was + * incorrectly used */ private function parse_dynamic_path($path, $include_type) { From 195014867ae84fe04ec01c913e38bf1d435590f7 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 11:25:22 +0100 Subject: [PATCH 040/544] [ticket/11183] Remove $load_extensions and weird dl() calls PHPBB3-11183 --- phpBB/common.php | 12 ----- .../plugins/phpbb_captcha_gd_plugin.php | 14 +----- .../plugins/phpbb_captcha_gd_wave_plugin.php | 14 +----- phpBB/includes/functions_install.php | 44 ++++--------------- .../includes/questionnaire/questionnaire.php | 1 - phpBB/install/database_update.php | 17 ++----- phpBB/install/install_install.php | 44 ++++--------------- .../phpbb_functional_test_case.php | 2 +- 8 files changed, 23 insertions(+), 125 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 6943b02fa0..6817b63d7b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -67,18 +67,6 @@ if (!defined('PHPBB_INSTALLED')) exit; } -// Load Extensions -// dl() is deprecated and disabled by default as of PHP 5.3. -if (!empty($load_extensions) && function_exists('dl')) -{ - $load_extensions = explode(',', $load_extensions); - - foreach ($load_extensions as $extension) - { - @dl(trim($extension)); - } -} - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index 4ad34f2a26..c0c355f33b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -57,19 +57,7 @@ class phpbb_captcha_gd extends phpbb_default_captcha static public function is_available() { - global $phpbb_root_path, $phpEx; - - if (@extension_loaded('gd')) - { - return true; - } - - if (!function_exists('can_load_dll')) - { - include($phpbb_root_path . 'includes/functions_install.' . $phpEx); - } - - return can_load_dll('gd'); + return @extension_loaded('gd'); } /** diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php index 26383c76a8..0d4b8bd451 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php @@ -46,19 +46,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha static public function is_available() { - global $phpbb_root_path, $phpEx; - - if (@extension_loaded('gd')) - { - return true; - } - - if (!function_exists('can_load_dll')) - { - include($phpbb_root_path . 'includes/functions_install.' . $phpEx); - } - - return can_load_dll('gd'); + return @extension_loaded('gd'); } static public function get_name() diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 10ec13669b..3421c90c88 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -15,27 +15,6 @@ if (!defined('IN_PHPBB')) exit; } -/** -* Determine if we are able to load a specified PHP module and do so if possible -*/ -function can_load_dll($dll) -{ - // SQLite2 is a tricky thing, from 5.0.0 it requires PDO; if PDO is not loaded we must state that SQLite is unavailable - // as the installer doesn't understand that the extension has a prerequisite. - // - // On top of this sometimes the SQLite extension is compiled for a different version of PDO - // by some Linux distributions which causes phpBB to bomb out with a blank page. - // - // Net result we'll disable automatic inclusion of SQLite support - // - // See: r9618 and #56105 - if ($dll == 'sqlite') - { - return false; - } - return ((@ini_get('enable_dl') || strtolower(@ini_get('enable_dl')) == 'on') && (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') && function_exists('dl') && @dl($dll . '.' . PHP_SHLIB_SUFFIX)) ? true : false; -} - /** * Returns an array of available DBMS with some data, if a DBMS is specified it will only * return data for that DBMS and will load its extension if necessary. @@ -159,18 +138,15 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 if (!@extension_loaded($dll)) { - if (!can_load_dll($dll)) + if ($return_unavailable) { - if ($return_unavailable) - { - $available_dbms[$db_name]['AVAILABLE'] = false; - } - else - { - unset($available_dbms[$db_name]); - } - continue; + $available_dbms[$db_name]['AVAILABLE'] = false; } + else + { + unset($available_dbms[$db_name]); + } + continue; } $any_db_support = true; } @@ -520,17 +496,14 @@ function adjust_language_keys_callback($matches) * * @param array $data Array containing the database connection information * @param string $dbms The name of the DBAL class to use -* @param array $load_extensions Array of additional extensions that should be loaded * @param bool $debug If the debug constants should be enabled by default or not * @param bool $debug_test If the DEBUG_TEST constant should be added * NOTE: Only for use within the testing framework * * @return string The output to write to the file */ -function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false, $debug_test = false) +function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test = false) { - $load_extensions = implode(',', $load_extensions); - $config_data = " htmlspecialchars_decode($data['dbpasswd']), 'table_prefix' => $data['table_prefix'], 'acm_type' => 'phpbb_cache_driver_file', - 'load_extensions' => $load_extensions, ); foreach ($config_data_array as $key => $value) diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 5cb441d536..f0fb8c3c06 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -476,7 +476,6 @@ class phpbb_questionnaire_phpbb_data_provider $result['dbms'] = $dbms; $result['acm_type'] = $acm_type; - $result['load_extensions'] = $load_extensions; $result['user_agent'] = 'Unknown'; $result['dbms_version'] = $db->sql_server_info(true); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 527108af08..dcdd17cbc0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -73,17 +73,6 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) die("Please read: INSTALL.html before attempting to update."); } -// Load Extensions -if (!empty($load_extensions) && function_exists('dl')) -{ - $load_extensions = explode(',', $load_extensions); - - foreach ($load_extensions as $extension) - { - @dl(trim($extension)); - } -} - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); @@ -2716,10 +2705,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) @@ -2752,7 +2741,7 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } - + if (!isset($config['site_home_url'])) { $config->set('site_home_url', ''); diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index eb9a92f4d1..42102442f8 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -271,14 +271,6 @@ class install_install extends module 'S_LEGEND' => false, )); -/** -* Better not enabling and adding to the loaded extensions due to the specific requirements needed - if (!@extension_loaded('mbstring')) - { - can_load_dll('mbstring'); - } -*/ - $passed['mbstring'] = true; if (@extension_loaded('mbstring')) { @@ -382,17 +374,14 @@ class install_install extends module { if (!@extension_loaded($dll)) { - if (!can_load_dll($dll)) - { - $template->assign_block_vars('checks', array( - 'TITLE' => $lang['DLL_' . strtoupper($dll)], - 'RESULT' => '' . $lang['UNAVAILABLE'] . '', + $template->assign_block_vars('checks', array( + 'TITLE' => $lang['DLL_' . strtoupper($dll)], + 'RESULT' => '' . $lang['UNAVAILABLE'] . '', - 'S_EXPLAIN' => false, - 'S_LEGEND' => false, - )); - continue; - } + 'S_EXPLAIN' => false, + 'S_LEGEND' => false, + )); + continue; } $template->assign_block_vars('checks', array( @@ -873,22 +862,7 @@ class install_install extends module $written = false; // Create a list of any PHP modules we wish to have loaded - $load_extensions = array(); $available_dbms = get_available_dbms($data['dbms']); - $check_exts = array_merge(array($available_dbms[$data['dbms']]['MODULE']), $this->php_dlls_other); - - foreach ($check_exts as $dll) - { - if (!@extension_loaded($dll)) - { - if (!can_load_dll($dll)) - { - continue; - } - - $load_extensions[] = $dll . '.' . PHP_SHLIB_SUFFIX; - } - } // Create a lock file to indicate that there is an install in progress $fp = @fopen($phpbb_root_path . 'cache/install_lock', 'wb'); @@ -902,7 +876,7 @@ class install_install extends module @chmod($phpbb_root_path . 'cache/install_lock', 0777); // Time to convert the data provided into a config file - $config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER'], $load_extensions); + $config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER']); // Attempt to write out the config file directly. If it works, this is the easiest way to do it ... if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path)) @@ -1368,7 +1342,7 @@ class install_install extends module WHERE config_name = 'dbms_version'", ); - if (@extension_loaded('gd') || can_load_dll('gd')) + if (@extension_loaded('gd')) { $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = 'phpbb_captcha_gd' diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d002615e8c..2d44bfc359 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -199,7 +199,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->do_request('create_table', $data); $this->do_request('config_file', $data); - file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true)); + file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], true, true)); $this->do_request('final', $data); copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); From f48709f5bb8fb1b916d308e3b4bb06bc96d08611 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 19 Oct 2012 19:53:29 -0400 Subject: [PATCH 041/544] [feature/compiled-dic] Compile the DI Container into a cached class PHPBB3-11152 --- phpBB/common.php | 39 +++-- phpBB/config/services.yml | 4 +- phpBB/download/file.php | 27 ++- phpBB/includes/cache/driver/file.php | 2 +- phpBB/includes/cache/driver/memory.php | 2 +- .../di/{processor => extension}/config.php | 61 ++++--- phpBB/includes/di/extension/core.php | 76 +++++++++ phpBB/includes/di/extension/ext.php | 73 ++++++++ phpBB/includes/di/processor/ext.php | 54 ------ phpBB/includes/di/processor/interface.php | 28 --- phpBB/includes/event/dispatcher.php | 4 +- phpBB/includes/event/kernel_compiler_pass.php | 72 ++++++++ phpBB/includes/event/kernel_subscriber.php | 94 ++++++++++ phpBB/includes/extension/controller.php | 84 --------- .../extension/controller_interface.php | 31 ---- phpBB/includes/functions.php | 102 +++++++++++ phpBB/install/database_update.php | 34 ++-- phpBB/install/index.php | 16 +- tests/event/dispatcher_test.php | 2 +- tests/mock/container_builder.php | 160 ++++++++++++++++++ 20 files changed, 692 insertions(+), 273 deletions(-) rename phpBB/includes/di/{processor => extension}/config.php (52%) create mode 100644 phpBB/includes/di/extension/core.php create mode 100644 phpBB/includes/di/extension/ext.php delete mode 100644 phpBB/includes/di/processor/ext.php delete mode 100644 phpBB/includes/di/processor/interface.php create mode 100644 phpBB/includes/event/kernel_compiler_pass.php create mode 100644 phpBB/includes/event/kernel_subscriber.php delete mode 100644 phpBB/includes/extension/controller.php delete mode 100644 phpBB/includes/extension/controller_interface.php create mode 100644 tests/mock/container_builder.php diff --git a/phpBB/common.php b/phpBB/common.php index 6943b02fa0..a681561619 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -81,8 +81,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -94,16 +92,28 @@ 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'); -$phpbb_container = new ContainerBuilder(); -$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config')); -$loader->load('services.yml'); - -$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); -$processor->process($phpbb_container); - // Setup class loader first -$phpbb_class_loader = $phpbb_container->get('class_loader'); -$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); +$phpbb_class_loader_ext->register(); + +// Set up container +$phpbb_container = phpbb_create_compiled_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_event_kernel_compiler_pass(), + ), + $phpbb_root_path . 'config.' . $phpEx, + $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'); @@ -130,13 +140,6 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); $phpbb_style = $phpbb_container->get('style'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // 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'))); diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 038c8a862d..6c904ac2c8 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -47,7 +47,7 @@ services: cron.task_provider: class: phpbb_cron_task_provider arguments: - - @container + - @service_container cron.manager: class: phpbb_cron_manager @@ -65,6 +65,8 @@ services: dispatcher: class: phpbb_event_dispatcher + arguments: + - @service_container dbal.conn: class: %dbal.driver.class% diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 7ed53d54b6..85dc8acb81 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -51,15 +51,28 @@ if (isset($_GET['avatar'])) require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - $phpbb_container = new ContainerBuilder(); - $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); - $loader->load('services.yml'); + // Setup class loader first + $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); + $phpbb_class_loader->register(); + $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); + $phpbb_class_loader_ext->register(); - $processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); - $processor->process($phpbb_container); + // Set up container + $phpbb_container = phpbb_create_compiled_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_event_kernel_compiler_pass(), + ), + $phpbb_root_path . 'config.' . $phpEx, + $phpbb_root_path, + $phpEx + ); - $phpbb_class_loader = $phpbb_container->get('class_loader'); - $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); + $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'); diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php index f64a9e3ea8..b8876b03b4 100644 --- a/phpBB/includes/cache/driver/file.php +++ b/phpBB/includes/cache/driver/file.php @@ -214,7 +214,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base while (($entry = readdir($dir)) !== false) { - if (strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + if (strpos($entry, 'container') !== 0 && strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) { continue; } diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php index e0771ab1d3..9ee32fff28 100644 --- a/phpBB/includes/cache/driver/memory.php +++ b/phpBB/includes/cache/driver/memory.php @@ -162,7 +162,7 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base while (($entry = readdir($dir)) !== false) { - if (strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + if (strpos($entry, 'container') !== 0 && strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) { continue; } diff --git a/phpBB/includes/di/processor/config.php b/phpBB/includes/di/extension/config.php similarity index 52% rename from phpBB/includes/di/processor/config.php rename to phpBB/includes/di/extension/config.php index 22b6252a6d..b9c752c5de 100644 --- a/phpBB/includes/di/processor/config.php +++ b/phpBB/includes/di/extension/config.php @@ -16,40 +16,33 @@ if (!defined('IN_PHPBB')) } use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\Config\FileLocator; /** -* Configure the container for phpBB's services though -* user-defined parameters defined in the config.php file. +* Container config extension */ -class phpbb_di_processor_config implements phpbb_di_processor_interface +class phpbb_di_extension_config extends Extension { - private $config_file; - private $phpbb_root_path; - private $php_ext; - - /** - * Constructor. - * - * @param string $config_file The config file - * @param string $phpbb_root_path The root path - * @param string $php_ext The PHP extension - */ - public function __construct($config_file, $phpbb_root_path, $php_ext) + public function __construct($config_file) { $this->config_file = $config_file; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; } /** - * @inheritdoc + * Loads a specific configuration. + * + * @param array $config An array of configuration values + * @param ContainerBuilder $container A ContainerBuilder instance + * + * @throws InvalidArgumentException When provided tag is not defined in this extension + * + * @api */ - public function process(ContainerBuilder $container) + public function load(array $config, ContainerBuilder $container) { - require $this->config_file; - - $container->setParameter('core.root_path', $this->phpbb_root_path); - $container->setParameter('core.php_ext', $this->php_ext); + require($this->config_file); $container->setParameter('core.table_prefix', $table_prefix); $container->setParameter('cache.driver.class', $this->fix_acm_type($acm_type)); @@ -60,10 +53,28 @@ class phpbb_di_processor_config implements phpbb_di_processor_interface $container->setParameter('dbal.dbname', $dbname); $container->setParameter('dbal.dbport', $dbport); $container->setParameter('dbal.new_link', defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK); - - $container->set('container', $container); } + /** + * Returns the recommended alias to use in XML. + * + * This alias is also the mandatory prefix to use when using YAML. + * + * @return string The alias + * + * @api + */ + public function getAlias() + { + return 'config'; + } + + /** + * Convert old (3.0) values to 3.1 class names + * + * @param style $acm_type ACM type + * @return ACM type class + */ protected function fix_acm_type($acm_type) { if (preg_match('#^[a-z]+$#', $acm_type)) diff --git a/phpBB/includes/di/extension/core.php b/phpBB/includes/di/extension/core.php new file mode 100644 index 0000000000..26aa325bdd --- /dev/null +++ b/phpBB/includes/di/extension/core.php @@ -0,0 +1,76 @@ +phpbb_root_path = $phpbb_root_path; + } + + /** + * Loads a specific configuration. + * + * @param array $config An array of configuration values + * @param ContainerBuilder $container A ContainerBuilder instance + * + * @throws InvalidArgumentException When provided tag is not defined in this extension + * + * @api + */ + public function load(array $config, ContainerBuilder $container) + { + if (file_exists($this->phpbb_root_path . 'config/services.yml')) + { + $loader = new YamlFileLoader($container, new FileLocator(realpath($this->phpbb_root_path . 'config'))); + $loader->load('services.yml'); + } + } + + /** + * Returns the recommended alias to use in XML. + * + * This alias is also the mandatory prefix to use when using YAML. + * + * @return string The alias + * + * @api + */ + public function getAlias() + { + return 'core'; + } +} diff --git a/phpBB/includes/di/extension/ext.php b/phpBB/includes/di/extension/ext.php new file mode 100644 index 0000000000..2539ff5667 --- /dev/null +++ b/phpBB/includes/di/extension/ext.php @@ -0,0 +1,73 @@ + $path) + { + $this->paths[] = $path; + } + } + + /** + * Loads a specific configuration. + * + * @param array $config An array of configuration values + * @param ContainerBuilder $container A ContainerBuilder instance + * + * @throws InvalidArgumentException When provided tag is not defined in this extension + * + * @api + */ + public function load(array $config, ContainerBuilder $container) + { + foreach ($this->paths as $path) + { + if (file_exists($path . '/config/services.yml')) + { + $loader = new YamlFileLoader($container, new FileLocator($path . '/config')); + $loader->load('services.yml'); + } + } + } + + /** + * Returns the recommended alias to use in XML. + * + * This alias is also the mandatory prefix to use when using YAML. + * + * @return string The alias + * + * @api + */ + public function getAlias() + { + return 'ext'; + } +} diff --git a/phpBB/includes/di/processor/ext.php b/phpBB/includes/di/processor/ext.php deleted file mode 100644 index e69a3d73b3..0000000000 --- a/phpBB/includes/di/processor/ext.php +++ /dev/null @@ -1,54 +0,0 @@ -extension_manager = $extension_manager; - } - - /** - * @inheritdoc - */ - public function process(ContainerBuilder $container) - { - $enabled_exts = $this->extension_manager->all_enabled(); - foreach ($enabled_exts as $name => $path) - { - if (file_exists($path . '/config/services.yml')) - { - $loader = new YamlFileLoader($container, new FileLocator($path . '/config')); - $loader->load('services.yml'); - } - } - } -} diff --git a/phpBB/includes/di/processor/interface.php b/phpBB/includes/di/processor/interface.php deleted file mode 100644 index b8563791cc..0000000000 --- a/phpBB/includes/di/processor/interface.php +++ /dev/null @@ -1,28 +0,0 @@ -trigger_event('core.index', compact($vars))); * */ -class phpbb_event_dispatcher extends EventDispatcher +class phpbb_event_dispatcher extends ContainerAwareEventDispatcher { public function trigger_event($eventName, $data = array()) { diff --git a/phpBB/includes/event/kernel_compiler_pass.php b/phpBB/includes/event/kernel_compiler_pass.php new file mode 100644 index 0000000000..18b6661cd4 --- /dev/null +++ b/phpBB/includes/event/kernel_compiler_pass.php @@ -0,0 +1,72 @@ +getDefinition('dispatcher'); + $user = $container->get('user'); + + foreach ($container->findTaggedServiceIds('kernel.event_listener') as $id => $events) + { + foreach ($events as $event) + { + $priority = isset($event['priority']) ? $event['priority'] : 0; + + if (!isset($event['event'])) + { + throw new InvalidArgumentException($user->lang('NO_EVENT_ATTRIBUTE', $id)); + } + + if (!isset($event['method'])) + { + $event['method'] = 'on'.preg_replace(array( + '/(?<=\b)[a-z]/ie', + '/[^a-z0-9]/i' + ), array('strtoupper("\\0")', ''), $event['event']); + } + + $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); + } + } + + foreach ($container->findTaggedServiceIds('kernel.event_subscriber') as $id => $attributes) + { + // We must assume that the class value has been correctly filled, even if the service is created by a factory + $class = $container->getDefinition($id)->getClass(); + + $refClass = new ReflectionClass($class); + $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; + if (!$refClass->implementsInterface($interface)) + { + throw new InvalidArgumentException($user->lang('SUBSCRIBER_WRONG_TYPE', $id, $interface)); + } + + $definition->addMethodCall('addSubscriberService', array($id, $class)); + } + } +} diff --git a/phpBB/includes/event/kernel_subscriber.php b/phpBB/includes/event/kernel_subscriber.php new file mode 100644 index 0000000000..9737d9bc23 --- /dev/null +++ b/phpBB/includes/event/kernel_subscriber.php @@ -0,0 +1,94 @@ +template = $template; + $this->user = $user; + } + + /** + * This listener is run when the KernelEvents::TERMINATE event is triggered + * This comes after a Response has been sent to the server; this is + * primarily cleanup stuff. + * + * @param PostResponseEvent $event + * @return null + */ + public function on_kernel_terminate(PostResponseEvent $event) + { + exit_handler(); + } + + /** + * This listener is run when the KernelEvents::EXCEPTION event is triggered + * + * @param GetResponseForExceptionEvent $event + * @return null + */ + public function on_kernel_exception(GetResponseForExceptionEvent $event) + { + page_header($this->user->lang('INFORMATION')); + + $this->template->assign_vars(array( + 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), + 'MESSAGE_TEXT' => $event->getException()->getMessage(), + )); + + $this->template->set_filenames(array( + 'body' => 'message_body.html', + )); + + page_footer(true, false, false); + + $event->setResponse(new Response($this->template->return_display('body'), 404)); + } + + public static function getSubscribedEvents() + { + return array( + KernelEvents::TERMINATE => 'on_kernel_terminate', + KernelEvents::EXCEPTION => 'on_kernel_exception', + ); + } +} diff --git a/phpBB/includes/extension/controller.php b/phpBB/includes/extension/controller.php deleted file mode 100644 index f97b69c7ed..0000000000 --- a/phpBB/includes/extension/controller.php +++ /dev/null @@ -1,84 +0,0 @@ -request = $request; - $this->db = $db; - $this->user = $user; - $this->template = $template; - $this->config = $config; - $this->php_ext = $phpEx; - $this->phpbb_root_path = $phpbb_root_path; - } -} diff --git a/phpBB/includes/extension/controller_interface.php b/phpBB/includes/extension/controller_interface.php deleted file mode 100644 index 2b88925388..0000000000 --- a/phpBB/includes/extension/controller_interface.php +++ /dev/null @@ -1,31 +0,0 @@ - PHP_INT_MAX) ? (float) $input : (int) $input; } + +/** +* Create the ContainerBuilder object +* +* @param array $extensions Array of Container extension objects +* @param string $phpbb_root_path Root path +* @param string $phpEx PHP Extension +* @return ContainerBuilder object +*/ +function phpbb_create_container(array $extensions, $phpbb_root_path, $phpEx) +{ + $container = new ContainerBuilder(); + + foreach ($extensions as $extension) + { + $container->registerExtension($extension); + $container->loadFromExtension($extension->getAlias()); + } + + $container->set('container', $container); + $container->setParameter('core.root_path', $phpbb_root_path); + $container->setParameter('core.php_ext', $phpEx); + + return $container; +} + +/** +* Create installer container +* +* @param string $phpbb_root_path Root path +* @param string $phpEx PHP Extension +* @return ContainerBuilder object +*/ +function phpbb_create_install_container($phpbb_root_path, $phpEx) +{ + // We have to do it like this instead of with extensions + $container = new ContainerBuilder(); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); + $loader->load('services.yml'); + + $container->setParameter('core.root_path', $phpbb_root_path); + $container->setParameter('core.php_ext', $phpEx); + + $container->setAlias('cache.driver', 'cache.driver.install'); + + return $container; +} + +/** +* Create a compiled ContainerBuilder object +* +* @param array $extensions Array of Container extension objects +* @param array $passes Array of Compiler Pass objects +* @param string $phpbb_root_path Root path +* @param string $phpEx PHP Extension +* @return ContainerBuilder object (compiled) +*/ +function phpbb_create_compiled_container(array $extensions, array $passes, $config_file_path, $phpbb_root_path, $phpEx) +{ + // Check for our cached container; if it exists, use it + if (file_exists("{$phpbb_root_path}cache/container.$phpEx")) + { + require("{$phpbb_root_path}cache/container.$phpEx"); + return new phpbb_cache_container(); + } + + // If we don't have the cached container class, we make it now + // First, we create the temporary container so we can access the + // extension_manager + $tmp_container = phpbb_create_container($extensions, $phpbb_root_path, $phpEx); + $tmp_container->compile(); + + // Now we pass the enabled extension paths into the ext compiler extension + $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled()); + + // And create our final container + $container = phpbb_create_container($extensions, $phpbb_root_path, $phpEx); + + foreach ($passes as $pass) + { + $container->addCompilerPass($pass); + } + $container->compile(); + + // Lastly, we create our cached container class + $dumper = new PhpDumper($container); + $cached_container_dump = $dumper->dump(array( + 'class' => 'phpbb_cache_container', + 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', + )); + + $file = file_put_contents("{$phpbb_root_path}cache/container.$phpEx", $cached_container_dump); + + return $container; +} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 527108af08..65c72ad635 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -109,20 +109,28 @@ if (!defined('EXT_TABLE')) define('EXT_TABLE', $table_prefix . 'ext'); } -$phpbb_container = new ContainerBuilder(); -$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); -$loader->load('services.yml'); - -// We must include the DI processor class files because the class loader -// is not yet set up -require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); -$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); -$processor->process($phpbb_container); - // Setup class loader first -$phpbb_class_loader = $phpbb_container->get('class_loader'); -$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); +$phpbb_class_loader_ext->register(); + +// Set up container +$phpbb_container = phpbb_create_compiled_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_event_kernel_compiler_pass(), + ), + $phpbb_root_path . 'config.' . $phpEx, + $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'); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index f71e5ada54..9203a7d3bc 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -75,8 +75,6 @@ else // Include essential scripts require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); @@ -86,14 +84,18 @@ 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); -$phpbb_container = new ContainerBuilder(); -$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); -$loader->load('services.yml'); +// Setup class loader first +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); +$phpbb_class_loader_ext->register(); -$phpbb_container->setParameter('core.root_path', $phpbb_root_path); -$phpbb_container->setParameter('core.php_ext', $phpEx); +// Set up container +$phpbb_container = phpbb_create_install_container($phpbb_root_path, $phpEx); $phpbb_container->setAlias('cache.driver', 'cache.driver.install'); +$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); +$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php index f8fe060d99..9b9203e06a 100644 --- a/tests/event/dispatcher_test.php +++ b/tests/event/dispatcher_test.php @@ -11,7 +11,7 @@ class phpbb_event_dispatcher_test extends phpbb_test_case { public function test_trigger_event() { - $dispatcher = new phpbb_event_dispatcher(); + $dispatcher = new phpbb_event_dispatcher(new phpbb_mock_container_builder()); $dispatcher->addListener('core.test_event', function (phpbb_event_data $event) { $event['foo'] = $event['foo'] . '2'; diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php new file mode 100644 index 0000000000..8a81dd72d1 --- /dev/null +++ b/tests/mock/container_builder.php @@ -0,0 +1,160 @@ + Date: Sat, 20 Oct 2012 10:23:04 -0400 Subject: [PATCH 042/544] [feature/compiled-dic] Split if() over multiple lines for improved readability PHPBB3-11152 --- phpBB/includes/cache/driver/file.php | 6 +++++- phpBB/includes/cache/driver/memory.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php index b8876b03b4..b20c0064ea 100644 --- a/phpBB/includes/cache/driver/file.php +++ b/phpBB/includes/cache/driver/file.php @@ -214,7 +214,11 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base while (($entry = readdir($dir)) !== false) { - if (strpos($entry, 'container') !== 0 && strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + if (strpos($entry, 'container') !== 0 && + strpos($entry, 'sql_') !== 0 && + strpos($entry, 'data_') !== 0 && + strpos($entry, 'ctpl_') !== 0 && + strpos($entry, 'tpl_') !== 0) { continue; } diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php index 9ee32fff28..98ac02b161 100644 --- a/phpBB/includes/cache/driver/memory.php +++ b/phpBB/includes/cache/driver/memory.php @@ -162,7 +162,11 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base while (($entry = readdir($dir)) !== false) { - if (strpos($entry, 'container') !== 0 && strpos($entry, 'sql_') !== 0 && strpos($entry, 'data_') !== 0 && strpos($entry, 'ctpl_') !== 0 && strpos($entry, 'tpl_') !== 0) + if (strpos($entry, 'container') !== 0 && + strpos($entry, 'sql_') !== 0 && + strpos($entry, 'data_') !== 0 && + strpos($entry, 'ctpl_') !== 0 && + strpos($entry, 'tpl_') !== 0) { continue; } From 2f692ef3b9bf87375f1e0922f8f42a595bda9d88 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 10:34:42 -0400 Subject: [PATCH 043/544] [feature/compiled-dic] Remove redundant method call PHPBB3-11152 --- phpBB/install/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 9203a7d3bc..9d8e9e87aa 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -93,7 +93,6 @@ $phpbb_class_loader_ext->register(); // Set up container $phpbb_container = phpbb_create_install_container($phpbb_root_path, $phpEx); -$phpbb_container->setAlias('cache.driver', 'cache.driver.install'); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); From 996f63fb34de9f631374fb4b3fb0fb14598affa4 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 10:36:09 -0400 Subject: [PATCH 044/544] [feature/compiled-dic] Remove re-creation of class loader in install PHPBB3-11152 --- phpBB/install/index.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 9d8e9e87aa..0afa24066a 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -96,9 +96,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')); -$phpbb_class_loader = $phpbb_container->get('class_loader'); -$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); - // set up caching $cache = $phpbb_container->get('cache'); From d88e11413ac89ac2bfda303dd4ecaacef6dc8c0f Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 10:46:38 -0400 Subject: [PATCH 045/544] [feature/compiled-dic] Remove unused service definition PHPBB3-11152 --- phpBB/includes/functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 72c5a26bd5..d724374744 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5438,7 +5438,6 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $phpEx) $container->loadFromExtension($extension->getAlias()); } - $container->set('container', $container); $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); From 6d40b81dda242f5f07fe1e01430d70e6879d1885 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 10:58:35 -0400 Subject: [PATCH 046/544] [feature/compiled-dic] Remove unused function parameter PHPBB3-11152 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d724374744..ac63bd086c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5475,7 +5475,7 @@ function phpbb_create_install_container($phpbb_root_path, $phpEx) * @param string $phpEx PHP Extension * @return ContainerBuilder object (compiled) */ -function phpbb_create_compiled_container(array $extensions, array $passes, $config_file_path, $phpbb_root_path, $phpEx) +function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $phpEx) { // Check for our cached container; if it exists, use it if (file_exists("{$phpbb_root_path}cache/container.$phpEx")) From b20d852b7fc43431ade40ee97fd5ece5e3271d5d Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 16:57:21 -0400 Subject: [PATCH 047/544] [feature/compiled-dic] Remove HttpKernel-related stuff These things should be added in the Controller PR instead. PHPBB3-11152 --- phpBB/common.php | 4 +- phpBB/includes/event/kernel_compiler_pass.php | 72 -------------- phpBB/includes/event/kernel_subscriber.php | 94 ------------------- 3 files changed, 1 insertion(+), 169 deletions(-) delete mode 100644 phpBB/includes/event/kernel_compiler_pass.php delete mode 100644 phpBB/includes/event/kernel_subscriber.php diff --git a/phpBB/common.php b/phpBB/common.php index a681561619..fce08f3834 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,9 +104,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array( - new phpbb_event_kernel_compiler_pass(), - ), + array(), $phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx diff --git a/phpBB/includes/event/kernel_compiler_pass.php b/phpBB/includes/event/kernel_compiler_pass.php deleted file mode 100644 index 18b6661cd4..0000000000 --- a/phpBB/includes/event/kernel_compiler_pass.php +++ /dev/null @@ -1,72 +0,0 @@ -getDefinition('dispatcher'); - $user = $container->get('user'); - - foreach ($container->findTaggedServiceIds('kernel.event_listener') as $id => $events) - { - foreach ($events as $event) - { - $priority = isset($event['priority']) ? $event['priority'] : 0; - - if (!isset($event['event'])) - { - throw new InvalidArgumentException($user->lang('NO_EVENT_ATTRIBUTE', $id)); - } - - if (!isset($event['method'])) - { - $event['method'] = 'on'.preg_replace(array( - '/(?<=\b)[a-z]/ie', - '/[^a-z0-9]/i' - ), array('strtoupper("\\0")', ''), $event['event']); - } - - $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); - } - } - - foreach ($container->findTaggedServiceIds('kernel.event_subscriber') as $id => $attributes) - { - // We must assume that the class value has been correctly filled, even if the service is created by a factory - $class = $container->getDefinition($id)->getClass(); - - $refClass = new ReflectionClass($class); - $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; - if (!$refClass->implementsInterface($interface)) - { - throw new InvalidArgumentException($user->lang('SUBSCRIBER_WRONG_TYPE', $id, $interface)); - } - - $definition->addMethodCall('addSubscriberService', array($id, $class)); - } - } -} diff --git a/phpBB/includes/event/kernel_subscriber.php b/phpBB/includes/event/kernel_subscriber.php deleted file mode 100644 index 9737d9bc23..0000000000 --- a/phpBB/includes/event/kernel_subscriber.php +++ /dev/null @@ -1,94 +0,0 @@ -template = $template; - $this->user = $user; - } - - /** - * This listener is run when the KernelEvents::TERMINATE event is triggered - * This comes after a Response has been sent to the server; this is - * primarily cleanup stuff. - * - * @param PostResponseEvent $event - * @return null - */ - public function on_kernel_terminate(PostResponseEvent $event) - { - exit_handler(); - } - - /** - * This listener is run when the KernelEvents::EXCEPTION event is triggered - * - * @param GetResponseForExceptionEvent $event - * @return null - */ - public function on_kernel_exception(GetResponseForExceptionEvent $event) - { - page_header($this->user->lang('INFORMATION')); - - $this->template->assign_vars(array( - 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), - 'MESSAGE_TEXT' => $event->getException()->getMessage(), - )); - - $this->template->set_filenames(array( - 'body' => 'message_body.html', - )); - - page_footer(true, false, false); - - $event->setResponse(new Response($this->template->return_display('body'), 404)); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::TERMINATE => 'on_kernel_terminate', - KernelEvents::EXCEPTION => 'on_kernel_exception', - ); - } -} From f9f03435f0681ab1aba1ff23d84fb4101be37e46 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 17:03:06 -0400 Subject: [PATCH 048/544] [feature/compiled-dic] Move this to the other PR PHPBB3-11152 --- phpBB/download/file.php | 4 +--- phpBB/install/database_update.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 85dc8acb81..3e71bf9961 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -63,9 +63,7 @@ if (isset($_GET['avatar'])) new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array( - new phpbb_event_kernel_compiler_pass(), - ), + array(), $phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 65c72ad635..3d296545b4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,9 +121,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array( - new phpbb_event_kernel_compiler_pass(), - ), + array(), $phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx From ad3edf505a9e9ef7f139b033f70a1106539ce0de Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 14:20:52 -0400 Subject: [PATCH 049/544] [feature/compiled-dic] Add HttpKernel; the Extension class is loaded from it The phpbb_di_extension_* classes extend the Extension class that is included in the HttpKernel component. If I don't include HttpKernel I have to implement the ExtensionInterface from the DependencyInjection component and have to define all of the methods; this way, I can just overwrite what I need. PHPBB3-10864 --- phpBB/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/composer.json b/phpBB/composer.json index 5e88144bc4..380bdc367c 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -4,6 +4,7 @@ "symfony/config": "2.1.*", "symfony/dependency-injection": "2.1.*", "symfony/event-dispatcher": "2.1.*", + "symfony/http-kernel": "2.1.*", "symfony/yaml": "2.1.*" }, "require-dev": { From cb2725dd5a04118de8628e10f940e926f4fa8fa1 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 16:09:43 -0400 Subject: [PATCH 050/544] [feature/compiled-dic] Fix cron task loading We cannot use container tags at run time if we are using a cached, compiled container object (i.e. phpbb_cache_container) so we have to load them beforehand. PHPBB3-11152 --- phpBB/common.php | 5 +- phpBB/composer.lock | 750 ++++++++++++++++++++++-- phpBB/config/services.yml | 4 + phpBB/download/file.php | 5 +- phpBB/includes/cron/task/collection.php | 72 +++ phpBB/includes/cron/task/provider.php | 27 +- phpBB/includes/di/pass/cron.php | 38 ++ phpBB/install/database_update.php | 5 +- 8 files changed, 856 insertions(+), 50 deletions(-) create mode 100644 phpBB/includes/cron/task/collection.php create mode 100644 phpBB/includes/di/pass/cron.php diff --git a/phpBB/common.php b/phpBB/common.php index fce08f3834..6a7def1884 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,8 +104,9 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 6b0d3584d1..44c2723842 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,67 +1,749 @@ { - "hash": "1632798bc1d5298a4f5bd3087c972a9f", + "hash": "f83c386aaaf04acc7fd1724dd46c0127", "packages": [ { - "package": "symfony/config", - "version": "v2.1.0-RC1" + "name": "symfony/config", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Config/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Config": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/dependency-injection", - "version": "v2.1.0-RC1" + "name": "symfony/dependency-injection", + "version": "v2.1.2", + "target-dir": "Symfony/Component/DependencyInjection", + "source": { + "type": "git", + "url": "https://github.com/symfony/DependencyInjection", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/DependencyInjection/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/yaml": "2.1.*", + "symfony/config": "2.1.*" + }, + "suggest": { + "symfony/yaml": "2.1.*", + "symfony/config": "2.1.*" + }, + "time": "2012-09-17 13:41:57", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\DependencyInjection": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/event-dispatcher", - "version": "v2.1.0-RC1" + "name": "symfony/event-dispatcher", + "version": "v2.1.2", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/EventDispatcher/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": "2.1.*" + }, + "suggest": { + "symfony/dependency-injection": "2.1.*", + "symfony/http-kernel": "2.1.*" + }, + "time": "2012-09-10 03:53:42", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/yaml", - "version": "v2.1.0-RC1" + "name": "symfony/http-foundation", + "version": "v2.1.2", + "target-dir": "Symfony/Component/HttpFoundation", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpFoundation", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/HttpFoundation/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-09-18 09:09:52", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation": "", + "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpFoundation Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/http-kernel", + "version": "v2.1.2", + "target-dir": "Symfony/Component/HttpKernel", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpKernel", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/HttpKernel/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/event-dispatcher": "2.1.*", + "symfony/http-foundation": "2.1.*" + }, + "require-dev": { + "symfony/browser-kit": "2.1.*", + "symfony/class-loader": "2.1.*", + "symfony/config": "2.1.*", + "symfony/console": "2.1.*", + "symfony/dependency-injection": "2.1.*", + "symfony/finder": "2.1.*", + "symfony/process": "2.1.*", + "symfony/routing": "2.1.*" + }, + "suggest": { + "symfony/browser-kit": "2.1.*", + "symfony/class-loader": "2.1.*", + "symfony/config": "2.1.*", + "symfony/console": "2.1.*", + "symfony/dependency-injection": "2.1.*", + "symfony/finder": "2.1.*" + }, + "time": "2012-09-20 00:13:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpKernel": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpKernel Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/yaml", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml", + "reference": "v2.1.0-RC2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Yaml/zipball/v2.1.0-RC2", + "reference": "v2.1.0-RC2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com" } ], "packages-dev": [ { - "package": "fabpot/goutte", + "name": "fabpot/goutte", "version": "dev-master", - "alias-pretty-version": "1.0.x-dev", - "alias-version": "1.0.9999999.9999999-dev" + "source": { + "type": "git", + "url": "https://github.com/fabpot/Goutte", + "reference": "e1c3306617e350ac17e7631166fd3fd7d689e8ea" + }, + "dist": { + "type": "zip", + "url": "https://github.com/fabpot/Goutte/zipball/e1c3306617e350ac17e7631166fd3fd7d689e8ea", + "reference": "e1c3306617e350ac17e7631166fd3fd7d689e8ea", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/browser-kit": "2.1.*", + "symfony/css-selector": "2.1.*", + "symfony/dom-crawler": "2.1.*", + "symfony/finder": "2.1.*", + "symfony/process": "2.1.*", + "ext-curl": "*", + "guzzle/http": "2.8.*" + }, + "time": "1349861753", + "type": "application", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-0": { + "Goutte": "." + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A simple PHP Web Scraper", + "homepage": "https://github.com/fabpot/Goutte", + "keywords": [ + "scraper" + ] }, { - "package": "fabpot/goutte", - "version": "dev-master", - "source-reference": "6d26279344736f6983a969e46afef082ebf30a67", - "commit-date": "1345141401" + "name": "guzzle/common", + "version": "v2.8.8", + "target-dir": "Guzzle/Common", + "source": { + "type": "git", + "url": "git://github.com/guzzle/common.git", + "reference": "v2.8.8" + }, + "dist": { + "type": "zip", + "url": "https://github.com/guzzle/common/zipball/v2.8.8", + "reference": "v2.8.8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "symfony/event-dispatcher": "2.1.*" + }, + "time": "2012-10-15 17:42:47", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Guzzle\\Common": "" + } + }, + "license": [ + "MIT" + ], + "description": "Common libraries used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "log", + "event", + "cache", + "validation", + "Socket", + "common", + "batch", + "inflection" + ] }, { - "package": "guzzle/common", - "version": "v2.8.4" + "name": "guzzle/http", + "version": "v2.8.8", + "target-dir": "Guzzle/Http", + "source": { + "type": "git", + "url": "git://github.com/guzzle/http.git", + "reference": "v2.8.8" + }, + "dist": { + "type": "zip", + "url": "https://github.com/guzzle/http/zipball/v2.8.8", + "reference": "v2.8.8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "guzzle/common": "self.version", + "guzzle/parser": "self.version" + }, + "time": "2012-10-15 17:42:47", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Guzzle\\Http": "" + } + }, + "license": [ + "MIT" + ], + "description": "HTTP libraries used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "curl", + "http", + "http client", + "client", + "Guzzle" + ] }, { - "package": "guzzle/http", - "version": "v2.8.4" + "name": "guzzle/parser", + "version": "v2.8.8", + "target-dir": "Guzzle/Parser", + "source": { + "type": "git", + "url": "git://github.com/guzzle/parser.git", + "reference": "v2.8.8" + }, + "dist": { + "type": "zip", + "url": "https://github.com/guzzle/parser/zipball/v2.8.8", + "reference": "v2.8.8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2012-09-20 13:28:06", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Guzzle\\Parser": "" + } + }, + "license": [ + "MIT" + ], + "description": "Interchangeable parsers used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "http", + "url", + "message", + "cookie", + "URI Template" + ] }, { - "package": "guzzle/parser", - "version": "v2.8.4" + "name": "symfony/browser-kit", + "version": "v2.1.2", + "target-dir": "Symfony/Component/BrowserKit", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/BrowserKit/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/dom-crawler": "2.1.*" + }, + "require-dev": { + "symfony/process": "2.1.*", + "symfony/css-selector": "2.1.*" + }, + "suggest": { + "symfony/process": "2.1.*" + }, + "time": "2012-09-10 03:53:42", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\BrowserKit": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony BrowserKit Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/browser-kit", - "version": "v2.1.0-RC1" + "name": "symfony/css-selector", + "version": "v2.1.2", + "target-dir": "Symfony/Component/CssSelector", + "source": { + "type": "git", + "url": "https://github.com/symfony/CssSelector", + "reference": "v2.1.0-RC2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/CssSelector/zipball/v2.1.0-RC2", + "reference": "v2.1.0-RC2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\CssSelector": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony CssSelector Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/css-selector", - "version": "v2.1.0-RC1" + "name": "symfony/dom-crawler", + "version": "v2.1.2", + "target-dir": "Symfony/Component/DomCrawler", + "source": { + "type": "git", + "url": "https://github.com/symfony/DomCrawler", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/DomCrawler/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/css-selector": "2.1.*" + }, + "suggest": { + "symfony/css-selector": "2.1.*" + }, + "time": "2012-09-10 03:53:42", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\DomCrawler": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DomCrawler Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/dom-crawler", - "version": "v2.1.0-RC1" + "name": "symfony/finder", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Finder/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Finder": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/finder", - "version": "v2.1.0-RC1" - }, - { - "package": "symfony/process", - "version": "v2.1.0-RC1" + "name": "symfony/process", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Process/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-09-18 15:37:29", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Process": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "http://symfony.com" } ], "aliases": [ diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 6c904ac2c8..b77c3d6c3f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -47,8 +47,12 @@ services: cron.task_provider: class: phpbb_cron_task_provider arguments: + - @cron.task_collection - @service_container + cron.task_collection: + class: phpbb_cron_task_collection + cron.manager: class: phpbb_cron_manager arguments: diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 3e71bf9961..7ffd335daa 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -63,8 +63,9 @@ if (isset($_GET['avatar'])) new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); diff --git a/phpBB/includes/cron/task/collection.php b/phpBB/includes/cron/task/collection.php new file mode 100644 index 0000000000..d05be9012c --- /dev/null +++ b/phpBB/includes/cron/task/collection.php @@ -0,0 +1,72 @@ +tasks[$offset]); + } + + /** + * ArrayAccess method + * + * @param mixed $offset Array offset + */ + public function offsetGet($offset) + { + return $this->offsetExists($offset) ? $this->tasks[$offset] : null; + } + + /** + * ArrayAccess method + * + * @param mixed $offset Array offset + * @param mixed $value New value + */ + public function offsetSet($offset, $value) + { + if ($offset === null) + { + $this->tasks[] = $value; + } + else + { + $this->tasks[$offset] = $value; + } + } + + /** + * ArrayAccess method + * + * @param mixed $offset Array offset + */ + public function offsetUnset($offset) + { + $this->tasks[$offset] = null; + } +} diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php index 134723ebd1..08e54a651a 100644 --- a/phpBB/includes/cron/task/provider.php +++ b/phpBB/includes/cron/task/provider.php @@ -26,10 +26,11 @@ use Symfony\Component\DependencyInjection\TaggedContainerInterface; */ class phpbb_cron_task_provider implements IteratorAggregate { - private $container; + private $tasks; - public function __construct(TaggedContainerInterface $container) + public function __construct(phpbb_cron_task_collection $tasks, TaggedContainerInterface $container) { + $this->tasks = $tasks; $this->container = $container; } @@ -40,18 +41,24 @@ class phpbb_cron_task_provider implements IteratorAggregate */ public function getIterator() { - $definitions = $this->container->findTaggedServiceIds('cron.task'); - $tasks = array(); - foreach ($definitions as $name => $definition) + foreach ($this->tasks as $names) { - $task = $this->container->get($name); - if ($task instanceof phpbb_cron_task_base) + foreach ($names as $name) { - $task->set_name($name); - } + if (!$this->container->has($name)) + { + continue; + } - $tasks[] = $task; + $task = $this->container->get($name); + if ($task instanceof phpbb_cron_task_base) + { + $task->set_name($name); + } + + $tasks[] = $task; + } } return new ArrayIterator($tasks); diff --git a/phpBB/includes/di/pass/cron.php b/phpBB/includes/di/pass/cron.php new file mode 100644 index 0000000000..b5fc4af9fc --- /dev/null +++ b/phpBB/includes/di/pass/cron.php @@ -0,0 +1,38 @@ +getDefinition('cron.task_collection'); + + foreach ($container->findTaggedServiceIds('cron.task') as $id => $data) + { + $definition->addMethodCall('offsetSet', array(null, $id)); + } + } +} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3d296545b4..1734272486 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,8 +121,9 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); From a6428c8dc3c211675da5e7e58503849791d2d3e5 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 22 Oct 2012 11:17:49 -0400 Subject: [PATCH 051/544] [feature/compiled-dic] Fix cron tasks again PHPBB3-11152 --- phpBB/config/services.yml | 10 ++-- phpBB/includes/cron/task/collection.php | 51 ++++++------------- phpBB/includes/cron/task/provider.php | 66 ------------------------- phpBB/includes/di/pass/cron.php | 2 +- 4 files changed, 18 insertions(+), 111 deletions(-) delete mode 100644 phpBB/includes/cron/task/provider.php diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index b77c3d6c3f..b1aaf1660d 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -44,19 +44,15 @@ services: - @cache.driver - %tables.config% - cron.task_provider: - class: phpbb_cron_task_provider - arguments: - - @cron.task_collection - - @service_container - cron.task_collection: class: phpbb_cron_task_collection + arguments: + - @service_container cron.manager: class: phpbb_cron_manager arguments: - - @cron.task_provider + - @cron.task_collection - %core.root_path% - %core.php_ext% diff --git a/phpBB/includes/cron/task/collection.php b/phpBB/includes/cron/task/collection.php index d05be9012c..84607dc28d 100644 --- a/phpBB/includes/cron/task/collection.php +++ b/phpBB/includes/cron/task/collection.php @@ -15,58 +15,35 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\DependencyInjection\TaggedContainerInterface; + /** * Collects cron tasks * * @package phpBB3 */ -class phpbb_cron_task_collection implements ArrayAccess +class phpbb_cron_task_collection extends ArrayObject { /** - * ArrayAccess method + * Constructor * - * @param mixed $offset Array offset + * @param TaggedContainerInterface $container Container object */ - public function offsetExists($offset) + public function __construct(TaggedContainerInterface $container) { - return isset($this->tasks[$offset]); + $this->container = $container; } /** - * ArrayAccess method + * Add a cron task to the collection * - * @param mixed $offset Array offset + * @param string $name The service name of the cron task + * @return null */ - public function offsetGet($offset) + public function add($name) { - return $this->offsetExists($offset) ? $this->tasks[$offset] : null; - } - - /** - * ArrayAccess method - * - * @param mixed $offset Array offset - * @param mixed $value New value - */ - public function offsetSet($offset, $value) - { - if ($offset === null) - { - $this->tasks[] = $value; - } - else - { - $this->tasks[$offset] = $value; - } - } - - /** - * ArrayAccess method - * - * @param mixed $offset Array offset - */ - public function offsetUnset($offset) - { - $this->tasks[$offset] = null; + $task = $this->container->get($name); + $task->set_name($name); + $this->offsetSet($name, $task); } } diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php deleted file mode 100644 index 08e54a651a..0000000000 --- a/phpBB/includes/cron/task/provider.php +++ /dev/null @@ -1,66 +0,0 @@ -tasks = $tasks; - $this->container = $container; - } - - /** - * Retrieve an iterator over all items - * - * @return ArrayIterator An iterator for the array of cron tasks - */ - public function getIterator() - { - $tasks = array(); - foreach ($this->tasks as $names) - { - foreach ($names as $name) - { - if (!$this->container->has($name)) - { - continue; - } - - $task = $this->container->get($name); - if ($task instanceof phpbb_cron_task_base) - { - $task->set_name($name); - } - - $tasks[] = $task; - } - } - - return new ArrayIterator($tasks); - } -} diff --git a/phpBB/includes/di/pass/cron.php b/phpBB/includes/di/pass/cron.php index b5fc4af9fc..53fe0a61c8 100644 --- a/phpBB/includes/di/pass/cron.php +++ b/phpBB/includes/di/pass/cron.php @@ -32,7 +32,7 @@ class phpbb_di_pass_cron implements CompilerPassInterface foreach ($container->findTaggedServiceIds('cron.task') as $id => $data) { - $definition->addMethodCall('offsetSet', array(null, $id)); + $definition->addMethodCall('add', array($id)); } } } From 1e3a5dde7d232054d86f91f6908cc23f8b726fdf Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 22 Oct 2012 11:27:07 -0400 Subject: [PATCH 052/544] [feature/compiled-dic] Remove old test PHPBB3-11152 --- tests/cron/task_provider_test.php | 50 ------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 tests/cron/task_provider_test.php diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php deleted file mode 100644 index ec853bb3ba..0000000000 --- a/tests/cron/task_provider_test.php +++ /dev/null @@ -1,50 +0,0 @@ -tasks = array( - 'phpbb_cron_task_core_dummy_task', - 'phpbb_cron_task_core_second_dummy_task', - 'phpbb_ext_testext_cron_dummy_task', - ); - - $container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface'); - $container - ->expects($this->once()) - ->method('findTaggedServiceIds') - ->will($this->returnValue(array_flip($this->tasks))); - $container - ->expects($this->any()) - ->method('get') - ->will($this->returnCallback(function ($name) { - return new $name; - })); - - $this->provider = new phpbb_cron_task_provider($container); - } - - public function test_manager_finds_shipped_tasks() - { - $task_names = array(); - foreach ($this->provider as $task) - { - $task_names[] = $task->get_name(); - } - sort($task_names); - - $this->assertEquals(array( - 'phpbb_cron_task_core_dummy_task', - 'phpbb_cron_task_core_second_dummy_task', - 'phpbb_ext_testext_cron_dummy_task', - ), $task_names); - } -} From af3f07d8c9d79b305f34eb19aa100786d4a3faf8 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 22 Oct 2012 12:17:06 -0400 Subject: [PATCH 053/544] [feature/compiled-dic] Fix root path when container is created after install PHPBB3-11152 --- phpBB/includes/functions.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ac63bd086c..bb98ba4eb9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5484,6 +5484,23 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb return new phpbb_cache_container(); } + // When the board is first installed, the container is initiall created on + // the send_statistics step in the ACP. In that case, the phpbb_root_path + // is "./../". This becomes forever stored in the cached container as the + // core.root_path property, until the container is deleted and recached + // We need to ensure that this does not happen. + // + // However, if we change the root path here, it will try to create a + // ./adm/cache/container.php later on because the root path is wrong + // We need to store the current $phpbb_root_path for use later and then we + // can change it for the controller + $real_root_path = $phpbb_root_path; + if (defined('ADMIN_START')) + { + // Remove the first instance of ../ in the root path + $phpbb_root_path = preg_replace('/..\//', '', $phpbb_root_path, 1); + } + // If we don't have the cached container class, we make it now // First, we create the temporary container so we can access the // extension_manager @@ -5509,7 +5526,8 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', )); - $file = file_put_contents("{$phpbb_root_path}cache/container.$phpEx", $cached_container_dump); + // Use the $real_root_path in case $phpbb_root_path was changed above + $file = file_put_contents("{$real_root_path}cache/container.$phpEx", $cached_container_dump); return $container; } From c16bb2b2c62f3fa68716b40745cba437cebe5433 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 2 Nov 2012 16:40:12 -0400 Subject: [PATCH 054/544] [feature/compiled-dic] Purge cache to make ext services available right away PHPBB3-11152 --- phpBB/includes/extension/manager.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index cfa6a0e000..bfd4edde93 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -195,7 +195,7 @@ class phpbb_extension_manager if ($this->cache) { - $this->cache->destroy($this->cache_name); + $this->cache->purge(); } return !$active; @@ -252,7 +252,7 @@ class phpbb_extension_manager if ($this->cache) { - $this->cache->destroy($this->cache_name); + $this->cache->purge(); } return true; @@ -272,7 +272,7 @@ class phpbb_extension_manager if ($this->cache) { - $this->cache->destroy($this->cache_name); + $this->cache->purge(); } return false; @@ -335,7 +335,7 @@ class phpbb_extension_manager if ($this->cache) { - $this->cache->destroy($this->cache_name); + $this->cache->purge(); } return true; @@ -349,7 +349,7 @@ class phpbb_extension_manager if ($this->cache) { - $this->cache->destroy($this->cache_name); + $this->cache->purge(); } return false; From e6a6e85d7e6ce53eb7167ea82f08e06c55a87b00 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 2 Nov 2012 16:41:51 -0400 Subject: [PATCH 055/544] [feature/compiled-dic] Update the composer.lock file PHPBB3-11152 --- phpBB/composer.lock | 120 ++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 44c2723842..69e4a2b4b8 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,25 +1,25 @@ { - "hash": "f83c386aaaf04acc7fd1724dd46c0127", + "hash": "407cc89f4bb0e409146c863dee51b0ae", "packages": [ { "name": "symfony/config", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Config/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/Config/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-22 06:48:41", + "time": "2012-10-20 00:10:30", "type": "library", "extra": { "branch-alias": { @@ -50,17 +50,17 @@ }, { "name": "symfony/dependency-injection", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/DependencyInjection/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/DependencyInjection/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { @@ -74,7 +74,7 @@ "symfony/yaml": "2.1.*", "symfony/config": "2.1.*" }, - "time": "2012-09-17 13:41:57", + "time": "2012-10-22 07:37:12", "type": "library", "extra": { "branch-alias": { @@ -105,17 +105,17 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/EventDispatcher/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/EventDispatcher/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { @@ -128,7 +128,7 @@ "symfony/dependency-injection": "2.1.*", "symfony/http-kernel": "2.1.*" }, - "time": "2012-09-10 03:53:42", + "time": "2012-10-04 08:17:57", "type": "library", "extra": { "branch-alias": { @@ -159,23 +159,23 @@ }, { "name": "symfony/http-foundation", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/HttpFoundation/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/HttpFoundation/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-09-18 09:09:52", + "time": "2012-10-20 00:10:30", "type": "library", "extra": { "branch-alias": { @@ -207,17 +207,17 @@ }, { "name": "symfony/http-kernel", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/HttpKernel/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/HttpKernel/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { @@ -243,7 +243,7 @@ "symfony/dependency-injection": "2.1.*", "symfony/finder": "2.1.*" }, - "time": "2012-09-20 00:13:00", + "time": "2012-10-30 01:14:14", "type": "library", "extra": { "branch-alias": { @@ -274,23 +274,23 @@ }, { "name": "symfony/yaml", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml", - "reference": "v2.1.0-RC2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Yaml/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/Yaml/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-22 06:48:41", + "time": "2012-10-29 04:15:41", "type": "library", "extra": { "branch-alias": { @@ -327,12 +327,12 @@ "source": { "type": "git", "url": "https://github.com/fabpot/Goutte", - "reference": "e1c3306617e350ac17e7631166fd3fd7d689e8ea" + "reference": "f2940f9c7c1f409159f5e9f512e575946c5cff48" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Goutte/zipball/e1c3306617e350ac17e7631166fd3fd7d689e8ea", - "reference": "e1c3306617e350ac17e7631166fd3fd7d689e8ea", + "url": "https://github.com/fabpot/Goutte/zipball/f2940f9c7c1f409159f5e9f512e575946c5cff48", + "reference": "f2940f9c7c1f409159f5e9f512e575946c5cff48", "shasum": "" }, "require": { @@ -345,7 +345,7 @@ "ext-curl": "*", "guzzle/http": "2.8.*" }, - "time": "1349861753", + "time": "1351086217", "type": "application", "extra": { "branch-alias": { @@ -498,17 +498,17 @@ }, { "name": "symfony/browser-kit", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/BrowserKit", "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/BrowserKit/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/BrowserKit/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { @@ -522,7 +522,7 @@ "suggest": { "symfony/process": "2.1.*" }, - "time": "2012-09-10 03:53:42", + "time": "2012-10-25 06:11:50", "type": "library", "extra": { "branch-alias": { @@ -553,23 +553,23 @@ }, { "name": "symfony/css-selector", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector", - "reference": "v2.1.0-RC2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/CssSelector/zipball/v2.1.0-RC2", - "reference": "v2.1.0-RC2", + "url": "https://github.com/symfony/CssSelector/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-22 06:48:41", + "time": "2012-10-04 08:17:57", "type": "library", "extra": { "branch-alias": { @@ -600,17 +600,17 @@ }, { "name": "symfony/dom-crawler", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/DomCrawler/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/DomCrawler/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { @@ -622,7 +622,7 @@ "suggest": { "symfony/css-selector": "2.1.*" }, - "time": "2012-09-10 03:53:42", + "time": "2012-10-18 14:16:01", "type": "library", "extra": { "branch-alias": { @@ -653,23 +653,23 @@ }, { "name": "symfony/finder", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Finder/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/Finder/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-08-22 06:48:41", + "time": "2012-10-20 00:10:30", "type": "library", "extra": { "branch-alias": { @@ -700,23 +700,23 @@ }, { "name": "symfony/process", - "version": "v2.1.2", + "version": "v2.1.3", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process", - "reference": "v2.1.2" + "reference": "v2.1.3" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Process/zipball/v2.1.2", - "reference": "v2.1.2", + "url": "https://github.com/symfony/Process/zipball/v2.1.3", + "reference": "v2.1.3", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-09-18 15:37:29", + "time": "2012-10-20 00:10:30", "type": "library", "extra": { "branch-alias": { From 2de8827b1e35d7e522303cadf37da4878bdc89a3 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 2 Nov 2012 16:42:35 -0400 Subject: [PATCH 056/544] [feature/compiled-dic] Use an absolute path for core.root_path parameter PHPBB3-11152 --- phpBB/includes/functions.php | 40 +++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bb98ba4eb9..b7905c5510 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5484,35 +5484,34 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb return new phpbb_cache_container(); } - // When the board is first installed, the container is initiall created on - // the send_statistics step in the ACP. In that case, the phpbb_root_path - // is "./../". This becomes forever stored in the cached container as the - // core.root_path property, until the container is deleted and recached - // We need to ensure that this does not happen. - // - // However, if we change the root path here, it will try to create a - // ./adm/cache/container.php later on because the root path is wrong - // We need to store the current $phpbb_root_path for use later and then we - // can change it for the controller - $real_root_path = $phpbb_root_path; + // When the board is first installed, the container is initially created + // during the send_statistics step in the ACP. At that point, the path + // relative to the board root is "./../". This becomes forever stored in + // the cached container as the core.root_path property, until the + // container is deleted and recached. We need to ensure that this does + // not happen. if (defined('ADMIN_START')) { // Remove the first instance of ../ in the root path - $phpbb_root_path = preg_replace('/..\//', '', $phpbb_root_path, 1); + $phpbb_root_path = preg_replace('/\.\.\//', '', $phpbb_root_path, 1); } - // If we don't have the cached container class, we make it now - // First, we create the temporary container so we can access the - // extension_manager - $tmp_container = phpbb_create_container($extensions, $phpbb_root_path, $phpEx); + // We must use an absolute path in the container because we cannot + // change the value at runtime when accessing it in different + // directory levels. + $phpbb_absolute_path = phpbb_realpath($phpbb_root_path); + + // Create a temporary container for access to the ext.manager service + $tmp_container = phpbb_create_container($extensions, $phpbb_absolute_path, $phpEx); $tmp_container->compile(); - // Now we pass the enabled extension paths into the ext compiler extension + // Now pass the enabled extension paths into the ext compiler extension $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled()); - // And create our final container - $container = phpbb_create_container($extensions, $phpbb_root_path, $phpEx); + // Create the final container to be compiled and cached + $container = phpbb_create_container($extensions, $phpbb_absolute_path, $phpEx); + // Compile the container foreach ($passes as $pass) { $container->addCompilerPass($pass); @@ -5526,8 +5525,7 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', )); - // Use the $real_root_path in case $phpbb_root_path was changed above - $file = file_put_contents("{$real_root_path}cache/container.$phpEx", $cached_container_dump); + $file = file_put_contents("{$phpbb_absolute_path}cache/container.{$phpEx}", $cached_container_dump); return $container; } From 3f2cbaac34e1cf126c73bebc7dcc3cdbd203d1b2 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 2 Nov 2012 18:36:52 -0400 Subject: [PATCH 057/544] [feature/compiled-dic] Rename $phpEx to $php_ext in new code PHPBB3-11152 --- phpBB/includes/functions.php | 40 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b7905c5510..b4db1ff891 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5425,10 +5425,10 @@ function phpbb_to_numeric($input) * * @param array $extensions Array of Container extension objects * @param string $phpbb_root_path Root path -* @param string $phpEx PHP Extension +* @param string $php_ext PHP Extension * @return ContainerBuilder object */ -function phpbb_create_container(array $extensions, $phpbb_root_path, $phpEx) +function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) { $container = new ContainerBuilder(); @@ -5439,7 +5439,7 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $phpEx) } $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.php_ext', $phpEx); + $container->setParameter('core.php_ext', $php_ext); return $container; } @@ -5448,10 +5448,10 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $phpEx) * Create installer container * * @param string $phpbb_root_path Root path -* @param string $phpEx PHP Extension +* @param string $php_ext PHP Extension * @return ContainerBuilder object */ -function phpbb_create_install_container($phpbb_root_path, $phpEx) +function phpbb_create_install_container($phpbb_root_path, $php_ext) { // We have to do it like this instead of with extensions $container = new ContainerBuilder(); @@ -5459,7 +5459,7 @@ function phpbb_create_install_container($phpbb_root_path, $phpEx) $loader->load('services.yml'); $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.php_ext', $phpEx); + $container->setParameter('core.php_ext', $php_ext); $container->setAlias('cache.driver', 'cache.driver.install'); @@ -5472,44 +5472,32 @@ function phpbb_create_install_container($phpbb_root_path, $phpEx) * @param array $extensions Array of Container extension objects * @param array $passes Array of Compiler Pass objects * @param string $phpbb_root_path Root path -* @param string $phpEx PHP Extension +* @param string $php_ext PHP Extension * @return ContainerBuilder object (compiled) */ -function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $phpEx) +function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $php_ext) { // Check for our cached container; if it exists, use it - if (file_exists("{$phpbb_root_path}cache/container.$phpEx")) + if (file_exists("{$phpbb_root_path}cache/container.$php_ext")) { - require("{$phpbb_root_path}cache/container.$phpEx"); + require("{$phpbb_root_path}cache/container.$php_ext"); return new phpbb_cache_container(); } - // When the board is first installed, the container is initially created - // during the send_statistics step in the ACP. At that point, the path - // relative to the board root is "./../". This becomes forever stored in - // the cached container as the core.root_path property, until the - // container is deleted and recached. We need to ensure that this does - // not happen. - if (defined('ADMIN_START')) - { - // Remove the first instance of ../ in the root path - $phpbb_root_path = preg_replace('/\.\.\//', '', $phpbb_root_path, 1); - } - // We must use an absolute path in the container because we cannot // change the value at runtime when accessing it in different // directory levels. - $phpbb_absolute_path = phpbb_realpath($phpbb_root_path); + $phpbb_absolute_path = phpbb_realpath($phpbb_root_path) . '/'; // Create a temporary container for access to the ext.manager service - $tmp_container = phpbb_create_container($extensions, $phpbb_absolute_path, $phpEx); + $tmp_container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); $tmp_container->compile(); // Now pass the enabled extension paths into the ext compiler extension $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled()); // Create the final container to be compiled and cached - $container = phpbb_create_container($extensions, $phpbb_absolute_path, $phpEx); + $container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); // Compile the container foreach ($passes as $pass) @@ -5525,7 +5513,7 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', )); - $file = file_put_contents("{$phpbb_absolute_path}cache/container.{$phpEx}", $cached_container_dump); + $file = file_put_contents("{$phpbb_absolute_path}cache/container.{$php_ext}", $cached_container_dump); return $container; } From 897e8f2e8361839a92acae7e77225ef212e44647 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 9 Nov 2012 23:00:44 +0100 Subject: [PATCH 058/544] [ticket/11152] Move container functions to a separate function file PHPBB3-11152 --- phpBB/common.php | 1 + phpBB/download/file.php | 3 +- phpBB/includes/functions.php | 105 ---------------------- phpBB/includes/functions_container.php | 119 +++++++++++++++++++++++++ phpBB/install/database_update.php | 7 +- phpBB/install/index.php | 1 + 6 files changed, 127 insertions(+), 109 deletions(-) create mode 100644 phpBB/includes/functions_container.php diff --git a/phpBB/common.php b/phpBB/common.php index 6a7def1884..e24f9b4359 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -84,6 +84,7 @@ require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/db/' . ltrim($dbms, 'dbal_') . '.' . $phpEx); diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 7ffd335daa..eb1ec85afe 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -48,6 +48,7 @@ if (isset($_GET['avatar'])) 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_container.' . $phpEx); require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); @@ -404,7 +405,7 @@ else $disallowed[$attach['extension']] = $attach['extension']; continue; } - + $prefix = ''; if ($topic_id) { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b4db1ff891..43b81f3f26 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -7,13 +7,6 @@ * */ -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - /** * @ignore */ @@ -5419,101 +5412,3 @@ function phpbb_to_numeric($input) { return ($input > PHP_INT_MAX) ? (float) $input : (int) $input; } - -/** -* Create the ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object -*/ -function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) -{ - $container = new ContainerBuilder(); - - foreach ($extensions as $extension) - { - $container->registerExtension($extension); - $container->loadFromExtension($extension->getAlias()); - } - - $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.php_ext', $php_ext); - - return $container; -} - -/** -* Create installer container -* -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object -*/ -function phpbb_create_install_container($phpbb_root_path, $php_ext) -{ - // We have to do it like this instead of with extensions - $container = new ContainerBuilder(); - $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); - $loader->load('services.yml'); - - $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.php_ext', $php_ext); - - $container->setAlias('cache.driver', 'cache.driver.install'); - - return $container; -} - -/** -* Create a compiled ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $php_ext) -{ - // Check for our cached container; if it exists, use it - if (file_exists("{$phpbb_root_path}cache/container.$php_ext")) - { - require("{$phpbb_root_path}cache/container.$php_ext"); - return new phpbb_cache_container(); - } - - // We must use an absolute path in the container because we cannot - // change the value at runtime when accessing it in different - // directory levels. - $phpbb_absolute_path = phpbb_realpath($phpbb_root_path) . '/'; - - // Create a temporary container for access to the ext.manager service - $tmp_container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); - $tmp_container->compile(); - - // Now pass the enabled extension paths into the ext compiler extension - $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled()); - - // Create the final container to be compiled and cached - $container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); - - // Compile the container - foreach ($passes as $pass) - { - $container->addCompilerPass($pass); - } - $container->compile(); - - // Lastly, we create our cached container class - $dumper = new PhpDumper($container); - $cached_container_dump = $dumper->dump(array( - 'class' => 'phpbb_cache_container', - 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', - )); - - $file = file_put_contents("{$phpbb_absolute_path}cache/container.{$php_ext}", $cached_container_dump); - - return $container; -} diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php new file mode 100644 index 0000000000..88adc64882 --- /dev/null +++ b/phpBB/includes/functions_container.php @@ -0,0 +1,119 @@ +registerExtension($extension); + $container->loadFromExtension($extension->getAlias()); + } + + $container->setParameter('core.root_path', $phpbb_root_path); + $container->setParameter('core.php_ext', $php_ext); + + return $container; +} + +/** +* Create installer container +* +* @param string $phpbb_root_path Root path +* @param string $php_ext PHP Extension +* @return ContainerBuilder object +*/ +function phpbb_create_install_container($phpbb_root_path, $php_ext) +{ + // We have to do it like this instead of with extensions + $container = new ContainerBuilder(); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); + $loader->load('services.yml'); + + $container->setParameter('core.root_path', $phpbb_root_path); + $container->setParameter('core.php_ext', $php_ext); + + $container->setAlias('cache.driver', 'cache.driver.install'); + + return $container; +} + +/** +* Create a compiled ContainerBuilder object +* +* @param array $extensions Array of Container extension objects +* @param array $passes Array of Compiler Pass objects +* @param string $phpbb_root_path Root path +* @param string $php_ext PHP Extension +* @return ContainerBuilder object (compiled) +*/ +function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $php_ext) +{ + // Check for our cached container; if it exists, use it + if (file_exists("{$phpbb_root_path}cache/container.$php_ext")) + { + require("{$phpbb_root_path}cache/container.$php_ext"); + return new phpbb_cache_container(); + } + + // We must use an absolute path in the container because we cannot + // change the value at runtime when accessing it in different + // directory levels. + $phpbb_absolute_path = phpbb_realpath($phpbb_root_path) . '/'; + + // Create a temporary container for access to the ext.manager service + $tmp_container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); + $tmp_container->compile(); + + // Now pass the enabled extension paths into the ext compiler extension + $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled()); + + // Create the final container to be compiled and cached + $container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); + + // Compile the container + foreach ($passes as $pass) + { + $container->addCompilerPass($pass); + } + $container->compile(); + + // Lastly, we create our cached container class + $dumper = new PhpDumper($container); + $cached_container_dump = $dumper->dump(array( + 'class' => 'phpbb_cache_container', + 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', + )); + + $file = file_put_contents("{$phpbb_absolute_path}cache/container.{$php_ext}", $cached_container_dump); + + return $container; +} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1734272486..a5c4e2acd3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -88,6 +88,7 @@ if (!empty($load_extensions) && function_exists('dl')) require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); @@ -2723,10 +2724,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) @@ -2759,7 +2760,7 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } - + if (!isset($config['site_home_url'])) { $config->set('site_home_url', ''); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 0afa24066a..7975ac2709 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -77,6 +77,7 @@ else require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); From 38e1c4ec5d363900285a6a72ee78f4f2e2943bd0 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 09:55:17 +0100 Subject: [PATCH 059/544] [ticket/11152] Use relative root path in container, one dumped container per path PHPBB3-11152 --- phpBB/includes/functions_container.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index 88adc64882..8e2c9606cd 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -78,26 +78,22 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext) function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $php_ext) { // Check for our cached container; if it exists, use it - if (file_exists("{$phpbb_root_path}cache/container.$php_ext")) + $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext); + if (file_exists($container_filename)) { - require("{$phpbb_root_path}cache/container.$php_ext"); + require($container_filename); return new phpbb_cache_container(); } - // We must use an absolute path in the container because we cannot - // change the value at runtime when accessing it in different - // directory levels. - $phpbb_absolute_path = phpbb_realpath($phpbb_root_path) . '/'; - // Create a temporary container for access to the ext.manager service - $tmp_container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); + $tmp_container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); $tmp_container->compile(); // Now pass the enabled extension paths into the ext compiler extension $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled()); // Create the final container to be compiled and cached - $container = phpbb_create_container($extensions, $phpbb_absolute_path, $php_ext); + $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); // Compile the container foreach ($passes as $pass) @@ -113,7 +109,13 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', )); - $file = file_put_contents("{$phpbb_absolute_path}cache/container.{$php_ext}", $cached_container_dump); + file_put_contents($container_filename, $cached_container_dump); return $container; } + +function phpbb_container_filename($phpbb_root_path, $php_ext) +{ + $filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path); + return $phpbb_root_path . 'cache/' . $filename . '_container.' . $php_ext; +} From 3ea5b0abbd7f4b0fc95c19a1b76214f044a7d44f Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 10 Nov 2012 12:53:45 +0100 Subject: [PATCH 060/544] [ticket/10780] Make L_COLON available in the installer. PHPBB3-10780 --- phpBB/install/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index c6d0b4cef7..753e5eb226 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -366,6 +366,7 @@ class module $template->assign_vars(array( 'L_CHANGE' => $lang['CHANGE'], + 'L_COLON' => $lang['COLON'], 'L_INSTALL_PANEL' => $lang['INSTALL_PANEL'], 'L_SELECT_LANG' => $lang['SELECT_LANG'], 'L_SKIP' => $lang['SKIP'], From f7f21fa6927eab5fcff7d51d3618d2c48bd4e29d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 10 Nov 2012 14:34:52 +0100 Subject: [PATCH 061/544] [ticket/11186] Database unit tests fail on windows using sqlite2 The problem is, that we try to recreate the db and reconnect to it, while the old connection is still hold. To resolve this, we just drop all tables and recreate the tables instead of the hole db. PHPBB3-11186 --- .../phpbb_database_test_connection_manager.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 25e0972f42..a43215bcf2 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -166,12 +166,6 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { case 'sqlite': - if (file_exists($this->config['dbhost'])) - { - unlink($this->config['dbhost']); - } - break; - case 'firebird': $this->connect(); // Drop all of the tables From c73293d82673631da61acffeef31a93bcca139dd Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sat, 10 Nov 2012 13:46:40 +0000 Subject: [PATCH 062/544] [ticket/11187] Added a blank array to fix errors in functional tests PHPBB3-11187 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d002615e8c..d0bbf85960 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -125,7 +125,7 @@ class phpbb_functional_test_case extends phpbb_test_case { $this->extension_manager = new phpbb_extension_manager( $this->get_db(), - new phpbb_config(), + new phpbb_config(array()), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", From 798c006e7fe55bc1de30e42a4c25e8c74911c865 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 16:38:19 +0100 Subject: [PATCH 063/544] [ticket/11152] Convert cron_task_collection to generic di_service_collection PHPBB3-11152 --- phpBB/config/services.yml | 2 +- .../collection.php => di/service_collection.php} | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) rename phpBB/includes/{cron/task/collection.php => di/service_collection.php} (55%) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index b1aaf1660d..76a7049f19 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -45,7 +45,7 @@ services: - %tables.config% cron.task_collection: - class: phpbb_cron_task_collection + class: phpbb_di_service_collection arguments: - @service_container diff --git a/phpBB/includes/cron/task/collection.php b/phpBB/includes/di/service_collection.php similarity index 55% rename from phpBB/includes/cron/task/collection.php rename to phpBB/includes/di/service_collection.php index 84607dc28d..60323c8dba 100644 --- a/phpBB/includes/cron/task/collection.php +++ b/phpBB/includes/di/service_collection.php @@ -15,29 +15,29 @@ if (!defined('IN_PHPBB')) exit; } -use Symfony\Component\DependencyInjection\TaggedContainerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** -* Collects cron tasks +* Collection of services to be configured at container compile time. * * @package phpBB3 */ -class phpbb_cron_task_collection extends ArrayObject +class phpbb_di_service_collection extends ArrayObject { /** * Constructor * - * @param TaggedContainerInterface $container Container object + * @param ContainerInterface $container Container object */ - public function __construct(TaggedContainerInterface $container) + public function __construct(ContainerInterface $container) { $this->container = $container; } /** - * Add a cron task to the collection + * Add a service to the collection * - * @param string $name The service name of the cron task + * @param string $name The service name * @return null */ public function add($name) From 7085a6c74d9bc5a4c5a92033977a89f56cce01e1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 10 Nov 2012 10:12:25 -0600 Subject: [PATCH 064/544] [ticket/11189] Always log critical errors when in cron or in image output PHPBB3-11189 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 43b81f3f26..7801c48aa7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4196,7 +4196,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $msg_text = $log_text; } - if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) + if ((defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) { // let's avoid loops $db->sql_return_on_error(true); From bd37f7f6c04780819dfa8f81b2d761b91859fd67 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 10 Nov 2012 10:45:02 -0600 Subject: [PATCH 065/544] [ticket/11189] Replace DEBUG_EXTRA with DEBUG PHPBB3-11189 --- phpBB/cron.php | 6 +++--- phpBB/feed.php | 2 +- phpBB/includes/db/dbal.php | 4 ++-- phpBB/includes/db/firebird.php | 6 +++--- phpBB/includes/db/mssql.php | 6 +++--- phpBB/includes/db/mssql_odbc.php | 6 +++--- phpBB/includes/db/mssqlnative.php | 6 +++--- phpBB/includes/db/mysql.php | 6 +++--- phpBB/includes/db/mysqli.php | 6 +++--- phpBB/includes/db/oracle.php | 6 +++--- phpBB/includes/db/postgres.php | 6 +++--- phpBB/includes/db/sqlite.php | 6 +++--- phpBB/includes/functions.php | 6 +++--- phpBB/includes/functions_acp.php | 4 ++-- phpBB/includes/functions_install.php | 2 -- phpBB/includes/session.php | 2 +- phpBB/includes/template/template.php | 4 ++-- phpBB/includes/user.php | 10 +++++----- phpBB/install/database_update.php | 2 +- phpBB/install/install_convert.php | 8 ++++---- 20 files changed, 51 insertions(+), 53 deletions(-) diff --git a/phpBB/cron.php b/phpBB/cron.php index 95d2f8f9b6..787183f689 100644 --- a/phpBB/cron.php +++ b/phpBB/cron.php @@ -39,7 +39,7 @@ function do_cron($cron_lock, $run_tasks) foreach ($run_tasks as $task) { - if (defined('DEBUG_EXTRA') && $config['use_system_cron']) + if (defined('DEBUG') && $config['use_system_cron']) { echo "[phpBB cron] Running task '{$task->get_name()}'\n"; } @@ -57,7 +57,7 @@ function do_cron($cron_lock, $run_tasks) // // Attempt to alleviate the problem by doing setup outside of the lock as much as possible. // -// If DEBUG_EXTRA is defined and cron lock cannot be obtained, a message will be printed. +// If DEBUG is defined and cron lock cannot be obtained, a message will be printed. if ($config['use_system_cron']) { @@ -100,7 +100,7 @@ if ($cron_lock->acquire()) } else { - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { echo "Could not obtain cron lock.\n"; } diff --git a/phpBB/feed.php b/phpBB/feed.php index 9b7ef3a575..58ae251089 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -150,7 +150,7 @@ if ($config['gzip_compress']) } // IF debug extra is enabled and admin want to "explain" the page we need to set other headers... -if (defined('DEBUG_EXTRA') && request_var('explain', 0) && $auth->acl_get('a_')) +if (defined('DEBUG') && request_var('explain', 0) && $auth->acl_get('a_')) { header('Content-type: text/html; charset=UTF-8'); header('Cache-Control: private, no-cache="set-cookie"'); diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 1de236d3de..ef1dd7d14d 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -766,8 +766,8 @@ class dbal // Show complete SQL error and path to administrators only // Additionally show complete error on installation or if extended debug mode is enabled - // The DEBUG_EXTRA constant is for development only! - if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) + // The DEBUG constant is for development only! + if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG')) { $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; } diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 9f9b8a1abd..5728eb901c 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -150,7 +150,7 @@ class dbal_firebird extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -251,7 +251,7 @@ class dbal_firebird extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -279,7 +279,7 @@ class dbal_firebird extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index bde283c3ea..1ec8517308 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -139,7 +139,7 @@ class dbal_mssql extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -154,7 +154,7 @@ class dbal_mssql extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -169,7 +169,7 @@ class dbal_mssql extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 687bc52abc..7c1ffbc808 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -157,7 +157,7 @@ class dbal_mssql_odbc extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -173,7 +173,7 @@ class dbal_mssql_odbc extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -188,7 +188,7 @@ class dbal_mssql_odbc extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index c31f7f6892..e9191fae8a 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -311,7 +311,7 @@ class dbal_mssqlnative extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -329,7 +329,7 @@ class dbal_mssqlnative extends dbal // reset options for next query $this->query_options = array(); - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -344,7 +344,7 @@ class dbal_mssqlnative extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 5b4ff86579..f685ab055c 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -167,7 +167,7 @@ class dbal_mysql extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -182,7 +182,7 @@ class dbal_mysql extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -197,7 +197,7 @@ class dbal_mysql extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 1f13bd5459..6d81b8bc3e 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -174,7 +174,7 @@ class dbal_mysqli extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -189,7 +189,7 @@ class dbal_mysqli extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -199,7 +199,7 @@ class dbal_mysqli extends dbal $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index de2729e973..6d9339b2d8 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -236,7 +236,7 @@ class dbal_oracle extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -413,7 +413,7 @@ class dbal_oracle extends dbal } } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -428,7 +428,7 @@ class dbal_oracle extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index f0a4a7a7a2..8dfbfc3b60 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -194,7 +194,7 @@ class dbal_postgres extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -210,7 +210,7 @@ class dbal_postgres extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -225,7 +225,7 @@ class dbal_postgres extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 2cf55b07e2..5fc89ced18 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -112,7 +112,7 @@ class dbal_sqlite extends dbal global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } @@ -127,7 +127,7 @@ class dbal_sqlite extends dbal $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -142,7 +142,7 @@ class dbal_sqlite extends dbal $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7801c48aa7..804d89d1a2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4191,7 +4191,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $log_text .= '

BACKTRACE
' . $backtrace; } - if (defined('IN_INSTALL') || defined('DEBUG_EXTRA') || isset($auth) && $auth->acl_get('a_')) + if (defined('IN_INSTALL') || defined('DEBUG') || isset($auth) && $auth->acl_get('a_')) { $msg_text = $log_text; } @@ -5241,14 +5241,14 @@ function page_footer($run_cron = true) $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; - if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) + if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG') && method_exists($db, 'sql_report')) { $db->sql_report('display'); } $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); - if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) + if ($auth->acl_get('a_') && defined('DEBUG')) { if (function_exists('memory_get_peak_usage')) { diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 11cc1f6dd8..2f3fd7bac0 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -145,14 +145,14 @@ function adm_page_footer($copyright_html = true) $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; - if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report')) + if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG') && method_exists($db, 'sql_report')) { $db->sql_report('display'); } $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime); - if ($auth->acl_get('a_') && defined('DEBUG_EXTRA')) + if ($auth->acl_get('a_') && defined('DEBUG')) { if (function_exists('memory_get_peak_usage')) { diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 3421c90c88..7a799993db 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -528,12 +528,10 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test if ($debug) { $config_data .= "@define('DEBUG', true);\n"; - $config_data .= "@define('DEBUG_EXTRA', true);\n"; } else { $config_data .= "// @define('DEBUG', true);\n"; - $config_data .= "// @define('DEBUG_EXTRA', true);\n"; } if ($debug_test) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 257ffb07f6..ee8a4094c7 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -474,7 +474,7 @@ class phpbb_session else { // Added logging temporarly to help debug bugs... - if (defined('DEBUG_EXTRA') && $this->data['user_id'] != ANONYMOUS) + if (defined('DEBUG') && $this->data['user_id'] != ANONYMOUS) { if ($referer_valid) { diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 5d3ce4c82b..367c02aa15 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -250,7 +250,7 @@ class phpbb_template * If template cache is writable the compiled php code will be stored * on filesystem and template will not be subsequently recompiled. * If template cache is not writable template source will be recompiled - * every time it is needed. DEBUG_EXTRA define and load_tplcompile + * every time it is needed. DEBUG define and load_tplcompile * configuration setting may be used to force templates to be always * recompiled. * @@ -268,7 +268,7 @@ class phpbb_template { $output_file = $this->_compiled_file_for_handle($handle); - $recompile = defined('DEBUG_EXTRA') || + $recompile = defined('DEBUG') || !file_exists($output_file) || @filesize($output_file) === 0; diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php index 93557f3558..9ddd806b27 100644 --- a/phpBB/includes/user.php +++ b/phpBB/includes/user.php @@ -162,8 +162,8 @@ class phpbb_user extends phpbb_session // We include common language file here to not load it every time a custom language file is included $lang = &$this->lang; - // Do not suppress error if in DEBUG_EXTRA mode - $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); + // Do not suppress error if in DEBUG mode + $include_result = (defined('DEBUG')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); if ($include_result === false) { @@ -252,7 +252,7 @@ class phpbb_user extends phpbb_session // Disable board if the install/ directory is still present // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally - if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) + if (!defined('DEBUG') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) { // Adjust the message slightly according to the permissions if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) @@ -618,8 +618,8 @@ class phpbb_user extends phpbb_session return; } - // Do not suppress error if in DEBUG_EXTRA mode - $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); + // Do not suppress error if in DEBUG mode + $include_result = (defined('DEBUG')) ? (include $language_filename) : (@include $language_filename); if ($include_result === false) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index dcdd17cbc0..899394cd08 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -620,7 +620,7 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { global $db; - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { echo "
\n{$sql}\n
"; } diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index b8045cb98b..41de9de44c 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -1196,7 +1196,7 @@ class install_convert extends module $template->assign_block_vars('checks', array( 'TITLE' => "skip_rows = $skip_rows", - 'RESULT' => $rows . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] : ''), + 'RESULT' => $rows . ((defined('DEBUG') && function_exists('memory_get_usage')) ? ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] : ''), )); $mtime = explode(' ', microtime()); @@ -1380,7 +1380,7 @@ class install_convert extends module } // When we reach this point, either the current table has been processed or we're running out of time. - if (still_on_time() && $counting < $convert->batch_size/* && !defined('DEBUG_EXTRA')*/) + if (still_on_time() && $counting < $convert->batch_size/* && !defined('DEBUG')*/) { $skip_rows = 0; $current_table++; @@ -1469,7 +1469,7 @@ class install_convert extends module sync('topic', 'range', 'topic_id BETWEEN ' . $sync_batch . ' AND ' . $end, true, true); $template->assign_block_vars('checks', array( - 'TITLE' => sprintf($user->lang['SYNC_TOPIC_ID'], $sync_batch, ($sync_batch + $batch_size)) . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ' [' . ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] . ']' : ''), + 'TITLE' => sprintf($user->lang['SYNC_TOPIC_ID'], $sync_batch, ($sync_batch + $batch_size)) . ((defined('DEBUG') && function_exists('memory_get_usage')) ? ' [' . ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] . ']' : ''), 'RESULT' => $user->lang['DONE'], )); @@ -1757,7 +1757,7 @@ class install_convert extends module global $convert; // Can we use IGNORE with this DBMS? - $sql_ignore = (strpos($db->sql_layer, 'mysql') === 0 && !defined('DEBUG_EXTRA')) ? 'IGNORE ' : ''; + $sql_ignore = (strpos($db->sql_layer, 'mysql') === 0 && !defined('DEBUG')) ? 'IGNORE ' : ''; $insert_query = 'INSERT ' . $sql_ignore . 'INTO ' . $schema['target'] . ' ('; $aliases = array(); From 231d743ba9966e8304e0dd226ebf5eb7fb3b70d8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:34:27 +0100 Subject: [PATCH 066/544] [ticket/11152] Change phpbb_di_pass_cron to generic phpbb_di_pass_collection PHPBB3-11152 --- phpBB/common.php | 2 +- phpBB/config/services.yml | 7 ------- phpBB/download/file.php | 2 +- .../includes/di/pass/{cron.php => collection.php} | 15 ++++++++++++--- phpBB/install/database_update.php | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) rename phpBB/includes/di/pass/{cron.php => collection.php} (59%) diff --git a/phpBB/common.php b/phpBB/common.php index e24f9b4359..fb2f86341b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -106,7 +106,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_cron(), + new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 76a7049f19..42bb473e66 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -91,13 +91,6 @@ services: - .%core.php_ext% - @cache.driver - processor.ext: - class: phpbb_di_processor_ext - arguments: - - @ext.manager - tags: - - { name: container.processor } - request: class: phpbb_request diff --git a/phpBB/download/file.php b/phpBB/download/file.php index eb1ec85afe..b99ce2d688 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -65,7 +65,7 @@ if (isset($_GET['avatar'])) new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_cron(), + new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx diff --git a/phpBB/includes/di/pass/cron.php b/phpBB/includes/di/pass/collection.php similarity index 59% rename from phpBB/includes/di/pass/cron.php rename to phpBB/includes/di/pass/collection.php index 53fe0a61c8..09e4b08f62 100644 --- a/phpBB/includes/di/pass/cron.php +++ b/phpBB/includes/di/pass/collection.php @@ -18,8 +18,17 @@ if (!defined('IN_PHPBB')) use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -class phpbb_di_pass_cron implements CompilerPassInterface +class phpbb_di_pass_collection implements CompilerPassInterface { + private $collection_service; + private $service_tag; + + public function __construct($collection_service, $service_tag) + { + $this->collection_service = $collection_service; + $this->service_tag = $service_tag; + } + /** * Modify the container before it is passed to the rest of the code * @@ -28,9 +37,9 @@ class phpbb_di_pass_cron implements CompilerPassInterface */ public function process(ContainerBuilder $container) { - $definition = $container->getDefinition('cron.task_collection'); + $definition = $container->getDefinition($this->collection_service); - foreach ($container->findTaggedServiceIds('cron.task') as $id => $data) + foreach ($container->findTaggedServiceIds($this->service_tag) as $id => $data) { $definition->addMethodCall('add', array($id)); } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a5c4e2acd3..bc45b27cdc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,7 +123,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_cron(), + new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx From 8851b797fbf0f1b4120aa4d3ae713711e01ef98f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:35:52 +0100 Subject: [PATCH 067/544] [ticket/11152] Create separate function for debug-dependent container PHPBB3-11152 --- phpBB/common.php | 2 +- phpBB/download/file.php | 2 +- phpBB/includes/functions_container.php | 32 +++++++++++++++++++------- phpBB/install/database_update.php | 2 +- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index fb2f86341b..b435970692 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,7 +100,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat $phpbb_class_loader_ext->register(); // Set up container -$phpbb_container = phpbb_create_compiled_container( +$phpbb_container = phpbb_create_dumped_container_unless_debug( array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), diff --git a/phpBB/download/file.php b/phpBB/download/file.php index b99ce2d688..5ef64e6ecc 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -59,7 +59,7 @@ if (isset($_GET['avatar'])) $phpbb_class_loader_ext->register(); // Set up container - $phpbb_container = phpbb_create_compiled_container( + $phpbb_container = phpbb_create_dumped_container_unless_debug( array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index 8e2c9606cd..e31fe381ac 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -77,14 +77,6 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext) */ function phpbb_create_compiled_container(array $extensions, array $passes, $phpbb_root_path, $php_ext) { - // Check for our cached container; if it exists, use it - $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext); - if (file_exists($container_filename)) - { - require($container_filename); - return new phpbb_cache_container(); - } - // Create a temporary container for access to the ext.manager service $tmp_container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); $tmp_container->compile(); @@ -102,6 +94,21 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb } $container->compile(); + return $container; +} + +function phpbb_create_dumped_container(array $extensions, array $passes, $phpbb_root_path, $php_ext) +{ + // Check for our cached container; if it exists, use it + $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext); + if (file_exists($container_filename)) + { + require($container_filename); + return new phpbb_cache_container(); + } + + $container = phpbb_create_compiled_container($extensions, $passes, $phpbb_root_path, $php_ext); + // Lastly, we create our cached container class $dumper = new PhpDumper($container); $cached_container_dump = $dumper->dump(array( @@ -114,6 +121,15 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb return $container; } +function phpbb_create_dumped_container_unless_debug(array $extensions, array $passes, $phpbb_root_path, $php_ext) +{ + if (defined('DEBUG')) { + return phpbb_create_compiled_container($extensions, $passes, $phpbb_root_path, $php_ext); + } + + return phpbb_create_dumped_container($extensions, $passes, $phpbb_root_path, $php_ext); +} + function phpbb_container_filename($phpbb_root_path, $php_ext) { $filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index bc45b27cdc..add59b3c85 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -117,7 +117,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat $phpbb_class_loader_ext->register(); // Set up container -$phpbb_container = phpbb_create_compiled_container( +$phpbb_container = phpbb_create_dumped_container_unless_debug( array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), From bdbf7d5de61c902c54fa5882440a5334ac7ad24f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:36:13 +0100 Subject: [PATCH 068/544] [ticket/11152] Remove @api docblocks PHPBB3-11152 --- phpBB/includes/di/extension/config.php | 4 ---- phpBB/includes/di/extension/core.php | 4 ---- phpBB/includes/di/extension/ext.php | 4 ---- 3 files changed, 12 deletions(-) diff --git a/phpBB/includes/di/extension/config.php b/phpBB/includes/di/extension/config.php index b9c752c5de..fb5ca90070 100644 --- a/phpBB/includes/di/extension/config.php +++ b/phpBB/includes/di/extension/config.php @@ -37,8 +37,6 @@ class phpbb_di_extension_config extends Extension * @param ContainerBuilder $container A ContainerBuilder instance * * @throws InvalidArgumentException When provided tag is not defined in this extension - * - * @api */ public function load(array $config, ContainerBuilder $container) { @@ -61,8 +59,6 @@ class phpbb_di_extension_config extends Extension * This alias is also the mandatory prefix to use when using YAML. * * @return string The alias - * - * @api */ public function getAlias() { diff --git a/phpBB/includes/di/extension/core.php b/phpBB/includes/di/extension/core.php index 26aa325bdd..701ae453d1 100644 --- a/phpBB/includes/di/extension/core.php +++ b/phpBB/includes/di/extension/core.php @@ -48,8 +48,6 @@ class phpbb_di_extension_core extends Extension * @param ContainerBuilder $container A ContainerBuilder instance * * @throws InvalidArgumentException When provided tag is not defined in this extension - * - * @api */ public function load(array $config, ContainerBuilder $container) { @@ -66,8 +64,6 @@ class phpbb_di_extension_core extends Extension * This alias is also the mandatory prefix to use when using YAML. * * @return string The alias - * - * @api */ public function getAlias() { diff --git a/phpBB/includes/di/extension/ext.php b/phpBB/includes/di/extension/ext.php index 2539ff5667..5898989717 100644 --- a/phpBB/includes/di/extension/ext.php +++ b/phpBB/includes/di/extension/ext.php @@ -42,8 +42,6 @@ class phpbb_di_extension_ext extends Extension * @param ContainerBuilder $container A ContainerBuilder instance * * @throws InvalidArgumentException When provided tag is not defined in this extension - * - * @api */ public function load(array $config, ContainerBuilder $container) { @@ -63,8 +61,6 @@ class phpbb_di_extension_ext extends Extension * This alias is also the mandatory prefix to use when using YAML. * * @return string The alias - * - * @api */ public function getAlias() { From 9b2024a48e5607e2a9473546916663bb27cb43cc Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Nov 2012 11:11:47 +0100 Subject: [PATCH 069/544] [ticket/11175] Add microdata to subsilver2 Add breadcrumb data to subsilver2 PHPBB3-11175 --- phpBB/styles/subsilver2/template/breadcrumbs.html | 3 ++- phpBB/styles/subsilver2/template/overall_header.html | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/subsilver2/template/breadcrumbs.html b/phpBB/styles/subsilver2/template/breadcrumbs.html index 73386ed851..49e31c0749 100644 --- a/phpBB/styles/subsilver2/template/breadcrumbs.html +++ b/phpBB/styles/subsilver2/template/breadcrumbs.html @@ -1,7 +1,8 @@ + diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index 8bedec4c9e..1c212969a4 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -195,6 +195,8 @@ function marklist(id, name, state)
+ +
From f72eaa0d95edf399df2c021303ecdb7566308606 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Nov 2012 11:15:48 +0100 Subject: [PATCH 070/544] [ticket/11175] Add microdata to prosilver Add breadcrumb microdata to prosilver PHPBB3-11175 --- phpBB/styles/prosilver/template/overall_header.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 0900222d09..291b67812b 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -120,7 +120,8 @@
- +

{S_TIMEZONE}

- - - - - - - - - - -
Query #' . $this->num_queries['total'] . '
- - ' . $this->html_hold . ' - -

- '; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $this->sql_report .= 'Affected rows: ' . $this->sql_affectedrows($this->query_result) . ' | '; - } - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $this->curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $this->sql_report .= 'FAILED - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $this->sql_report .= '



'; - - $this->sql_time += $endtime - $this->curtime; - break; - - case 'start': - $this->query_hold = $query; - $this->html_hold = ''; - - $this->_sql_report($mode, $query); - - $this->curtime = explode(' ', microtime()); - $this->curtime = $this->curtime[0] + $this->curtime[1]; - - break; - - case 'add_select_row': - - $html_table = func_get_arg(2); - $row = func_get_arg(3); - - if (!$html_table && sizeof($row)) - { - $html_table = true; - $this->html_hold .= ''; - - foreach (array_keys($row) as $val) - { - $this->html_hold .= ''; - } - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - $class = 'row1'; - foreach (array_values($row) as $val) - { - $class = ($class == 'row1') ? 'row2' : 'row1'; - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - return $html_table; - - break; - - case 'fromcache': - - $this->_sql_report($mode, $query); - - break; - - case 'record_fromcache': - - $endtime = func_get_arg(2); - $splittime = func_get_arg(3); - - $time_cache = $endtime - $this->curtime; - $time_db = $splittime - $endtime; - $color = ($time_db > $time_cache) ? 'green' : 'red'; - - $this->sql_report .= '
' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '
' . (($val) ? $val : ' ') . '
'; - $this->sql_report .= '
Query results obtained from the cache
'; - $this->sql_report .= '

'; - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: ' . sprintf('%.5f', ($time_cache)) . 's | Elapsed [db]: ' . sprintf('%.5f', $time_db) . 's



'; - - // Pad the start time to not interfere with page timing - $starttime += $time_db; - - break; - - default: - - $this->_sql_report($mode, $query); - - break; - } - - return true; - } - - /** - * Gets the estimated number of rows in a specified table. - * - * @param string $table_name Table name - * - * @return string Number of rows in $table_name. - * Prefixed with ~ if estimated (otherwise exact). - * - * @access public - */ - function get_estimated_row_count($table_name) - { - return $this->get_row_count($table_name); - } - - /** - * Gets the exact number of rows in a specified table. - * - * @param string $table_name Table name - * - * @return string Exact number of rows in $table_name. - * - * @access public - */ - function get_row_count($table_name) - { - $sql = 'SELECT COUNT(*) AS rows_total - FROM ' . $this->sql_escape($table_name); - $result = $this->sql_query($sql); - $rows_total = $this->sql_fetchfield('rows_total'); - $this->sql_freeresult($result); - - return $rows_total; - } -} - -/** -* This variable holds the class name to use later -*/ -$sql_db = (!empty($dbms)) ? 'dbal_' . basename($dbms) : 'dbal'; diff --git a/phpBB/includes/db/driver/driver.php b/phpBB/includes/db/driver/driver.php index 9692ee71b9..4b831d2f79 100644 --- a/phpBB/includes/db/driver/driver.php +++ b/phpBB/includes/db/driver/driver.php @@ -206,7 +206,7 @@ class phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($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) && isset($cache->sql_rowset[$query_id])) + if (!is_object($query_id) && $cache->sql_exists($query_id)) { return $cache->sql_fetchfield($query_id, $field); } @@ -766,8 +766,8 @@ class phpbb_db_driver // Show complete SQL error and path to administrators only // Additionally show complete error on installation or if extended debug mode is enabled - // The DEBUG_EXTRA constant is for development only! - if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) + // The DEBUG constant is for development only! + if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG')) { $message .= ($sql) ? '

SQL

' . htmlspecialchars($sql) : ''; } diff --git a/phpBB/includes/db/driver/firebird.php b/phpBB/includes/db/driver/firebird.php index c793e0a51f..a55175c345 100644 --- a/phpBB/includes/db/driver/firebird.php +++ b/phpBB/includes/db/driver/firebird.php @@ -148,13 +148,13 @@ class phpbb_db_driver_firebird extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } $this->last_query_text = $query; - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -249,7 +249,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -267,17 +267,17 @@ class phpbb_db_driver_firebird extends phpbb_db_driver } } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -330,7 +330,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($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 (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/mssql.php b/phpBB/includes/db/driver/mssql.php index e68738f918..04bb75f5ce 100644 --- a/phpBB/includes/db/driver/mssql.php +++ b/phpBB/includes/db/driver/mssql.php @@ -137,12 +137,12 @@ class phpbb_db_driver_mssql extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -152,7 +152,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } @@ -160,14 +160,14 @@ class phpbb_db_driver_mssql extends phpbb_db_driver if ($cache_ttl && method_exists($cache, 'sql_save')) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -232,7 +232,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -269,7 +269,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_rowseek($rownum, $query_id); } @@ -308,7 +308,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/mssql_odbc.php b/phpBB/includes/db/driver/mssql_odbc.php index 7b35ce3d11..d1f31a6554 100644 --- a/phpBB/includes/db/driver/mssql_odbc.php +++ b/phpBB/includes/db/driver/mssql_odbc.php @@ -155,13 +155,13 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } $this->last_query_text = $query; - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -171,22 +171,22 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -252,7 +252,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -293,7 +293,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/mssqlnative.php b/phpBB/includes/db/driver/mssqlnative.php index 99b9d7975a..67a019f5a5 100644 --- a/phpBB/includes/db/driver/mssqlnative.php +++ b/phpBB/includes/db/driver/mssqlnative.php @@ -216,7 +216,6 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver $this->server = $sqlserver . (($port) ? $port_delimiter . $port : ''); //connect to database - error_reporting(E_ALL); $this->db_connect_id = sqlsrv_connect($this->server, array( 'Database' => $this->dbname, 'UID' => $this->user, @@ -310,13 +309,13 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } $this->last_query_text = $query; - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -328,22 +327,22 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver // reset options for next query $this->query_options = array(); - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -416,7 +415,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -476,7 +475,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/mysql.php b/phpBB/includes/db/driver/mysql.php index 987691341a..f8c2be2366 100644 --- a/phpBB/includes/db/driver/mysql.php +++ b/phpBB/includes/db/driver/mysql.php @@ -165,12 +165,12 @@ class phpbb_db_driver_mysql extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -180,22 +180,22 @@ class phpbb_db_driver_mysql extends phpbb_db_driver $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -247,7 +247,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -268,7 +268,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_rowseek($rownum, $query_id); } @@ -296,7 +296,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/mysqli.php b/phpBB/includes/db/driver/mysqli.php index c473c7fe99..0cc3eb359a 100644 --- a/phpBB/includes/db/driver/mysqli.php +++ b/phpBB/includes/db/driver/mysqli.php @@ -172,12 +172,12 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -187,17 +187,17 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -249,7 +249,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $query_id = $this->query_result; } - if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) + if (!is_object($query_id) && $cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -276,7 +276,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $query_id = $this->query_result; } - if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) + if (!is_object($query_id) && $cache->sql_exists($query_id)) { return $cache->sql_rowseek($rownum, $query_id); } @@ -304,7 +304,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $query_id = $this->query_result; } - if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) + if (!is_object($query_id) && $cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/oracle.php b/phpBB/includes/db/driver/oracle.php index 25803e57bd..d8474694e3 100644 --- a/phpBB/includes/db/driver/oracle.php +++ b/phpBB/includes/db/driver/oracle.php @@ -234,13 +234,13 @@ class phpbb_db_driver_oracle extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } $this->last_query_text = $query; - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -411,22 +411,22 @@ class phpbb_db_driver_oracle extends phpbb_db_driver } } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -471,7 +471,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -523,7 +523,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_rowseek($rownum, $query_id); } @@ -592,7 +592,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/postgres.php b/phpBB/includes/db/driver/postgres.php index 3f54936d23..147ecd04d9 100644 --- a/phpBB/includes/db/driver/postgres.php +++ b/phpBB/includes/db/driver/postgres.php @@ -187,13 +187,13 @@ class phpbb_db_driver_postgres extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } $this->last_query_text = $query; - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -203,22 +203,22 @@ class phpbb_db_driver_postgres extends phpbb_db_driver $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -278,7 +278,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($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 (isset($cache->sql_rowset[$query_id])) + if ($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 (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/phpBB/includes/db/driver/sqlite.php b/phpBB/includes/db/driver/sqlite.php index 363f26da2b..0b09fa758d 100644 --- a/phpBB/includes/db/driver/sqlite.php +++ b/phpBB/includes/db/driver/sqlite.php @@ -110,12 +110,12 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver global $cache; // EXPLAIN only in extra debug mode - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('start', $query); } - $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -125,22 +125,22 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver $this->sql_error($query); } - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { $this->sql_report('stop', $query); } - if ($cache_ttl && method_exists($cache, 'sql_save')) + if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { $this->open_queries[(int) $this->query_result] = $this->query_result; } } - else if (defined('DEBUG_EXTRA')) + else if (defined('DEBUG')) { $this->sql_report('fromcache', $query); } @@ -191,7 +191,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -212,7 +212,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_rowseek($rownum, $query_id); } @@ -240,7 +240,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver $query_id = $this->query_result; } - if (isset($cache->sql_rowset[$query_id])) + if ($cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index c2b8a0fc0b..6de8803df9 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -9,7 +9,6 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_container.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/dbal.php'; class phpbb_di_container_test extends phpbb_test_case { @@ -52,7 +51,7 @@ class phpbb_di_container_test extends phpbb_test_case } } -class dbal_container_mock extends dbal +class phpbb_db_driver_container_mock extends phpbb_db_driver { public function sql_connect() { diff --git a/tests/mock/cache.php b/tests/mock/cache.php index c6d08afef0..b64c92ea89 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -121,7 +121,7 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface public function sql_load($query) { } - public function sql_save($query, &$query_result, $ttl) + public function sql_save($query, $query_result, $ttl) { } public function sql_exists($query_id) From d33aaac199bf1305d37b49a83b91a1bd014ea6cd Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 12 Nov 2012 16:16:40 -0500 Subject: [PATCH 088/544] [ticket/11195] Condense logic, remove improperly formatted if() PHPBB3-11195 --- phpBB/includes/functions_container.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index 1de1d9f7ea..1763d1082a 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -126,11 +126,8 @@ function phpbb_create_dumped_container(array $extensions, array $passes, $phpbb_ function phpbb_create_dumped_container_unless_debug(array $extensions, array $passes, $phpbb_root_path, $php_ext) { - if (defined('DEBUG')) { - return phpbb_create_compiled_container($extensions, $passes, $phpbb_root_path, $php_ext); - } - - return phpbb_create_dumped_container($extensions, $passes, $phpbb_root_path, $php_ext); + $container_factory = defined('DEBUG') ? 'phpbb_create_compiled_container' : 'phpbb_create_dumped_container'; + return $container_factory($extensions, $passes, $phpbb_root_path, $php_ext); } function phpbb_container_filename($phpbb_root_path, $php_ext) From 170967c48a583e4db5fa1131e23d7abe71681ae6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 13 Nov 2012 20:26:49 +0100 Subject: [PATCH 089/544] [ticket/10879] Remove arrow icon from attachment link in editor If you upload a file with a long filename the filename will partially cover the arrow icon background image. Remove the icon as it's not needed anyways. PHPBB3-10879 --- phpBB/styles/prosilver/template/posting_editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 5b3f2beed0..5acdb3a08c 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -165,7 +165,7 @@
-
{attach_row.FILENAME}
+
{attach_row.FILENAME}
  From 5f15c98c1d6cce71fb94e2a36ccabd5472a4de1f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 15 Oct 2012 23:31:43 +0200 Subject: [PATCH 090/544] [ticket/11197] Prefix the css classes for the small arrow with "arrow" It does not make sense to have classes named "right" and "left" produce a small arrow next to text. It should be made clear that an arrow will appear. PHPBB3-11197 --- phpBB/styles/prosilver/template/jumpbox.html | 8 +++---- .../styles/prosilver/template/mcp_forum.html | 4 ++-- phpBB/styles/prosilver/template/mcp_logs.html | 4 ++-- .../prosilver/template/mcp_notes_user.html | 4 ++-- .../styles/prosilver/template/mcp_queue.html | 4 ++-- .../prosilver/template/mcp_reports.html | 4 ++-- .../styles/prosilver/template/mcp_whois.html | 4 ++-- .../prosilver/template/memberlist_body.html | 4 ++-- .../prosilver/template/message_body.html | 2 +- .../prosilver/template/search_results.html | 10 ++++---- .../prosilver/template/ucp_attachments.html | 4 ++-- .../template/ucp_pm_message_header.html | 2 +- .../prosilver/template/ucp_pm_viewfolder.html | 4 ++-- .../template/ucp_pm_viewmessage.html | 8 +++---- .../prosilver/template/viewforum_body.html | 4 ++-- .../prosilver/template/viewonline_body.html | 2 +- .../prosilver/template/viewtopic_body.html | 4 ++-- phpBB/styles/prosilver/theme/colours.css | 14 +++++------ phpBB/styles/prosilver/theme/links.css | 24 +++++++++---------- 19 files changed, 57 insertions(+), 57 deletions(-) diff --git a/phpBB/styles/prosilver/template/jumpbox.html b/phpBB/styles/prosilver/template/jumpbox.html index 0060e83b15..ff234464dc 100644 --- a/phpBB/styles/prosilver/template/jumpbox.html +++ b/phpBB/styles/prosilver/template/jumpbox.html @@ -1,12 +1,12 @@ -

{L_RETURN_TO} {FORUM_NAME}

+

{L_RETURN_TO} {FORUM_NAME}

-

{L_RETURN_TO} {L_INDEX}

+

{L_RETURN_TO} {L_INDEX}

-

{L_RETURN_TO}{L_COLON} {SEARCH_TOPIC}

+

{L_RETURN_TO}{L_COLON} {SEARCH_TOPIC}

-

{L_RETURN_TO_SEARCH_ADV}

+

{L_RETURN_TO_SEARCH_ADV}

diff --git a/phpBB/styles/prosilver/template/mcp_forum.html b/phpBB/styles/prosilver/template/mcp_forum.html index cd4ae69fe7..e559f178f2 100644 --- a/phpBB/styles/prosilver/template/mcp_forum.html +++ b/phpBB/styles/prosilver/template/mcp_forum.html @@ -80,8 +80,8 @@
- {L_NEXT} - {L_PREVIOUS} + {L_NEXT} + {L_PREVIOUS} diff --git a/phpBB/styles/prosilver/template/mcp_logs.html b/phpBB/styles/prosilver/template/mcp_logs.html index 15974802bc..9e4a6f272e 100644 --- a/phpBB/styles/prosilver/template/mcp_logs.html +++ b/phpBB/styles/prosilver/template/mcp_logs.html @@ -54,8 +54,8 @@
- {L_NEXT} - {L_PREVIOUS} + {L_NEXT} + {L_PREVIOUS} diff --git a/phpBB/styles/prosilver/template/mcp_notes_user.html b/phpBB/styles/prosilver/template/mcp_notes_user.html index c7c568657c..3bbbd10f12 100644 --- a/phpBB/styles/prosilver/template/mcp_notes_user.html +++ b/phpBB/styles/prosilver/template/mcp_notes_user.html @@ -95,8 +95,8 @@
- {L_NEXT} - {L_PREVIOUS} + {L_NEXT} + {L_PREVIOUS} diff --git a/phpBB/styles/prosilver/template/mcp_queue.html b/phpBB/styles/prosilver/template/mcp_queue.html index dc8869713d..847151a01e 100644 --- a/phpBB/styles/prosilver/template/mcp_queue.html +++ b/phpBB/styles/prosilver/template/mcp_queue.html @@ -65,8 +65,8 @@
- {L_NEXT} - {L_PREVIOUS} + {L_NEXT} + {L_PREVIOUS} diff --git a/phpBB/styles/prosilver/template/mcp_reports.html b/phpBB/styles/prosilver/template/mcp_reports.html index f9a0ec4bd6..ea9a4edd6f 100644 --- a/phpBB/styles/prosilver/template/mcp_reports.html +++ b/phpBB/styles/prosilver/template/mcp_reports.html @@ -68,8 +68,8 @@
- {L_NEXT} - {L_PREVIOUS} + {L_NEXT} + {L_PREVIOUS} diff --git a/phpBB/styles/prosilver/template/mcp_whois.html b/phpBB/styles/prosilver/template/mcp_whois.html index 88d3269a71..41a825458d 100644 --- a/phpBB/styles/prosilver/template/mcp_whois.html +++ b/phpBB/styles/prosilver/template/mcp_whois.html @@ -4,11 +4,11 @@ diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html index 273182ec3f..4ba0c5cb2a 100644 --- a/phpBB/styles/prosilver/template/memberlist_body.html +++ b/phpBB/styles/prosilver/template/memberlist_body.html @@ -143,8 +143,8 @@
- {L_PREVIOUS} - {L_NEXT} + {L_PREVIOUS} + {L_NEXT}
diff --git a/phpBB/styles/prosilver/template/message_body.html b/phpBB/styles/prosilver/template/message_body.html index fb6dfce35f..a844246055 100644 --- a/phpBB/styles/prosilver/template/message_body.html +++ b/phpBB/styles/prosilver/template/message_body.html @@ -8,7 +8,7 @@

{MESSAGE_TITLE}

{MESSAGE_TEXT}

-

{L_RETURN_TO_SEARCH_ADV}

+

{L_RETURN_TO_SEARCH_ADV}

diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html index 136ca991b1..62b7c61eb3 100644 --- a/phpBB/styles/prosilver/template/search_results.html +++ b/phpBB/styles/prosilver/template/search_results.html @@ -6,9 +6,9 @@

{L_PHRASE_SEARCH_DISABLED}

-

{L_RETURN_TO}{L_COLON} {SEARCH_TOPIC}

+

{L_RETURN_TO}{L_COLON} {SEARCH_TOPIC}

-

{L_RETURN_TO_SEARCH_ADV}

+

{L_RETURN_TO_SEARCH_ADV}

@@ -131,7 +131,7 @@ @@ -150,8 +150,8 @@
- {L_PREVIOUS} - {L_NEXT} + {L_PREVIOUS} + {L_NEXT} diff --git a/phpBB/styles/prosilver/template/ucp_attachments.html b/phpBB/styles/prosilver/template/ucp_attachments.html index 8c93547388..478b14ab86 100644 --- a/phpBB/styles/prosilver/template/ucp_attachments.html +++ b/phpBB/styles/prosilver/template/ucp_attachments.html @@ -47,8 +47,8 @@
- {L_NEXT} - {L_PREVIOUS} + {L_NEXT} + {L_PREVIOUS} diff --git a/phpBB/styles/prosilver/template/ucp_pm_message_header.html b/phpBB/styles/prosilver/template/ucp_pm_message_header.html index 29e6a5a46b..c47f93f739 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_message_header.html +++ b/phpBB/styles/prosilver/template/ucp_pm_message_header.html @@ -18,7 +18,7 @@ diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index a3239602ae..0f2c1a30ec 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -28,7 +28,7 @@ From 4980d8b01150593175274dad45890544f56075d6 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 2 Sep 2012 23:44:13 -0400 Subject: [PATCH 402/544] [ticket/11088] Move style, extension and language pack management to customise Instead of being separated, these related ACP modules are now grouped intuitively. PHPBB3-11088 --- phpBB/includes/acp/info/acp_extensions.php | 4 ++-- phpBB/includes/acp/info/acp_language.php | 2 +- phpBB/install/database_update.php | 14 ++++++++++++++ phpBB/install/install_install.php | 5 +++-- phpBB/language/en/acp/common.php | 12 +++++++----- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/acp/info/acp_extensions.php b/phpBB/includes/acp/info/acp_extensions.php index f5953fb1dd..03d7059165 100644 --- a/phpBB/includes/acp/info/acp_extensions.php +++ b/phpBB/includes/acp/info/acp_extensions.php @@ -16,10 +16,10 @@ class acp_extensions_info { return array( 'filename' => 'acp_extensions', - 'title' => 'ACP_EXTENSIONS', + 'title' => 'ACP_EXTENSIONS_MANAGEMENT', 'version' => '1.0.0', 'modes' => array( - 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_GENERAL_TASKS')), + 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSIONS_MANAGEMENT')), ), ); } diff --git a/phpBB/includes/acp/info/acp_language.php b/phpBB/includes/acp/info/acp_language.php index 85dfb119ea..7f33a22fa6 100644 --- a/phpBB/includes/acp/info/acp_language.php +++ b/phpBB/includes/acp/info/acp_language.php @@ -19,7 +19,7 @@ class acp_language_info 'title' => 'ACP_LANGUAGE', 'version' => '1.0.0', 'modes' => array( - 'lang_packs' => array('title' => 'ACP_LANGUAGE_PACKS', 'auth' => 'acl_a_language', 'cat' => array('ACP_GENERAL_TASKS')), + 'lang_packs' => array('title' => 'ACP_LANGUAGE_PACKS', 'auth' => 'acl_a_language', 'cat' => array('ACP_LANGUAGE')), ), ); } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 30592b995d..d276cdbc57 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2489,6 +2489,20 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), + 'lang_management' => array( + 'base' => 'acp_language', + 'class' => 'acp', + 'title' => 'ACL_LANGUAGE_PACKS', + 'auth' => 'acl_a_language', + 'cat' => 'ACL_LANGUAGE', + ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 4b2fa046bc..b29b5c8605 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -2095,9 +2095,10 @@ class install_install extends module 'ACP_PERMISSION_ROLES', 'ACP_PERMISSION_MASKS', ), - 'ACP_CAT_STYLES' => array( + 'ACP_CAT_CUSTOMISE' => array( 'ACP_STYLE_MANAGEMENT', - 'ACP_STYLE_COMPONENTS', + 'ACP_EXTENSIONS_MANAGEMENT', + 'ACP_LANGUAGE' ), 'ACP_CAT_MAINTENANCE' => array( 'ACP_FORUM_LOGS', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 5eb10d50b3..61fc704b65 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -59,6 +59,7 @@ $lang = array_merge($lang, array( 'ACP_CAPTCHA' => 'CAPTCHA', + 'ACP_CAT_CUSTOMISE' => 'Customise', 'ACP_CAT_DATABASE' => 'Database', 'ACP_CAT_DOT_MODS' => '.MODs', 'ACP_CAT_FORUMS' => 'Forums', @@ -80,8 +81,10 @@ $lang = array_merge($lang, array( 'ACP_DISALLOW_USERNAMES' => 'Disallow usernames', 'ACP_EMAIL_SETTINGS' => 'Email settings', - 'ACP_EXTENSION_GROUPS' => 'Manage extension groups', - 'ACP_EXTENSIONS' => 'Manage board extensions', + 'ACP_EXTENSION_GROUPS' => 'Manage file extension groups', + 'ACP_EXTENSIONS' => 'Extensions', + 'ACP_EXTENSIONS_MANAGEMENT' => 'Extension management', + 'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions', 'ACP_FORUM_LOGS' => 'Forum logs', @@ -119,7 +122,7 @@ $lang = array_merge($lang, array( 'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments', 'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can list and delete files attached to posts and private messages.', - 'ACP_MANAGE_EXTENSIONS' => 'Manage extensions', + 'ACP_MANAGE_EXTENSIONS' => 'Manage file extensions', 'ACP_MANAGE_FORUMS' => 'Manage forums', 'ACP_MANAGE_RANKS' => 'Manage ranks', 'ACP_MANAGE_REASONS' => 'Manage report/denial reasons', @@ -165,8 +168,7 @@ $lang = array_merge($lang, array( 'ACP_SERVER_CONFIGURATION' => 'Server configuration', 'ACP_SERVER_SETTINGS' => 'Server settings', 'ACP_SIGNATURE_SETTINGS' => 'Signature settings', - 'ACP_SMILIES' => 'Smilies', - 'ACP_STYLE_COMPONENTS' => 'Style components', + 'ACP_SMILIES' => 'Smilies', 'ACP_STYLE_MANAGEMENT' => 'Style management', 'ACP_STYLES' => 'Styles', 'ACP_STYLES_CACHE' => 'Purge Cache', From f7d9b15a973feec355ed50313207f4b71c50930e Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 3 Sep 2012 12:32:57 -0300 Subject: [PATCH 403/544] [ticket/11088] Removed added space PHPBB3-11088 --- phpBB/language/en/acp/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 61fc704b65..e490a2c31f 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -168,7 +168,7 @@ $lang = array_merge($lang, array( 'ACP_SERVER_CONFIGURATION' => 'Server configuration', 'ACP_SERVER_SETTINGS' => 'Server settings', 'ACP_SIGNATURE_SETTINGS' => 'Signature settings', - 'ACP_SMILIES' => 'Smilies', + 'ACP_SMILIES' => 'Smilies', 'ACP_STYLE_MANAGEMENT' => 'Style management', 'ACP_STYLES' => 'Styles', 'ACP_STYLES_CACHE' => 'Purge Cache', From e2aef2bfd1385b31e923690c3a12628a876c2b13 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 28 Sep 2012 17:23:27 -0400 Subject: [PATCH 404/544] [ticket/11088] Added missing comma PHPBB3-11088 --- phpBB/install/install_install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index b29b5c8605..1857b9f3fd 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -2098,7 +2098,7 @@ class install_install extends module 'ACP_CAT_CUSTOMISE' => array( 'ACP_STYLE_MANAGEMENT', 'ACP_EXTENSIONS_MANAGEMENT', - 'ACP_LANGUAGE' + 'ACP_LANGUAGE', ), 'ACP_CAT_MAINTENANCE' => array( 'ACP_FORUM_LOGS', From e58c6536f0407ec5f82c634c058270c4e627d03d Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 28 Sep 2012 18:03:35 -0400 Subject: [PATCH 405/544] [ticket/11088] Untested progress for update script PHPBB3-11088 --- phpBB/install/database_update.php | 55 +++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d276cdbc57..73efa3f7f6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,6 +2459,19 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } + // Create new Customise ACP tab + $module_manager = new acp_modules(); + $module_manager->update_module_data(array( + 'parent_id' => 0, + 'module_enabled' => 1, + 'module_display' => 1, + 'module_basename' => ''. + 'module_class' => 'acp', + 'module_mode' => '', + 'module_auth' => '', + 'module_langname' => 'ACP_CAT_CUSTOMISE', + )); + // Install modules $modules_to_install = array( 'position' => array( @@ -2489,20 +2502,6 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), - 'extensions' => array( - 'base' => 'acp_extensions', - 'class' => 'acp', - 'title' => 'ACP_EXTENSIONS', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_EXTENSION_MANAGEMENT', - ), - 'lang_management' => array( - 'base' => 'acp_language', - 'class' => 'acp', - 'title' => 'ACL_LANGUAGE_PACKS', - 'auth' => 'acl_a_language', - 'cat' => 'ACL_LANGUAGE', - ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', @@ -2510,6 +2509,13 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), ); _add_modules($modules_to_install); @@ -2518,6 +2524,27 @@ function change_database_data(&$no_updates, $version) WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language' OR module_langname = 'styles'"; + $result = $db->sql_query($sql); + $modules_to_move = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + // Next, selec the ID of the new parent module + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; + $result = $db->sql_query($sql); + $customise_category_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + // Now perform the move + foreach ($modules_to_move as $module_id) + { + $module_manager->move_module($module_id, $customise_category_id); + } + // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' From 72d1a210de0f08550ce6a1b44c5ac468520146f2 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:25:24 -0400 Subject: [PATCH 406/544] [ticket/11088] Fix typo (period instead of comma) PHPBB3-11088 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 73efa3f7f6..7fa853938d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2465,7 +2465,7 @@ function change_database_data(&$no_updates, $version) 'parent_id' => 0, 'module_enabled' => 1, 'module_display' => 1, - 'module_basename' => ''. + 'module_basename' => '', 'module_class' => 'acp', 'module_mode' => '', 'module_auth' => '', From 30c64f6a01e7d5706c4c0e6b429c1d200f1c3e46 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:37:46 -0400 Subject: [PATCH 407/544] [ticket/11088] Untested, progress on update script This should rename Styles category to Customise, move language packs, and add extension management PHPBB3-11088 --- phpBB/install/database_update.php | 49 +++++++++++++------------------ 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7fa853938d..610c591fcc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,19 +2459,31 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } - // Create new Customise ACP tab + // Rename styles module to Customise + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_STYLE_MANAGEMENT'"; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $styles_module_id = (int) $row['module_id']; + $db->sql_freeresult($result); + $module_manager = new acp_modules(); $module_manager->update_module_data(array( - 'parent_id' => 0, - 'module_enabled' => 1, - 'module_display' => 1, - 'module_basename' => '', - 'module_class' => 'acp', - 'module_mode' => '', - 'module_auth' => '', + 'module_id' => $styles_module_id, 'module_langname' => 'ACP_CAT_CUSTOMISE', )); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $customise_category_id); + } + $db->sql_freeresult($result); + // Install modules $modules_to_install = array( 'position' => array( @@ -2524,27 +2536,6 @@ function change_database_data(&$no_updates, $version) WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language' OR module_langname = 'styles'"; - $result = $db->sql_query($sql); - $modules_to_move = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - // Next, selec the ID of the new parent module - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; - $result = $db->sql_query($sql); - $customise_category_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - // Now perform the move - foreach ($modules_to_move as $module_id) - { - $module_manager->move_module($module_id, $customise_category_id); - } - // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' From 80f68c358ff9e01d5cf4327c5c0d748e6e6de448 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 11:38:44 -0500 Subject: [PATCH 408/544] [ticket/11088] Put language pack module move below extension module creation PHPBB3-11088 --- phpBB/install/database_update.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 610c591fcc..47983676cc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2473,17 +2473,6 @@ function change_database_data(&$no_updates, $version) 'module_langname' => 'ACP_CAT_CUSTOMISE', )); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language'"; - $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) - { - $module_manager->move_module($row['module_id'], $customise_category_id); - } - $db->sql_freeresult($result); - // Install modules $modules_to_install = array( 'position' => array( @@ -2532,6 +2521,16 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Move language management to Customise + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $styles_module_id); + } + $db->sql_freeresult($result); + $sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); From a57c81481d21433bdb185accfd7f2b82858ba461 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Dec 2012 18:38:17 +0100 Subject: [PATCH 409/544] [ticket/10954] Mark topics read without popup Also added missing handling of locked forums. PHPBB3-10954 --- phpBB/styles/prosilver/template/ajax.js | 37 +++++++++++++++++++ .../prosilver/template/viewforum_body.html | 4 +- phpBB/viewforum.php | 15 +++++++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 4ae4f91d8d..7752c00367 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -16,6 +16,43 @@ phpbb.add_ajax_callback('mark_forums_read', function(res) { $(this).removeClass('forum_unread_subforum').addClass('forum_read_subforum'); $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); }); + + $('li.row dl.forum_unread_locked').each(function(e) { + $(this).removeClass('forum_unread_locked').addClass('forum_read_locked'); + $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); + }); +}); + +// This callback will mark all topic icons read +phpbb.add_ajax_callback('mark_topics_read', function(res) { + var i,j; + var read_title = res.NO_UNREAD_POSTS; + var unread_title = res.UNREAD_POSTS; + var icons_array = [ + ['global_unread', 'global_read'], + ['announce_unread', 'announce_read'], + ['sticky_unread', 'sticky_read'], + ['topic_unread', 'topic_read'] + ]; + + var icons_state = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine']; + + // Make sure all icons are marked as read + for (i = 0; i < icons_array.length; i++) + { + for (j = 0; j < icons_state.length; j++) + { + $('li.row dl.' + icons_array[i][0] + icons_state[j]).each(function(e) { + $(this).removeClass(icons_array[i][0] + icons_state[j]).addClass(icons_array[i][1] + icons_state[j]); + $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); + }); + } + } + + // Remove link to first unread post + $('span.icon_topic_newest').each(function(e) { + $(this).remove(); + }); }); // This callback finds the post from the delete link, and removes it. diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index 0f2c1a30ec..b47c13d573 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -57,7 +57,7 @@ -