aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit-tools/hooks/commit-msg34
-rwxr-xr-xgit-tools/hooks/prepare-commit-msg4
-rw-r--r--phpBB/docs/AUTHORS23
-rw-r--r--phpBB/docs/coding-guidelines.html2
-rw-r--r--phpBB/includes/functions.php18
-rw-r--r--phpBB/install/install_install.php2
-rw-r--r--tests/bootstrap.php4
-rw-r--r--tests/cron/manager_test.php18
-rw-r--r--tests/lock/db_test.php2
-rw-r--r--tests/request/request_var_test.php9
-rw-r--r--tests/template/template_test.php247
-rw-r--r--tests/template/templates/includephp.html2
-rw-r--r--tests/template/templates/loop_nested.html4
13 files changed, 134 insertions, 235 deletions
diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg
index a6777ff9c9..ad4d69a9da 100755
--- a/git-tools/hooks/commit-msg
+++ b/git-tools/hooks/commit-msg
@@ -55,6 +55,17 @@ quit()
fi
}
+# Check for empty commit message
+if ! grep -qv '^#' "$1"
+then
+ # Commit message is empty (or contains only comments).
+ # Let git handle this.
+ # It will abort with a message like so:
+ #
+ # Aborting commit due to empty commit message.
+ exit 0
+fi
+
msg=$(grep -nE '.{81,}' "$1");
if [ $? -eq 0 ]
@@ -107,7 +118,19 @@ do
case $expect in
"header")
err=$ERR_HEADER;
- echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$"
+ echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] .+$"
+ result=$?
+ if ! echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$"
+ then
+ # Don't be too strict.
+ # Commits may be temporary, intended to be squashed later.
+ # Just issue a warning here.
+ echo "Warning: heading should be a sentence beginning with a capital letter." 1>&2
+ echo "You entered:" 1>&2
+ echo "$line" 1>&2
+ fi
+ # restore exit code
+ (exit $result)
;;
"empty")
err=$ERR_EMPTY;
@@ -128,6 +151,10 @@ do
# Should not end up here
false
;;
+ "possibly-eof")
+ # Allow empty and/or comment lines at the end
+ ! tail -n +"$i" "$1" |grep -qvE '^($|#)'
+ ;;
"comment")
echo "$line" | grep -Eq "^#";
;;
@@ -188,7 +215,7 @@ do
in_description=1;
;;
"footer")
- expecting="footer eof";
+ expecting="footer possibly-eof";
if [ "$tickets" = "" ]
then
tickets="$line";
@@ -199,6 +226,9 @@ do
"comment")
# Comments should expect the same thing again
;;
+ "possibly-eof")
+ expecting="eof";
+ ;;
*)
echo "Unrecognised token $expect" >&2;
quit 254;
diff --git a/git-tools/hooks/prepare-commit-msg b/git-tools/hooks/prepare-commit-msg
index 2bf25e58a4..11d2b6b2f2 100755
--- a/git-tools/hooks/prepare-commit-msg
+++ b/git-tools/hooks/prepare-commit-msg
@@ -35,8 +35,8 @@ then
# Branch is prefixed with 'ticket/', append ticket ID to message
if [ "$branch" != "${branch##ticket/}" ];
then
- tail="\n\nPHPBB3-${branch##ticket/}";
+ tail="$(printf "\n\nPHPBB3-${branch##ticket/}")";
fi
- echo "[$branch]$tail $(cat "$1")" > "$1"
+ echo "[$branch] $tail$(cat "$1")" > "$1"
fi
diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS
index 1dfb80141c..83feca009b 100644
--- a/phpBB/docs/AUTHORS
+++ b/phpBB/docs/AUTHORS
@@ -22,20 +22,18 @@ involved in phpBB.
phpBB Lead Developer: naderman (Nils Adermann)
-phpBB Developers: A_Jelly_Doughnut (Josh Woody)
- Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
+phpBB Developers: Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
APTX (Marek A. R.)
bantu (Andreas Fischer)
- dhn (Dominik Dröscher)
+ ckwalsh (Cullen Walsh)
igorw (Igor Wiedler)
kellanved (Henry Sudhof)
nickvergessen (Joas Schilling)
+ nn- (Oleg Pudeyev)
rxu (Ruslan Uzdenov)
- Terrafrost (Jim Wigginton)
ToonArmy (Chris Smith)
-Contributions by: Brainy (Cullen Walsh)
- leviatan21 (Gabriel Vazquez)
+Contributions by: leviatan21 (Gabriel Vazquez)
Raimon (Raimon Meuldijk)
Xore (Robert Hetzler)
@@ -47,11 +45,14 @@ phpBB Project Manager: theFinn (James Atkinson) [Founder - 04/2007]
phpBB Lead Developer: psoTFX (Paul S. Owen) [2001 - 09/2005]
-phpBB Developers: Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
- BartVB (Bart van Bragt) [11/2000 - 03/2006]
- DavidMJ (David M.) [12/2005 - 08/2009]
- GrahamJE (Graham Eames) [09/2005 - 11/2006]
- Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
+phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010]
+ Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
+ BartVB (Bart van Bragt) [11/2000 - 03/2006]
+ DavidMJ (David M.) [12/2005 - 08/2009]
+ dhn (Dominik Dröscher) [05/2007 - 01/2011]
+ GrahamJE (Graham Eames) [09/2005 - 11/2006]
+ TerraFrost (Jim Wigginton) [04/2009 - 01/2011]
+ Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
-- Copyrights --
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 83985fe9d7..ef4d6b13a1 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -1097,7 +1097,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&
<h4>General function usage: </h4>
- <p>Some of these functions are only chosen over others because of personal preference and having no other benefit than to be consistant over the code.</p>
+ <p>Some of these functions are only chosen over others because of personal preference and having no other benefit than to be consistent over the code.</p>
<ul>
<li>
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 418e8dc51d..8e8bd56af6 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -48,11 +48,16 @@ function set_var(&$result, $var, $type, $multibyte = false)
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
* @param bool $cookie This param is mapped to phpbb_request_interface::COOKIE as the last param for
* phpbb_request_interface::variable for backwards compatability reasons.
+* @param phpbb_request_interface|null|false If an instance of phpbb_request_interface is given the instance is stored in
+* a static variable and used for all further calls where this parameters is null. Until
+* the function is called with an instance it automatically creates a new phpbb_request
+* instance on every call. By passing false this per-call instantiation can be restored
+* after having passed in a phpbb_request_interface instance.
*
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
* the same as that of $default. If the variable is not set $default is returned.
*/
-function request_var($var_name, $default, $multibyte = false, $cookie = false, phpbb_request_interface $request = null)
+function request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null)
{
// This is all just an ugly hack to add "Dependency Injection" to a function
// the only real code is the function call which maps this function to a method.
@@ -67,6 +72,15 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, p
return;
}
}
+ else if ($request === false)
+ {
+ $static_request = null;
+
+ if (empty($var_name))
+ {
+ return;
+ }
+ }
$tmp_request = $static_request;
@@ -3253,7 +3267,7 @@ function get_preg_expression($mode)
* Depends on whether installed PHP version supports unicode properties
*
* @param string $word word template to be replaced
-* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode
+* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode
*
* @return string $preg_expr regex to use with word censor
*/
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 01ed223c27..e18ed43778 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1867,7 +1867,7 @@ class install_install extends module
if (!$user_id)
{
- // If we can't insert this user then continue to the next one to avoid inconsistant data
+ // If we can't insert this user then continue to the next one to avoid inconsistent data
$this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true);
continue;
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 8c4f1ed874..b7c3534cde 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -12,6 +12,10 @@ $phpbb_root_path = 'phpBB/';
$phpEx = 'php';
$table_prefix = 'phpbb_';
+if (!defined('E_DEPRECATED'))
+{
+ define('E_DEPRECATED', 8192);
+}
error_reporting(E_ALL & ~E_DEPRECATED);
// If we are on PHP >= 6.0.0 we do not need some code
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index 6288a5c641..65d8360fbb 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -7,18 +7,18 @@
*
*/
-require_once __DIR__ . '/../mock/cache.php';
-require_once __DIR__ . '/task/testmod/dummy_task.php';
-require_once __DIR__ . '/task/testmod/second_dummy_task.php';
-require_once __DIR__ . '/task2/testmod/simple_ready.php';
-require_once __DIR__ . '/task2/testmod/simple_not_runnable.php';
-require_once __DIR__ . '/task2/testmod/simple_should_not_run.php';
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/task/testmod/dummy_task.php';
+require_once dirname(__FILE__) . '/task/testmod/second_dummy_task.php';
+require_once dirname(__FILE__) . '/task2/testmod/simple_ready.php';
+require_once dirname(__FILE__) . '/task2/testmod/simple_not_runnable.php';
+require_once dirname(__FILE__) . '/task2/testmod/simple_should_not_run.php';
class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- $this->manager = new phpbb_cron_manager(__DIR__ . '/task/', 'php');
+ $this->manager = new phpbb_cron_manager(dirname(__FILE__) . '/task/', 'php');
$this->task_name = 'phpbb_cron_task_testmod_dummy_task';
}
@@ -57,7 +57,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
public function test_manager_finds_all_ready_tasks_cached()
{
$cache = new phpbb_mock_cache(array('_cron_tasks' => array($this->task_name)));
- $manager = new phpbb_cron_manager(__DIR__ . '/../../phpBB/', 'php', $cache);
+ $manager = new phpbb_cron_manager(dirname(__FILE__) . '/../../phpBB/', 'php', $cache);
$tasks = $manager->find_all_ready_tasks();
$this->assertEquals(1, sizeof($tasks));
@@ -65,7 +65,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
public function test_manager_finds_only_ready_tasks()
{
- $manager = new phpbb_cron_manager(__DIR__ . '/task2/', 'php');
+ $manager = new phpbb_cron_manager(dirname(__FILE__) . '/task2/', 'php');
$tasks = $manager->find_all_ready_tasks();
$task_names = $this->tasks_to_names($tasks);
$this->assertEquals(array('phpbb_cron_task_testmod_simple_ready'), $task_names);
diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php
index 3b2e3ea3b2..ed15423314 100644
--- a/tests/lock/db_test.php
+++ b/tests/lock/db_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_lock_db_test extends phpbb_database_test_case
{
diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php
index 6a0ede0106..7a45ef2fee 100644
--- a/tests/request/request_var_test.php
+++ b/tests/request/request_var_test.php
@@ -13,6 +13,15 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_request_var_test extends phpbb_test_case
{
/**
+ * Makes sure request_var has its standard behaviour.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ request_var(false, false, false, false, false);
+ }
+
+ /**
* @dataProvider request_variables
*/
public function test_post($variable_value, $default, $multibyte, $expected)
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index a3ba3e581f..62f94f7d32 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -324,8 +324,7 @@ class phpbb_template_template_test extends phpbb_test_case
*/
public function test_template($file, array $vars, array $block_vars, array $destroy, $expected)
{
- global $phpEx;
- $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . $phpEx;
+ $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->assertFileNotExists($cache_file);
@@ -375,11 +374,9 @@ class phpbb_template_template_test extends phpbb_test_case
public function test_php()
{
- global $phpEx;
-
$GLOBALS['config']['tpl_allow_php'] = true;
- $cache_file = $this->template->cachepath . 'php.html.' . $phpEx;
+ $cache_file = $this->template->cachepath . 'php.html.php';
$this->assertFileNotExists($cache_file);
@@ -390,21 +387,14 @@ class phpbb_template_template_test extends phpbb_test_case
public function test_includephp()
{
- $this->markTestIncomplete('Include PHP test file paths are broken');
-
$GLOBALS['config']['tpl_allow_php'] = true;
- $cache_file = $this->template->cachepath . 'includephp.html.' . PHP_EXT;
-
- $cwd = getcwd();
- chdir(dirname(__FILE__) . '/templates');
+ $cache_file = $this->template->cachepath . 'includephp.html.php';
$this->run_template('includephp.html', array(), array(), array(), 'testing included php', $cache_file);
$this->template->set_filenames(array('test' => 'includephp.html'));
- $this->assertEquals('testing included php', $this->display('test'), "Testing $file");
-
- chdir($cwd);
+ $this->assertEquals('testing included php', $this->display('test'), "Testing INCLUDEPHP");
$GLOBALS['config']['tpl_allow_php'] = false;
}
@@ -418,17 +408,16 @@ class phpbb_template_template_test extends phpbb_test_case
false,
'insert',
<<<EOT
-outer - 0/4 - before
-outer - 1/4
-middle - 0/2
-middle - 1/2
-outer - 2/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 3/4
-middle - 0/2
-middle - 1/2
+outer - 0 - before
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
+outer - 3
+middle - 0
+middle - 1
EOT
,
'Test inserting before on top level block',
@@ -439,17 +428,16 @@ EOT
true,
'insert',
<<<EOT
-outer - 0/4
-middle - 0/2
-middle - 1/2
-outer - 1/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/4
-middle - 0/2
-middle - 1/2
-outer - 3/4 - after
+outer - 0
+middle - 0
+middle - 1
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
+outer - 3 - after
EOT
,
'Test inserting after on top level block',
@@ -460,17 +448,16 @@ EOT
1,
'insert',
<<<EOT
-outer - 0/4
-middle - 0/2
-middle - 1/2
-outer - 1/4 - pos #1
-outer - 2/4
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 3/4
-middle - 0/2
-middle - 1/2
+outer - 0
+middle - 0
+middle - 1
+outer - 1 - pos #1
+outer - 2
+middle - 0
+middle - 1
+outer - 3
+middle - 0
+middle - 1
EOT
,
'Test inserting at 1 on top level block',
@@ -481,172 +468,27 @@ EOT
0,
'change',
<<<EOT
-outer - 0/3 - pos #1
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
+outer - 0 - pos #1
+middle - 0
+middle - 1
+outer - 1
+middle - 0
+middle - 1
+outer - 2
+middle - 0
+middle - 1
EOT
,
'Test inserting at 1 on top level block',
),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting before on nested block',
- ),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'after'),
- true,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3
-middle - 1/3
-middle - 2/3 - after
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting after on nested block',
- ),
- array(
- 'outer[0].middle',
- array('VARIABLE' => 'pos #1'),
- 1,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/3
-middle - 1/3 - pos #1
-middle - 2/3
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting at pos 1 on nested block',
- ),
- array(
- 'outer[1].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/4 - before
-middle - 1/4
-middle - 2/4
-middle - 3/4
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
- 'Test inserting before on nested block (pos 1)',
- ),
- array(
- 'outer[].middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-EOT
-,
- 'Test inserting before on nested block (end)',
- ),
- array(
- 'outer.middle',
- array('VARIABLE' => 'before'),
- false,
- 'insert',
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/3 - before
-middle - 1/3
-middle - 2/3
-EOT
-,
- 'Test inserting before on nested block (end)',
- ),
);
}
-/*
- <<<EOT
-outer - 0/3
-middle - 0/2
-middle - 1/2
-outer - 1/3
-middle - 0/3
-middle - 1/3
-middle - 2/3
-outer - 2/3
-middle - 0/2
-middle - 1/2
-EOT
-,
-*/
-
/**
* @dataProvider alter_block_array_data
*/
public function test_alter_block_array($alter_block, array $vararray, $key, $mode, $expect, $description)
{
- $this->markTestIncomplete('Alter Block Test is broken');
-
$this->template->set_filenames(array('test' => 'loop_nested.html'));
// @todo Change this
@@ -656,12 +498,11 @@ EOT
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
- $this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
- $this->assertEquals("outer - 0/3\nmiddle - 0/2\nmiddle - 1/2\nouter - 1/3\nmiddle - 0/3\nmiddle - 1/3\nmiddle - 2/3\nouter - 2/3\nmiddle - 0/2\nmiddle - 1/2", $this->display('test'), 'Ensuring template is built correctly before modification');
+ $this->assertEquals("outer - 0\nmiddle - 0\nmiddle - 1\nouter - 1\nmiddle - 0\nmiddle - 1\nouter - 2\nmiddle - 0\nmiddle - 1", $this->display('test'), 'Ensuring template is built correctly before modification');
$this->template->alter_block_array($alter_block, $vararray, $key, $mode);
$this->assertEquals($expect, $this->display('test'), $description);
diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html
index 117d4273f0..70ebdac0d0 100644
--- a/tests/template/templates/includephp.html
+++ b/tests/template/templates/includephp.html
@@ -1 +1 @@
-<!-- INCLUDEPHP ../templates/_dummy_include.php.inc -->
+<!-- INCLUDEPHP ../tests/template/templates/_dummy_include.php.inc -->
diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html
index 571df97b4c..9b251cd453 100644
--- a/tests/template/templates/loop_nested.html
+++ b/tests/template/templates/loop_nested.html
@@ -1,8 +1,8 @@
<!-- BEGIN outer -->
- {outer.S_BLOCK_NAME} - {outer.S_ROW_NUM}/{outer.S_NUM_ROWS}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
+ outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
<!-- BEGIN middle -->
- {middle.S_BLOCK_NAME} - {middle.S_ROW_NUM}/{middle.S_NUM_ROWS}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
+ middle - {middle.S_ROW_COUNT}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
<!-- END middle -->
<!-- END outer -->