From 4f65a003344a3aeec0c5f608e990c2860146d39e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 26 Aug 2012 18:40:23 +0200 Subject: [PATCH 001/196] [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 002/196] [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 003/196] [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 004/196] [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 005/196] [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 615d5ef628767ec127735fb4797171de3f886de2 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 11 Jun 2012 23:43:00 -0400 Subject: [PATCH 006/196] [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 007/196] [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 008/196] [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 009/196] [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 010/196] [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 011/196] [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 012/196] [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 013/196] [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 9b2024a48e5607e2a9473546916663bb27cb43cc Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Nov 2012 11:11:47 +0100 Subject: [PATCH 014/196] [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 015/196] [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}

+
+ From 0c430a1f9365260502b7b293b32a34f97edeada4 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 27 Nov 2012 08:46:15 -0500 Subject: [PATCH 125/196] [ticket/11174] These tests do not need posts fixtures. PHPBB3-11174 --- tests/search/mysql_test.php | 2 +- tests/search/postgres_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index cf89facc83..097e46d855 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -16,7 +16,7 @@ class phpbb_search_mysql_test extends phpbb_search_test_case public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/posts.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml'); } protected function setUp() diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index 211755c7db..b6dc5ef1a3 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -16,7 +16,7 @@ class phpbb_search_postgres_test extends phpbb_search_test_case public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/posts.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml'); } protected function setUp() From cb2d029abf2d4857fa462f46af21728afde3cd28 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 27 Nov 2012 08:56:32 -0500 Subject: [PATCH 126/196] [ticket/11174] Drop needless teardown functions. PHPBB3-11174 --- tests/search/mysql_test.php | 5 ----- tests/search/native_test.php | 5 ----- tests/search/postgres_test.php | 5 ----- 3 files changed, 15 deletions(-) diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index 097e46d855..9f38ef2ef6 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -38,11 +38,6 @@ class phpbb_search_mysql_test extends phpbb_search_test_case $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } - protected function tearDown() - { - parent::tearDown(); - } - public function keywords() { return array( diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 544ab7ca17..53d7a1fe78 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -34,11 +34,6 @@ class phpbb_search_native_test extends phpbb_search_test_case $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } - protected function tearDown() - { - parent::tearDown(); - } - public function keywords() { return array( diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index b6dc5ef1a3..b8c9bcfbe9 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -38,11 +38,6 @@ class phpbb_search_postgres_test extends phpbb_search_test_case $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } - protected function tearDown() - { - parent::tearDown(); - } - public function keywords() { return array( From 7dcb03faf1e9c2374f5d5fd36e3b01e8f0315d73 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 27 Nov 2012 09:06:56 -0500 Subject: [PATCH 127/196] [ticket/11174] Delete more copy pasting. PHPBB3-11174 --- tests/search/common_test_case.php | 106 ++++++++++++++++++++++++++++++ tests/search/mysql_test.php | 97 +-------------------------- tests/search/postgres_test.php | 97 +-------------------------- 3 files changed, 110 insertions(+), 190 deletions(-) create mode 100644 tests/search/common_test_case.php diff --git a/tests/search/common_test_case.php b/tests/search/common_test_case.php new file mode 100644 index 0000000000..dd04f7048c --- /dev/null +++ b/tests/search/common_test_case.php @@ -0,0 +1,106 @@ +search->split_keywords($keywords, $terms); + $this->assertEquals($ok, $rv); + if ($ok) + { + // only check criteria if the search is going to be performed + $this->assert_array_content_equals($split_words, $this->search->get_split_words()); + } + $this->assert_array_content_equals($common, $this->search->get_common_words()); + } +} diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index 9f38ef2ef6..e1538bc81c 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -7,9 +7,9 @@ * */ -require_once dirname(__FILE__) . '/../test_framework/phpbb_search_test_case.php'; +require_once dirname(__FILE__) . '/common_test_case.php'; -class phpbb_search_mysql_test extends phpbb_search_test_case +class phpbb_search_mysql_test extends phpbb_search_common_test_case { protected $db; protected $search; @@ -37,97 +37,4 @@ class phpbb_search_mysql_test extends phpbb_search_test_case $class = self::get_search_wrapper('phpbb_search_fulltext_mysql'); $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } - - public function keywords() - { - return array( - // keywords - // terms - // ok - // split words - // common words - array( - 'fooo', - 'all', - true, - array('fooo'), - array(), - ), - array( - 'fooo baar', - 'all', - true, - array('fooo', 'baar'), - array(), - ), - // leading, trailing and multiple spaces - array( - ' fooo baar ', - 'all', - true, - array('fooo', 'baar'), - array(), - ), - // words too short - array( - 'f', - 'all', - false, - null, - // short words count as "common" words - array('f'), - ), - array( - 'f o o', - 'all', - false, - null, - array('f', 'o', 'o'), - ), - array( - 'f -o -o', - 'all', - false, - null, - array('f', '-o', '-o'), - ), - array( - 'fooo -baar', - 'all', - true, - array('-baar', 'fooo'), - array(), - ), - // all negative - array( - '-fooo', - 'all', - true, - array('-fooo'), - array(), - ), - array( - '-fooo -baar', - 'all', - true, - array('-fooo', '-baar'), - array(), - ), - ); - } - - /** - * @dataProvider keywords - */ - public function test_split_keywords($keywords, $terms, $ok, $split_words, $common) - { - $rv = $this->search->split_keywords($keywords, $terms); - $this->assertEquals($ok, $rv); - if ($ok) - { - // only check criteria if the search is going to be performed - $this->assert_array_content_equals($split_words, $this->search->get_split_words()); - } - $this->assert_array_content_equals($common, $this->search->get_common_words()); - } } diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index b8c9bcfbe9..6a65e6bf8f 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -7,9 +7,9 @@ * */ -require_once dirname(__FILE__) . '/../test_framework/phpbb_search_test_case.php'; +require_once dirname(__FILE__) . '/common_test_case.php'; -class phpbb_search_postgres_test extends phpbb_search_test_case +class phpbb_search_postgres_test extends phpbb_search_common_test_case { protected $db; protected $search; @@ -37,97 +37,4 @@ class phpbb_search_postgres_test extends phpbb_search_test_case $class = self::get_search_wrapper('phpbb_search_fulltext_postgres'); $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } - - public function keywords() - { - return array( - // keywords - // terms - // ok - // split words - // common words - array( - 'fooo', - 'all', - true, - array('fooo'), - array(), - ), - array( - 'fooo baar', - 'all', - true, - array('fooo', 'baar'), - array(), - ), - // leading, trailing and multiple spaces - array( - ' fooo baar ', - 'all', - true, - array('fooo', 'baar'), - array(), - ), - // words too short - array( - 'f', - 'all', - false, - null, - // short words count as "common" words - array('f'), - ), - array( - 'f o o', - 'all', - false, - null, - array('f', 'o', 'o'), - ), - array( - 'f -o -o', - 'all', - false, - null, - array('f', '-o', '-o'), - ), - array( - 'fooo -baar', - 'all', - true, - array('-baar', 'fooo'), - array(), - ), - // all negative - array( - '-fooo', - 'all', - true, - array('-fooo'), - array(), - ), - array( - '-fooo -baar', - 'all', - true, - array('-fooo', '-baar'), - array(), - ), - ); - } - - /** - * @dataProvider keywords - */ - public function test_split_keywords($keywords, $terms, $ok, $split_words, $common) - { - $rv = $this->search->split_keywords($keywords, $terms); - $this->assertEquals($ok, $rv); - if ($ok) - { - // only check criteria if the search is going to be performed - $this->assert_array_content_equals($split_words, $this->search->get_split_words()); - } - $this->assert_array_content_equals($common, $this->search->get_common_words()); - } } From 79237b60b6b234e10f14cbcb00691b5e4374fd04 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 27 Nov 2012 10:24:31 -0500 Subject: [PATCH 128/196] [ticket/11174] Global $cache is a cache service instance. PHPBB3-11174 --- tests/search/mysql_test.php | 2 +- tests/search/native_test.php | 2 +- tests/search/postgres_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index e1538bc81c..3ba3915714 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -26,7 +26,7 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case parent::setUp(); // dbal uses cache - $cache = new phpbb_cache_driver_null; + $cache = new phpbb_cache_service(new phpbb_cache_driver_null); // set config values $config['fulltext_mysql_min_word_len'] = 4; diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 53d7a1fe78..eeee3a44f3 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -26,7 +26,7 @@ class phpbb_search_native_test extends phpbb_search_test_case parent::setUp(); // dbal uses cache - $cache = new phpbb_cache_driver_null; + $cache = new phpbb_cache_service(new phpbb_cache_driver_null); $this->db = $this->new_dbal(); $error = null; diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index 6a65e6bf8f..9c77e0c09e 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -26,7 +26,7 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case parent::setUp(); // dbal uses cache - $cache = new phpbb_cache_driver_null; + $cache = new phpbb_cache_service(new phpbb_cache_driver_null); // set config values $config['fulltext_postgres_min_word_len'] = 4; From a4cc07617726bffd4c64cdebaa2e20a463990c5d Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 28 Nov 2012 19:36:13 +0000 Subject: [PATCH 129/196] [ticket/10601] Requested code changes - Renamed the comment to PHPBB3-10601 - Removed backslashes - Traded double quotes into single quotes inside. PHPBB3-10601 --- phpBB/install/database_update.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1dae3e566b..eed484dfae 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2753,9 +2753,9 @@ function change_database_data(&$no_updates, $version) // ticket/10601: Make inbox default. Add basename to ucp's pm category // Check if this was already applied $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id - FROM ' . MODULES_TABLE . ' - WHERE module_basename = "ucp_pm" - ORDER BY module_id'; + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_pm' + ORDER BY module_id"; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) @@ -2765,9 +2765,9 @@ function change_database_data(&$no_updates, $version) { // This update is still not applied. Applying it - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_basename = \'ucp_pm\' - WHERE module_id = ' . (int) $row['parent_id']; + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['parent_id']; _sql($sql, $errored, $error_ary); From 1d9891588182c831aeb1ce20065f6ceaa3f892b4 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 28 Nov 2012 19:37:16 +0000 Subject: [PATCH 130/196] [ticket/10601] Comment to help understanding the code PHPBB3-10601 --- phpBB/includes/functions_module.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 6f38dc60ce..0d387ace6d 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -767,6 +767,7 @@ class p_master } else { + // if the category has a name, then use it. $u_title .= $item_ary['name']; } // If the item is not a category append the mode From 65253a3023a78b1068be63b91b77618e3fb2d5fd Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 29 Nov 2012 15:35:21 -0500 Subject: [PATCH 131/196] [ticket/11227] @return void -> @return null in develop-olympus. PHPBB3-11227 --- phpBB/develop/generate_utf_casefold.php | 2 +- phpBB/develop/generate_utf_confusables.php | 2 +- phpBB/develop/generate_utf_tables.php | 2 +- phpBB/develop/utf_normalizer_test.php | 2 +- phpBB/docs/auth_api.html | 2 +- phpBB/includes/acm/acm_apc.php | 2 +- phpBB/includes/acm/acm_eaccelerator.php | 4 ++-- phpBB/includes/acm/acm_memcache.php | 4 ++-- phpBB/includes/acm/acm_redis.php | 4 ++-- phpBB/includes/acm/acm_wincache.php | 2 +- phpBB/includes/acm/acm_xcache.php | 2 +- phpBB/includes/functions.php | 4 ++-- phpBB/includes/functions_admin.php | 2 +- phpBB/includes/questionnaire/questionnaire.php | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/phpBB/develop/generate_utf_casefold.php b/phpBB/develop/generate_utf_casefold.php index 73951cb4dc..08f67c3eb6 100644 --- a/phpBB/develop/generate_utf_casefold.php +++ b/phpBB/develop/generate_utf_casefold.php @@ -111,7 +111,7 @@ function my_var_export($var) * Download a file to the develop/ dir * * @param string $url URL of the file to download -* @return void +* @return null */ function download($url) { diff --git a/phpBB/develop/generate_utf_confusables.php b/phpBB/develop/generate_utf_confusables.php index d2ffbcfc65..fd0439a4bb 100644 --- a/phpBB/develop/generate_utf_confusables.php +++ b/phpBB/develop/generate_utf_confusables.php @@ -199,7 +199,7 @@ function my_var_export($var) * Download a file to the develop/ dir * * @param string $url URL of the file to download -* @return void +* @return null */ function download($url) { diff --git a/phpBB/develop/generate_utf_tables.php b/phpBB/develop/generate_utf_tables.php index 6fe5d68ffd..6372270b78 100644 --- a/phpBB/develop/generate_utf_tables.php +++ b/phpBB/develop/generate_utf_tables.php @@ -481,7 +481,7 @@ function my_var_export($var) * Download a file to the develop/ dir * * @param string $url URL of the file to download -* @return void +* @return null */ function download($url) { diff --git a/phpBB/develop/utf_normalizer_test.php b/phpBB/develop/utf_normalizer_test.php index 71f24a716b..b8709888fe 100644 --- a/phpBB/develop/utf_normalizer_test.php +++ b/phpBB/develop/utf_normalizer_test.php @@ -222,7 +222,7 @@ die("\n\nALL TESTS PASSED SUCCESSFULLY\n"); * Download a file to the develop/ dir * * @param string $url URL of the file to download -* @return void +* @return null */ function download($url) { diff --git a/phpBB/docs/auth_api.html b/phpBB/docs/auth_api.html index 29469c21ac..a319460360 100644 --- a/phpBB/docs/auth_api.html +++ b/phpBB/docs/auth_api.html @@ -200,7 +200,7 @@ $user_id = 2; $auth->acl_clear_prefetch($user_id); -

This method returns void.

+

This method returns null.

2.viii. acl_get_list

diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php index 1a487f94ad..205353d3a5 100644 --- a/phpBB/includes/acm/acm_apc.php +++ b/phpBB/includes/acm/acm_apc.php @@ -33,7 +33,7 @@ class acm extends acm_memory /** * Purge cache data * - * @return void + * @return null */ function purge() { diff --git a/phpBB/includes/acm/acm_eaccelerator.php b/phpBB/includes/acm/acm_eaccelerator.php index 645067c199..ecec3ac9a5 100644 --- a/phpBB/includes/acm/acm_eaccelerator.php +++ b/phpBB/includes/acm/acm_eaccelerator.php @@ -37,7 +37,7 @@ class acm extends acm_memory /** * Purge cache data * - * @return void + * @return null */ function purge() { @@ -54,7 +54,7 @@ class acm extends acm_memory /** * Perform cache garbage collection * - * @return void + * @return null */ function tidy() { diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index e54fa36c38..70bc219952 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -71,7 +71,7 @@ class acm extends acm_memory /** * Unload the cache resources * - * @return void + * @return null */ function unload() { @@ -83,7 +83,7 @@ class acm extends acm_memory /** * Purge cache data * - * @return void + * @return null */ function purge() { diff --git a/phpBB/includes/acm/acm_redis.php b/phpBB/includes/acm/acm_redis.php index 41533eaacb..dc11ca7768 100644 --- a/phpBB/includes/acm/acm_redis.php +++ b/phpBB/includes/acm/acm_redis.php @@ -80,7 +80,7 @@ class acm extends acm_memory /** * Unload the cache resources * - * @return void + * @return null */ function unload() { @@ -92,7 +92,7 @@ class acm extends acm_memory /** * Purge cache data * - * @return void + * @return null */ function purge() { diff --git a/phpBB/includes/acm/acm_wincache.php b/phpBB/includes/acm/acm_wincache.php index 0501ab74c5..7faba4f5b6 100644 --- a/phpBB/includes/acm/acm_wincache.php +++ b/phpBB/includes/acm/acm_wincache.php @@ -32,7 +32,7 @@ class acm extends acm_memory /** * Purge cache data * - * @return void + * @return null */ function purge() { diff --git a/phpBB/includes/acm/acm_xcache.php b/phpBB/includes/acm/acm_xcache.php index d0a614660c..e3d83f8bfa 100644 --- a/phpBB/includes/acm/acm_xcache.php +++ b/phpBB/includes/acm/acm_xcache.php @@ -48,7 +48,7 @@ class acm extends acm_memory /** * Purge cache data * - * @return void + * @return null */ function purge() { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6e661228b7..571c863839 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2745,7 +2745,7 @@ function meta_refresh($time, $url, $disable_cd_check = false) * * @param int $code HTTP status code * @param string $message Message for the status code -* @return void +* @return null */ function send_status_line($code, $message) { @@ -4332,7 +4332,7 @@ function phpbb_optionset($bit, $set, $data) * * @param array $param Parameter array, see $param_defaults array. * -* @return void +* @return null */ function phpbb_http_login($param) { diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 7352b3d1f3..190185cfcf 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3343,7 +3343,7 @@ function obtain_latest_version_info($force_update = false, $warn_fail = false, $ * @param int $flag The binary flag which is OR-ed with the current column value * @param string $sql_more This string is attached to the sql query generated to update the table. * - * @return void + * @return null */ function enable_bitfield_column_flag($table_name, $column_name, $flag, $sql_more = '') { diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index cbd7638809..3268775cb6 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -71,7 +71,7 @@ class phpbb_questionnaire_data_collector /** * Collect info into the data property. * - * @return void + * @return null */ function collect() { From ee16ed7b76315f629adc1f234d6cf3ddd9552a97 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 11:53:19 -0500 Subject: [PATCH 132/196] [ticket/10875] Spelling fix. PHPBB3-10875 --- phpBB/includes/cache/driver/interface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/cache/driver/interface.php b/phpBB/includes/cache/driver/interface.php index 6adc95a86a..26dfd497aa 100644 --- a/phpBB/includes/cache/driver/interface.php +++ b/phpBB/includes/cache/driver/interface.php @@ -63,7 +63,7 @@ interface phpbb_cache_driver_interface public function destroy($var_name, $table = ''); /** - * Check if a given cache entry exist + * Check if a given cache entry exists */ public function _exists($var_name); @@ -94,7 +94,7 @@ interface phpbb_cache_driver_interface public function sql_save($query, $query_result, $ttl); /** - * Ceck if a given sql query exist in cache + * Check if a given sql query exists in cache * * @param int $query_id * @return bool From 3eb15ab59e202f6d995f40da7cbee0056e73f5d1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 12:04:05 -0500 Subject: [PATCH 133/196] [ticket/10875] More documentation. PHPBB3-10875 --- phpBB/includes/cache/driver/interface.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/cache/driver/interface.php b/phpBB/includes/cache/driver/interface.php index 26dfd497aa..d403bbcd71 100644 --- a/phpBB/includes/cache/driver/interface.php +++ b/phpBB/includes/cache/driver/interface.php @@ -68,7 +68,7 @@ interface phpbb_cache_driver_interface public function _exists($var_name); /** - * Load cached sql query + * Load result of an SQL query from cache. * * @param string $query SQL query * @@ -79,7 +79,11 @@ interface phpbb_cache_driver_interface public function sql_load($query); /** - * Save sql query + * Save result of an SQL query in cache. + * + * In persistent cache stores, this function stores the query + * result to persistent storage. In other words, there is no need + * to call save() afterwards. * * @param string $query SQL query, should be used for generating storage key * @param mixed $query_result The result from dbal::sql_query, to be passed to @@ -94,7 +98,7 @@ interface phpbb_cache_driver_interface public function sql_save($query, $query_result, $ttl); /** - * Check if a given sql query exists in cache + * Check if result for a given SQL query exists in cache. * * @param int $query_id * @return bool From 1ebc6eb68bedc4d6708cb6f23959d129030cf31e Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 12:11:52 -0500 Subject: [PATCH 134/196] [ticket/10875] Must return query result on failure. PHPBB3-10875 --- phpBB/includes/cache/driver/memory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php index bc08494c0c..e4da5767cf 100644 --- a/phpBB/includes/cache/driver/memory.php +++ b/phpBB/includes/cache/driver/memory.php @@ -294,7 +294,7 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base if (!preg_match('/FROM \\(?(`?\\w+`?(?: \\w+)?(?:, ?`?\\w+`?(?: \\w+)?)*)\\)?/', $query, $regs)) { // Bail out if the match fails. - return; + return $query_result; } $tables = array_map('trim', explode(',', $regs[1])); From 7bba09811c65acfd98ebf1e6626f59de7a16cbb3 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 12:18:33 -0500 Subject: [PATCH 135/196] [ticket/10875] Revise sql cache test. Delete data from database before retrieving it from cache, ensuring results come from cache. PHPBB3-10875 --- tests/cache/cache_test.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php index c5f5fac88c..40eef91d53 100644 --- a/tests/cache/cache_test.php +++ b/tests/cache/cache_test.php @@ -89,20 +89,26 @@ class phpbb_cache_test extends phpbb_database_test_case WHERE config_name = 'foo'"; $result = $db->sql_query($sql, 300); $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); $this->assertFileExists($this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php'); + $sql = "DELETE FROM phpbb_config"; + $result = $db->sql_query($sql); + $sql = "SELECT * FROM phpbb_config WHERE config_name = 'foo'"; $result = $db->sql_query($sql, 300); - $this->assertEquals($first_result, $db->sql_fetchrow($result)); + $this->assertEquals($expected, $db->sql_fetchrow($result)); $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'bar'"; - $result = $db->sql_query($sql, 300); + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql); - $this->assertNotEquals($first_result, $db->sql_fetchrow($result)); + $no_cache_result = $db->sql_fetchrow($result); + $this->assertSame(false, $no_cache_result); $db->sql_close(); } From 0c06ac466f61cdab1c647cec23ea66ef70b2ad7e Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 12:28:13 -0500 Subject: [PATCH 136/196] [ticket/10875] Test for null cache driver and sql cache. PHPBB3-10875 --- tests/cache/cache_test.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php index 40eef91d53..c904aa6c41 100644 --- a/tests/cache/cache_test.php +++ b/tests/cache/cache_test.php @@ -112,4 +112,33 @@ class phpbb_cache_test extends phpbb_database_test_case $db->sql_close(); } + + public function test_null_cache_sql() + { + $driver = new phpbb_cache_driver_null($this->cache_dir); + + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($driver); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $sql = "DELETE FROM phpbb_config"; + $result = $db->sql_query($sql); + + // As null cache driver does not actually cache, + // this should return no results + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertSame(false, $db->sql_fetchrow($result)); + + $db->sql_close(); + } } From e4d2ad6b2788d9c3c030382f5ad2f02b6b7f75db Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 1 Dec 2012 00:36:34 +0100 Subject: [PATCH 137/196] [ticket/10875] tests/cache/cache_test.php: Use single quotes where possible. PHPBB3-10875 --- tests/cache/cache_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php index c904aa6c41..285af5cd0c 100644 --- a/tests/cache/cache_test.php +++ b/tests/cache/cache_test.php @@ -94,7 +94,7 @@ class phpbb_cache_test extends phpbb_database_test_case $this->assertFileExists($this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php'); - $sql = "DELETE FROM phpbb_config"; + $sql = 'DELETE FROM phpbb_config'; $result = $db->sql_query($sql); $sql = "SELECT * FROM phpbb_config @@ -128,7 +128,7 @@ class phpbb_cache_test extends phpbb_database_test_case $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); $this->assertEquals($expected, $first_result); - $sql = "DELETE FROM phpbb_config"; + $sql = 'DELETE FROM phpbb_config'; $result = $db->sql_query($sql); // As null cache driver does not actually cache, From ec4343c7447911c7e822a03c0f57fc2bb1c4ab3d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 23:03:06 -0500 Subject: [PATCH 138/196] [ticket/11227] @return void -> @return null, per coding guidelines. PHPBB3-11227 --- phpBB/includes/config/config.php | 2 +- phpBB/includes/config/db.php | 2 +- phpBB/includes/cron/manager.php | 2 +- phpBB/includes/cron/task/core/prune_all_forums.php | 2 +- phpBB/includes/cron/task/core/prune_forum.php | 4 ++-- phpBB/includes/cron/task/core/queue.php | 2 +- phpBB/includes/cron/task/core/tidy_cache.php | 2 +- phpBB/includes/cron/task/core/tidy_database.php | 2 +- phpBB/includes/cron/task/core/tidy_search.php | 2 +- phpBB/includes/cron/task/core/tidy_sessions.php | 2 +- phpBB/includes/cron/task/core/tidy_warnings.php | 2 +- phpBB/includes/cron/task/parametrized.php | 2 +- phpBB/includes/cron/task/task.php | 2 +- phpBB/includes/functions_download.php | 2 +- phpBB/includes/group_positions.php | 10 +++++----- phpBB/includes/lock/db.php | 2 +- phpBB/includes/style/resource_locator.php | 4 ++-- phpBB/includes/template/compile.php | 2 +- 18 files changed, 24 insertions(+), 24 deletions(-) diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 12a4a418b2..4b533dd55c 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -109,7 +109,7 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * @param String $key The configuration option's name * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached - * @return void + * @return null */ public function delete($key, $use_cache = true) { diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index 993a764a7f..45f9f1cb21 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -96,7 +96,7 @@ class phpbb_config_db extends phpbb_config * @param String $key The configuration option's name * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached - * @return void + * @return null */ public function delete($key, $use_cache = true) { diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index ccaa4f3764..84c9650830 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -54,7 +54,7 @@ class phpbb_cron_manager * * @param array|Traversable $tasks Array of instances of phpbb_cron_task * - * @return void + * @return null */ public function load_tasks($tasks) { diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 252e16e57d..ee0b5f7626 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -50,7 +50,7 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base /** * Runs this cron task. * - * @return void + * @return null */ public function run() { diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 41d60af921..fa7a761d88 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -70,7 +70,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p /** * Runs this cron task. * - * @return void + * @return null */ public function run() { @@ -138,7 +138,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p * * @param phpbb_request_interface $request Request object. * - * @return void + * @return null */ public function parse_parameters(phpbb_request_interface $request) { diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index c765660906..732f9c6bea 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -43,7 +43,7 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base /** * Runs this cron task. * - * @return void + * @return null */ public function run() { diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index 6017eea561..16a45dae7c 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -40,7 +40,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base /** * Runs this cron task. * - * @return void + * @return null */ public function run() { diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index 1d256f964f..b882e7b500 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -43,7 +43,7 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base /** * Runs this cron task. * - * @return void + * @return null */ public function run() { diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index 2e5f3d79d5..fdbe31346e 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -54,7 +54,7 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base /** * Runs this cron task. * - * @return void + * @return null */ public function run() { diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index 13531aa30b..95f55235c9 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -40,7 +40,7 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base /** * Runs this cron task. * - * @return void + * @return null */ public function run() { diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index 8dd0674fe5..2a7798e56e 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -45,7 +45,7 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base /** * Runs this cron task. * - * @return void + * @return null */ public function run() { diff --git a/phpBB/includes/cron/task/parametrized.php b/phpBB/includes/cron/task/parametrized.php index 0714b2e701..5f0e46eafc 100644 --- a/phpBB/includes/cron/task/parametrized.php +++ b/phpBB/includes/cron/task/parametrized.php @@ -46,7 +46,7 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task * * @param phpbb_request_interface $request Request object. * - * @return void + * @return null */ public function parse_parameters(phpbb_request_interface $request); } diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php index 7b08fed413..2d585df96d 100644 --- a/phpBB/includes/cron/task/task.php +++ b/phpBB/includes/cron/task/task.php @@ -31,7 +31,7 @@ interface phpbb_cron_task /** * Runs this cron task. * - * @return void + * @return null */ public function run(); diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php index b6371dbecc..fc6f1cc762 100644 --- a/phpBB/includes/functions_download.php +++ b/phpBB/includes/functions_download.php @@ -433,7 +433,7 @@ function set_modified_headers($stamp, $browser) * * @param bool $exit Whether to die or not. * -* @return void +* @return null */ function file_gc($exit = true) { diff --git a/phpBB/includes/group_positions.php b/phpBB/includes/group_positions.php index 74de3516cb..60352ed97d 100644 --- a/phpBB/includes/group_positions.php +++ b/phpBB/includes/group_positions.php @@ -104,7 +104,7 @@ class phpbb_group_positions * Addes a group by group_id * * @param int $group_id group_id of the group to be added - * @return void + * @return null */ public function add_group($group_id) { @@ -128,7 +128,7 @@ class phpbb_group_positions * * @param int $group_id group_id of the group to be deleted * @param bool $skip_group Skip setting the group to GROUP_DISABLED, to save the query, when you need to update it anyway. - * @return void + * @return null */ public function delete_group($group_id, $skip_group = false) { @@ -159,7 +159,7 @@ class phpbb_group_positions * Moves a group up by group_id * * @param int $group_id group_id of the group to be moved - * @return void + * @return null */ public function move_up($group_id) { @@ -170,7 +170,7 @@ class phpbb_group_positions * Moves a group down by group_id * * @param int $group_id group_id of the group to be moved - * @return void + * @return null */ public function move_down($group_id) { @@ -184,7 +184,7 @@ class phpbb_group_positions * @param int $delta number of steps: * - positive = move up * - negative = move down - * @return void + * @return null */ public function move($group_id, $delta) { diff --git a/phpBB/includes/lock/db.php b/phpBB/includes/lock/db.php index fa559d6887..6e94dd5a85 100644 --- a/phpBB/includes/lock/db.php +++ b/phpBB/includes/lock/db.php @@ -125,7 +125,7 @@ class phpbb_lock_db * Note: Attempting to release a lock that is already released, * that is, calling release() multiple times, is harmless. * - * @return void + * @return null */ public function release() { diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 04beddb434..4cf767c062 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -110,7 +110,7 @@ class phpbb_style_resource_locator implements phpbb_template_locator * Typically it is one directory level deep, e.g. "template/". * * @param string $template_path Relative path to templates directory within style directories - * @return void + * @return null */ public function set_template_path($template_path) { @@ -121,7 +121,7 @@ class phpbb_style_resource_locator implements phpbb_template_locator * Sets the location of templates directory within style directories * to the default, which is "template/". * - * @return void + * @return null */ public function set_default_template_path() { diff --git a/phpBB/includes/template/compile.php b/phpBB/includes/template/compile.php index 82b301c1a2..d0b3d0f115 100644 --- a/phpBB/includes/template/compile.php +++ b/phpBB/includes/template/compile.php @@ -118,7 +118,7 @@ class phpbb_template_compile * * @param resource $source_stream Source stream * @param resource $dest_stream Destination stream - * @return void + * @return null */ private function compile_stream_to_stream($source_stream, $dest_stream) { From e5e8087bebdae8c4da2e59e9afd984d6a2008caf Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 23:03:48 -0500 Subject: [PATCH 139/196] [ticket/11227] @return void -> @return null in code sniffer. PHPBB3-11227 --- .../phpbb/Sniffs/Commenting/FileCommentSniff.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php b/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php index ba2b40ecba..68e9e6bb86 100644 --- a/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php +++ b/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php @@ -35,7 +35,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return void + * @return null */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { @@ -120,7 +120,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff * @param integer The stack pointer for the first comment token. * @param array(string=>array) $tags The found file doc comment tags. * - * @return void + * @return null */ protected function processPackage(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags) { @@ -143,7 +143,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff * @param integer The stack pointer for the first comment token. * @param array(string=>array) $tags The found file doc comment tags. * - * @return void + * @return null */ protected function processVersion(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags) { @@ -166,7 +166,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff * @param integer The stack pointer for the first comment token. * @param array(string=>array) $tags The found file doc comment tags. * - * @return void + * @return null */ protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags) { @@ -189,7 +189,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff * @param integer The stack pointer for the first comment token. * @param array(string=>array) $tags The found file doc comment tags. * - * @return void + * @return null */ protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags) { From c852044d6eecc0a652800b1661491c0f9c545054 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 00:48:21 -0500 Subject: [PATCH 140/196] [ticket/9983] Add redis cache driver tests. In order to not overwrite data in default redis store, at least one of redis host or post must be explicitly specified. Redis cache driver constructor has been modified to accept host and port as parameters. This was not added to public API as there are more parameters being passed via global constants. PHPBB3-9983 --- phpBB/includes/cache/driver/redis.php | 27 +++++++- tests/RUNNING_TESTS.txt | 15 ++++ tests/cache/cache_test.php | 68 ++++++++++++++++++- .../phpbb_test_case_helpers.php | 19 ++++++ 4 files changed, 126 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/includes/cache/driver/redis.php index d256b5600e..ae6f9e04f2 100644 --- a/phpBB/includes/cache/driver/redis.php +++ b/phpBB/includes/cache/driver/redis.php @@ -39,13 +39,38 @@ class phpbb_cache_driver_redis extends phpbb_cache_driver_memory var $redis; + /** + * Creates a redis cache driver. + * + * The following global constants affect operation: + * + * PHPBB_ACM_REDIS_HOST + * PHPBB_ACM_REDIS_PORT + * PHPBB_ACM_REDIS_PASSWORD + * PHPBB_ACM_REDIS_DB + * + * There are no publicly documented constructor parameters. + */ function __construct() { // Call the parent constructor parent::__construct(); $this->redis = new Redis(); - $this->redis->connect(PHPBB_ACM_REDIS_HOST, PHPBB_ACM_REDIS_PORT); + + $args = func_get_args(); + if (!empty($args)) + { + $ok = call_user_func_array(array($this->redis, 'connect'), $args); + } + else + { + $ok = $this->redis->connect(PHPBB_ACM_REDIS_HOST, PHPBB_ACM_REDIS_PORT); + } + if (!$ok) + { + trigger_error('Could not connect to redis server'); + } if (defined('PHPBB_ACM_REDIS_PASSWORD')) { diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index 7c2a7c3fce..11617964cb 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -72,6 +72,21 @@ to connect to that database in phpBB. Additionally, you will need to be running the DbUnit fork from https://github.com/phpbb/dbunit/tree/phpbb. +Redis +----- + +In order to run tests for the Redis cache driver, at least one of Redis host +or port must be specified in test configuration. This can be done via +test_config.php as follows: + + cache_dir); @@ -87,12 +87,76 @@ class phpbb_cache_test extends phpbb_database_test_case $sql = "SELECT * FROM phpbb_config WHERE config_name = 'foo'"; + + $cache_path = $this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php'; + $this->assertFileNotExists($cache_path); + $result = $db->sql_query($sql, 300); $first_result = $db->sql_fetchrow($result); $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); $this->assertEquals($expected, $first_result); - $this->assertFileExists($this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php'); + $this->assertFileExists($cache_path); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertEquals($expected, $db->sql_fetchrow($result)); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql); + + $no_cache_result = $db->sql_fetchrow($result); + $this->assertSame(false, $no_cache_result); + + $db->sql_close(); + } + + public function test_cache_sql_redis() + { + if (!extension_loaded('redis')) + { + $this->markTestSkipped('redis extension is not loaded'); + } + + $config = phpbb_test_case_helpers::get_test_config(); + if (isset($config['redis_host']) || isset($config['redis_port'])) + { + $host = isset($config['redis_host']) ? $config['redis_host'] : 'localhost'; + $port = isset($config['redis_port']) ? $config['redis_port'] : 6379; + } + else + { + $this->markTestSkipped('Test redis host/port is not specified'); + } + $driver = new phpbb_cache_driver_redis($host, $port); + $driver->purge(); + + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($driver); + + $redis = new Redis(); + $ok = $redis->connect($host, $port); + $this->assertTrue($ok); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + + $key = $driver->key_prefix . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)); + $this->assertFalse($redis->exists($key)); + + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $this->assertTrue($redis->exists($key)); $sql = 'DELETE FROM phpbb_config'; $result = $db->sql_query($sql); diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index d10645a732..b56a699d1c 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -91,6 +91,15 @@ class phpbb_test_case_helpers { $config['phpbb_functional_url'] = $phpbb_functional_url; } + + if (isset($redis_host)) + { + $config['redis_host'] = $redis_host; + } + if (isset($redis_port)) + { + $config['redis_port'] = $redis_port; + } } if (isset($_SERVER['PHPBB_TEST_DBMS'])) @@ -113,6 +122,16 @@ class phpbb_test_case_helpers )); } + if (isset($_SERVER['PHPBB_TEST_REDIS_HOST'])) + { + $config['redis_host'] = $_SERVER['PHPBB_TEST_REDIS_HOST']; + } + + if (isset($_SERVER['PHPBB_TEST_REDIS_PORT'])) + { + $config['redis_port'] = $_SERVER['PHPBB_TEST_REDIS_PORT']; + } + return $config; } From a0d5c52eb6e8ef3a6bb44cff60b364d3a3a5bf3e Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 1 Dec 2012 09:44:51 +0000 Subject: [PATCH 141/196] [ticket/10601] New approach in the update algorithm - New approach in the database update algorithm PHPBB3-10601 --- phpBB/install/database_update.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index eed484dfae..f3136690a2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2750,28 +2750,25 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_text', ''); } - // ticket/10601: Make inbox default. Add basename to ucp's pm category - // Check if this was already applied - $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id + // PHPBB3-10601: Make inbox default. Add basename to ucp's pm category + + // Get the category wanted while checking, at the same time, if this has already been applied + $sql = 'SELECT module_id, module_basename FROM ' . MODULES_TABLE . " - WHERE module_basename = 'ucp_pm' + WHERE module_basename <> 'ucp_pm' AND + module_langname='UCP_PM' ORDER BY module_id"; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) { - // Checking if this is not a category - if ($row['left_id'] === $row['right_id'] - 1) - { - // This update is still not applied. Applying it + // This update is still not applied. Applying it - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_basename = 'ucp_pm' - WHERE module_id = " . (int) $row['parent_id']; + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['module_id']; - _sql($sql, $errored, $error_ary); - - } + _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); From 314462d8352a6b5ea1fd27ce1bb21cb0a8fb1310 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 22:36:01 +0100 Subject: [PATCH 142/196] [ticket/10184] Disable receiving pms for bots by default PHPBB3-10184 --- phpBB/install/database_update.php | 6 ++++++ phpBB/install/install_install.php | 1 + 2 files changed, 7 insertions(+) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 399ad3429a..8e23434b5b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2171,6 +2171,12 @@ function change_database_data(&$no_updates, $version) } } + // Disable receiving pms for bots + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE user_type = ' . USER_IGNORE; + $db->sql_query($sql); + $no_updates = false; break; } diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 67ebb8b1c5..0575b58d92 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1859,6 +1859,7 @@ class install_install extends module 'user_timezone' => 0, 'user_dateformat' => $lang['default_dateformat'], 'user_allow_massemail' => 0, + 'user_allow_pm' => 0, ); $user_id = user_add($user_row); From ad2d560f3f6ab0232728392b2c1c946f2b07902d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Nov 2012 14:32:31 +0100 Subject: [PATCH 143/196] [ticket/10184] Query bots table to get the user_ids of the bots PHPBB3-10184 --- phpBB/install/database_update.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8e23434b5b..983b1b46c4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2172,10 +2172,24 @@ function change_database_data(&$no_updates, $version) } // Disable receiving pms for bots - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_allow_pm = 0 - WHERE user_type = ' . USER_IGNORE; - $db->sql_query($sql); + $sql = 'SELECT user_id + FROM ' . BOTS_TABLE; + $result = $db->sql_query($sql); + + $bot_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $bot_user_ids[] = (int) $row['user_id']; + } + $db->sql_freeresult($result); + + if (!empty($bot_user_ids)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_allow_pm = 0 + WHERE ' . $db->sql_in_set('user_id', $bot_user_ids); + _sql($sql, $errored, $error_ary); + } $no_updates = false; break; From 1ce06711811561d2e3fa3c6ba2aeac4ebffa6581 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 1 Dec 2012 10:05:20 +0000 Subject: [PATCH 144/196] [ticket/10601] The ORDER BY is only taking space there PHPBB3-10601 --- 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 f3136690a2..ae6e3bd9cf 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2757,7 +2757,7 @@ function change_database_data(&$no_updates, $version) FROM ' . MODULES_TABLE . " WHERE module_basename <> 'ucp_pm' AND module_langname='UCP_PM' - ORDER BY module_id"; + "; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) From 1e3dff83b3e56353fd97a6581989c478e52ed892 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 15:03:44 -0500 Subject: [PATCH 145/196] [ticket/9983] Split cache test into per-driver files. PHPBB3-9983 --- tests/cache/cache_test.php | 208 ------------------------------ tests/cache/file_driver_test.php | 117 +++++++++++++++++ tests/cache/null_driver_test.php | 45 +++++++ tests/cache/redis_driver_test.php | 89 +++++++++++++ 4 files changed, 251 insertions(+), 208 deletions(-) delete mode 100644 tests/cache/cache_test.php create mode 100644 tests/cache/file_driver_test.php create mode 100644 tests/cache/null_driver_test.php create mode 100644 tests/cache/redis_driver_test.php diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php deleted file mode 100644 index ad60a9077e..0000000000 --- a/tests/cache/cache_test.php +++ /dev/null @@ -1,208 +0,0 @@ -cache_dir = dirname(__FILE__) . '/../tmp/cache/'; - } - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); - } - - protected function setUp() - { - parent::setUp(); - - if (file_exists($this->cache_dir)) - { - // cache directory possibly left after aborted - // or failed run earlier - $this->remove_cache_dir(); - } - $this->create_cache_dir(); - } - - protected function tearDown() - { - if (file_exists($this->cache_dir)) - { - $this->remove_cache_dir(); - } - - parent::tearDown(); - } - - private function create_cache_dir() - { - $this->get_test_case_helpers()->makedirs($this->cache_dir); - } - - private function remove_cache_dir() - { - $iterator = new DirectoryIterator($this->cache_dir); - foreach ($iterator as $file) - { - if ($file != '.' && $file != '..') - { - unlink($this->cache_dir . '/' . $file); - } - } - rmdir($this->cache_dir); - } - - public function test_cache_driver_file() - { - $driver = new phpbb_cache_driver_file($this->cache_dir); - $driver->put('test_key', 'test_value'); - $driver->save(); - - $this->assertEquals( - 'test_value', - $driver->get('test_key'), - 'File ACM put and get' - ); - } - - public function test_cache_sql_file() - { - $driver = new phpbb_cache_driver_file($this->cache_dir); - - global $db, $cache; - $db = $this->new_dbal(); - $cache = new phpbb_cache_service($driver); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - - $cache_path = $this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php'; - $this->assertFileNotExists($cache_path); - - $result = $db->sql_query($sql, 300); - $first_result = $db->sql_fetchrow($result); - $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); - $this->assertEquals($expected, $first_result); - - $this->assertFileExists($cache_path); - - $sql = 'DELETE FROM phpbb_config'; - $result = $db->sql_query($sql); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - - $this->assertEquals($expected, $db->sql_fetchrow($result)); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql); - - $no_cache_result = $db->sql_fetchrow($result); - $this->assertSame(false, $no_cache_result); - - $db->sql_close(); - } - - public function test_cache_sql_redis() - { - if (!extension_loaded('redis')) - { - $this->markTestSkipped('redis extension is not loaded'); - } - - $config = phpbb_test_case_helpers::get_test_config(); - if (isset($config['redis_host']) || isset($config['redis_port'])) - { - $host = isset($config['redis_host']) ? $config['redis_host'] : 'localhost'; - $port = isset($config['redis_port']) ? $config['redis_port'] : 6379; - } - else - { - $this->markTestSkipped('Test redis host/port is not specified'); - } - $driver = new phpbb_cache_driver_redis($host, $port); - $driver->purge(); - - global $db, $cache; - $db = $this->new_dbal(); - $cache = new phpbb_cache_service($driver); - - $redis = new Redis(); - $ok = $redis->connect($host, $port); - $this->assertTrue($ok); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - - $key = $driver->key_prefix . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)); - $this->assertFalse($redis->exists($key)); - - $result = $db->sql_query($sql, 300); - $first_result = $db->sql_fetchrow($result); - $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); - $this->assertEquals($expected, $first_result); - - $this->assertTrue($redis->exists($key)); - - $sql = 'DELETE FROM phpbb_config'; - $result = $db->sql_query($sql); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - - $this->assertEquals($expected, $db->sql_fetchrow($result)); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql); - - $no_cache_result = $db->sql_fetchrow($result); - $this->assertSame(false, $no_cache_result); - - $db->sql_close(); - } - - public function test_null_cache_sql() - { - $driver = new phpbb_cache_driver_null($this->cache_dir); - - global $db, $cache; - $db = $this->new_dbal(); - $cache = new phpbb_cache_service($driver); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - $first_result = $db->sql_fetchrow($result); - $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); - $this->assertEquals($expected, $first_result); - - $sql = 'DELETE FROM phpbb_config'; - $result = $db->sql_query($sql); - - // As null cache driver does not actually cache, - // this should return no results - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - - $this->assertSame(false, $db->sql_fetchrow($result)); - - $db->sql_close(); - } -} diff --git a/tests/cache/file_driver_test.php b/tests/cache/file_driver_test.php new file mode 100644 index 0000000000..436bd2f6bc --- /dev/null +++ b/tests/cache/file_driver_test.php @@ -0,0 +1,117 @@ +cache_dir = dirname(__FILE__) . '/../tmp/cache/'; + } + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + protected function setUp() + { + parent::setUp(); + + if (file_exists($this->cache_dir)) + { + // cache directory possibly left after aborted + // or failed run earlier + $this->remove_cache_dir(); + } + $this->create_cache_dir(); + + $this->driver = new phpbb_cache_driver_file($this->cache_dir); + } + + protected function tearDown() + { + if (file_exists($this->cache_dir)) + { + $this->remove_cache_dir(); + } + + parent::tearDown(); + } + + private function create_cache_dir() + { + $this->get_test_case_helpers()->makedirs($this->cache_dir); + } + + private function remove_cache_dir() + { + $iterator = new DirectoryIterator($this->cache_dir); + foreach ($iterator as $file) + { + if ($file != '.' && $file != '..') + { + unlink($this->cache_dir . '/' . $file); + } + } + rmdir($this->cache_dir); + } + + public function test_cache_driver_file() + { + $this->driver->put('test_key', 'test_value'); + $this->driver->save(); + + $this->assertEquals( + 'test_value', + $this->driver->get('test_key'), + 'File ACM put and get' + ); + } + + public function test_cache_sql_file() + { + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($this->driver); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + + $cache_path = $this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php'; + $this->assertFileNotExists($cache_path); + + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $this->assertFileExists($cache_path); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertEquals($expected, $db->sql_fetchrow($result)); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql); + + $no_cache_result = $db->sql_fetchrow($result); + $this->assertSame(false, $no_cache_result); + + $db->sql_close(); + } +} diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php new file mode 100644 index 0000000000..7bf72931a0 --- /dev/null +++ b/tests/cache/null_driver_test.php @@ -0,0 +1,45 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + public function test_null_cache_sql() + { + $driver = new phpbb_cache_driver_null; + + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($driver); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + // As null cache driver does not actually cache, + // this should return no results + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertSame(false, $db->sql_fetchrow($result)); + + $db->sql_close(); + } +} diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php new file mode 100644 index 0000000000..be8b518dca --- /dev/null +++ b/tests/cache/redis_driver_test.php @@ -0,0 +1,89 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + static public function setUpBeforeClass() + { + if (!extension_loaded('redis')) + { + self::markTestSkipped('redis extension is not loaded'); + } + + $config = phpbb_test_case_helpers::get_test_config(); + if (isset($config['redis_host']) || isset($config['redis_port'])) + { + $host = isset($config['redis_host']) ? $config['redis_host'] : 'localhost'; + $port = isset($config['redis_port']) ? $config['redis_port'] : 6379; + self::$config = array('host' => $host, 'port' => $port); + } + else + { + $this->markTestSkipped('Test redis host/port is not specified'); + } + } + + protected function setUp() + { + parent::setUp(); + + $this->driver = new phpbb_cache_driver_redis(self::$config['host'], self::$config['port']); + $this->driver->purge(); + } + + public function test_cache_sql_redis() + { + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($this->driver); + + $redis = new Redis(); + $ok = $redis->connect(self::$config['host'], self::$config['port']); + $this->assertTrue($ok); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + + $key = $this->driver->key_prefix . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)); + $this->assertFalse($redis->exists($key)); + + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $this->assertTrue($redis->exists($key)); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertEquals($expected, $db->sql_fetchrow($result)); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql); + + $no_cache_result = $db->sql_fetchrow($result); + $this->assertSame(false, $no_cache_result); + + $db->sql_close(); + } +} From 829b75e5c8d7b053f3988db89f6f9505102c92b3 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 15:06:32 -0500 Subject: [PATCH 146/196] [ticket/9983] Create driver in setup in null driver test. PHPBB3-9983 --- tests/cache/null_driver_test.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index 7bf72931a0..45e53edaa1 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -9,18 +9,25 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case { + protected $driver; + public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); } + protected function setUp() + { + parent::setUp(); + + $this->driver = new phpbb_cache_driver_null; + } + public function test_null_cache_sql() { - $driver = new phpbb_cache_driver_null; - global $db, $cache; $db = $this->new_dbal(); - $cache = new phpbb_cache_service($driver); + $cache = new phpbb_cache_service($this->driver); $sql = "SELECT * FROM phpbb_config WHERE config_name = 'foo'"; From c3d1408c52dabcafa314fcc13d19f0c537d3a5df Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 18:49:27 -0500 Subject: [PATCH 147/196] [ticket/9983] get/put cache test moved to a base class. PHPBB3-9983 --- tests/cache/common_test_case.php | 24 ++++++++++++++++++++++++ tests/cache/file_driver_test.php | 16 +++------------- tests/cache/null_driver_test.php | 10 ++++++++++ tests/cache/redis_driver_test.php | 4 +++- 4 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 tests/cache/common_test_case.php diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php new file mode 100644 index 0000000000..059ce25133 --- /dev/null +++ b/tests/cache/common_test_case.php @@ -0,0 +1,24 @@ +assertSame(false, $this->driver->get('test_key')); + + $this->driver->put('test_key', 'test_value'); + + $this->assertEquals( + 'test_value', + $this->driver->get('test_key'), + 'File ACM put and get' + ); + } +} diff --git a/tests/cache/file_driver_test.php b/tests/cache/file_driver_test.php index 436bd2f6bc..67408cc6d9 100644 --- a/tests/cache/file_driver_test.php +++ b/tests/cache/file_driver_test.php @@ -7,7 +7,9 @@ * */ -class phpbb_cache_file_driver_test extends phpbb_database_test_case +require_once dirname(__FILE__) . '/common_test_case.php'; + +class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case { private $cache_dir; protected $driver; @@ -65,18 +67,6 @@ class phpbb_cache_file_driver_test extends phpbb_database_test_case rmdir($this->cache_dir); } - public function test_cache_driver_file() - { - $this->driver->put('test_key', 'test_value'); - $this->driver->save(); - - $this->assertEquals( - 'test_value', - $this->driver->get('test_key'), - 'File ACM put and get' - ); - } - public function test_cache_sql_file() { global $db, $cache; diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index 45e53edaa1..efa56762bf 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -23,6 +23,16 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case $this->driver = new phpbb_cache_driver_null; } + public function test_get_put() + { + $this->assertSame(false, $this->driver->get('key')); + + $this->driver->put('key', 'value'); + + // null driver does not cache + $this->assertSame(false, $this->driver->get('key')); + } + public function test_null_cache_sql() { global $db, $cache; diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php index be8b518dca..bf8e49eb65 100644 --- a/tests/cache/redis_driver_test.php +++ b/tests/cache/redis_driver_test.php @@ -7,7 +7,9 @@ * */ -class phpbb_cache_redis_driver_test extends phpbb_database_test_case +require_once dirname(__FILE__) . '/common_test_case.php'; + +class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case { protected static $config; protected $driver; From 90bd7858fdf418c45bac1b30a4dc634cd23f5247 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 18:52:04 -0500 Subject: [PATCH 148/196] [ticket/9983] Rename test methods. PHPBB3-9983 --- tests/cache/file_driver_test.php | 2 +- tests/cache/null_driver_test.php | 2 +- tests/cache/redis_driver_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cache/file_driver_test.php b/tests/cache/file_driver_test.php index 67408cc6d9..2353940277 100644 --- a/tests/cache/file_driver_test.php +++ b/tests/cache/file_driver_test.php @@ -67,7 +67,7 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case rmdir($this->cache_dir); } - public function test_cache_sql_file() + public function test_cache_sql() { global $db, $cache; $db = $this->new_dbal(); diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index efa56762bf..a9b40c5f40 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -33,7 +33,7 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case $this->assertSame(false, $this->driver->get('key')); } - public function test_null_cache_sql() + public function test_cache_sql() { global $db, $cache; $db = $this->new_dbal(); diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php index bf8e49eb65..cd24e33baf 100644 --- a/tests/cache/redis_driver_test.php +++ b/tests/cache/redis_driver_test.php @@ -47,7 +47,7 @@ class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case $this->driver->purge(); } - public function test_cache_sql_redis() + public function test_cache_sql() { global $db, $cache; $db = $this->new_dbal(); From d9e636fab0b1c2de36e38e7bdd3498711108a0e6 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 18:53:13 -0500 Subject: [PATCH 149/196] [ticket/9983] Add a purge test. PHPBB3-9983 --- tests/cache/common_test_case.php | 15 +++++++++++++++ tests/cache/null_driver_test.php | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php index 059ce25133..c44dbf5250 100644 --- a/tests/cache/common_test_case.php +++ b/tests/cache/common_test_case.php @@ -21,4 +21,19 @@ abstract class phpbb_cache_common_test_case extends phpbb_database_test_case 'File ACM put and get' ); } + + public function test_purge() + { + $this->driver->put('test_key', 'test_value'); + + $this->assertEquals( + 'test_value', + $this->driver->get('test_key'), + 'File ACM put and get' + ); + + $this->driver->purge(); + + $this->assertSame(false, $this->driver->get('test_key')); + } } diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index a9b40c5f40..1e8b254294 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -33,6 +33,12 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case $this->assertSame(false, $this->driver->get('key')); } + public function test_purge() + { + // does nothing + $this->driver->purge(); + } + public function test_cache_sql() { global $db, $cache; From 8595b1f56018d0bfac0b83ac1511175c88a8b9cb Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 18:57:09 -0500 Subject: [PATCH 150/196] [ticket/9983] Exercise exists also. PHPBB3-9983 --- tests/cache/common_test_case.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php index c44dbf5250..5c387d98a1 100644 --- a/tests/cache/common_test_case.php +++ b/tests/cache/common_test_case.php @@ -9,12 +9,14 @@ abstract class phpbb_cache_common_test_case extends phpbb_database_test_case { - public function test_get_put() + public function test_get_put_exists() { + $this->assertFalse($this->driver->_exists('test_key')); $this->assertSame(false, $this->driver->get('test_key')); $this->driver->put('test_key', 'test_value'); + $this->assertTrue($this->driver->_exists('test_key')); $this->assertEquals( 'test_value', $this->driver->get('test_key'), From dd36b128e80112ba47ae51dca47702209e8aac18 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 18:59:28 -0500 Subject: [PATCH 151/196] [ticket/9983] Add a test for destroy. PHPBB3-9983 --- tests/cache/common_test_case.php | 23 +++++++++++++++++++++++ tests/cache/null_driver_test.php | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php index 5c387d98a1..45cf80e424 100644 --- a/tests/cache/common_test_case.php +++ b/tests/cache/common_test_case.php @@ -38,4 +38,27 @@ abstract class phpbb_cache_common_test_case extends phpbb_database_test_case $this->assertSame(false, $this->driver->get('test_key')); } + + public function test_destroy() + { + $this->driver->put('first_key', 'first_value'); + $this->driver->put('second_key', 'second_value'); + + $this->assertEquals( + 'first_value', + $this->driver->get('first_key') + ); + $this->assertEquals( + 'second_value', + $this->driver->get('second_key') + ); + + $this->driver->destroy('first_key'); + + $this->assertFalse($this->driver->_exists('first_key')); + $this->assertEquals( + 'second_value', + $this->driver->get('second_key') + ); + } } diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index 1e8b254294..86553d4dc5 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -39,6 +39,12 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case $this->driver->purge(); } + public function test_destroy() + { + // does nothing + $this->driver->destroy('foo'); + } + public function test_cache_sql() { global $db, $cache; From 720ef233b122d00ef9d2128c9a0a518ff017b0d7 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sat, 1 Dec 2012 22:34:03 -0600 Subject: [PATCH 152/196] [ticket/11219] Only update sequences that are affected by a fixture PHPBB3-11219 --- .../phpbb_database_test_case.php | 18 +++-- ...phpbb_database_test_connection_manager.php | 73 +++++++++++-------- 2 files changed, 55 insertions(+), 36 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 0916679108..429bb92bf1 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -13,6 +13,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test protected $test_case_helpers; + protected $fixture_xml_data; + public function __construct($name = NULL, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); @@ -32,10 +34,14 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test { parent::setUp(); - $config = $this->get_database_config(); - $manager = $this->create_connection_manager($config); - $manager->connect(); - $manager->post_setup_synchronisation(); + // Resynchronise tables if a fixture was loaded + if (isset($this->fixture_xml_data)) + { + $config = $this->get_database_config(); + $manager = $this->create_connection_manager($config); + $manager->connect(); + $manager->post_setup_synchronisation($this->fixture_xml_data); + } } public function createXMLDataSet($path) @@ -57,7 +63,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $path = $meta_data['uri']; } - return parent::createXMLDataSet($path); + $this->fixture_xml_data = parent::createXMLDataSet($path); + + return $this->fixture_xml_data; } public function get_test_case_helpers() diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index e79a764e1d..97281a0812 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -429,12 +429,19 @@ class phpbb_database_test_connection_manager /** * Performs synchronisations on the database after a fixture has been loaded + * + * @param PHPUnit_Extensions_Database_DataSet_XmlDataSet $tables Tables contained within the loaded fixture + * + * @return null */ - public function post_setup_synchronisation() + public function post_setup_synchronisation($xmlDataSet) { $this->ensure_connected(__METHOD__); $queries = array(); + // Get escaped versions of the table names used in the fixture + $table_names = array_map(array($this->pdo, 'PDO::quote'), $xmlDataSet->getTableNames()); + switch ($this->config['dbms']) { case 'oracle': @@ -445,7 +452,9 @@ class phpbb_database_test_connection_manager JOIN USER_TRIGGER_COLS tc ON (tc.trigger_name = t.trigger_name) JOIN USER_SEQUENCES s ON (s.sequence_name = d.referenced_name) WHERE d.referenced_type = 'SEQUENCE' - AND d.type = 'TRIGGER'"; + AND d.type = 'TRIGGER' + AND t.table_name IN (" . implode(', ', array_map('strtoupper', $table_names)) . ')'; + $result = $this->pdo->query($sql); while ($row = $result->fetch(PDO::FETCH_ASSOC)) @@ -476,41 +485,43 @@ class phpbb_database_test_connection_manager break; case 'postgres': - // First get the sequences - $sequences = array(); - $sql = "SELECT relname FROM pg_class WHERE relkind = 'S'"; + // Get the sequences attached to the tables + $sql = 'SELECT column_name, table_name FROM information_schema.columns + WHERE table_name IN (' . implode(', ', $table_names) . ") + AND strpos(column_default, '_seq''::regclass') > 0"; $result = $this->pdo->query($sql); + + $setval_queries = array(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $sequences[] = $row['relname']; + // Get the columns used in the fixture for this table + $column_names = $xmlDataSet->getTableMetaData($row['table_name'])->getColumns(); + + // Skip sequences that weren't specified in the fixture + if (!in_array($row['column_name'], $column_names)) + { + continue; + } + + // Get the old value if it exists, or use 1 if it doesn't + $sql = "SELECT COALESCE((SELECT MAX({$row['column_name']}) + 1 FROM {$row['table_name']}), 1) AS val"; + $result_max = $this->pdo->query($sql); + $row_max = $result_max->fetch(PDO::FETCH_ASSOC); + + if ($row_max) + { + $seq_name = $this->pdo->quote($row['table_name'] . '_seq'); + $max_val = (int) $row_max['val']; + + // The last parameter is false so that the system doesn't increment it again + $setval_queries[] = "SETVAL($seq_name, $max_val, false)"; + } } - // Now get the name of the column using it - foreach ($sequences as $sequence) + // Combine all of the SETVALs into one query + if (sizeof($setval_queries)) { - $table = str_replace('_seq', '', $sequence); - $sql = "SELECT column_name FROM information_schema.columns - WHERE table_name = '$table' - AND column_default = 'nextval(''$sequence''::regclass)'"; - $result = $this->pdo->query($sql); - $row = $result->fetch(PDO::FETCH_ASSOC); - - // Finally, set the new sequence value - if ($row) - { - $column = $row['column_name']; - - // Get the old value if it exists, or use 1 if it doesn't - $sql = "SELECT COALESCE((SELECT MAX({$column}) + 1 FROM {$table}), 1) AS val"; - $result = $this->pdo->query($sql); - $row = $result->fetch(PDO::FETCH_ASSOC); - - if ($row) - { - // The last parameter is false so that the system doesn't increment it again - $queries[] = "SELECT SETVAL('{$sequence}', {$row['val']}, false)"; - } - } + $queries[] = 'SELECT ' . implode(', ', $setval_queries); } break; } From dacacbbd52dc22f3344f313301cf6b4fb0f77233 Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Sun, 15 Apr 2012 13:08:44 +0530 Subject: [PATCH 153/196] [ticket/10771] Using Remember Me instead of autologin or persistent keys Changed language variable LOG_ME_IN's value to "Remember me" PHPBB3-10771 --- phpBB/language/en/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 4300ef431a..71f1beb66a 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -343,7 +343,7 @@ $lang = array_merge($lang, array( 'LOGIN_EXPLAIN_VIEWONLINE' => 'In order to view the online list you have to be registered and logged in.', 'LOGOUT' => 'Logout', 'LOGOUT_USER' => 'Logout [ %s ]', - 'LOG_ME_IN' => 'Log me on automatically each visit', + 'LOG_ME_IN' => 'Remember me', 'MARK' => 'Mark', 'MARK_ALL' => 'Mark all', From a17c1a29f8ce5781082dcf87a8bde261647062f0 Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Wed, 18 Apr 2012 12:13:00 +0530 Subject: [PATCH 154/196] [ticket/10771] changed value in help_faq.php PHPBB3-10771 --- phpBB/language/en/help_faq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/help_faq.php b/phpBB/language/en/help_faq.php index 5c99f81c06..9500943b88 100644 --- a/phpBB/language/en/help_faq.php +++ b/phpBB/language/en/help_faq.php @@ -43,7 +43,7 @@ $help = array( ), array( 0 => 'Why do I get logged off automatically?', - 1 => 'If you do not check the Log me in automatically box when you login, the board will only keep you logged in for a preset time. This prevents misuse of your account by anyone else. To stay logged in, check the box during login. This is not recommended if you access the board from a shared computer, e.g. library, internet cafe, university computer lab, etc. If you do not see this checkbox, it means the board administrator has disabled this feature.' + 1 => 'If you do not check the Remember me box when you login, the board will only keep you logged in for a preset time. This prevents misuse of your account by anyone else. To stay logged in, check the box during login. This is not recommended if you access the board from a shared computer, e.g. library, internet cafe, university computer lab, etc. If you do not see this checkbox, it means the board administrator has disabled this feature.' ), array( 0 => 'How do I prevent my username appearing in the online user listings?', From a97401a180657b8b9526c5a0af055d46cf3e8487 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 11 Nov 2012 00:03:22 +0100 Subject: [PATCH 155/196] [ticket/10771] use remember me in acp PHPBB3-10771 --- phpBB/language/en/acp/board.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index a4380486cc..4adcbd689e 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -449,10 +449,10 @@ $lang = array_merge($lang, array( 'ACP_SECURITY_SETTINGS_EXPLAIN' => 'Here you are able to define session and login related settings.', 'ALL' => 'All', - 'ALLOW_AUTOLOGIN' => 'Allow persistent logins', - 'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users can autologin when they visit the board.', - 'AUTOLOGIN_LENGTH' => 'Persistent login key expiration length (in days)', - 'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which persistent login keys are removed or zero to disable.', + 'ALLOW_AUTOLOGIN' => 'Allow remember me logins', + 'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users can select remember me option when they visit the board.', + 'AUTOLOGIN_LENGTH' => 'Remember me login key expiration length (in days)', + 'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which remember me login keys are removed or zero to disable.', 'BROWSER_VALID' => 'Validate browser', 'BROWSER_VALID_EXPLAIN' => 'Enables browser validation for each session improving security.', 'CHECK_DNSBL' => 'Check IP against DNS Blackhole List', From 619e15378dd6839b26ceb7a698b8d07fa5ebbec9 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 11 Nov 2012 00:03:45 +0100 Subject: [PATCH 156/196] [ticket/10771] use remember me in ucp PHPBB3-10771 --- phpBB/language/en/ucp.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 705b07b170..0ae58392d5 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -87,7 +87,7 @@ $lang = array_merge($lang, array( 'ATTACHMENTS_EXPLAIN' => 'This is a list of attachments you have made in posts to this board.', 'ATTACHMENTS_DELETED' => 'Attachments successfully deleted.', 'ATTACHMENT_DELETED' => 'Attachment successfully deleted.', - 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected persistent login keys were successfully deleted.', + 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected remember me login keys were successfully deleted.', 'AVATAR_CATEGORY' => 'Category', 'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$s, height: %2$s, file size: %3$.2f KiB.', 'AVATAR_FEATURES_DISABLED' => 'The avatar functionality is currently disabled.', @@ -380,8 +380,8 @@ $lang = array_merge($lang, array( 'PREFERENCES_UPDATED' => 'Your preferences have been updated.', 'PROFILE_INFO_NOTICE' => 'Please note that this information may be viewable to other members. Be careful when including any personal details. Any fields marked with a * must be completed.', 'PROFILE_UPDATED' => 'Your profile has been updated.', - 'PROFILE_AUTOLOGIN_KEYS' => 'The persistent login keys automatically log you in when you visit the board. If you logout, the persistent login key is deleted only on the computer you are using to logout. Here you can see persistent login keys created on other computers you used to access this site.', - 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved persistent login keys.', + 'PROFILE_AUTOLOGIN_KEYS' => 'The remember me login keys automatically log you in when you visit the board. If you logout, the remember me login key is deleted only on the computer you are using to logout. Here you can see remember login keys created on other computers you used to access this site.', + 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved remember me login keys.', 'RECIPIENT' => 'Recipient', 'RECIPIENTS' => 'Recipients', @@ -476,7 +476,7 @@ $lang = array_merge($lang, array( 'UCP_PROFILE_PROFILE_INFO' => 'Edit profile', 'UCP_PROFILE_REG_DETAILS' => 'Edit account settings', 'UCP_PROFILE_SIGNATURE' => 'Edit signature', - 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Edit persistent login keys', + 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Edit remember me login keys', 'UCP_USERGROUPS' => 'Usergroups', 'UCP_USERGROUPS_MEMBER' => 'Edit memberships', From 37f2841af2d1027b92953ee2c08da44481d0a06e Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 2 Dec 2012 15:20:43 +0530 Subject: [PATCH 157/196] [ticket/10771] fix remember me language PHPBB3-10771 --- phpBB/language/en/acp/board.php | 8 ++++---- phpBB/language/en/ucp.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 4adcbd689e..1b99c87938 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -449,10 +449,10 @@ $lang = array_merge($lang, array( 'ACP_SECURITY_SETTINGS_EXPLAIN' => 'Here you are able to define session and login related settings.', 'ALL' => 'All', - 'ALLOW_AUTOLOGIN' => 'Allow remember me logins', - 'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users can select remember me option when they visit the board.', - 'AUTOLOGIN_LENGTH' => 'Remember me login key expiration length (in days)', - 'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which remember me login keys are removed or zero to disable.', + 'ALLOW_AUTOLOGIN' => 'Allow "Remember Me" logins', + 'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users are given "Remember Me" option when they visit the board.', + 'AUTOLOGIN_LENGTH' => '"Remember Me" login key expiration length (in days)', + 'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which "Remember Me" login keys are removed or zero to disable.', 'BROWSER_VALID' => 'Validate browser', 'BROWSER_VALID_EXPLAIN' => 'Enables browser validation for each session improving security.', 'CHECK_DNSBL' => 'Check IP against DNS Blackhole List', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 0ae58392d5..b919699ea0 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -87,7 +87,7 @@ $lang = array_merge($lang, array( 'ATTACHMENTS_EXPLAIN' => 'This is a list of attachments you have made in posts to this board.', 'ATTACHMENTS_DELETED' => 'Attachments successfully deleted.', 'ATTACHMENT_DELETED' => 'Attachment successfully deleted.', - 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected remember me login keys were successfully deleted.', + 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected "Remember Me" login keys were successfully deleted.', 'AVATAR_CATEGORY' => 'Category', 'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$s, height: %2$s, file size: %3$.2f KiB.', 'AVATAR_FEATURES_DISABLED' => 'The avatar functionality is currently disabled.', @@ -380,8 +380,8 @@ $lang = array_merge($lang, array( 'PREFERENCES_UPDATED' => 'Your preferences have been updated.', 'PROFILE_INFO_NOTICE' => 'Please note that this information may be viewable to other members. Be careful when including any personal details. Any fields marked with a * must be completed.', 'PROFILE_UPDATED' => 'Your profile has been updated.', - 'PROFILE_AUTOLOGIN_KEYS' => 'The remember me login keys automatically log you in when you visit the board. If you logout, the remember me login key is deleted only on the computer you are using to logout. Here you can see remember login keys created on other computers you used to access this site.', - 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved remember me login keys.', + 'PROFILE_AUTOLOGIN_KEYS' => 'The "Remember Me" login keys automatically log you in when you visit the board. If you logout, the remember me login key is deleted only on the computer you are using to logout. Here you can see remember login keys created on other computers you used to access this site.', + 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved "Remember Me" login keys.', 'RECIPIENT' => 'Recipient', 'RECIPIENTS' => 'Recipients', @@ -476,7 +476,7 @@ $lang = array_merge($lang, array( 'UCP_PROFILE_PROFILE_INFO' => 'Edit profile', 'UCP_PROFILE_REG_DETAILS' => 'Edit account settings', 'UCP_PROFILE_SIGNATURE' => 'Edit signature', - 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Edit remember me login keys', + 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Edit "Remember Me" login keys', 'UCP_USERGROUPS' => 'Usergroups', 'UCP_USERGROUPS_MEMBER' => 'Edit memberships', From 9d5fc4ae33ac5a5ea2dc85fd4157ce56653c4a16 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 2 Dec 2012 13:16:11 -0500 Subject: [PATCH 158/196] [ticket/11238] Set goutte to 0.1.0 in develop. PHPBB3-11238 --- phpBB/composer.json | 2 +- phpBB/composer.lock | 170 +++++++++++++++++--------------------------- 2 files changed, 68 insertions(+), 104 deletions(-) diff --git a/phpBB/composer.json b/phpBB/composer.json index 5a03e68f73..d2536a73cf 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -9,6 +9,6 @@ "symfony/yaml": "2.1.*" }, "require-dev": { - "fabpot/goutte": "1.0.x-dev" + "fabpot/goutte": "v0.1.0" } } diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 62ece6d505..e96c15fe8b 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,5 +1,5 @@ { - "hash": "efb4768ba71d7cd2c84baa0610d84067", + "hash": "c1a76530df6b9daa16b8033d61b76503", "packages": [ { "name": "symfony/config", @@ -381,29 +381,29 @@ "packages-dev": [ { "name": "fabpot/goutte", - "version": "dev-master", + "version": "v0.1.0", "source": { "type": "git", "url": "https://github.com/fabpot/Goutte", - "reference": "f2940f9c7c1f409159f5e9f512e575946c5cff48" + "reference": "v0.1.0" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Goutte/archive/f2940f9c7c1f409159f5e9f512e575946c5cff48.zip", - "reference": "f2940f9c7c1f409159f5e9f512e575946c5cff48", + "url": "https://github.com/fabpot/Goutte/archive/v0.1.0.zip", + "reference": "v0.1.0", "shasum": "" }, "require": { "php": ">=5.3.0", + "ext-curl": "*", "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.*" + "guzzle/guzzle": "3.0.*" }, - "time": "1351086217", + "time": "2012-12-02 13:44:35", "type": "application", "extra": { "branch-alias": { @@ -432,126 +432,90 @@ ] }, { - "name": "guzzle/common", - "version": "v2.8.8", - "target-dir": "Guzzle/Common", + "name": "guzzle/guzzle", + "version": "v3.0.5", "source": { "type": "git", - "url": "git://github.com/guzzle/common.git", - "reference": "v2.8.8" + "url": "https://github.com/guzzle/guzzle", + "reference": "v3.0.5" }, "dist": { "type": "zip", - "url": "https://github.com/guzzle/common/zipball/v2.8.8", - "reference": "v2.8.8", + "url": "https://github.com/guzzle/guzzle/archive/v3.0.5.zip", + "reference": "v3.0.5", "shasum": "" }, "require": { "php": ">=5.3.2", + "ext-curl": "*", "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" - ] - }, - { - "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", + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", "guzzle/common": "self.version", - "guzzle/parser": "self.version" + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" }, - "time": "2012-10-15 17:42:47", + "require-dev": { + "doctrine/common": "*", + "symfony/class-loader": "*", + "monolog/monolog": "1.*", + "zendframework/zend-cache": "2.0.*", + "zendframework/zend-log": "2.0.*", + "zend/zend-log1": "1.12", + "zend/zend-cache1": "1.12", + "phpunit/phpunit": "3.7.*" + }, + "time": "2012-11-19 00:15:33", "type": "library", "installation-source": "dist", "autoload": { "psr-0": { - "Guzzle\\Http": "" + "Guzzle\\Tests": "tests/", + "Guzzle": "src/" } }, "license": [ "MIT" ], - "description": "HTTP libraries used by Guzzle", + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", "homepage": "http://guzzlephp.org/", "keywords": [ + "framework", "curl", "http", + "rest", "http client", "client", - "Guzzle" - ] - }, - { - "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" + "web service" ] }, { @@ -808,7 +772,7 @@ ], "minimum-stability": "beta", - "stability-flags": { - "fabpot/goutte": 20 - } + "stability-flags": [ + + ] } From 6f7e39996c926b0f0080ccdd594fd465c311cb79 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 2 Dec 2012 23:44:49 -0500 Subject: [PATCH 159/196] [ticket/11238] Set goutte version to 0.1.0. PHPBB3-11238 --- phpBB/composer.json | 2 +- phpBB/composer.lock | 463 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 433 insertions(+), 32 deletions(-) diff --git a/phpBB/composer.json b/phpBB/composer.json index c2811ad1d7..8d5dd1d52e 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -1,6 +1,6 @@ { "minimum-stability": "beta", "require-dev": { - "fabpot/goutte": "1.0.x-dev" + "fabpot/goutte": "v0.1.0" } } diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 9f2195e70a..a78fff9a14 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,55 +1,456 @@ { - "hash": "a5d02c59e3a91c84c1a96aca0f1ae81a", + "hash": "23352b29002e6d22658e314a8e737f71", "packages": [ - + { + "name": "symfony/event-dispatcher", + "version": "v2.1.4", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher", + "reference": "v2.1.4" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/EventDispatcher/archive/v2.1.4.zip", + "reference": "v2.1.4", + "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-11-08 09:51:48", + "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" + } ], "packages-dev": [ { - "package": "fabpot/goutte", - "version": "dev-master", - "alias-pretty-version": "1.0.x-dev", - "alias-version": "1.0.9999999.9999999-dev" + "name": "fabpot/goutte", + "version": "v0.1.0", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Goutte", + "reference": "v0.1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/fabpot/Goutte/archive/v0.1.0.zip", + "reference": "v0.1.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "ext-curl": "*", + "symfony/browser-kit": "2.1.*", + "symfony/css-selector": "2.1.*", + "symfony/dom-crawler": "2.1.*", + "symfony/finder": "2.1.*", + "symfony/process": "2.1.*", + "guzzle/guzzle": "3.0.*" + }, + "time": "2012-12-02 13:44:35", + "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": "c2ea8d9a6682d14482e57ede2371001b8a5238d2", - "commit-date": "1340264258" + "name": "guzzle/guzzle", + "version": "v3.0.5", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle", + "reference": "v3.0.5" + }, + "dist": { + "type": "zip", + "url": "https://github.com/guzzle/guzzle/archive/v3.0.5.zip", + "reference": "v3.0.5", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "ext-curl": "*", + "symfony/event-dispatcher": "2.1.*" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/common": "*", + "symfony/class-loader": "*", + "monolog/monolog": "1.*", + "zendframework/zend-cache": "2.0.*", + "zendframework/zend-log": "2.0.*", + "zend/zend-log1": "1.12", + "zend/zend-cache1": "1.12", + "phpunit/phpunit": "3.7.*" + }, + "time": "2012-11-19 00:15:33", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Guzzle\\Tests": "tests/", + "Guzzle": "src/" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "framework", + "curl", + "http", + "rest", + "http client", + "client", + "web service" + ] }, { - "package": "guzzle/guzzle", - "version": "v2.6.6" + "name": "symfony/browser-kit", + "version": "v2.1.4", + "target-dir": "Symfony/Component/BrowserKit", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit", + "reference": "v2.1.4" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/BrowserKit/archive/v2.1.4.zip", + "reference": "v2.1.4", + "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-11-08 09:51:48", + "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-BETA3" + "name": "symfony/css-selector", + "version": "v2.1.4", + "target-dir": "Symfony/Component/CssSelector", + "source": { + "type": "git", + "url": "https://github.com/symfony/CssSelector", + "reference": "v2.1.4" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/CssSelector/archive/v2.1.4.zip", + "reference": "v2.1.4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-11-08 09:51:48", + "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-BETA3" + "name": "symfony/dom-crawler", + "version": "v2.1.4", + "target-dir": "Symfony/Component/DomCrawler", + "source": { + "type": "git", + "url": "https://github.com/symfony/DomCrawler", + "reference": "v2.1.4" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/DomCrawler/archive/v2.1.4.zip", + "reference": "v2.1.4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/css-selector": "2.1.*" + }, + "suggest": { + "symfony/css-selector": "2.1.*" + }, + "time": "2012-11-29 10:32:18", + "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-BETA3" + "name": "symfony/finder", + "version": "v2.1.4", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder", + "reference": "v2.1.4" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Finder/archive/v2.1.4.zip", + "reference": "v2.1.4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-11-08 09:51:48", + "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/event-dispatcher", - "version": "v2.1.0-BETA3" - }, - { - "package": "symfony/finder", - "version": "v2.1.0-BETA3" - }, - { - "package": "symfony/process", - "version": "v2.1.0-BETA3" + "name": "symfony/process", + "version": "v2.1.4", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process", + "reference": "v2.1.4" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Process/archive/v2.1.4.zip", + "reference": "v2.1.4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-11-19 20:53:52", + "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": [ ], "minimum-stability": "beta", - "stability-flags": { - "fabpot/goutte": 20 - } + "stability-flags": [ + + ] } From df78c616aadf57ebb00988b299b34d39b558fda1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 2 Dec 2012 23:54:59 -0500 Subject: [PATCH 160/196] [ticket/9983] Indeed, it is Date: Sun, 2 Dec 2012 23:55:42 -0500 Subject: [PATCH 161/196] [ticket/9983] Empty line by request. PHPBB3-9983 --- phpBB/includes/cache/driver/redis.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/includes/cache/driver/redis.php index ae6f9e04f2..960735b673 100644 --- a/phpBB/includes/cache/driver/redis.php +++ b/phpBB/includes/cache/driver/redis.php @@ -67,6 +67,7 @@ class phpbb_cache_driver_redis extends phpbb_cache_driver_memory { $ok = $this->redis->connect(PHPBB_ACM_REDIS_HOST, PHPBB_ACM_REDIS_PORT); } + if (!$ok) { trigger_error('Could not connect to redis server'); From 7d09b9b4bb58e71f0e7b895ef32059ad08d12416 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 2 Dec 2012 23:57:37 -0500 Subject: [PATCH 162/196] [ticket/9983] Add phpbb prefix to global variables. PHPBB3-9983 --- tests/RUNNING_TESTS.txt | 4 ++-- tests/test_framework/phpbb_test_case_helpers.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index 395cf1240a..75a6fc94f6 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -80,8 +80,8 @@ or port must be specified in test configuration. This can be done via test_config.php as follows: Date: Mon, 3 Dec 2012 00:18:52 -0500 Subject: [PATCH 163/196] [ticket/9983] Test for apc cache driver. PHPBB3-9983 --- tests/cache/apc_driver_test.php | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/cache/apc_driver_test.php diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php new file mode 100644 index 0000000000..f6e001f705 --- /dev/null +++ b/tests/cache/apc_driver_test.php @@ -0,0 +1,79 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + static public function setUpBeforeClass() + { + if (!extension_loaded('apc')) + { + self::markTestSkipped('apc extension is not loaded'); + } + } + + protected function setUp() + { + parent::setUp(); + + $this->driver = new phpbb_cache_driver_apc; + $this->driver->purge(); + } + + public function test_cache_sql() + { + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($this->driver); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + + $key = $this->driver->key_prefix . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)); + $this->assertFalse(apc_fetch($key)); + + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $this->assertTrue((bool) apc_fetch($key)); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertEquals($expected, $db->sql_fetchrow($result)); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql); + + $no_cache_result = $db->sql_fetchrow($result); + $this->assertSame(false, $no_cache_result); + + $db->sql_close(); + } +} From 0b4b7e68a75438368868ede050bc6dd66fc80767 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 3 Dec 2012 14:17:34 +0100 Subject: [PATCH 164/196] [ticket/9983] Skip tests if APC is not enabled for CLI. PHPBB3-9983 --- tests/cache/apc_driver_test.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index f6e001f705..f7cf2119ed 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -29,6 +29,12 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case { self::markTestSkipped('apc extension is not loaded'); } + + $php_ini = new phpbb_php_ini; + if (PHP_SAPI == 'cli' && !$php_ini->get_bool('apc.enable_cli')) + { + self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini'); + } } protected function setUp() From 2e851baab90b0c9960eb7427acf41bfb8a848195 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 3 Dec 2012 14:18:05 +0100 Subject: [PATCH 165/196] [ticket/9983] Use APC instead of apc in error messages. PHPBB3-9983 --- tests/cache/apc_driver_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index f7cf2119ed..100ba76686 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -27,7 +27,7 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case { if (!extension_loaded('apc')) { - self::markTestSkipped('apc extension is not loaded'); + self::markTestSkipped('APC extension is not loaded'); } $php_ini = new phpbb_php_ini; From db6b11a3902c27b612d7d6d4696c4cd8cf1f0bdf Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 3 Dec 2012 14:35:59 +0100 Subject: [PATCH 166/196] [ticket/9983] Also check generic APC enable/disable. PHPBB3-9983 --- tests/cache/apc_driver_test.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index 100ba76686..c8b8f82b67 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -31,6 +31,12 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case } $php_ini = new phpbb_php_ini; + + if (!$php_ini->get_bool('apc.enabled')) + { + self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini'); + } + if (PHP_SAPI == 'cli' && !$php_ini->get_bool('apc.enable_cli')) { self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini'); From e845e2ed89f75a5c9f14191f833334d84d389faf Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 4 Dec 2012 00:40:24 +0100 Subject: [PATCH 167/196] [ticket/11240] Enable PHPUnit's verbose mode so we get a list of skipped tests. PHPBB3-11240 --- travis/phpunit-mysql-travis.xml | 1 + travis/phpunit-postgres-travis.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index e54b2bb77b..5366494c8b 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -9,6 +9,7 @@ stopOnFailure="false" syntaxCheck="true" strict="true" + verbose="true" bootstrap="../tests/bootstrap.php"> diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 55ba996548..0383edd9d6 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -9,6 +9,7 @@ stopOnFailure="false" syntaxCheck="true" strict="true" + verbose="true" bootstrap="../tests/bootstrap.php"> From d93f582b04d2e6d0738cd6a2ffee739b8c987276 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 3 Dec 2012 21:47:29 -0500 Subject: [PATCH 168/196] [ticket/9983] Make sql cache test into a black box. This makes it non-driver-specific and also makes it possible to make prefix variable private on drivers. PHPBB3-9983 --- tests/cache/apc_driver_test.php | 38 ---------------------------- tests/cache/common_test_case.php | 33 ++++++++++++++++++++++++ tests/cache/file_driver_test.php | 38 ---------------------------- tests/cache/redis_driver_test.php | 42 ------------------------------- 4 files changed, 33 insertions(+), 118 deletions(-) diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index c8b8f82b67..3380762878 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -50,42 +50,4 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case $this->driver = new phpbb_cache_driver_apc; $this->driver->purge(); } - - public function test_cache_sql() - { - global $db, $cache; - $db = $this->new_dbal(); - $cache = new phpbb_cache_service($this->driver); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - - $key = $this->driver->key_prefix . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)); - $this->assertFalse(apc_fetch($key)); - - $result = $db->sql_query($sql, 300); - $first_result = $db->sql_fetchrow($result); - $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); - $this->assertEquals($expected, $first_result); - - $this->assertTrue((bool) apc_fetch($key)); - - $sql = 'DELETE FROM phpbb_config'; - $result = $db->sql_query($sql); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - - $this->assertEquals($expected, $db->sql_fetchrow($result)); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql); - - $no_cache_result = $db->sql_fetchrow($result); - $this->assertSame(false, $no_cache_result); - - $db->sql_close(); - } } diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php index 45cf80e424..fa298ec9ae 100644 --- a/tests/cache/common_test_case.php +++ b/tests/cache/common_test_case.php @@ -61,4 +61,37 @@ abstract class phpbb_cache_common_test_case extends phpbb_database_test_case $this->driver->get('second_key') ); } + + public function test_cache_sql() + { + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($this->driver); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertEquals($expected, $db->sql_fetchrow($result)); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql); + + $no_cache_result = $db->sql_fetchrow($result); + $this->assertSame(false, $no_cache_result); + + $db->sql_close(); + } } diff --git a/tests/cache/file_driver_test.php b/tests/cache/file_driver_test.php index 2353940277..745c6bb081 100644 --- a/tests/cache/file_driver_test.php +++ b/tests/cache/file_driver_test.php @@ -66,42 +66,4 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case } rmdir($this->cache_dir); } - - public function test_cache_sql() - { - global $db, $cache; - $db = $this->new_dbal(); - $cache = new phpbb_cache_service($this->driver); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - - $cache_path = $this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php'; - $this->assertFileNotExists($cache_path); - - $result = $db->sql_query($sql, 300); - $first_result = $db->sql_fetchrow($result); - $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); - $this->assertEquals($expected, $first_result); - - $this->assertFileExists($cache_path); - - $sql = 'DELETE FROM phpbb_config'; - $result = $db->sql_query($sql); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - - $this->assertEquals($expected, $db->sql_fetchrow($result)); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql); - - $no_cache_result = $db->sql_fetchrow($result); - $this->assertSame(false, $no_cache_result); - - $db->sql_close(); - } } diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php index cd24e33baf..c59d5e1929 100644 --- a/tests/cache/redis_driver_test.php +++ b/tests/cache/redis_driver_test.php @@ -46,46 +46,4 @@ class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case $this->driver = new phpbb_cache_driver_redis(self::$config['host'], self::$config['port']); $this->driver->purge(); } - - public function test_cache_sql() - { - global $db, $cache; - $db = $this->new_dbal(); - $cache = new phpbb_cache_service($this->driver); - - $redis = new Redis(); - $ok = $redis->connect(self::$config['host'], self::$config['port']); - $this->assertTrue($ok); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - - $key = $this->driver->key_prefix . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)); - $this->assertFalse($redis->exists($key)); - - $result = $db->sql_query($sql, 300); - $first_result = $db->sql_fetchrow($result); - $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); - $this->assertEquals($expected, $first_result); - - $this->assertTrue($redis->exists($key)); - - $sql = 'DELETE FROM phpbb_config'; - $result = $db->sql_query($sql); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql, 300); - - $this->assertEquals($expected, $db->sql_fetchrow($result)); - - $sql = "SELECT * FROM phpbb_config - WHERE config_name = 'foo'"; - $result = $db->sql_query($sql); - - $no_cache_result = $db->sql_fetchrow($result); - $this->assertSame(false, $no_cache_result); - - $db->sql_close(); - } } From f08c28c77a585e35cc17a2248ba61428275ccdd7 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 01:59:27 -0500 Subject: [PATCH 169/196] [ticket/10103] Factor out flock lock class. PHPBB3-10103 --- phpBB/includes/functions_messenger.php | 58 ------------ phpBB/includes/lock/flock.php | 124 +++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 58 deletions(-) create mode 100644 phpBB/includes/lock/flock.php diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index cf03de08c4..503f419e5a 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -650,64 +650,6 @@ class queue $this->data[$object]['data'][] = $scope; } - /** - * Obtains exclusive lock on queue cache file. - * Returns resource representing the lock - */ - function lock() - { - // For systems that can't have two processes opening - // one file for writing simultaneously - if (file_exists($this->cache_file . '.lock')) - { - $mode = 'rb'; - } - else - { - $mode = 'wb'; - } - - $lock_fp = @fopen($this->cache_file . '.lock', $mode); - - if ($mode == 'wb') - { - if (!$lock_fp) - { - // Two processes may attempt to create lock file at the same time. - // Have the losing process try opening the lock file again for reading - // on the assumption that the winning process created it - $mode = 'rb'; - $lock_fp = @fopen($this->cache_file . '.lock', $mode); - } - else - { - // Only need to set mode when the lock file is written - @chmod($this->cache_file . '.lock', 0666); - } - } - - if ($lock_fp) - { - @flock($lock_fp, LOCK_EX); - } - - return $lock_fp; - } - - /** - * Releases lock on queue cache file, using resource obtained from lock() - */ - function unlock($lock_fp) - { - // lock() will return null if opening lock file, and thus locking, failed. - // Accept null values here so that client code does not need to check them - if ($lock_fp) - { - @flock($lock_fp, LOCK_UN); - fclose($lock_fp); - } - } - /** * Process queue * Using lock file diff --git a/phpBB/includes/lock/flock.php b/phpBB/includes/lock/flock.php new file mode 100644 index 0000000000..e24a5f3e1c --- /dev/null +++ b/phpBB/includes/lock/flock.php @@ -0,0 +1,124 @@ +path = $path; + $this->lock_fp = null; + } + + /** + * Tries to acquire the lock. + * + * As a lock may only be held by one process at a time, lock + * acquisition may fail if another process is holding the lock. + * + * @return bool true if lock was acquired + * false otherwise + */ + public function acquire() + { + if ($this->locked) + { + return false; + } + + // For systems that can't have two processes opening + // one file for writing simultaneously + if (file_exists($this->path . '.lock')) + { + $mode = 'rb'; + } + else + { + $mode = 'wb'; + } + + $this->lock_fp = @fopen($this->path . '.lock', $mode); + + if ($mode == 'wb') + { + if (!$this->lock_fp) + { + // Two processes may attempt to create lock file at the same time. + // Have the losing process try opening the lock file again for reading + // on the assumption that the winning process created it + $mode = 'rb'; + $this->lock_fp = @fopen($this->path . '.lock', $mode); + } + else + { + // Only need to set mode when the lock file is written + @chmod($this->path . '.lock', 0666); + } + } + + if ($this->lock_fp) + { + @flock($this->lock_fp, LOCK_EX); + } + + return (bool) $this->lock_fp; + } + + /** + * Releases the lock. + * + * The lock must have been previously obtained, that is, acquire() call + * was issued and returned true. + * + * Note: Attempting to release a lock that is already released, + * that is, calling release() multiple times, is harmless. + * + * @return null + */ + public function release() + { + if ($this->lock_fp) + { + @flock($this->lock_fp, LOCK_UN); + fclose($this->lock_fp); + $this->lock_fp = null; + } + } +} From 4010f4085aa56f20fd95274ecfc2fe7404f98269 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 02:00:27 -0500 Subject: [PATCH 170/196] [ticket/10103] Use flock lock class in messenger. PHPBB3-10103 --- phpBB/includes/functions_messenger.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 503f419e5a..56fc7e628f 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -658,13 +658,14 @@ class queue { global $db, $config, $phpEx, $phpbb_root_path, $user; - $lock_fp = $this->lock(); + $lock = new phpbb_lock_flock($this->cache_file); + $lock->acquire(); set_config('last_queue_run', time(), true); if (!file_exists($this->cache_file) || filemtime($this->cache_file) > time() - $config['queue_interval']) { - $this->unlock($lock_fp); + $lock->release(); return; } @@ -731,7 +732,7 @@ class queue break; default: - $this->unlock($lock_fp); + $lock->release(); return; } @@ -807,7 +808,7 @@ class queue } } - $this->unlock($lock_fp); + $lock->release(); } /** @@ -820,7 +821,8 @@ class queue return; } - $lock_fp = $this->lock(); + $lock = new phpbb_lock_flock($this->cache_file); + $lock->acquire(); if (file_exists($this->cache_file)) { @@ -847,7 +849,7 @@ class queue phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); } - $this->unlock($lock_fp); + $lock->release(); } } From f72e435759e8fafe3b06af35072c1907ba016546 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 02:21:53 -0500 Subject: [PATCH 171/196] [ticket/10103] Test for flock lock class, with concurrency no less. PHPBB3-10103 --- tests/lock/flock_test.php | 108 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 tests/lock/flock_test.php diff --git a/tests/lock/flock_test.php b/tests/lock/flock_test.php new file mode 100644 index 0000000000..5c645de27c --- /dev/null +++ b/tests/lock/flock_test.php @@ -0,0 +1,108 @@ +acquire(); + $this->assertTrue($ok); + $lock->release(); + } + + public function test_consecutive_locking() + { + $path = __DIR__ . '/../tmp/precious'; + + $lock = new phpbb_lock_flock($path); + $ok = $lock->acquire(); + $this->assertTrue($ok); + $lock->release(); + + $ok = $lock->acquire(); + $this->assertTrue($ok); + $lock->release(); + + $ok = $lock->acquire(); + $this->assertTrue($ok); + $lock->release(); + } + + /* This hangs the process. + public function test_concurrent_locking_fail() + { + $path = __DIR__ . '/../tmp/precious'; + + $lock1 = new phpbb_lock_flock($path); + $ok = $lock1->acquire(); + $this->assertTrue($ok); + + $lock2 = new phpbb_lock_flock($path); + $ok = $lock2->acquire(); + $this->assertFalse($ok); + + $lock->release(); + $ok = $lock2->acquire(); + $this->assertTrue($ok); + } + */ + + public function test_concurrent_locking() + { + if (!function_exists('pcntl_fork')) + { + $this->markTestSkipped('pcntl extension and pcntl_fork are required for this test'); + } + + $path = __DIR__ . '/../tmp/precious'; + + if ($pid = pcntl_fork()) + { + // parent + // wait 0.5 s, acquire the lock, note how long it took + sleep(0.5); + + $lock = new phpbb_lock_flock($path); + $start = time(); + $ok = $lock->acquire(); + $delta = time() - $start; + $this->assertTrue($ok); + $this->assertTrue($delta > 0.5); + + $lock->release(); + + // acquire again, this should be instantaneous + $start = time(); + $ok = $lock->acquire(); + $delta = time() - $start; + $this->assertTrue($ok); + $this->assertTrue($delta < 0.1); + + // reap the child + $status = null; + pcntl_waitpid($pid, $status); + } + else + { + // child + // immediately acquire the lock and sleep for 2 s + $lock = new phpbb_lock_flock($path); + $ok = $lock->acquire(); + $this->assertTrue($ok); + sleep(2); + $lock->release(); + + // and go away silently + pcntl_exec('/usr/bin/env', array('true')); + } + } +} From 318140b4d6257dd49ae86ed1185568f4d523e53e Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 02:26:55 -0500 Subject: [PATCH 172/196] [ticket/10103] Convert the rest of the tree to flock class. PHPBB3-10103 --- phpBB/includes/cache/driver/file.php | 16 +++++++++++----- phpBB/includes/template/compile.php | 8 +++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php index a0f06dde4b..ee1b430451 100644 --- a/phpBB/includes/cache/driver/file.php +++ b/phpBB/includes/cache/driver/file.php @@ -653,10 +653,11 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base $file = "{$this->cache_dir}$filename.$phpEx"; + $lock = new phpbb_lock_flock($file); + $lock->acquire(); + if ($handle = @fopen($file, 'wb')) { - @flock($handle, LOCK_EX); - // File header fwrite($handle, '<' . '?php exit; ?' . '>'); @@ -697,7 +698,6 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base fwrite($handle, $data); } - @flock($handle, LOCK_UN); fclose($handle); if (!function_exists('phpbb_chmod')) @@ -708,10 +708,16 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE); - return true; + $rv = true; + } + else + { + $rv = false; } - return false; + $lock->release(); + + return $rv; } /** diff --git a/phpBB/includes/template/compile.php b/phpBB/includes/template/compile.php index d0b3d0f115..22da21820e 100644 --- a/phpBB/includes/template/compile.php +++ b/phpBB/includes/template/compile.php @@ -58,6 +58,9 @@ class phpbb_template_compile */ public function compile_file_to_file($source_file, $compiled_file) { + $lock = new phpbb_lock_flock($compiled_file); + $lock->acquire(); + $source_handle = @fopen($source_file, 'rb'); $destination_handle = @fopen($compiled_file, 'wb'); @@ -66,16 +69,15 @@ class phpbb_template_compile return false; } - @flock($destination_handle, LOCK_EX); - $this->compile_stream_to_stream($source_handle, $destination_handle); @fclose($source_handle); - @flock($destination_handle, LOCK_UN); @fclose($destination_handle); phpbb_chmod($compiled_file, CHMOD_READ | CHMOD_WRITE); + $lock->release(); + clearstatcache(); return true; From fc410e1cd0071a2de3dc90ce62a5abbef0266f15 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 02:38:57 -0500 Subject: [PATCH 173/196] [ticket/10103] Try a longer sleep for travis. Apparently travis takes longer than half a second to fork php. PHPBB3-10103 --- tests/lock/flock_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lock/flock_test.php b/tests/lock/flock_test.php index 5c645de27c..bc682f9410 100644 --- a/tests/lock/flock_test.php +++ b/tests/lock/flock_test.php @@ -69,7 +69,7 @@ class phpbb_lock_flock_test extends phpbb_test_case { // parent // wait 0.5 s, acquire the lock, note how long it took - sleep(0.5); + sleep(1); $lock = new phpbb_lock_flock($path); $start = time(); From cf3080b83ed6f90b24cfd99a9fc7dd71dddde827 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 02:39:50 -0500 Subject: [PATCH 174/196] [ticket/9983] Correct incorrect markTestSkipped call. PHPBB3-9983 --- tests/cache/redis_driver_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php index cd24e33baf..a90a750460 100644 --- a/tests/cache/redis_driver_test.php +++ b/tests/cache/redis_driver_test.php @@ -35,7 +35,7 @@ class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case } else { - $this->markTestSkipped('Test redis host/port is not specified'); + self::markTestSkipped('Test redis host/port is not specified'); } } From b67f112e03cf37436bdd650ea4b9a75b35000fdd Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 02:52:18 -0500 Subject: [PATCH 175/196] [ticket/10091] Bump minimum supported postgresql version to 8.3. PHPBB3-10091 --- phpBB/docs/INSTALL.html | 2 +- phpBB/docs/coding-guidelines.html | 2 +- phpBB/includes/functions_install.php | 2 +- phpBB/language/en/install.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/docs/INSTALL.html b/phpBB/docs/INSTALL.html index 07f0cbc8c2..58aeb904c7 100644 --- a/phpBB/docs/INSTALL.html +++ b/phpBB/docs/INSTALL.html @@ -132,7 +132,7 @@
  • A SQL database system, one of:
    • MySQL 3.23 or above (MySQLi supported)
    • -
    • PostgreSQL 7.3+
    • +
    • PostgreSQL 8.3+
    • SQLite 2.8.2+ (SQLite 3 is not supported)
    • Firebird 2.1+
    • MS SQL Server 2000 or above (directly or via ODBC or the native adapter)
    • diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 0e3a97c004..eb569d12d5 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -740,7 +740,7 @@ static private function f()

      2.iii. SQL/SQL Layout

      Common SQL Guidelines:

      -

      All SQL should be cross-DB compatible, if DB specific SQL is used alternatives must be provided which work on all supported DB's (MySQL3/4/5, MSSQL (7.0 and 2000), PostgreSQL (7.0+), Firebird, SQLite, Oracle8, ODBC (generalised if possible)).

      +

      All SQL should be cross-DB compatible, if DB specific SQL is used alternatives must be provided which work on all supported DB's (MySQL3/4/5, MSSQL (7.0 and 2000), PostgreSQL (8.3+), Firebird, SQLite, Oracle8, ODBC (generalised if possible)).

      All SQL commands should utilise the DataBase Abstraction Layer (DBAL)

      SQL code layout:

      diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 7a799993db..ab6b3ea009 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -87,7 +87,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 '2.0.x' => false, ), 'postgres' => array( - 'LABEL' => 'PostgreSQL 7.x/8.x', + 'LABEL' => 'PostgreSQL 8.3+', 'SCHEMA' => 'postgres', 'MODULE' => 'pgsql', 'DELIM' => ';', diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index cb6a17afa2..1c45deae11 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -210,7 +210,7 @@ $lang = array_merge($lang, array(

      phpBB3 supports the following databases:

      • MySQL 3.23 or above (MySQLi supported)
      • -
      • PostgreSQL 7.3+
      • +
      • PostgreSQL 8.3+
      • SQLite 2.8.2+
      • Firebird 2.1+
      • MS SQL Server 2000 or above (directly or via ODBC)
      • From af2887f3a7f27b33c2ecd14d4baab846b71ddb62 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 03:34:51 -0500 Subject: [PATCH 176/196] [ticket/10716] php parse all php files as part of the test suite. PHPBB3-10716 --- tests/lint_test.php | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/lint_test.php diff --git a/tests/lint_test.php b/tests/lint_test.php new file mode 100644 index 0000000000..57c78ae809 --- /dev/null +++ b/tests/lint_test.php @@ -0,0 +1,49 @@ +check($root); + } + + protected function check($root) + { + $dh = opendir($root); + while (($filename = readdir($dh)) !== false) + { + if ($filename == '.' || $filename == '..' || $filename == 'git') + { + continue; + } + $path = $root . '/' . $filename; + // skip symlinks to avoid infinite loops + if (is_link($path)) + { + continue; + } + if (is_dir($path)) + { + $this->check($path); + } + else if (substr($filename, strlen($filename)-4) == '.php') + { + // assume php binary is called php and it is in PATH + $cmd = 'php -l ' . escapeshellarg($path); + $output = array(); + $status = 1; + exec($cmd, $output, $status); + $output = implode("\n", $output); + $this->assertEquals(0, $status, "php -l failed for $path:\n$output"); + } + } + } +} From 4cc81f1ffa62cdbcbb656300c7dd9fbd44cc21fc Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 13:44:22 -0500 Subject: [PATCH 177/196] [ticket/10103] Correct flock class documentation. PHPBB3-10103 --- phpBB/includes/lock/flock.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/lock/flock.php b/phpBB/includes/lock/flock.php index e24a5f3e1c..09450644bc 100644 --- a/phpBB/includes/lock/flock.php +++ b/phpBB/includes/lock/flock.php @@ -35,9 +35,9 @@ class phpbb_lock_flock private $lock_fp; /** - * Creates an instance of the lock. + * Constructor. * - * You have to call acquire() to actually create the lock. + * You have to call acquire() to actually acquire the lock. * * @param string $path Path to the file access to which is controlled */ @@ -50,8 +50,17 @@ class phpbb_lock_flock /** * Tries to acquire the lock. * - * As a lock may only be held by one process at a time, lock - * acquisition may fail if another process is holding the lock. + * If the lock is already held by another process, this call will block + * until the other process releases the lock. If a lock is acquired and + * is not released before script finishes but the process continues to + * live (apache/fastcgi) then subsequent processes trying to acquire + * the same lock will be blocked forever. + * + * If the lock is already held by the same process via another instance + * of this class, this call will block forever. + * + * If flock function is disabled in php or fails to work, lock + * acquisition will fail and false will be returned. * * @return bool true if lock was acquired * false otherwise From 3924676f2bd1a30ff56ab1db985cf622f1fac286 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 13:45:02 -0500 Subject: [PATCH 178/196] [ticket/10103] $rv had too few characters. PHPBB3-10103 --- phpBB/includes/cache/driver/file.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php index ee1b430451..691abe0438 100644 --- a/phpBB/includes/cache/driver/file.php +++ b/phpBB/includes/cache/driver/file.php @@ -708,16 +708,16 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE); - $rv = true; + $return_value = true; } else { - $rv = false; + $return_value = false; } $lock->release(); - return $rv; + return $return_value; } /** From a553cfbc30472f136f9904d97bf4d09a7187518f Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 13:46:01 -0500 Subject: [PATCH 179/196] [ticket/10103] Inline assignment is bad? PHPBB3-10103 --- tests/lock/flock_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/lock/flock_test.php b/tests/lock/flock_test.php index bc682f9410..abcb4e79c2 100644 --- a/tests/lock/flock_test.php +++ b/tests/lock/flock_test.php @@ -65,7 +65,8 @@ class phpbb_lock_flock_test extends phpbb_test_case $path = __DIR__ . '/../tmp/precious'; - if ($pid = pcntl_fork()) + $pid = pcntl_fork(); + if ($pid) { // parent // wait 0.5 s, acquire the lock, note how long it took From 285feb49f82084b5b489aa1fc6765b9b02ea1b29 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 13:47:57 -0500 Subject: [PATCH 180/196] [ticket/10103] assertLessThan/assertGreaterThan. PHPBB3-10103 --- tests/lock/flock_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lock/flock_test.php b/tests/lock/flock_test.php index abcb4e79c2..8bb7d0a041 100644 --- a/tests/lock/flock_test.php +++ b/tests/lock/flock_test.php @@ -77,7 +77,7 @@ class phpbb_lock_flock_test extends phpbb_test_case $ok = $lock->acquire(); $delta = time() - $start; $this->assertTrue($ok); - $this->assertTrue($delta > 0.5); + $this->assertGreaterThan(0.5, $delta); $lock->release(); @@ -86,7 +86,7 @@ class phpbb_lock_flock_test extends phpbb_test_case $ok = $lock->acquire(); $delta = time() - $start; $this->assertTrue($ok); - $this->assertTrue($delta < 0.1); + $this->assertLessThan(0.1, $delta); // reap the child $status = null; From e22dd7dfadedd951d1fd17b61fa700c572ca4d79 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 13:50:35 -0500 Subject: [PATCH 181/196] [ticket/10103] Assert with messages. PHPBB3-10103 --- tests/lock/flock_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lock/flock_test.php b/tests/lock/flock_test.php index 8bb7d0a041..1edc96b3a4 100644 --- a/tests/lock/flock_test.php +++ b/tests/lock/flock_test.php @@ -77,7 +77,7 @@ class phpbb_lock_flock_test extends phpbb_test_case $ok = $lock->acquire(); $delta = time() - $start; $this->assertTrue($ok); - $this->assertGreaterThan(0.5, $delta); + $this->assertGreaterThan(0.5, $delta, 'First lock acquired too soon'); $lock->release(); @@ -86,7 +86,7 @@ class phpbb_lock_flock_test extends phpbb_test_case $ok = $lock->acquire(); $delta = time() - $start; $this->assertTrue($ok); - $this->assertLessThan(0.1, $delta); + $this->assertLessThan(0.1, $delta, 'Second lock not acquired instantaneously'); // reap the child $status = null; From 4133fae99ec4146a01c67f6a6b3020020d1c6464 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 13:58:14 -0500 Subject: [PATCH 182/196] [ticket/10716] Only lint on php 5.3+. PHPBB3-10716 --- tests/lint_test.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/lint_test.php b/tests/lint_test.php index 57c78ae809..1642b571dd 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -11,6 +11,11 @@ class phpbb_lint_test extends phpbb_test_case { public function test_lint() { + if (version_compare(PHP_VERSION, '5.3.0', '<')) + { + $this->markTestSkipped('phpBB uses PHP 5.3 syntax in some files, linting on PHP < 5.3 will fail'); + } + $root = dirname(__FILE__) . '/..'; $this->check($root); } From 3e093c282a63df4d16b212859fd8137fd2bbca81 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 14:05:49 -0500 Subject: [PATCH 183/196] [ticket/10103] New and improved wording. PHPBB3-10103 --- phpBB/includes/lock/flock.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/lock/flock.php b/phpBB/includes/lock/flock.php index 09450644bc..5c2288ce1b 100644 --- a/phpBB/includes/lock/flock.php +++ b/phpBB/includes/lock/flock.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) class phpbb_lock_flock { /** - * Path to the file access to which is controlled + * Path to the file to which access is controlled * * @var string */ @@ -39,7 +39,7 @@ class phpbb_lock_flock * * You have to call acquire() to actually acquire the lock. * - * @param string $path Path to the file access to which is controlled + * @param string $path Path to the file to which access is controlled */ public function __construct($path) { From 8897efe087195ba31920c6b3aadbe8ea1b393c12 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 16:42:58 -0500 Subject: [PATCH 184/196] [ticket/10716] Exclude our dependencies from linting. PHPBB3-10716 --- tests/lint_test.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/lint_test.php b/tests/lint_test.php index 1642b571dd..67b7413cb4 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -9,6 +9,17 @@ class phpbb_lint_test extends phpbb_test_case { + static protected $exclude; + + static public function setUpBeforeClass() + { + self::$exclude = array( + // PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20 + // https://gist.github.com/e003913ffd493da63cbc + dirname(__FILE__) . '/../phpBB/vendor', + ); + } + public function test_lint() { if (version_compare(PHP_VERSION, '5.3.0', '<')) @@ -35,7 +46,7 @@ class phpbb_lint_test extends phpbb_test_case { continue; } - if (is_dir($path)) + if (is_dir($path) && !in_array($path, self::$exclude)) { $this->check($path); } From 8ea52b56197cc9a234d6b0ce3ddd10820feb6dd1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 17:43:36 -0500 Subject: [PATCH 185/196] [ticket/10716] Skip test if php is not in PATH. PHPBB3-10716 --- tests/lint_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/lint_test.php b/tests/lint_test.php index 67b7413cb4..d73ab7fedd 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -13,6 +13,14 @@ class phpbb_lint_test extends phpbb_test_case static public function setUpBeforeClass() { + $output = array(); + $status = 1; + exec('php -v', $output, $status); + if ($status) + { + self::markTestSkipped("php is not in PATH or broken: $output"); + } + self::$exclude = array( // PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20 // https://gist.github.com/e003913ffd493da63cbc From fb261e19ffc3bf19477510fa3877a8d9ea251655 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 18:52:27 -0500 Subject: [PATCH 186/196] [ticket/10716] Collect standard error from executed php process. php executes everything via a shell. The standard error of this top level shell is not captured by exec/shell_exec/popen/etc. and there is no way to capture it. proc_open might work but it is a nightmare to use and without multiplexing reads from standard error and standard output it can deadlock. Thus the solution in this commit. Put the command into a subshell and redirect standard error to standard output for the subshell. PHPBB3-10716 --- tests/lint_test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/lint_test.php b/tests/lint_test.php index d73ab7fedd..905067072d 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -15,9 +15,10 @@ class phpbb_lint_test extends phpbb_test_case { $output = array(); $status = 1; - exec('php -v', $output, $status); + exec('(php -v) 2>&1', $output, $status); if ($status) { + $output = implode("\n", $output); self::markTestSkipped("php is not in PATH or broken: $output"); } @@ -61,7 +62,7 @@ class phpbb_lint_test extends phpbb_test_case else if (substr($filename, strlen($filename)-4) == '.php') { // assume php binary is called php and it is in PATH - $cmd = 'php -l ' . escapeshellarg($path); + $cmd = '(php -l ' . escapeshellarg($path) . ') 2>&1'; $output = array(); $status = 1; exec($cmd, $output, $status); From 03f819862f15efa2ef64331b23394086746d09be Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 00:41:47 -0500 Subject: [PATCH 187/196] [ticket/10602] Use last_queue_run for its intended purpose. We keep the last queue run time around, therefore for determining whether enough time has passed since the last run we can simply use this config variable. When there is no queue file we consider a queue run successful. Previously queue.php ("cache file") modification time would be used for determining whether enough time has passed since last queue run. The problem was that modification time would be updated whenever anything was added to the queue, creating a situation where if queue is processed less frequently than it is added to that email would not be sent. PHPBB3-10602 --- phpBB/includes/functions_messenger.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 6549693333..ae0f7823cc 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -715,14 +715,19 @@ class queue $lock_fp = $this->lock(); - set_config('last_queue_run', time(), true); - - if (!file_exists($this->cache_file) || filemtime($this->cache_file) > time() - $config['queue_interval']) + if (!file_exists($this->cache_file) || $config['last_queue_run'] > time() - $config['queue_interval']) { + if (!file_exists($this->cache_file)) + { + set_config('last_queue_run', time(), true); + } + $this->unlock($lock_fp); return; } + set_config('last_queue_run', time(), true); + include($this->cache_file); foreach ($this->queue_data as $object => $data_ary) From 1e50116c54ec7ffbaba4622d5481207423ef2bbe Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 00:57:24 -0500 Subject: [PATCH 188/196] [ticket/10602] Avoid a race condition. PHPBB3-10602 --- phpBB/includes/functions_messenger.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index ae0f7823cc..e837811c86 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -715,9 +715,11 @@ class queue $lock_fp = $this->lock(); - if (!file_exists($this->cache_file) || $config['last_queue_run'] > time() - $config['queue_interval']) + // avoid races, check file existence once + $have_cache_file = file_exists($this->cache_file); + if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval']) { - if (!file_exists($this->cache_file)) + if (!$have_cache_file) { set_config('last_queue_run', time(), true); } From a8d02ffc27d8cee916f267c91488276fca3606e7 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 01:54:29 -0500 Subject: [PATCH 189/196] [ticket/11247] Fix wrong property reference in flock class. PHPBB3-11247 --- phpBB/includes/lock/flock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/lock/flock.php b/phpBB/includes/lock/flock.php index 5c2288ce1b..97bc7dd2b9 100644 --- a/phpBB/includes/lock/flock.php +++ b/phpBB/includes/lock/flock.php @@ -67,7 +67,7 @@ class phpbb_lock_flock */ public function acquire() { - if ($this->locked) + if ($this->lock_fp) { return false; } From af064cdaad357f705fc7c80f4d018d57cffa8d33 Mon Sep 17 00:00:00 2001 From: Senky Date: Wed, 16 May 2012 23:02:20 +0200 Subject: [PATCH 190/196] [ticket/10841] Modifying style and language selectors in UCP Commit also deletes all unnecessary blank spaces at the end of the lines in both ucp_prefs_personal.html PHPBB3-10841 --- phpBB/includes/ucp/ucp_prefs.php | 30 +++++++++++++ .../template/ucp_prefs_personal.html | 42 ++++++++++--------- .../template/ucp_prefs_personal.html | 18 ++++---- 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 17d7d23f02..19e1b45787 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -134,6 +134,33 @@ class ucp_prefs } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . ''; + // check for count of installed languages + $sql = 'SELECT lang_id + FROM ' . LANG_TABLE; + $result = $db->sql_query($sql); + if( $db->sql_affectedrows() > 1 ) + { + $s_more_languages = true; + } + else + { + $s_more_languages = false; + } + + // check for count of installed and active styles + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_active = 1'; + $result = $db->sql_query($sql); + if( $db->sql_affectedrows() > 1 ) + { + $s_more_styles = true; + } + else + { + $s_more_styles = false; + } + $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
        ', $error) : '', @@ -155,6 +182,9 @@ class ucp_prefs 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), + 'S_MORE_LANGUAGES' => $s_more_languages, + 'S_MORE_STYLES' => $s_more_styles, + 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['style']), 'S_TZ_OPTIONS' => tz_select($data['tz'], true), diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 9022346627..416343e57d 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -12,21 +12,21 @@
        - +
        - +

        {L_ALLOW_PM_EXPLAIN}
        - +
        @@ -34,17 +34,17 @@

        {L_HIDE_ONLINE_EXPLAIN}
        - +
        - +
        - - + +
        @@ -52,22 +52,24 @@
        - +
        - +
        -
        -
        -
        -
        - + +
        +
        +
        +
        + +
        @@ -80,7 +82,7 @@
        - +
        @@ -97,9 +99,9 @@ - +
        - {S_HIDDEN_FIELDS}  + {S_HIDDEN_FIELDS}  {S_FORM_TOKEN}
        @@ -113,9 +115,9 @@ function customDates() { var e = document.getElementById('dateoptions'); - + e.selectedIndex = e.length - 1; - + // Loop and match date_format in menu for (var i = 0; i < e.length; i++) { @@ -125,7 +127,7 @@ break; } } - + // Show/hide custom field if (e.selectedIndex == e.length - 1) { diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index e2266b7d38..c604671c5c 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -29,43 +29,45 @@ {ERROR} - + {L_SHOW_EMAIL}: checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_ADMIN_EMAIL}: checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_ALLOW_PM}:
        {L_ALLOW_PM_EXPLAIN} checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_HIDE_ONLINE}:
        {L_HIDE_ONLINE_EXPLAIN} checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_NOTIFY_METHOD}:
        {L_NOTIFY_METHOD_EXPLAIN} checked="checked" />{L_NOTIFY_METHOD_EMAIL}   checked="checked" />{L_NOTIFY_METHOD_IM}   checked="checked" />{L_NOTIFY_METHOD_BOTH} - + {L_NOTIFY_ON_PM}: checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_POPUP_ON_PM}: checked="checked" />{L_YES}   checked="checked" />{L_NO} + {L_BOARD_LANGUAGE}: - + + {L_BOARD_STYLE}: From dd6983b14bba4326d824b3abb130eafc5e8f666c Mon Sep 17 00:00:00 2001 From: Senky Date: Thu, 17 May 2012 20:01:44 +0200 Subject: [PATCH 191/196] [ticket/10841] changing affectedrows check to COUNT in sql this sould reduce load and be faster. Also freeresult functions added PHPBB3-10841 --- phpBB/includes/ucp/ucp_prefs.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 19e1b45787..b95d2d4ee8 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -134,11 +134,11 @@ class ucp_prefs } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . ''; - // check for count of installed languages - $sql = 'SELECT lang_id + // check if there are any user-selectable languages + $sql = 'SELECT COUNT(lang_id) as languages_count FROM ' . LANG_TABLE; $result = $db->sql_query($sql); - if( $db->sql_affectedrows() > 1 ) + if( $db->sql_fetchfield('languages_count') > 1 ) { $s_more_languages = true; } @@ -146,13 +146,14 @@ class ucp_prefs { $s_more_languages = false; } + $db->sql_freeresult($result); - // check for count of installed and active styles - $sql = 'SELECT style_id + // check if there are any user-selectable styles + $sql = 'SELECT COUNT(style_id) as styles_count FROM ' . STYLES_TABLE . ' WHERE style_active = 1'; $result = $db->sql_query($sql); - if( $db->sql_affectedrows() > 1 ) + if( $db->sql_fetchfield('styles_count') > 1 ) { $s_more_styles = true; } @@ -160,6 +161,7 @@ class ucp_prefs { $s_more_styles = false; } + $db->sql_freeresult($result); $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
        ', $error) : '', From f7508c3f042091f163a87829a051312fa58630f1 Mon Sep 17 00:00:00 2001 From: Senky Date: Wed, 7 Nov 2012 10:28:25 +0100 Subject: [PATCH 192/196] [ticket/10841] removing unnecessary spacing PHPBB3-10841 --- phpBB/includes/ucp/ucp_prefs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index b95d2d4ee8..e84c7e662a 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -138,7 +138,7 @@ class ucp_prefs $sql = 'SELECT COUNT(lang_id) as languages_count FROM ' . LANG_TABLE; $result = $db->sql_query($sql); - if( $db->sql_fetchfield('languages_count') > 1 ) + if($db->sql_fetchfield('languages_count') > 1) { $s_more_languages = true; } @@ -153,7 +153,7 @@ class ucp_prefs FROM ' . STYLES_TABLE . ' WHERE style_active = 1'; $result = $db->sql_query($sql); - if( $db->sql_fetchfield('styles_count') > 1 ) + if($db->sql_fetchfield('styles_count') > 1) { $s_more_styles = true; } From 120accb9d4b2a89ca05f712a54427e072584c2f9 Mon Sep 17 00:00:00 2001 From: Senky Date: Thu, 8 Nov 2012 17:30:58 +0100 Subject: [PATCH 193/196] [ticket/10841] adding space after if PHPBB3-10841 --- phpBB/includes/ucp/ucp_prefs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index e84c7e662a..c6e43b831c 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -138,7 +138,7 @@ class ucp_prefs $sql = 'SELECT COUNT(lang_id) as languages_count FROM ' . LANG_TABLE; $result = $db->sql_query($sql); - if($db->sql_fetchfield('languages_count') > 1) + if ($db->sql_fetchfield('languages_count') > 1) { $s_more_languages = true; } @@ -153,7 +153,7 @@ class ucp_prefs FROM ' . STYLES_TABLE . ' WHERE style_active = 1'; $result = $db->sql_query($sql); - if($db->sql_fetchfield('styles_count') > 1) + if ($db->sql_fetchfield('styles_count') > 1) { $s_more_styles = true; } From 0793f8e2e60453db8de1ff8e231a36b2c9024f3d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 11:54:49 -0500 Subject: [PATCH 194/196] [ticket/10841] Revert whitespace changes. PHPBB3-10841 --- .../template/ucp_prefs_personal.html | 26 +++++++++---------- .../template/ucp_prefs_personal.html | 14 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 416343e57d..01e0c9ba28 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -12,21 +12,21 @@
        - +
        - +

        {L_ALLOW_PM_EXPLAIN}
        - +
        @@ -34,17 +34,17 @@

        {L_HIDE_ONLINE_EXPLAIN}
        - +
        - +
        - - + +
        @@ -82,7 +82,7 @@
        - +
        @@ -99,9 +99,9 @@ - +
        - {S_HIDDEN_FIELDS}  + {S_HIDDEN_FIELDS}  {S_FORM_TOKEN}
        @@ -115,9 +115,9 @@ function customDates() { var e = document.getElementById('dateoptions'); - + e.selectedIndex = e.length - 1; - + // Loop and match date_format in menu for (var i = 0; i < e.length; i++) { @@ -127,7 +127,7 @@ break; } } - + // Show/hide custom field if (e.selectedIndex == e.length - 1) { diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index c604671c5c..4cd0f37a80 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -29,35 +29,35 @@ {ERROR} - + {L_SHOW_EMAIL}: checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_ADMIN_EMAIL}: checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_ALLOW_PM}:
        {L_ALLOW_PM_EXPLAIN} checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_HIDE_ONLINE}:
        {L_HIDE_ONLINE_EXPLAIN} checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_NOTIFY_METHOD}:
        {L_NOTIFY_METHOD_EXPLAIN} checked="checked" />{L_NOTIFY_METHOD_EMAIL}   checked="checked" />{L_NOTIFY_METHOD_IM}   checked="checked" />{L_NOTIFY_METHOD_BOTH} - + {L_NOTIFY_ON_PM}: checked="checked" />{L_YES}   checked="checked" />{L_NO} - + {L_POPUP_ON_PM}: checked="checked" />{L_YES}   checked="checked" />{L_NO} From a8e74f5292aaa74e2035dd5f3ab972f0201a1fe7 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 12:02:30 -0500 Subject: [PATCH 195/196] [ticket/10841] Revert more whitespace changes. PHPBB3-10841 --- phpBB/styles/prosilver/template/ucp_prefs_personal.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 01e0c9ba28..600319fc72 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -52,14 +52,14 @@
        - +
        - +
        From dbb54b217b4d0c0669a566f9c950e8331887d276 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Wed, 5 Dec 2012 22:57:06 -0600 Subject: [PATCH 196/196] [ticket/11219] Coding guidelines and naming consistency changes PHPBB3-11219 --- tests/dbal/write_sequence_test.php | 2 +- ...phpbb_database_test_connection_manager.php | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/dbal/write_sequence_test.php b/tests/dbal/write_sequence_test.php index d2c30b4e89..8975cfbfb1 100644 --- a/tests/dbal/write_sequence_test.php +++ b/tests/dbal/write_sequence_test.php @@ -13,7 +13,7 @@ class phpbb_dbal_write_sequence_test extends phpbb_database_test_case { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/three_users.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/three_users.xml'); } static public function write_sequence_data() diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 97281a0812..d7c2804aa7 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -430,17 +430,17 @@ class phpbb_database_test_connection_manager /** * Performs synchronisations on the database after a fixture has been loaded * - * @param PHPUnit_Extensions_Database_DataSet_XmlDataSet $tables Tables contained within the loaded fixture + * @param PHPUnit_Extensions_Database_DataSet_XmlDataSet $xml_data_set Information about the tables contained within the loaded fixture * * @return null */ - public function post_setup_synchronisation($xmlDataSet) + public function post_setup_synchronisation($xml_data_set) { $this->ensure_connected(__METHOD__); $queries = array(); // Get escaped versions of the table names used in the fixture - $table_names = array_map(array($this->pdo, 'PDO::quote'), $xmlDataSet->getTableNames()); + $table_names = array_map(array($this->pdo, 'PDO::quote'), $xml_data_set->getTableNames()); switch ($this->config['dbms']) { @@ -469,18 +469,20 @@ class phpbb_database_test_connection_manager continue; } - $maxval = (int)$max_row['MAX']; - $maxval++; + $max_val = (int) $max_row['MAX']; + $max_val++; - // This is not the "proper" way, but the proper way does not allow you to completely reset - // tables with no rows since you have to select the next value to make the change go into effct. - // You would have to go past the minimum value to set it correctly, but that's illegal. - // Since we have no objects attached to our sequencers (triggers aren't attached), this works fine. + /** + * This is not the "proper" way, but the proper way does not allow you to completely reset + * tables with no rows since you have to select the next value to make the change go into effect. + * You would have to go past the minimum value to set it correctly, but that's illegal. + * Since we have no objects attached to our sequencers (triggers aren't attached), this works fine. + */ $queries[] = 'DROP SEQUENCE ' . $row['SEQUENCE_NAME']; $queries[] = "CREATE SEQUENCE {$row['SEQUENCE_NAME']} MINVALUE {$row['MIN_VALUE']} INCREMENT BY {$row['INCREMENT_BY']} - START WITH $maxval"; + START WITH $max_val"; } break; @@ -495,7 +497,7 @@ class phpbb_database_test_connection_manager while ($row = $result->fetch(PDO::FETCH_ASSOC)) { // Get the columns used in the fixture for this table - $column_names = $xmlDataSet->getTableMetaData($row['table_name'])->getColumns(); + $column_names = $xml_data_set->getTableMetaData($row['table_name'])->getColumns(); // Skip sequences that weren't specified in the fixture if (!in_array($row['column_name'], $column_names))