aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php10
-rw-r--r--phpBB/adm/style/ajax.js8
-rw-r--r--phpBB/develop/generate_utf_casefold.php2
-rw-r--r--phpBB/develop/generate_utf_confusables.php2
-rw-r--r--phpBB/develop/generate_utf_tables.php2
-rw-r--r--phpBB/develop/utf_normalizer_test.php2
-rw-r--r--phpBB/docs/auth_api.html2
-rw-r--r--phpBB/includes/cache/driver/apc.php2
-rw-r--r--phpBB/includes/cache/driver/eaccelerator.php4
-rw-r--r--phpBB/includes/cache/driver/file.php4
-rw-r--r--phpBB/includes/cache/driver/interface.php47
-rw-r--r--phpBB/includes/cache/driver/memcache.php4
-rw-r--r--phpBB/includes/cache/driver/memory.php4
-rw-r--r--phpBB/includes/cache/driver/null.php1
-rw-r--r--phpBB/includes/cache/driver/redis.php4
-rw-r--r--phpBB/includes/cache/driver/wincache.php2
-rw-r--r--phpBB/includes/cache/driver/xcache.php2
-rw-r--r--phpBB/includes/config/config.php2
-rw-r--r--phpBB/includes/config/db.php2
-rw-r--r--phpBB/includes/cron/manager.php2
-rw-r--r--phpBB/includes/cron/task/core/prune_all_forums.php2
-rw-r--r--phpBB/includes/cron/task/core/prune_forum.php4
-rw-r--r--phpBB/includes/cron/task/core/queue.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_cache.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_database.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_search.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_sessions.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_warnings.php2
-rw-r--r--phpBB/includes/cron/task/parametrized.php2
-rw-r--r--phpBB/includes/cron/task/task.php2
-rw-r--r--phpBB/includes/functions.php4
-rw-r--r--phpBB/includes/functions_admin.php2
-rw-r--r--phpBB/includes/functions_download.php2
-rw-r--r--phpBB/includes/group_positions.php10
-rw-r--r--phpBB/includes/lock/db.php2
-rw-r--r--phpBB/includes/questionnaire/questionnaire.php2
-rw-r--r--phpBB/includes/search/fulltext_mysql.php10
-rw-r--r--phpBB/includes/search/fulltext_postgres.php8
-rw-r--r--phpBB/includes/style/resource_locator.php4
-rw-r--r--phpBB/includes/template/compile.php2
-rw-r--r--phpBB/install/database_update.php20
-rw-r--r--phpBB/install/install_install.php1
-rw-r--r--tests/cache/cache_test.php41
-rw-r--r--tests/fixtures/empty.xml5
-rw-r--r--tests/functional/fileupload_form_test.php3
-rw-r--r--tests/mock/cache.php1
-rw-r--r--tests/search/common_test_case.php106
-rw-r--r--tests/search/mysql_test.php40
-rw-r--r--tests/search/native_test.php52
-rw-r--r--tests/search/postgres_test.php40
-rw-r--r--tests/test_framework/phpbb_database_test_case.php16
-rw-r--r--tests/test_framework/phpbb_search_test_case.php29
52 files changed, 426 insertions, 104 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)
{
diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js
index a3a77df89b..3ccb368665 100644
--- a/phpBB/adm/style/ajax.js
+++ b/phpBB/adm/style/ajax.js
@@ -36,7 +36,7 @@ phpbb.add_ajax_callback('row_down', function() {
overlay: false
});
- tr_swap.find('.up').html(img_templates.up_disabled);
+ tr_swap.find('.up').html(img_templates.up_disabled.clone());
}
tr.insertAfter(tr_swap);
@@ -48,7 +48,7 @@ phpbb.add_ajax_callback('row_down', function() {
*/
if (tr.is(':last-child'))
{
- tr.find('.down').html(img_templates.down_disabled);
+ tr.find('.down').html(img_templates.down_disabled.clone());
var down_img = img_templates.down.clone().attr('href', tr_swap.attr('data-down'));
tr_swap.find('.down').html(down_img);
@@ -82,7 +82,7 @@ phpbb.add_ajax_callback('row_up', function() {
overlay: false
});
- tr_swap.find('.down').html(img_templates.down_disabled);
+ tr_swap.find('.down').html(img_templates.down_disabled.clone());
}
tr.insertBefore(tr_swap);
@@ -94,7 +94,7 @@ phpbb.add_ajax_callback('row_up', function() {
*/
if (tr.is(':first-child'))
{
- tr.find('.up').html(img_templates.up_disabled);
+ tr.find('.up').html(img_templates.up_disabled.clone());
var up_img = img_templates.up.clone().attr('href', tr_swap.attr('data-up'));
tr_swap.find('.up').html(up_img);
diff --git a/phpBB/develop/generate_utf_casefold.php b/phpBB/develop/generate_utf_casefold.php
index 5b99f3e55e..ad511a6153 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 027d75b661..763d8ee875 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 71a5bea851..e5d907d6a5 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 186e10fea2..af8556507f 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 2302140030..249ceebfbc 100644
--- a/phpBB/docs/auth_api.html
+++ b/phpBB/docs/auth_api.html
@@ -193,7 +193,7 @@ $user_id = 2;
$auth->acl_clear_prefetch($user_id);
</pre></div>
- <p>This method returns void.</p>
+ <p>This method returns null.</p>
<a name="acl_get_list"></a><h3>2.viii. acl_get_list</h3>
diff --git a/phpBB/includes/cache/driver/apc.php b/phpBB/includes/cache/driver/apc.php
index dc0144fac3..0516b669c8 100644
--- a/phpBB/includes/cache/driver/apc.php
+++ b/phpBB/includes/cache/driver/apc.php
@@ -26,7 +26,7 @@ class phpbb_cache_driver_apc extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/eaccelerator.php b/phpBB/includes/cache/driver/eaccelerator.php
index 7939f043c9..257b90c76e 100644
--- a/phpBB/includes/cache/driver/eaccelerator.php
+++ b/phpBB/includes/cache/driver/eaccelerator.php
@@ -30,7 +30,7 @@ class phpbb_cache_driver_eaccelerator extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
@@ -47,7 +47,7 @@ class phpbb_cache_driver_eaccelerator extends phpbb_cache_driver_memory
/**
* Perform cache garbage collection
*
- * @return void
+ * @return null
*/
function tidy()
{
diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php
index 5014ba18af..a0f06dde4b 100644
--- a/phpBB/includes/cache/driver/file.php
+++ b/phpBB/includes/cache/driver/file.php
@@ -388,10 +388,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;
}
/**
diff --git a/phpBB/includes/cache/driver/interface.php b/phpBB/includes/cache/driver/interface.php
index 847ba97262..d403bbcd71 100644
--- a/phpBB/includes/cache/driver/interface.php
+++ b/phpBB/includes/cache/driver/interface.php
@@ -63,42 +63,81 @@ 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);
/**
- * Load cached sql query
+ * Load result of an SQL query from cache.
+ *
+ * @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);
/**
- * 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
+ * dbal::sql_fetchrow to get all rows and store them
+ * in cache.
+ * @param int $ttl Time to live, after this timeout the query should
+ * expire from the cache.
+ * @return int|mixed If storing in cache succeeded, an integer $query_id
+ * representing the query should be returned. Otherwise
+ * the original $query_result should be returned.
*/
public function sql_save($query, $query_result, $ttl);
/**
- * Ceck if a given sql query exist in cache
+ * Check if result for a given SQL query exists in cache.
+ *
+ * @param int $query_id
+ * @return bool
*/
public function sql_exists($query_id);
/**
* Fetch row from cache (database)
+ *
+ * @param int $query_id
+ * @return array|bool The query result if found in the cache, otherwise
+ * false.
*/
public function sql_fetchrow($query_id);
/**
* Fetch a field from the current row of a cached database result (database)
+ *
+ * @param int $query_id
+ * @param $field The name of the column.
+ * @return string|bool The field of the query result if found in the cache,
+ * otherwise false.
*/
public function sql_fetchfield($query_id, $field);
/**
* Seek a specific row in an a cached database result (database)
+ *
+ * @param int $rownum Row to seek to.
+ * @param int $query_id
+ * @return bool
*/
public function sql_rowseek($rownum, $query_id);
/**
* Free memory used for a cached database result (database)
+ *
+ * @param int $query_id
+ * @return bool
*/
public function sql_freeresult($query_id);
}
diff --git a/phpBB/includes/cache/driver/memcache.php b/phpBB/includes/cache/driver/memcache.php
index 9fe70f8b44..3fd16b23b0 100644
--- a/phpBB/includes/cache/driver/memcache.php
+++ b/phpBB/includes/cache/driver/memcache.php
@@ -64,7 +64,7 @@ class phpbb_cache_driver_memcache extends phpbb_cache_driver_memory
/**
* Unload the cache resources
*
- * @return void
+ * @return null
*/
function unload()
{
@@ -76,7 +76,7 @@ class phpbb_cache_driver_memcache extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php
index f6c42c0ea6..c39f9f7850 100644
--- a/phpBB/includes/cache/driver/memory.php
+++ b/phpBB/includes/cache/driver/memory.php
@@ -299,7 +299,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]));
@@ -339,8 +339,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;
}
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;
}
/**
diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/includes/cache/driver/redis.php
index a768885962..d256b5600e 100644
--- a/phpBB/includes/cache/driver/redis.php
+++ b/phpBB/includes/cache/driver/redis.php
@@ -74,7 +74,7 @@ class phpbb_cache_driver_redis extends phpbb_cache_driver_memory
/**
* Unload the cache resources
*
- * @return void
+ * @return null
*/
function unload()
{
@@ -86,7 +86,7 @@ class phpbb_cache_driver_redis extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/wincache.php b/phpBB/includes/cache/driver/wincache.php
index fa9eb95f88..58f3b4a581 100644
--- a/phpBB/includes/cache/driver/wincache.php
+++ b/phpBB/includes/cache/driver/wincache.php
@@ -26,7 +26,7 @@ class phpbb_cache_driver_wincache extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/xcache.php b/phpBB/includes/cache/driver/xcache.php
index 0b768bdb3e..06c5fafd97 100644
--- a/phpBB/includes/cache/driver/xcache.php
+++ b/phpBB/includes/cache/driver/xcache.php
@@ -41,7 +41,7 @@ class phpbb_cache_driver_xcache extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
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.php b/phpBB/includes/functions.php
index d7088ac129..ebe9a9918d 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2856,7 +2856,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)
{
@@ -4795,7 +4795,7 @@ function phpbb_get_plural_form($rule, $number)
*
* @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 5e2ee8c8f6..15930f9a2c 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -3308,7 +3308,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/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/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php
index f0fb8c3c06..2d29fe978e 100644
--- a/phpBB/includes/questionnaire/questionnaire.php
+++ b/phpBB/includes/questionnaire/questionnaire.php
@@ -70,7 +70,7 @@ class phpbb_questionnaire_data_collector
/**
* Collect info into the data property.
*
- * @return void
+ * @return null
*/
function collect()
{
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 58a4dd7d6a..ff2e24aa05 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -86,6 +86,14 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$this->word_length = array('min' => $this->config['fulltext_mysql_min_word_len'], 'max' => $this->config['fulltext_mysql_max_word_len']);
+ /**
+ * Load the UTF tools
+ */
+ if (!function_exists('utf8_strlen'))
+ {
+ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
+ }
+
$error = false;
}
@@ -230,7 +238,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
else
{
- $tmp_split_words[] = $word . ' ';
+ $tmp_split_words[] = $word;
}
}
if ($phrase)
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index 08f64735b6..2880610655 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -121,6 +121,14 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
}
+ /**
+ * Load the UTF tools
+ */
+ if (!function_exists('utf8_strlen'))
+ {
+ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
+ }
+
$error = false;
}
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)
{
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index ae6e3bd9cf..e966756337 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -2303,6 +2303,26 @@ function change_database_data(&$no_updates, $version)
}
}
+ // Disable receiving pms for bots
+ $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;
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 33d6586e48..4b2fa046bc 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1784,6 +1784,7 @@ class install_install extends module
'user_timezone' => 'UTC',
'user_dateformat' => $lang['default_dateformat'],
'user_allow_massemail' => 0,
+ 'user_allow_pm' => 0,
);
$user_id = user_add($user_row);
diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php
index c5f5fac88c..285af5cd0c 100644
--- a/tests/cache/cache_test.php
+++ b/tests/cache/cache_test.php
@@ -89,20 +89,55 @@ 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'";
+ 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->assertNotEquals($first_result, $db->sql_fetchrow($result));
+ $this->assertSame(false, $db->sql_fetchrow($result));
$db->sql_close();
}
diff --git a/tests/fixtures/empty.xml b/tests/fixtures/empty.xml
new file mode 100644
index 0000000000..96eb1ab483
--- /dev/null
+++ b/tests/fixtures/empty.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_posts">
+ </table>
+</dataset>
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index f7267fa659..99afcfdc3d 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -64,6 +64,9 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
public function test_valid_file()
{
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
+ $this->assert_response_success();
+ // ensure there was no error message rendered
+ $this->assertNotContains('<h2>' . $this->lang('INFORMATION') . '</h2>', $this->client->getResponse()->getContent());
$this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text());
}
}
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)
{
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 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../test_framework/phpbb_search_test_case.php';
+
+abstract class phpbb_search_common_test_case extends phpbb_search_test_case
+{
+ 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/mysql_test.php b/tests/search/mysql_test.php
new file mode 100644
index 0000000000..3ba3915714
--- /dev/null
+++ b/tests/search/mysql_test.php
@@ -0,0 +1,40 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/common_test_case.php';
+
+class phpbb_search_mysql_test extends phpbb_search_common_test_case
+{
+ protected $db;
+ protected $search;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
+ }
+
+ protected function setUp()
+ {
+ global $phpbb_root_path, $phpEx, $config, $user, $cache;
+
+ parent::setUp();
+
+ // dbal uses cache
+ $cache = new phpbb_cache_service(new phpbb_cache_driver_null);
+
+ // set config values
+ $config['fulltext_mysql_min_word_len'] = 4;
+ $config['fulltext_mysql_max_word_len'] = 254;
+
+ $this->db = $this->new_dbal();
+ $error = null;
+ $class = self::get_search_wrapper('phpbb_search_fulltext_mysql');
+ $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
+ }
+}
diff --git a/tests/search/native_test.php b/tests/search/native_test.php
index 66972079cf..eeee3a44f3 100644
--- a/tests/search/native_test.php
+++ b/tests/search/native_test.php
@@ -7,24 +7,9 @@
*
*/
-function phpbb_search_wrapper($class)
-{
- $wrapped = $class . '_wrapper';
- if (!class_exists($wrapped))
- {
- $code = "
-class $wrapped extends $class
-{
- public function get_must_contain_ids() { return \$this->must_contain_ids; }
- public function get_must_not_contain_ids() { return \$this->must_not_contain_ids; }
-}
- ";
- eval($code);
- }
- return $wrapped;
-}
+require_once dirname(__FILE__) . '/../test_framework/phpbb_search_test_case.php';
-class phpbb_search_native_test extends phpbb_database_test_case
+class phpbb_search_native_test extends phpbb_search_test_case
{
protected $db;
protected $search;
@@ -41,19 +26,14 @@ class phpbb_search_native_test extends phpbb_database_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;
- $class = phpbb_search_wrapper('phpbb_search_fulltext_native');
+ $class = self::get_search_wrapper('phpbb_search_fulltext_native');
$this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
}
- protected function tearDown()
- {
- parent::tearDown();
- }
-
public function keywords()
{
return array(
@@ -107,6 +87,14 @@ class phpbb_search_native_test extends phpbb_database_test_case
array('f', 'o', 'o'),
),
array(
+ 'f -o -o',
+ 'all',
+ false,
+ null,
+ null,
+ array('f', 'o', 'o'),
+ ),
+ array(
'foo -bar',
'all',
true,
@@ -167,20 +155,4 @@ class phpbb_search_native_test extends phpbb_database_test_case
}
$this->assert_array_content_equals($common, $this->search->get_common_words());
}
-
- public function assert_array_content_equals($one, $two)
- {
- // http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
- // but one array_diff is not enough!
- if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
- {
- // get a nice error message
- $this->assertEquals($one, $two);
- }
- else
- {
- // increase assertion count
- $this->assertTrue(true);
- }
- }
}
diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php
new file mode 100644
index 0000000000..9c77e0c09e
--- /dev/null
+++ b/tests/search/postgres_test.php
@@ -0,0 +1,40 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/common_test_case.php';
+
+class phpbb_search_postgres_test extends phpbb_search_common_test_case
+{
+ protected $db;
+ protected $search;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
+ }
+
+ protected function setUp()
+ {
+ global $phpbb_root_path, $phpEx, $config, $user, $cache;
+
+ parent::setUp();
+
+ // dbal uses cache
+ $cache = new phpbb_cache_service(new phpbb_cache_driver_null);
+
+ // set config values
+ $config['fulltext_postgres_min_word_len'] = 4;
+ $config['fulltext_postgres_max_word_len'] = 254;
+
+ $this->db = $this->new_dbal();
+ $error = null;
+ $class = self::get_search_wrapper('phpbb_search_fulltext_postgres');
+ $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
+ }
+}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 75a3c0944b..514619687a 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -141,4 +141,20 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
return $matches[1] . strtoupper($matches[2]) . $matches[3];
}
+
+ public function assert_array_content_equals($one, $two)
+ {
+ // http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
+ // but one array_diff is not enough!
+ if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
+ {
+ // get a nice error message
+ $this->assertEquals($one, $two);
+ }
+ else
+ {
+ // increase assertion count
+ $this->assertTrue(true);
+ }
+ }
}
diff --git a/tests/test_framework/phpbb_search_test_case.php b/tests/test_framework/phpbb_search_test_case.php
new file mode 100644
index 0000000000..418d352c17
--- /dev/null
+++ b/tests/test_framework/phpbb_search_test_case.php
@@ -0,0 +1,29 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+abstract class phpbb_search_test_case extends phpbb_database_test_case
+{
+ static protected function get_search_wrapper($class)
+ {
+ $wrapped = $class . '_wrapper';
+ if (!class_exists($wrapped))
+ {
+ $code = "
+class $wrapped extends $class
+{
+ public function get_must_contain_ids() { return \$this->must_contain_ids; }
+ public function get_must_not_contain_ids() { return \$this->must_not_contain_ids; }
+ public function get_split_words() { return \$this->split_words; }
+}
+ ";
+ eval($code);
+ }
+ return $wrapped;
+ }
+}