aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php210
-rw-r--r--code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc19
-rw-r--r--code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php51
-rw-r--r--code_sniffer/phpbb/build.xml23
-rw-r--r--code_sniffer/phpbb/phpbbCodingStandard.php43
-rw-r--r--phpBB/common.php4
-rw-r--r--phpBB/develop/create_schema_files.php1
-rw-r--r--phpBB/develop/mysql_upgrader.php1
-rw-r--r--phpBB/docs/coding-guidelines.html224
-rw-r--r--phpBB/includes/acp/acp_board.php2
-rw-r--r--phpBB/includes/auth/auth_db.php4
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php2
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php2
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php2
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php22
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php2
-rw-r--r--phpBB/includes/class_loader.php162
-rw-r--r--phpBB/includes/functions.php14
-rw-r--r--phpBB/includes/functions_user.php8
-rw-r--r--phpBB/includes/session.php4
-rw-r--r--phpBB/includes/utf/utf_normalizer.php14
-rw-r--r--phpBB/install/index.php4
-rw-r--r--phpBB/install/schemas/firebird_schema.sql1
-rw-r--r--phpBB/install/schemas/mssql_schema.sql3
-rw-r--r--phpBB/install/schemas/mysql_40_schema.sql1
-rw-r--r--phpBB/install/schemas/mysql_41_schema.sql1
-rw-r--r--phpBB/install/schemas/oracle_schema.sql2
-rw-r--r--phpBB/install/schemas/postgres_schema.sql1
-rw-r--r--phpBB/install/schemas/sqlite_schema.sql1
-rw-r--r--phpBB/styles/prosilver/template/ucp_register.html2
-rw-r--r--tests/all_tests.php6
-rw-r--r--tests/bbcode/all_tests.php44
-rw-r--r--tests/bbcode/parser_test.php31
-rw-r--r--tests/class_loader/all_tests.php41
-rw-r--r--tests/class_loader/cache_mock.php29
-rw-r--r--tests/class_loader/class_loader_test.php71
-rw-r--r--tests/class_loader/includes/class_name.php6
-rw-r--r--tests/class_loader/includes/dir.php6
-rw-r--r--tests/class_loader/includes/dir/class_name.php6
-rw-r--r--tests/class_loader/includes/dir/subdir/class_name.php6
-rw-r--r--tests/request/request_class.php74
-rw-r--r--tests/request/request_var.php85
-rw-r--r--tests/template/template.php26
-rw-r--r--tests/template/templates/includephp.html2
-rw-r--r--tests/template/templates/loop_expressions.html11
45 files changed, 1098 insertions, 176 deletions
diff --git a/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php b/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
new file mode 100644
index 0000000000..e63c3f65fd
--- /dev/null
+++ b/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
@@ -0,0 +1,210 @@
+<?php
+/**
+*
+* @package code_sniffer
+* @version $Id: $
+* @copyright (c) 2007 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* Checks that each source file contains the standard header.
+*
+* Based on Coding Guidelines 1.ii File Header.
+*
+* @package code_sniffer
+* @author Manuel Pichler <mapi@phpundercontrol.org>
+*/
+class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_OPEN_TAG);
+ }
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token
+ * in the stack passed in $tokens.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ // We are only interested in the first file comment.
+ if ($stackPtr !== 0)
+ {
+ if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false)
+ {
+ return;
+ }
+ }
+
+ // Fetch next non whitespace token
+ $tokens = $phpcsFile->getTokens();
+ $start = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
+
+ // Skip empty files
+ if ($tokens[$start]['code'] === T_CLOSE_TAG)
+ {
+ return;
+ }
+ // Mark as error if this is not a doc comment
+ else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT)
+ {
+ $phpcsFile->addError('Missing required file doc comment.', $stackPtr);
+ return;
+ }
+
+ // Find comment end token
+ $end = $phpcsFile->findNext(T_DOC_COMMENT, $start + 1, null, true) - 1;
+
+ // If there is no end, skip processing here
+ if ($end === false)
+ {
+ return;
+ }
+
+ // List of found comment tags
+ $tags = array();
+
+ // check comment lines without the first(/**) an last(*/) line
+ for ($i = $start + 1, $c = ($end - $start); $i <= $c; ++$i)
+ {
+ $line = $tokens[$i]['content'];
+
+ // Check that each line starts with a '*'
+ if (substr($line, 0, 1) !== '*')
+ {
+ $message = 'The file doc comment should not be idented.';
+ $phpcsFile->addWarning($message, $i);
+ }
+ else if (preg_match('/^\*\s+@([\w]+)\s+(.*)$/', $line, $match) !== 0)
+ {
+ $tags[$match[1]] = array($match[2], $i);
+ }
+ }
+
+ // Check that the first and last line is empty
+ if (trim($tokens[$start + 1]['content']) !== '*')
+ {
+ $message = 'The first file comment line should be empty.';
+ $phpcsFile->addWarning($message, ($start + 1));
+ }
+ if (trim($tokens[$end - $start]['content']) !== '*')
+ {
+ $message = 'The last file comment line should be empty.';
+ $phpcsFile->addWarning($message, ($end - $start));
+ }
+
+ $this->processPackage($phpcsFile, $start, $tags);
+ $this->processVersion($phpcsFile, $start, $tags);
+ $this->processCopyright($phpcsFile, $start, $tags);
+ $this->processLicense($phpcsFile, $start, $tags);
+
+ //print_r($tags);
+ }
+
+ /**
+ * Checks that the tags array contains a valid package tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processPackage(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['package']))
+ {
+ $message = 'Missing require @package tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^([\w]+)$/', $tags['package'][0]) === 0)
+ {
+ $message = 'Invalid content found for @package tag.';
+ $phpcsFile->addWarning($message, $tags['package'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid version tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processVersion(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['version']))
+ {
+ $message = 'Missing require @version tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^\$Id:[^\$]+\$$/', $tags['version'][0]) === 0)
+ {
+ $message = 'Invalid content found for @version tag, use "$Id: $".';
+ $phpcsFile->addError($message, $tags['version'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid copyright tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['copyright']))
+ {
+ $message = 'Missing require @copyright tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^\(c\) 2[0-9]{3} phpBB Group\s*$/', $tags['copyright'][0]) === 0)
+ {
+ $message = 'Invalid content found for @copyright tag, use "(c) <year> phpBB Group".';
+ $phpcsFile->addError($message, $tags['copyright'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid license tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ $license = 'http://opensource.org/licenses/gpl-license.php GNU Public License';
+
+ if (!isset($tags['license']))
+ {
+ $message = 'Missing require @license tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (trim($tags['license'][0]) !== $license)
+ {
+ $message = 'Invalid content found for @license tag, use '
+ . '"' . $license . '".';
+ $phpcsFile->addError($message, $tags['license'][1]);
+ }
+ }
+} \ No newline at end of file
diff --git a/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc
new file mode 100644
index 0000000000..0ace1c1bda
--- /dev/null
+++ b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc
@@ -0,0 +1,19 @@
+<?php
+/**
+*
+* @package code_sniffer³
+* @version $Id: $
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php BSD License
+ *
+*/
+?>
+<?php
+/**
+* Broken but not first file doc comment.
+*
+* @version @package_version@
+* @license http://www.opensource.org/licenses/bsd-license.php BSD License
+* @copyright (c) 2007 phpBB Group
+*
+*/
diff --git a/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php
new file mode 100644
index 0000000000..849a7fb9a0
--- /dev/null
+++ b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php
@@ -0,0 +1,51 @@
+<?php
+/**
+*
+* @package code_sniffer
+* @version $Id: $
+* @copyright (c) 2007 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* Unit test class for the EmptyStatement sniff.
+*
+* @package code_sniffer
+* @author Manuel Pichler <mapi@phpundercontrol.org>
+*/
+class phpbb_Tests_Commenting_FileCommentUnitTest extends AbstractSniffUnitTest
+{
+
+ /**
+ * Returns the lines where errors should occur.
+ *
+ * The key of the array should represent the line number and the value
+ * should represent the number of errors that should occur on that line.
+ *
+ * @return array(int => int)
+ */
+ public function getErrorList()
+ {
+ return array(
+ 7 => 1 // BSD License error :)
+ );
+ }//end getErrorList()
+
+
+ /**
+ * Returns the lines where warnings should occur.
+ *
+ * The key of the array should represent the line number and the value
+ * should represent the number of warnings that should occur on that line.
+ *
+ * @return array(int => int)
+ */
+ public function getWarningList()
+ {
+ return array(
+ 4 => 1,
+ 8 => 1
+ );
+ }//end getWarningList()
+} \ No newline at end of file
diff --git a/code_sniffer/phpbb/build.xml b/code_sniffer/phpbb/build.xml
new file mode 100644
index 0000000000..b6d3bf6451
--- /dev/null
+++ b/code_sniffer/phpbb/build.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="code_sniffer" basedir="." default="install">
+
+ <property name="working.dir" value="${basedir}" />
+ <property name="target.dir" value="/usr/share/php/PHP/CodeSniffer/Standards" />
+
+ <!--
+ Install phpbb sniff
+ -->
+ <target name="install">
+ <delete dir="${target.dir}/phpbb" />
+ <mkdir dir="${target.dir}/phpbb"/>
+
+ <copy todir="${target.dir}/phpbb">
+ <fileset file="${working.dir}/phpbbCodingStandard.php" />
+ </copy>
+ <copy todir="${target.dir}/phpbb/Sniffs">
+ <fileset dir="${working.dir}/Sniffs" />
+ </copy>
+
+ </target>
+
+</project>
diff --git a/code_sniffer/phpbb/phpbbCodingStandard.php b/code_sniffer/phpbb/phpbbCodingStandard.php
new file mode 100644
index 0000000000..be51b54b40
--- /dev/null
+++ b/code_sniffer/phpbb/phpbbCodingStandard.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package code_sniffer
+* @version $Id: $
+* @copyright (c) 2007 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+ * @ignore
+ */
+if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) {
+ throw new PHP_CodeSniffer_Exception(
+ 'Class PHP_CodeSniffer_Standards_CodingStandard not found'
+ );
+}
+
+/**
+ * Primary class for the phpbb coding standard.
+ *
+ * @package code_sniffer
+ */
+class PHP_CodeSniffer_Standards_phpbb_phpbbCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard
+{
+ /**
+ * Return a list of external sniffs to include with this standard.
+ *
+ * External locations can be single sniffs, a whole directory of sniffs, or
+ * an entire coding standard. Locations start with the standard name. For
+ * example:
+ * PEAR => include all sniffs in this standard
+ * PEAR/Sniffs/Files => include all sniffs in this dir
+ * PEAR/Sniffs/Files/LineLengthSniff => include this single sniff
+ *
+ * @return array
+ */
+ public function getIncludedSniffs()
+ {
+ return array();
+ }
+} \ No newline at end of file
diff --git a/phpBB/common.php b/phpBB/common.php
index 9b6913e95f..6cc7abf118 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -188,6 +188,7 @@ if (!empty($load_extensions) && function_exists('dl'))
}
// Include files
+require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
require($phpbb_root_path . 'includes/cache.' . $phpEx);
require($phpbb_root_path . 'includes/template.' . $phpEx);
@@ -211,6 +212,9 @@ $template = new template();
$cache = new cache();
$db = new $sql_db();
+$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache);
+$class_loader->register();
+
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index 0515d801f2..4fb7b0d8f7 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -1200,6 +1200,7 @@ function get_schema_struct()
'PRIMARY_KEY' => 'log_id',
'KEYS' => array(
'log_type' => array('INDEX', 'log_type'),
+ 'log_time' => array('INDEX', 'log_time'),
'forum_id' => array('INDEX', 'forum_id'),
'topic_id' => array('INDEX', 'topic_id'),
'reportee_id' => array('INDEX', 'reportee_id'),
diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php
index 57230339e8..85da1dfa47 100644
--- a/phpBB/develop/mysql_upgrader.php
+++ b/phpBB/develop/mysql_upgrader.php
@@ -688,6 +688,7 @@ function get_schema_struct()
'PRIMARY_KEY' => 'log_id',
'KEYS' => array(
'log_type' => array('INDEX', 'log_type'),
+ 'log_time' => array('INDEX', 'log_time'),
'forum_id' => array('INDEX', 'forum_id'),
'topic_id' => array('INDEX', 'topic_id'),
'reportee_id' => array('INDEX', 'reportee_id'),
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 1978a0a307..113910387c 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -62,11 +62,12 @@
</li>
<li><a href="#code">Code Layout/Guidelines</a>
<ol style="list-style-type: lower-roman;">
- <li><a href="#namingvars">Variable/Function Naming</a></li>
+ <li><a href="#namingvars">Variable/Function/Class Naming</a></li>
<li><a href="#codelayout">Code Layout</a></li>
<li><a href="#sql">SQL/SQL Layout</a></li>
<li><a href="#optimizing">Optimizations</a></li>
<li><a href="#general">General Guidelines</a></li>
+ <li><a href="#phprestrictions">Restrictions on the Use of PHP</a></li>
</ol>
</li>
<li><a href="#styling">Styling</a>
@@ -90,7 +91,7 @@
<li><a href="#vcs">VCS Guidelines</a>
<ol style="list-style-type: lower-roman;">
<li><a href="#repostruct">Repository structure</a></li>
- <li><a href="#commitmessage">Commit messages</a></li>
+ <li><a href="#commitmessage">Commit Messages and Repository Rules</a></li>
</ol>
</li>
<li><a href="#changes">Guidelines Changelog</a></li>
@@ -127,7 +128,7 @@
<h3>Linefeeds:</h3>
<p>Ensure that your editor is saving files in the UNIX (LF) line ending format. This means that lines are terminated with a newline, not with Windows Line endings (CR/LF combo) as they are on Win32 or Classic Mac (CR) Line endings. Any decent editor should be able to do this, but it might not always be the default setting. Know your editor. If you want advice for an editor for your Operating System, just ask one of the developers. Some of them do their editing on Win32.</p>
- <a name="fileheader"></a><h3>1.ii. File Header</h3>
+ <a name="fileheader"></a><h3>1.ii. File Layout</h3>
<h4>Standard header for new files:</h4>
<p>This template of the header must be included at the start of all phpBB files: </p>
@@ -145,6 +146,14 @@
<p>Please see the <a href="#locations">File Locations section</a> for the correct package name.</p>
+ <h4>PHP closing tags</h4>
+
+ <p>A file containg only PHP code should not end with the optional PHP closing tag <strong>?&gt;</strong> to avoid issues with whitespace following it.</p>
+
+ <h4>Newline at end of file</h4>
+
+ <p>All files should end in a newline so the last line does not appear as modified in diffs, when a line is appended to the file.</p>
+
<h4>Files containing inline code:</h4>
<p>For those files you have to put an empty comment directly after the header to prevent the documentor assigning the header to the first code element found.</p>
@@ -290,7 +299,7 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c
<p>Please note that these guidelines apply to all php, html, javascript and css files.</p>
- <a name="namingvars"></a><h3>2.i. Variable/Function Naming</h3>
+ <a name="namingvars"></a><h3>2.i. Variable/Function/Class Naming</h3>
<p>We will not be using any form of hungarian notation in our naming conventions. Many of us believe that hungarian naming is one of the primary code obfuscation techniques currently in use.</p>
@@ -322,6 +331,36 @@ for ($i = 0; $i &lt; $outer_size; $i++)
<h4>Function Arguments:</h4>
<p>Arguments are subject to the same guidelines as variable names. We don't want a bunch of functions like: <code>do_stuff($a, $b, $c)</code>. In most cases, we'd like to be able to tell how to use a function by just looking at its declaration. </p>
+ <h4>Class Names:</h4>
+
+ <p>Apart from following the rules for function names, all classes should meet the following conditions:</p>
+ <ul>
+ <li>Every class must be defined in a separate file.</li>
+ <li>The classes have to be located in a subdirectory of <code>includes/</code>.</li>
+ <li>Classnames to be prefixed with <code>phpbb_</code> to avoid name clashes, the filename should not contain the prefix.</li>
+ <li>Class names have to reflect the location of the file they are defined in. The longest list of prefixes, separated by underscores, which is a valid path must be the directory in which the file is located. So the directory names must not contain any underscores, but the filename may. If the filename would be empty the last directory name is used for the filename as well.</li>
+ <li>Directories should typically be a singular noun (e.g. <code>dir</code> in the example below, not <code>dirs</code>.</li>
+ </ul>
+
+ <p>So given the following example directory structure you would result in the below listed lookups</p>
+ <div class="codebox"><pre>
+includes/
+ class_name.php
+ dir/
+ class_name.php
+ dir.php
+ subdir/
+ class_name.php
+ </pre></div>
+
+ <div class="codebox"><pre>
+phpbb_class_name - includes/class_name.php
+phpbb_dir_class_name - includes/dir/class_name.php
+phpbb_dir - includes/dir/dir.php
+phpbb_dir_subdir_class_name - includes/dir/subdir/class_name.php
+ </pre></div>
+
+
<h4>Summary:</h4>
<p>The basic philosophy here is to not hurt code clarity for the sake of laziness. This has to be balanced by a little bit of common sense, though; <code>print_login_status_for_a_given_user()</code> goes too far, for example -- that function would be better named <code>print_user_login_status()</code>, or just <code>print_login_status()</code>.</p>
@@ -471,6 +510,26 @@ $post_url = "{$phpbb_root_path}posting.$phpEx?mode=$mode&amp;amp;start=$start";
<p>In SQL Statements mixing single and double quotes is partly allowed (following the guidelines listed here about SQL Formatting), else it should be tryed to only use one method - mostly single quotes.</p>
+ <h4>Commas after every array element:</h4>
+ <p>If an array is defined with each element on its own line, you still have to modify the previous line to add a comma when appending a new element. PHP allows for trailing (useless) commas in array definitions. These should always be used so each element including the comma can be appended with a single line</p>
+
+ <p class="bad">// wrong</p>
+ <div class="codebox"><pre>
+$foo = array(
+ 'bar' => 42,
+ 'boo' => 23
+);
+ </pre></div>
+
+ <p class="good">// right </p>
+ <div class="codebox"><pre>
+$foo = array(
+ 'bar' => 42,
+ 'boo' => 23,
+);
+ </pre></div>
+
+
<h4>Associative array keys:</h4>
<p>In PHP, it's legal to use a literal string as a key to an associative array without quoting that string. We don't want to do this -- the string should always be quoted to avoid confusion. Note that this is only when we're using a literal, not when we're using a variable, examples:</p>
@@ -637,6 +696,26 @@ switch ($mode)
}
</pre></div>
+ <h4>Class Members</h4>
+ <p>Use the explicit visibility qualifiers <code>public</code>, <code>private</code> and <code>protected</code> for all properties instead of <code>var</code>.
+
+ <p>Place the <code>static</code> qualifier before the visibility qualifiers.</p>
+
+ <p class="bad">//Wrong </p>
+ <div class="codebox"><pre>
+var $x;
+private static function f()
+ </pre></div>
+
+ <p class="good">// Right </p>
+ <div class="codebox"><pre>
+public $x;
+static private function f()
+ </pre></div>
+
+ <h4>Constants</h4>
+ <p>Prefer class constants over global constants created with <code>define()</code>.</p>
+
<a name="sql"></a><h3>2.iii. SQL/SQL Layout</h3>
<h4>Common SQL Guidelines: </h4>
@@ -1043,6 +1122,22 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<p>Your page should either call <code>page_footer()</code> in the end to trigger output through the template engine and terminate the script, or alternatively at least call the <code>exit_handler()</code>. That call is necessary because it provides a method for external applications embedding phpBB to be called at the end of the script.</p>
+ <a name="phprestrictions"></a><h3>2.vi. Restrictions on the Use of PHP</h3>
+
+ <h4>Dynamic code execution:</h4>
+
+ <p>Never execute dynamic PHP code (generated or in a constant string) using any of the following PHP functions:</p>
+
+ <ul>
+ <li><strong>eval</strong></li>
+ <li><strong>create_function</strong></li>
+ <li><strong>preg_replace</strong> with the <strong>e</strong> modifier in the pattern</li>
+ </ul>
+
+ <p>If absolutely necessary a file should be created, and a mechanism for creating this file prior to running phpBB should be provided as a setup process.</p>
+
+ <p>The <strong>e</strong> modifier in <strong>preg_replace</strong> can be replaced by <strong>preg_replace_callback</strong> and objects to encapsulate state that is needed in the callback code.</p>
+
</div>
<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
@@ -2326,126 +2421,33 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<div class="content">
- <p>The version control system for phpBB3 is subversion. The repository is available at <a href="http://code.phpbb.com/svn/phpbb" title="repository">http://code.phpbb.com/svn/phpbb</a>.</p>
+ <p>The version control system for phpBB3 is git. The repository is available at <a href="http://github.com/phpbb/phpbb3" title="repository">http://github.com/phpbb/phpbb3</a>.</p>
<a name="repostruct"></a><h3>7.i. Repository Structure</h3>
<ul>
- <li><strong>trunk</strong><br />The latest unstable development version with new features etc. Contains the actual board in <code>/trunk/phpBB</code></li>
- <li><strong>branches</strong><br />Development branches of stable phpBB releases. Copied from <code>/trunk</code> at the time of release.
+ <li><strong>develop</strong><br />The latest unstable development version with new features etc.</li>
+ <li><strong>develop-*</strong><br />Development branches of stable phpBB releases. Branched off of <code>develop</code> at the time of feature freeze.
<ul>
- <li><strong>phpBB3.0</strong><code>/branches/phpBB-3_0_0/phpBB</code><br />Development branch of the stable 3.0 line. Bug fixes are applied here.</li>
- <li><strong>phpBB2</strong><code>/branches/phpBB-2_0_0/phpBB</code><br />Old phpBB2 development branch.</li>
+ <li><strong>phpBB3.0</strong><code>develop-olympus</code><br />Development branch of the stable 3.0 line. Bug fixes are applied here.</li>
+ <li><strong>phpBB3.1</strong><code>develop-ascraeus</code><br />Development branch of the stable 3.1 line. Bug fixes are applied here.</li>
</ul>
</li>
- <li><strong>tags</strong><br />Released versions. Copies of trunk or the respective branch, made at the time of release.
+ <li><strong>master</strong><br />A branch containing all stable phpBB3 release points</li>
+ <li><strong>tags</strong><br />Released versions. Stable ones get merged into the master branch.
<ul>
- <li><code>/tags/release_3_0_BX</code><br />Beta release X of the 3.0 line.</li>
- <li><code>/tags/release_3_0_RCX</code><br />Release candidate X of the 3.0 line.</li>
- <li><code>/tags/release_3_0_X-RCY</code><br />Release candidate Y of the stable 3.0.X release.</li>
- <li><code>/tags/release_3_0_X</code><br />Stable <strong>3.0.X</strong> release.</li>
- <li><code>/tags/release_2_0_X</code><br />Old stable 2.0.X release.</li>
+ <li><code>release-3.Y-BX</code><br />Beta release X of the 3.Y line.</li>
+ <li><code>release-3.Y-RCX</code><br />Release candidate X of the 3.Y line.</li>
+ <li><code>release-3.Y.Z-RCX</code><br />Release candidate X of the stable 3.Y.Z release.</li>
+ <li><code>release-3.0.X</code><br />Stable <strong>3.0.X</strong> release.</li>
+ <li><code>release-2.0.X</code><br />Old stable 2.0.X release.</li>
</ul>
</li>
</ul>
- <a name="commitmessage"></a><h3>7.ii. Commit Messages</h3>
-
- <p>The commit message should contain a brief explanation of all changes made within the commit. Often identical to the changelog entry. A bug ticket can be referenced by specifying the ticket ID with a hash, e.g. #12345. A reference to another revision should simply be prefixed with r, e.g. r12345.</p>
-
- <p>Junior Developers need to have their patches approved by a development team member first. The commit message must end in a line with the following format:</p>
-
- <div class="codebox"><pre>
-Authorised by: developer1[, developer2[, ...]]
- </pre></div>
-
- </div>
-
- <div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
-
- <span class="corners-bottom"><span></span></span></div>
- </div>
-
- <hr />
-
-<a name="changes"></a><h2>8. Guidelines Changelog</h2>
- <div class="paragraph">
- <div class="inner"><span class="corners-top"><span></span></span>
-
- <div class="content">
-<h3>Revision 10007</h3>
-
-<ul>
- <li>Added <a href="#constants">Special Constants</a> section.</li>
-</ul>
-
-<h3>Revision 9817</h3>
-
-<ul>
- <li>Added VCS section.</li>
-</ul>
-
-<h3>Revision 8732</h3>
-
-<ul>
- <li>Added cfg files.</li>
- <li>Added template <a href="#inheritance">inheritance</a>.</li>
-</ul>
-
-<h3>Revision 8596+</h3>
-
-<ul>
- <li>Removed sql_build_array('MULTI_INSERT'... statements.</li>
- <li>Added sql_multi_insert() explanation.</li>
-</ul>
-
-<h3>Revision 1.31</h3>
-
-<ul>
- <li>Added add_form_key and check_form_key. </li>
-</ul>
-
-<h3>Revision 1.24</h3>
-
-<ul>
- <li>Added <a href="#translation">5. Character Sets and Encodings</a> section to explain the recommended treatment of strings in phpBB.</li>
-</ul>
-
-<h3>Revision 1.16</h3>
-
-<ul>
- <li>Added <a href="#translation">6. Translation (<abbr title="Internationalisation">i18n</abbr>/<abbr title="Localisation">L10n</abbr>) Guidelines</a> section to explain expected format and authoring considerations for language packs that are to be created for phpBB.</li>
-</ul>
-
-<h3>Revision 1.11-1.15</h3>
-
-<ul>
- <li>Various document formatting, spelling, punctuation, grammar bugs.</li>
-</ul>
-
-<h3>Revision 1.9-1.10</h3>
-
-<ul>
- <li>Added sql_query_limit to <a href="#sql">2.iii. SQL/SQL Layout</a>.</li>
-</ul>
-
-<h3>Revision 1.8</h3>
-
-<ul>
- <li>Some adjustements to wordings</li>
- <li>Updated paragraph <a href="#locations">1.iii. File Locations</a> to reflect recent changes</li>
- <li>Extended paragraph <a href="#codelayout">2.ii. Code Layout</a>.</li>
- <li>Added sql_in_set and sql_build_query explanation to <a href="#sql">2.iii. SQL/SQL Layout</a>.</li>
- <li>Updated paragraph <a href="#styling">3. Styling</a>.</li>
- <li>Updated paragraph <a href="#templating">4. Templating</a> to explain loop checking, loop breaking and other changes we recently made.</li>
-</ul>
-
-<h3>Revision 1.5</h3>
-
-<ul>
- <li>Changed General function usage paragraph in <a href="#general">2.v. General Guidelines</a></li>
-</ul>
+ <a name="commitmessage"></a><h3>7.ii. Commit Messages and Reposiory Rules</h3>
+ <p>Information on repository rules, such as commit messages can be found at <a href="http://wiki.phpbb.com/display/DEV/Git" title="phpBB Git Information">http://wiki.phpbb.com/display/DEV/Git</p>.
</div>
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 927e72010e..7db361ba34 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -434,7 +434,7 @@ class acp_board
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
$error = array();
- // We validate the complete config if whished
+ // We validate the complete config if wished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
if ($submit && !check_form_key($form_key))
diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php
index 73c4f92976..b672e212bf 100644
--- a/phpBB/includes/auth/auth_db.php
+++ b/phpBB/includes/auth/auth_db.php
@@ -69,7 +69,7 @@ function login_db(&$username, &$password)
if ($show_captcha)
{
// Visual Confirmation handling
- if (!class_exists('phpbb_captcha_factory'))
+ if (!class_exists('phpbb_captcha_factory', false))
{
global $phpbb_root_path, $phpEx;
include ($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
@@ -90,7 +90,7 @@ function login_db(&$username, &$password)
{
$captcha->reset();
}
-
+
}
// If the password convert flag is set we need to convert it
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
index 6e899adc16..a326074c14 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php
@@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
/**
* Placeholder for autoload
*/
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
}
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
index 2f55d15efd..8ac0262302 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_wave_plugin.php
@@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
/**
* Placeholder for autoload
*/
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
}
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
index ac30ed4297..834d2a7f12 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php
@@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
/**
* Placeholder for autoload
*/
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
}
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
index 49a64b9339..c0cdc83fa1 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
@@ -87,7 +87,7 @@ class phpbb_captcha_qa
}
$db->sql_freeresult($result);
}
-
+
// okay, if there is a confirm_id, we try to load that confirm's state. If not, we try to find one
if (!$this->load_answer() && (!$this->load_confirm_id() || !$this->load_answer()))
{
@@ -113,7 +113,7 @@ class phpbb_captcha_qa
{
global $db, $phpbb_root_path, $phpEx;
- if (!class_exists('phpbb_db_tools'))
+ if (!class_exists('phpbb_db_tools', false))
{
include("$phpbb_root_path/includes/db/db_tools.$phpEx");
}
@@ -365,12 +365,12 @@ class phpbb_captcha_qa
global $config, $db, $user;
$error = '';
-
+
if (!sizeof($this->question_ids))
{
return false;
}
-
+
if (!$this->confirm_id)
{
$error = $user->lang['CONFIRM_QUESTION_WRONG'];
@@ -434,7 +434,7 @@ class phpbb_captcha_qa
function reselect_question()
{
global $db, $user;
-
+
if (!sizeof($this->question_ids))
{
return false;
@@ -482,8 +482,8 @@ class phpbb_captcha_qa
global $db, $user;
$sql = 'SELECT confirm_id
- FROM ' . CAPTCHA_QA_CONFIRM_TABLE . "
- WHERE
+ FROM ' . CAPTCHA_QA_CONFIRM_TABLE . "
+ WHERE
session_id = '" . $db->sql_escape($user->session_id) . "'
AND lang_iso = '" . $db->sql_escape($this->question_lang) . "'
AND confirm_type = " . $this->type;
@@ -505,7 +505,7 @@ class phpbb_captcha_qa
function load_answer()
{
global $db, $user;
-
+
if (!strlen($this->confirm_id) || !sizeof($this->question_ids))
{
return false;
@@ -990,9 +990,9 @@ class phpbb_captcha_qa
return $langs;
}
-
-
-
+
+
+
/**
* See if there is a question other than the one we have
*/
diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
index 0f0bfc4156..dad39867dc 100644
--- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
exit;
}
-if (!class_exists('phpbb_default_captcha'))
+if (!class_exists('phpbb_default_captcha', false))
{
// we need the classic captcha code for tracking solutions and attempts
include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx);
diff --git a/phpBB/includes/class_loader.php b/phpBB/includes/class_loader.php
new file mode 100644
index 0000000000..5df654799a
--- /dev/null
+++ b/phpBB/includes/class_loader.php
@@ -0,0 +1,162 @@
+<?php
+/**
+*
+* @package phpBB3
+* @version $Id$
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* The class loader resolves class names to file system paths and loads them if
+* necessary.
+*
+* Classes have to be of the form phpbb_(dir_)*(classpart_)*, so directory names
+* must never contain underscores. Example: phpbb_dir_subdir_class_name is a
+* valid class name, while phpbb_dir_sub_dir_class_name is not.
+*
+* If every part of the class name is a directory, the last directory name is
+* also used as the filename, e.g. phpbb_dir would resolve to dir/dir.php.
+*
+* @package phpBB3
+*/
+class phpbb_class_loader
+{
+ private $phpbb_root_path;
+ private $php_ext;
+ private $cache;
+ private $cached_paths = array();
+
+ /**
+ * Creates a new phpbb_class_loader, which loads files with the given
+ * file extension from the given phpbb root path.
+ *
+ * @param string $phpbb_root_path phpBB's root directory containing includes/
+ * @param string $php_ext The file extension for PHP files
+ */
+ public function __construct($phpbb_root_path, $php_ext = '.php', $cache = null)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+
+ $this->set_cache($cache);
+ }
+
+ /**
+ * Provide the class loader with a cache to store paths. If set to null, the
+ * the class loader will resolve paths by checking for the existance of every
+ * directory in the class name every time.
+ *
+ * @param acm $cache An implementation of the phpBB cache interface.
+ */
+ public function set_cache($cache = null)
+ {
+ if ($cache)
+ {
+ $this->cached_paths = $cache->get('class_loader');
+
+ if ($this->cached_paths === false)
+ {
+ $this->cached_paths = array();
+ }
+ }
+
+ $this->cache = $cache;
+ }
+
+ /**
+ * Registers the class loader as an autoloader using SPL.
+ */
+ public function register()
+ {
+ spl_autoload_register(array($this, 'load_class'));
+ }
+
+ /**
+ * Removes the class loader from the SPL autoloader stack.
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'load_class'));
+ }
+
+ /**
+ * Resolves a phpBB class name to a relative path which can be included.
+ *
+ * @param string $class The class name to resolve, must have a phpbb_
+ * prefix
+ * @return string|bool A relative path to the file containing the
+ * class or false if looking it up failed.
+ */
+ public function resolve_path($class)
+ {
+ $path_prefix = $this->phpbb_root_path . 'includes/';
+
+ if (isset($this->cached_paths[$class]))
+ {
+ return $path_prefix . $this->cached_paths[$class] . $this->php_ext;
+ }
+
+ if (!preg_match('/phpbb_[a-zA-Z0-9_]+/', $class))
+ {
+ return false;
+ }
+
+ $parts = explode('_', substr($class, 6));
+
+ $dirs = '';
+
+ for ($i = 0, $n = sizeof($parts); $i < $n && is_dir($path_prefix . $dirs . $parts[$i]); $i++)
+ {
+ $dirs .= $parts[$i] . '/';
+ }
+
+ // no file name left => use last dir name as file name
+ if ($i == sizeof($parts))
+ {
+ $parts[] = $parts[$i - 1];
+ }
+
+ $relative_path = $dirs . implode(array_slice($parts, $i, sizeof($parts) - $i), '_');
+
+ if (!file_exists($path_prefix . $relative_path . $this->php_ext))
+ {
+ return false;
+ }
+
+ if ($this->cache)
+ {
+ $this->cached_paths[$class] = $relative_path;
+ $this->cache->put('class_loader', $this->cached_paths);
+ }
+
+ return $path_prefix . $relative_path . $this->php_ext;
+ }
+
+ /**
+ * Resolves a class name to a path and then includes it.
+ *
+ * @param string $class The class name which is being loaded.
+ */
+ public function load_class($class)
+ {
+ if (substr($class, 0, 6) === 'phpbb_')
+ {
+ $path = $this->resolve_path($class);
+
+ if ($path)
+ {
+ require $path;
+ }
+ }
+ }
+}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index c4ff998e69..a7988cfa60 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2038,7 +2038,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
// Make sure $per_page is a valid value
$per_page = ($per_page <= 0) ? 1 : $per_page;
- $seperator = '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
+ $separator = '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
$total_pages = ceil($num_items / $per_page);
if ($total_pages == 1 || !$num_items)
@@ -2056,29 +2056,29 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
$start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
$end_cnt = max(min($total_pages, $on_page + 4), 6);
- $page_string .= ($start_cnt > 1) ? ' ... ' : $seperator;
+ $page_string .= ($start_cnt > 1) ? ' ... ' : $separator;
for ($i = $start_cnt + 1; $i < $end_cnt; $i++)
{
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
if ($i < $end_cnt - 1)
{
- $page_string .= $seperator;
+ $page_string .= $separator;
}
}
- $page_string .= ($end_cnt < $total_pages) ? ' ... ' : $seperator;
+ $page_string .= ($end_cnt < $total_pages) ? ' ... ' : $separator;
}
else
{
- $page_string .= $seperator;
+ $page_string .= $separator;
for ($i = 2; $i < $total_pages; $i++)
{
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
if ($i < $total_pages)
{
- $page_string .= $seperator;
+ $page_string .= $separator;
}
}
}
@@ -2862,7 +2862,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
{
global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config;
- if (!class_exists('phpbb_captcha_factory'))
+ if (!class_exists('phpbb_captcha_factory', false))
{
include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index f2c80705ba..0eecc903e5 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1774,15 +1774,15 @@ function validate_jabber($jid)
return false;
}
- $seperator_pos = strpos($jid, '@');
+ $separator_pos = strpos($jid, '@');
- if ($seperator_pos === false)
+ if ($separator_pos === false)
{
return 'WRONG_DATA';
}
- $username = substr($jid, 0, $seperator_pos);
- $realm = substr($jid, $seperator_pos + 1);
+ $username = substr($jid, 0, $separator_pos);
+ $realm = substr($jid, $separator_pos + 1);
if (strlen($username) == 0 || strlen($realm) < 3)
{
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 79023cc7bc..7da72cb6d2 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -39,7 +39,7 @@ class session
*
* @param string $root_path current root path (phpbb_root_path)
*/
- function extract_current_page($root_path)
+ static function extract_current_page($root_path)
{
$page_array = array();
@@ -983,7 +983,7 @@ class session
}
// only called from CRON; should be a safe workaround until the infrastructure gets going
- if (!class_exists('phpbb_captcha_factory'))
+ if (!class_exists('phpbb_captcha_factory', false))
{
include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx);
}
diff --git a/phpBB/includes/utf/utf_normalizer.php b/phpBB/includes/utf/utf_normalizer.php
index a77952499a..78684df69c 100644
--- a/phpBB/includes/utf/utf_normalizer.php
+++ b/phpBB/includes/utf/utf_normalizer.php
@@ -77,7 +77,7 @@ class utf_normalizer
* @param string &$str The dirty string
* @return string The same string, all shiny and cleaned-up
*/
- function cleanup(&$str)
+ static function cleanup(&$str)
{
// The string below is the list of all autorized characters, sorted by frequency in latin text
$pos = strspn($str, "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x0D");
@@ -119,7 +119,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfc(&$str)
+ static function nfc(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -151,7 +151,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfkc(&$str)
+ static function nfkc(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -183,7 +183,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfd(&$str)
+ static function nfd(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -209,7 +209,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfkd(&$str)
+ static function nfkd(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -242,7 +242,7 @@ class utf_normalizer
*
* @access private
*/
- function recompose($str, $pos, $len, &$qc, &$decomp_map)
+ static function recompose($str, $pos, $len, &$qc, &$decomp_map)
{
global $utf_combining_class, $utf_canonical_comp, $utf_jamo_type, $utf_jamo_index;
@@ -944,7 +944,7 @@ class utf_normalizer
*
* @access private
*/
- function decompose($str, $pos, $len, &$decomp_map)
+ static function decompose($str, $pos, $len, &$decomp_map)
{
global $utf_combining_class;
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index eb51ca5fb2..03b19d1c12 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -152,6 +152,7 @@ else
@ini_set('memory_limit', $mem_limit);
// Include essential scripts
+require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx))
@@ -168,6 +169,9 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
+$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx);
+$class_loader->register();
+
// Try and load an appropriate language if required
$language = basename(request_var('language', ''));
diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql
index 85f86781de..ab622e8fde 100644
--- a/phpBB/install/schemas/firebird_schema.sql
+++ b/phpBB/install/schemas/firebird_schema.sql
@@ -529,6 +529,7 @@ CREATE TABLE phpbb_log (
ALTER TABLE phpbb_log ADD PRIMARY KEY (log_id);;
CREATE INDEX phpbb_log_log_type ON phpbb_log(log_type);;
+CREATE INDEX phpbb_log_log_time ON phpbb_log(log_time);;
CREATE INDEX phpbb_log_forum_id ON phpbb_log(forum_id);;
CREATE INDEX phpbb_log_topic_id ON phpbb_log(topic_id);;
CREATE INDEX phpbb_log_reportee_id ON phpbb_log(reportee_id);;
diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql
index 0827b14cc2..068373c9a1 100644
--- a/phpBB/install/schemas/mssql_schema.sql
+++ b/phpBB/install/schemas/mssql_schema.sql
@@ -636,6 +636,9 @@ GO
CREATE INDEX [log_type] ON [phpbb_log]([log_type]) ON [PRIMARY]
GO
+CREATE INDEX [log_time] ON [phpbb_log]([log_time]) ON [PRIMARY]
+GO
+
CREATE INDEX [forum_id] ON [phpbb_log]([forum_id]) ON [PRIMARY]
GO
diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql
index 19b1b4f0f7..813cf8613f 100644
--- a/phpBB/install/schemas/mysql_40_schema.sql
+++ b/phpBB/install/schemas/mysql_40_schema.sql
@@ -362,6 +362,7 @@ CREATE TABLE phpbb_log (
log_data mediumblob NOT NULL,
PRIMARY KEY (log_id),
KEY log_type (log_type),
+ KEY log_time (log_time),
KEY forum_id (forum_id),
KEY topic_id (topic_id),
KEY reportee_id (reportee_id),
diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql
index 3b70630a9e..97369d2bf7 100644
--- a/phpBB/install/schemas/mysql_41_schema.sql
+++ b/phpBB/install/schemas/mysql_41_schema.sql
@@ -362,6 +362,7 @@ CREATE TABLE phpbb_log (
log_data mediumtext NOT NULL,
PRIMARY KEY (log_id),
KEY log_type (log_type),
+ KEY log_time (log_time),
KEY forum_id (forum_id),
KEY topic_id (topic_id),
KEY reportee_id (reportee_id),
diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql
index d577fce46c..7be7cd0756 100644
--- a/phpBB/install/schemas/oracle_schema.sql
+++ b/phpBB/install/schemas/oracle_schema.sql
@@ -715,6 +715,8 @@ CREATE TABLE phpbb_log (
CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type)
/
+CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time)
+/
CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id)
/
CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id)
diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql
index 50b3979adb..9cdf35024b 100644
--- a/phpBB/install/schemas/postgres_schema.sql
+++ b/phpBB/install/schemas/postgres_schema.sql
@@ -519,6 +519,7 @@ CREATE TABLE phpbb_log (
);
CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type);
+CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time);
CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id);
CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id);
CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id);
diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql
index 7ee821d395..34b4b05478 100644
--- a/phpBB/install/schemas/sqlite_schema.sql
+++ b/phpBB/install/schemas/sqlite_schema.sql
@@ -352,6 +352,7 @@ CREATE TABLE phpbb_log (
);
CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type);
+CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time);
CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id);
CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id);
CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id);
diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html
index 0c632f5c69..e63abaec05 100644
--- a/phpBB/styles/prosilver/template/ucp_register.html
+++ b/phpBB/styles/prosilver/template/ucp_register.html
@@ -48,7 +48,7 @@
</dl>
<dl>
<dt><label for="password_confirm">{L_CONFIRM_PASSWORD}:</label></dt>
- <dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="25" value="{PASSWORD_CONFIRM}" class="inputbox autowidth" title="{L_CONFIRM_PASSWORD}" /></dd>
+ <dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="25" value="{PASSWORD_CONFIRM}" class="inputbox autowidth" title="{L_CONFIRM_PASSWORD}" /></dd>
</dl>
<hr />
diff --git a/tests/all_tests.php b/tests/all_tests.php
index bae7725ee7..07d6f89524 100644
--- a/tests/all_tests.php
+++ b/tests/all_tests.php
@@ -7,8 +7,6 @@
*
*/
-error_reporting(E_ALL);
-
if (!defined('PHPUnit_MAIN_METHOD'))
{
define('PHPUnit_MAIN_METHOD', 'phpbb_all_tests::main');
@@ -17,10 +15,12 @@ if (!defined('PHPUnit_MAIN_METHOD'))
require_once 'test_framework/framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
+require_once 'class_loader/all_tests.php';
require_once 'utf/all_tests.php';
require_once 'request/all_tests.php';
require_once 'security/all_tests.php';
require_once 'template/all_tests.php';
+#require_once 'bbcode/all_tests.php';
require_once 'text_processing/all_tests.php';
require_once 'dbal/all_tests.php';
require_once 'regex/all_tests.php';
@@ -41,10 +41,12 @@ class phpbb_all_tests
{
$suite = new PHPUnit_Framework_TestSuite('phpBB');
+ $suite->addTest(phpbb_class_loader_all_tests::suite());
$suite->addTest(phpbb_utf_all_tests::suite());
$suite->addTest(phpbb_request_all_tests::suite());
$suite->addTest(phpbb_security_all_tests::suite());
$suite->addTest(phpbb_template_all_tests::suite());
+# $suite->addTest(phpbb_bbcode_all_tests::suite());
$suite->addTest(phpbb_text_processing_all_tests::suite());
$suite->addTest(phpbb_dbal_all_tests::suite());
$suite->addTest(phpbb_regex_all_tests::suite());
diff --git a/tests/bbcode/all_tests.php b/tests/bbcode/all_tests.php
new file mode 100644
index 0000000000..f4200fd0a9
--- /dev/null
+++ b/tests/bbcode/all_tests.php
@@ -0,0 +1,44 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+define('IN_PHPBB', true);
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_bbcode_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'bbcode/parser_test.php';
+
+class phpbb_bbcode_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Formatted Text / BBCode');
+
+ $suite->addTestSuite('phpbb_bbcode_parser_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_bbcode_all_tests::main')
+{
+ phpbb_bbcode_all_tests::main();
+}
+?> \ No newline at end of file
diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php
new file mode 100644
index 0000000000..729fe93fc2
--- /dev/null
+++ b/tests/bbcode/parser_test.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+define('IN_PHPBB', true);
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/bbcode/bbcode_parser_base.php';
+require_once '../phpBB/includes/bbcode/bbcode_parser.php';
+
+class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase
+{
+ public function test_both_passes()
+ {
+ $parser = new phpbb_bbcode_parser();
+
+ $result = $parser->first_pass('[i]Italic [u]underlined text[/u][/i]');
+ $result = $parser->second_pass($result);
+
+ $expected = '<span style="font-style: italic">Italic <span style="text-decoration: underline">underlined text</span></span>';
+
+ $this->assertEquals($expected, $result, 'Simple nested BBCode first+second pass');
+ }
+}
+?> \ No newline at end of file
diff --git a/tests/class_loader/all_tests.php b/tests/class_loader/all_tests.php
new file mode 100644
index 0000000000..451a1b02c2
--- /dev/null
+++ b/tests/class_loader/all_tests.php
@@ -0,0 +1,41 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_class_loader_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'class_loader/class_loader_test.php';
+
+class phpbb_class_loader_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Class Loader');
+
+ $suite->addTestSuite('phpbb_class_loader_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_class_loader_all_tests::main')
+{
+ phpbb_class_loader_all_tests::main();
+}
+
diff --git a/tests/class_loader/cache_mock.php b/tests/class_loader/cache_mock.php
new file mode 100644
index 0000000000..c8069fa9cc
--- /dev/null
+++ b/tests/class_loader/cache_mock.php
@@ -0,0 +1,29 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_cache_mock
+{
+ private $variables = array();
+
+ function get($var_name)
+ {
+ if (isset($this->variables[$var_name]))
+ {
+ return $this->variables[$var_name];
+ }
+
+ return false;
+ }
+
+ function put($var_name, $value)
+ {
+ $this->variables[$var_name] = $value;
+ }
+} \ No newline at end of file
diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php
new file mode 100644
index 0000000000..e53507ded3
--- /dev/null
+++ b/tests/class_loader/class_loader_test.php
@@ -0,0 +1,71 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+require_once 'class_loader/cache_mock.php';
+
+require_once '../phpBB/includes/class_loader.php';
+
+
+class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
+{
+ public function test_resolve_path()
+ {
+ $prefix = 'class_loader/';
+ $class_loader = new phpbb_class_loader($prefix);
+
+ $prefix .= 'includes/';
+
+ $this->assertEquals(
+ '',
+ $class_loader->resolve_path('phpbb_dir'),
+ 'Class with same name as a directory is unloadable'
+ );
+
+ $this->assertEquals(
+ $prefix . 'class_name.php',
+ $class_loader->resolve_path('phpbb_class_name'),
+ 'Top level class'
+ );
+ $this->assertEquals(
+ $prefix . 'dir/class_name.php',
+ $class_loader->resolve_path('phpbb_dir_class_name'),
+ 'Class in a directory'
+ );
+ $this->assertEquals(
+ $prefix . 'dir/subdir/class_name.php',
+ $class_loader->resolve_path('phpbb_dir_subdir_class_name'),
+ 'Class in a sub-directory'
+ );
+ }
+
+ public function test_resolve_cached()
+ {
+ $cache = new phpbb_cache_mock;
+ $cache->put('class_loader', array('phpbb_a_cached_name' => 'a/cached_name'));
+
+ $prefix = 'class_loader/';
+ $class_loader = new phpbb_class_loader($prefix, '.php', $cache);
+
+ $prefix .= 'includes/';
+
+ $this->assertEquals(
+ $prefix . 'dir/class_name.php',
+ $class_loader->resolve_path('phpbb_dir_class_name'),
+ 'Class in a directory'
+ );
+
+ $this->assertEquals(
+ $prefix . 'a/cached_name.php',
+ $class_loader->resolve_path('phpbb_a_cached_name'),
+ 'Class in a directory'
+ );
+ }
+}
diff --git a/tests/class_loader/includes/class_name.php b/tests/class_loader/includes/class_name.php
new file mode 100644
index 0000000000..e941173cdd
--- /dev/null
+++ b/tests/class_loader/includes/class_name.php
@@ -0,0 +1,6 @@
+<?php
+
+class phpbb_class_name
+{
+}
+
diff --git a/tests/class_loader/includes/dir.php b/tests/class_loader/includes/dir.php
new file mode 100644
index 0000000000..1c8930d8e7
--- /dev/null
+++ b/tests/class_loader/includes/dir.php
@@ -0,0 +1,6 @@
+<?php
+
+class phpbb_dir
+{
+}
+
diff --git a/tests/class_loader/includes/dir/class_name.php b/tests/class_loader/includes/dir/class_name.php
new file mode 100644
index 0000000000..0675aa8fc5
--- /dev/null
+++ b/tests/class_loader/includes/dir/class_name.php
@@ -0,0 +1,6 @@
+<?php
+
+class phpbb_dir_class_name
+{
+}
+
diff --git a/tests/class_loader/includes/dir/subdir/class_name.php b/tests/class_loader/includes/dir/subdir/class_name.php
new file mode 100644
index 0000000000..7321a609cc
--- /dev/null
+++ b/tests/class_loader/includes/dir/subdir/class_name.php
@@ -0,0 +1,6 @@
+<?php
+
+class phpbb_dir_subdir_class_name
+{
+}
+
diff --git a/tests/request/request_class.php b/tests/request/request_class.php
new file mode 100644
index 0000000000..e8c2154bab
--- /dev/null
+++ b/tests/request/request_class.php
@@ -0,0 +1,74 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+define('IN_PHPBB', true);
+
+require_once 'test_framework/framework.php';
+
+require_once '../phpBB/includes/functions.php';
+
+class phpbb_request_request_class_test extends phpbb_test_case
+{
+ protected function setUp()
+ {
+ $_POST['test'] = 1;
+ $_GET['test'] = 2;
+ $_COOKIE['test'] = 3;
+ $_REQUEST['test'] = 3;
+
+ // reread data from super globals
+ request::reset();
+ }
+
+ public function test_toggle_super_globals()
+ {
+ // toggle super globals
+ request::disable_super_globals();
+ request::enable_super_globals();
+
+ $this->assertEquals(1, $_POST['test'], 'Checking $_POST toggling via request::dis/enable_super_globals');
+ $this->assertEquals(2, $_GET['test'], 'Checking $_GET toggling via request::dis/enable_super_globals');
+ $this->assertEquals(3, $_COOKIE['test'], 'Checking $_COOKIE toggling via request::dis/enable_super_globals');
+ $this->assertEquals(3, $_REQUEST['test'], 'Checking $_REQUEST toggling via request::dis/enable_super_globals');
+
+ $_POST['x'] = 2;
+ $this->assertEquals($_POST, $GLOBALS['_POST'], 'Checking whether $_POST can still be accessed via $GLOBALS[\'_POST\']');
+ }
+
+ /**
+ * Checks that directly accessing $_POST will trigger
+ * an error.
+ */
+ public function test_disable_post_super_global()
+ {
+ request::disable_super_globals();
+
+ $this->setExpectedTriggerError(E_USER_ERROR);
+ $_POST['test'] = 3;
+ }
+
+ public function test_is_set_post()
+ {
+ $_GET['unset'] = '';
+ request::reset();
+
+ $this->assertTrue(request::is_set_post('test'));
+ $this->assertFalse(request::is_set_post('unset'));
+ }
+
+ /**
+ * Makes sure super globals work properly after these tests
+ */
+ protected function tearDown()
+ {
+ request::enable_super_globals();
+ request::reset();
+ }
+} \ No newline at end of file
diff --git a/tests/request/request_var.php b/tests/request/request_var.php
index b1dacef3fd..0f24d77034 100644
--- a/tests/request/request_var.php
+++ b/tests/request/request_var.php
@@ -73,6 +73,45 @@ class phpbb_request_request_var_test extends phpbb_test_case
unset($_GET[$var], $_POST[$var], $_REQUEST[$var], $_COOKIE[$var]);
}
+ /**
+ * @dataProvider deep_access
+ * Only possible with 3.1.x (later)
+ public function test_deep_multi_dim_array_access($path, $default, $expected)
+ {
+ $this->unset_variables('var');
+
+ $_REQUEST['var'] = array(
+ 0 => array(
+ 'b' => array(
+ true => array(
+ 5 => 'c',
+ 6 => 'd',
+ ),
+ ),
+ ),
+ 2 => array(
+ 3 => array(
+ false => 5,
+ ),
+ ),
+ );
+
+ $result = request_var($path, $default);
+ $this->assertEquals($expected, $result, 'Testing deep access to multidimensional input arrays: ' . $path);
+ }
+
+ public static function deep_access()
+ {
+ return array(
+ // array(path, default, expected result)
+ array(array('var', 0, 'b', true, 5), '', 'c'),
+ array(array('var', 0, 'b', true, 6), '', 'd'),
+ array(array('var', 2, 3, false), 0, 5),
+ array(array('var', 0, 'b', true), array(0 => ''), array(5 => 'c', 6 => 'd')),
+ );
+ }
+*/
+
public static function request_variables()
{
return array(
@@ -173,6 +212,52 @@ class phpbb_request_request_var_test extends phpbb_test_case
'abc' => array()
)
),
+ /* 3-dimensional (not supported atm!
+ array(
+ // input:
+ array(
+ 0 => array(0 => array(3, '4', 'ab'), 1 => array()),
+ 1 => array(array(3, 4)),
+ ),
+ // default:
+ array(0 => array(0 => array(0))),
+ false,
+ // expected:
+ array(
+ 0 => array(0 => array(3, 4, 0), 1 => array()),
+ 1 => array(array(3, 4))
+ )
+ ),
+ array(
+ // input:
+ array(
+ 'ü' => array(array('c' => 'd')),
+ 'ä' => array(4 => array('a' => 2, 'ö' => 3)),
+ ),
+ // default:
+ array('' => array(0 => array('' => 0))),
+ false,
+ // expected:
+ array(
+ '??' => array(4 => array('a' => 2, '??' => 3)),
+ )
+ ),
+ array(
+ // input:
+ array(
+ 'ü' => array(array('c' => 'd')),
+ 'ä' => array(4 => array('a' => 2, 'ö' => 3)),
+ ),
+ // default:
+ array('' => array(0 => array('' => 0))),
+ true,
+ // expected:
+ array(
+ 'ü' => array(array('c' => 0)),
+ 'ä' => array(4 => array('a' => 2, 'ö' => 3)),
+ )
+ ),
+ */
);
}
diff --git a/tests/template/template.php b/tests/template/template.php
index 024d3712f7..0a685bfd61 100644
--- a/tests/template/template.php
+++ b/tests/template/template.php
@@ -17,33 +17,13 @@ class phpbb_template_template_test extends phpbb_test_case
private $template_path;
// Keep the contents of the cache for debugging?
- const PRESERVE_CACHE = true;
+ const PRESERVE_CACHE = false;
private function display($handle)
{
- // allow the templates to throw notices
- $error_level = error_reporting();
- error_reporting($error_level & ~E_NOTICE);
-
ob_start();
-
- try
- {
- $this->assertTrue($this->template->display($handle, false));
- }
- catch (Exception $exception)
- {
- // reset the error level even when an error occured
- // PHPUnit turns trigger_error into exceptions as well
- error_reporting($error_level);
- throw $exception;
- }
-
- $result = self::trim_template_result(ob_get_clean());
-
- // reset error level
- error_reporting($error_level);
- return $result;
+ $this->assertTrue($this->template->display($handle, false));
+ return self::trim_template_result(ob_get_clean());
}
private static function trim_template_result($result)
diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html
index 3e13fa33fa..42c78b9377 100644
--- a/tests/template/templates/includephp.html
+++ b/tests/template/templates/includephp.html
@@ -1 +1 @@
-<!-- INCLUDEPHP ../templates/_dummy_include.php -->
+<!-- INCLUDEPHP _dummy_include.php -->
diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html
new file mode 100644
index 0000000000..6bff53f388
--- /dev/null
+++ b/tests/template/templates/loop_expressions.html
@@ -0,0 +1,11 @@
+<!-- BEGIN loop -->
+
+<!-- IF loop.S_ROW_NUM is even by 4 -->on<!-- ELSE -->off<!-- ENDIF -->
+
+<!-- END loop -->
+
+<!-- BEGIN loop -->
+
+<!-- IF loop.S_ROW_NUM is odd by 3 -->on<!-- ELSE -->off<!-- ENDIF -->
+
+<!-- END loop -->