aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/build.xml32
-rwxr-xr-xbuild/build_announcement.php98
-rwxr-xr-xbuild/build_diff.php3
-rwxr-xr-xbuild/package.php12
-rw-r--r--phpBB/app.php1
-rw-r--r--phpBB/common.php21
-rw-r--r--phpBB/config/services.yml16
-rw-r--r--phpBB/docs/CHANGELOG.html1
-rw-r--r--phpBB/includes/bbcode.php4
-rw-r--r--phpBB/includes/functions.php34
-rw-r--r--phpBB/includes/functions_content.php4
-rw-r--r--phpBB/includes/functions_messenger.php4
-rw-r--r--phpBB/includes/functions_user.php4
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php4
-rw-r--r--phpBB/install/index.php4
-rw-r--r--phpBB/memberlist.php2
-rw-r--r--phpBB/phpbb/content_visibility.php6
-rw-r--r--phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php42
-rw-r--r--phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php39
-rw-r--r--phpBB/phpbb/db/migration/data/v310/signature_module_auth.php2
-rw-r--r--phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php4
-rw-r--r--phpBB/phpbb/db/migration/data/v310/softdelete_p1.php37
-rw-r--r--phpBB/phpbb/db/migrator.php9
-rw-r--r--phpBB/phpbb/filesystem.php145
-rw-r--r--phpBB/phpbb/notification/type/quote.php2
-rw-r--r--phpBB/phpbb/notification/type/report_pm.php2
-rw-r--r--phpBB/phpbb/path_helper.php175
-rw-r--r--phpBB/phpbb/session.php20
-rw-r--r--phpBB/phpbb/template/asset.php10
-rw-r--r--phpBB/phpbb/template/twig/environment.php22
-rw-r--r--phpBB/phpbb/template/twig/node/includeasset.php2
-rw-r--r--phpBB/phpbb/template/twig/twig.php22
-rw-r--r--phpBB/viewtopic.php14
-rw-r--r--phpunit.xml.all2
-rw-r--r--phpunit.xml.dist2
-rw-r--r--phpunit.xml.functional2
-rw-r--r--tests/controller/helper_url_test.php10
-rw-r--r--tests/dbal/migrator_test.php8
-rw-r--r--tests/extension/manager_test.php8
-rw-r--r--tests/extension/metadata_manager_test.php11
-rw-r--r--tests/filesystem/clean_path_test.php8
-rw-r--r--tests/mock/extension_manager.php8
-rw-r--r--tests/notification/convert_test.php2
-rw-r--r--tests/path_helper/web_root_path_test.php (renamed from tests/filesystem/web_root_path_test.php)16
-rw-r--r--tests/security/base.php18
-rw-r--r--tests/security/extract_current_page_test.php40
-rw-r--r--tests/security/hash_test.php8
-rw-r--r--tests/session/extract_page_test.php74
-rw-r--r--tests/session/testable_facade.php16
-rw-r--r--tests/template/template_events_test.php5
-rw-r--r--tests/template/template_includecss_test.php4
-rw-r--r--tests/template/template_includejs_test.php26
-rw-r--r--tests/template/template_test_case.php5
-rw-r--r--tests/template/template_test_case_with_tree.php5
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php8
-rw-r--r--tests/test_framework/phpbb_session_test_case.php13
56 files changed, 700 insertions, 396 deletions
diff --git a/build/build.xml b/build/build.xml
index f29be5326d..063f1017fb 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -3,7 +3,7 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
<property name="newversion" value="3.1.0-dev" />
- <property name="prevversion" value="3.0.12-RC3" />
+ <property name="prevversion" value="3.0.12" />
<property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.10, 3.0.11" />
<!-- no configuration should be needed beyond this point -->
@@ -149,6 +149,36 @@
<exec dir="build" escape="false"
command="git diff --stat release-${prevversion}...HEAD >
save/save_${prevversion}_to_${newversion}/phpbb-${prevversion}_to_${newversion}_git_diffstat.txt" />
+
+ <phingcall target="checksum-dir">
+ <property name="dir" value="build/new_version/release_files" />
+ </phingcall>
+ </target>
+
+ <target name="checksum-dir">
+ <foreach param="filename" absparam="absfilename" target="checksum-file">
+ <fileset dir="${dir}">
+ <type type="file" />
+ </fileset>
+ </foreach>
+ </target>
+
+ <target name="checksum-file">
+ <echo msg="Creating checksum file for ${absfilename}" />
+ <php function="dirname" returnProperty="dir"><param value="${absfilename}"/></php>
+ <exec dir="${dir}" command="sha256sum ${filename} > ${filename}.sha256" />
+ </target>
+
+ <target name="announcement" depends="prepare">
+ <echo msg="Writing download links and checksums for email announcement to save/announcement_email_${newversion}.txt" />
+ <exec dir="build" escape="false"
+ command="php -f build_announcement.php email '${newversion}' 'new_version/release_files' sha256 >
+ save/announcement_email_${newversion}.txt" />
+
+ <echo msg="Writing download links and checksums for bbcode announcement to save/announcement_bbcode_${newversion}.txt" />
+ <exec dir="build" escape="false"
+ command="php -f build_announcement.php bbcode '${newversion}' 'new_version/release_files' sha256 >
+ save/announcement_bbcode_${newversion}.txt" />
</target>
<target name="changelog" depends="prepare">
diff --git a/build/build_announcement.php b/build/build_announcement.php
new file mode 100755
index 0000000000..3ee96fc67d
--- /dev/null
+++ b/build/build_announcement.php
@@ -0,0 +1,98 @@
+#!/usr/bin/env php
+<?php
+/**
+*
+* @package build
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+if (php_sapi_name() !== 'cli' || $_SERVER['argc'] != 5)
+{
+ echo "Usage (CLI only): build_announcement.php email|bbcode new_version release_files_dir checksum_algorithm\n";
+ exit(1);
+}
+
+$mode = $_SERVER['argv'][1];
+$version = $_SERVER['argv'][2];
+$root = $_SERVER['argv'][3];
+$checksum_algorithm = $_SERVER['argv'][4];
+
+$series_version = substr($version, 0, 3);
+$base_url = "https://download.phpbb.com/pub/release/$series_version";
+
+if (strpos($version, 'RC') === false)
+{
+ // Final release
+ $install_url = "$base_url/$version";
+ $update_url = "$base_url/update/to_$version";
+}
+else
+{
+ $install_url = "$base_url/release_candidates/$version";
+ $update_url = "$base_url/release_candidates/update/other_to_$version";
+}
+
+if ($mode === 'bbcode')
+{
+ $template = "[url=%1\$s/%2\$s]%2\$s[/url]\n{$checksum_algorithm}sum: %3\$s\n";
+}
+else
+{
+ $template = "%s/%s\n{$checksum_algorithm}sum: %s\n";
+}
+
+function phpbb_rnatsort($array)
+{
+ $strrnatcmp = function($a, $b)
+ {
+ return strnatcmp($b, $a);
+ };
+ usort($array, $strrnatcmp);
+ return $array;
+}
+
+function phpbb_string_ends_with($haystack, $needle)
+{
+ return substr($haystack, -strlen($needle)) === $needle;
+}
+
+function phpbb_is_update_file($filename)
+{
+ return strpos($filename, '_to_') !== false;
+}
+
+function phpbb_get_checksum($checksum_file)
+{
+ return array_shift(explode(' ', file_get_contents($checksum_file)));
+}
+
+$install_files = $update_files = array();
+foreach (phpbb_rnatsort(array_diff(scandir($root), array('.', '..'))) as $filename)
+{
+ if (phpbb_string_ends_with($filename, $checksum_algorithm))
+ {
+ continue;
+ }
+ else if (phpbb_is_update_file($filename))
+ {
+ $update_files[] = $filename;
+ }
+ else
+ {
+ $install_files[] = $filename;
+ }
+}
+
+foreach ($install_files as $filename)
+{
+ printf($template, $install_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
+}
+
+echo "\n";
+
+foreach ($update_files as $filename)
+{
+ printf($template, $update_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
+}
diff --git a/build/build_diff.php b/build/build_diff.php
index 74630232b3..68bac65a66 100755
--- a/build/build_diff.php
+++ b/build/build_diff.php
@@ -83,9 +83,6 @@ if (!$echo_changes)
// Build Package
run_command("$compress_command ./../../new_version/release_files/{$code_changes_filename}.{$extension} *");
-
- // Build MD5 Sum
- run_command("md5sum ./../../new_version/release_files/{$code_changes_filename}.{$extension} > ./../../new_version/release_files/{$code_changes_filename}.{$extension}.md5");
flush();
}
}
diff --git a/build/package.php b/build/package.php
index eef6765af6..d05448dfb4 100755
--- a/build/package.php
+++ b/build/package.php
@@ -287,9 +287,6 @@ if (sizeof($package->old_packages))
// Build Package
$package->run_command($compress_command . ' ../release_files/' . $package->get('release_filename') . '-patch.' . $extension . ' *');
-
- // Build MD5 Sum
- $package->run_command('md5sum ../release_files/' . $package->get('release_filename') . '-patch.' . $extension . ' > ../release_files/' . $package->get('release_filename') . '-patch.' . $extension . '.md5');
}
// Build Files Package
@@ -321,8 +318,6 @@ if (sizeof($package->old_packages))
chdir('./release');
$package->run_command("$compress_command ../../release_files/" . $package->get('release_filename') . '-files.' . $extension . ' *');
- // Build MD5 Sum
- $package->run_command('md5sum ../../release_files/' . $package->get('release_filename') . '-files.' . $extension . ' > ../../release_files/' . $package->get('release_filename') . '-files.' . $extension . '.md5');
chdir('..');
$package->run_command('rm -Rv ' . $package->get('files_directory') . '/release');
@@ -365,9 +360,6 @@ if (sizeof($package->old_packages))
// Copy last package over...
$package->run_command('rm -v ../release_files/phpBB-' . $last_version . ".$extension");
$package->run_command("$compress_command ../../release_files/phpBB-$last_version.$extension *");
-
- // Build MD5 Sum
- $package->run_command("md5sum ../../release_files/phpBB-$last_version.$extension > ../../release_files/phpBB-$last_version.$extension.md5");
chdir('..');
}
@@ -390,9 +382,6 @@ foreach ($compress_programs as $extension => $compress_command)
// Build Package
$package->run_command("$compress_command ./release_files/" . $package->get('release_filename') . '.' . $extension . ' ' . $package->get('package_name'));
-
- // Build MD5 Sum
- $package->run_command('md5sum ./release_files/' . $package->get('release_filename') . '.' . $extension . ' > ./release_files/' . $package->get('release_filename') . '.' . $extension . '.md5');
}
// Microsoft Web PI packaging
@@ -400,7 +389,6 @@ $package->begin_status('Packaging phpBB for Microsoft WebPI');
$file = './release_files/' . $package->get('release_filename') . '.webpi.zip';
$package->run_command('cp -p ./release_files/' . $package->get('release_filename') . ".zip $file");
$package->run_command('cd ./../webpi && ' . $compress_programs['zip'] . " ./../new_version/$file *");
-$package->run_command("md5sum $file > $file.md5");
// verify results
chdir($package->locations['root']);
diff --git a/phpBB/app.php b/phpBB/app.php
index f1023ff1b5..7dc778e3a8 100644
--- a/phpBB/app.php
+++ b/phpBB/app.php
@@ -25,6 +25,7 @@ $auth->acl($user->data);
$user->setup('app');
$http_kernel = $phpbb_container->get('http_kernel');
+$symfony_request = $phpbb_container->get('symfony_request');
$response = $http_kernel->handle($symfony_request);
$response->send();
$http_kernel->terminate($symfony_request, $response);
diff --git a/phpBB/common.php b/phpBB/common.php
index 80375f7a9c..b1da2215fb 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -47,19 +47,7 @@ if (!defined('PHPBB_INSTALLED'))
// Eliminate . and .. from the path
require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
- require($phpbb_root_path . 'phpbb/symfony_request.' . $phpEx);
- require($phpbb_root_path . 'phpbb/request/deactivated_super_global.' . $phpEx);
- require($phpbb_root_path . 'phpbb/request/type_cast_helper_interface.' . $phpEx);
- require($phpbb_root_path . 'phpbb/request/type_cast_helper.' . $phpEx);
- require($phpbb_root_path . 'phpbb/request/request_interface.' . $phpEx);
- require($phpbb_root_path . 'phpbb/request/request.' . $phpEx);
- $phpbb_filesystem = new phpbb\filesystem(
- new phpbb\symfony_request(
- new phpbb\request\request()
- ),
- $phpbb_root_path,
- $phpEx
- );
+ $phpbb_filesystem = new phpbb\filesystem();
$script_path = $phpbb_filesystem->clean_path($script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name;
@@ -121,16 +109,15 @@ $db = $phpbb_container->get('dbal.conn');
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function
-// Create a Symfony Request object from our phpbb_request object
-$symfony_request = $phpbb_container->get('symfony_request');
-$phpbb_filesystem = $phpbb_container->get('filesystem');
-
// Grab global variables, re-cache if necessary
$config = $phpbb_container->get('config');
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
$phpbb_log = $phpbb_container->get('log');
+$symfony_request = $phpbb_container->get('symfony_request');
+$phpbb_filesystem = $phpbb_container->get('filesystem');
+$phpbb_path_helper = $phpbb_container->get('path_helper');
// load extensions
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index e33db0c2bc..51ae5c454d 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -169,11 +169,6 @@ services:
filesystem:
class: phpbb\filesystem
- arguments:
- - @symfony_request
- - %core.root_path%
- - %core.php_ext%
- - %core.adm_relative_path%
groupposition.legend:
class: phpbb\groupposition\legend
@@ -251,6 +246,15 @@ services:
- %tables.notifications%
- %tables.user_notifications%
+ path_helper:
+ class: phpbb\path_helper
+ arguments:
+ - @symfony_request
+ - @filesystem
+ - %core.root_path%
+ - %core.php_ext%
+ - %core.adm_relative_path%
+
php_ini:
class: phpbb\php\ini
@@ -265,7 +269,7 @@ services:
template:
class: phpbb\template\twig\twig
arguments:
- - @filesystem
+ - @path_helper
- @config
- @user
- @template_context
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index c2eb48137a..2be63eb866 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -211,6 +211,7 @@
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11368">PHPBB3-11368</a>] - Latest pm reports row count</li>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11583">PHPBB3-11583</a>] - InnoDB supports FULLTEXT index since MySQL 5.6.4.</li>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11740">PHPBB3-11740</a>] - Update link in FAQ to Ideas Centre</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11873">PHPBB3-11873</a>] - Prevent expensive hash computation in phpbb_check_hash() by rejecting very long passwords</li>
</ul>
<h4>Sub-task</h4>
<ul>
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index cd2ca7ffce..c4076a0120 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -126,13 +126,13 @@ class bbcode
*/
function bbcode_cache_init()
{
- global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager, $phpbb_filesystem;
+ global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager, $phpbb_path_helper;
if (empty($this->template_filename))
{
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
- $template = new phpbb\template\twig\twig($phpbb_filesystem, $config, $user, new phpbb\template\context(), $phpbb_extension_manager);
+ $template = new phpbb\template\twig\twig($phpbb_path_helper, $config, $user, new phpbb\template\context(), $phpbb_extension_manager);
$template->set_style();
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
$this->template_filename = $template->get_source_file_for_handle('bbcode.html');
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index b3e50847fd..e1f96c0b1e 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -442,6 +442,13 @@ function phpbb_hash($password)
*/
function phpbb_check_hash($password, $hash)
{
+ if (strlen($password) > 4096)
+ {
+ // If the password is too huge, we will simply reject it
+ // and not let the server try to hash it.
+ return false;
+ }
+
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (strlen($hash) == 34)
{
@@ -1056,31 +1063,32 @@ else
*/
function phpbb_clean_path($path)
{
- global $phpbb_container;
+ global $phpbb_path_helper, $phpbb_container;
- if ($phpbb_container)
+ if (!$phpbb_path_helper && $phpbb_container)
{
- $phpbb_filesystem = $phpbb_container->get('filesystem');
+ $phpbb_path_helper = $phpbb_container->get('path_helper');
}
- else
+ else if (!$phpbb_path_helper)
{
// The container is not yet loaded, use a new instance
- if (!class_exists('\phpbb\filesystem'))
+ if (!class_exists('\phpbb\path_helper'))
{
global $phpbb_root_path, $phpEx;
- require($phpbb_root_path . 'includes/filesystem.' . $phpEx);
+ require($phpbb_root_path . 'phpbb/path_helper.' . $phpEx);
}
- $phpbb_filesystem = new phpbb\filesystem(
+ $phpbb_path_helper = new phpbb\path_helper(
new phpbb\symfony_request(
new phpbb\request\request()
),
+ new phpbb\filesystem(),
$phpbb_root_path,
$phpEx
);
}
- return $phpbb_filesystem->clean_path($path);
+ return $phpbb_path_helper->clean_path($path);
}
// functions used for building option fields
@@ -2445,7 +2453,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
*/
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
- global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_filesystem;
+ global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_path_helper;
global $phpbb_dispatcher;
if ($params === '' || (is_array($params) && empty($params)))
@@ -2455,9 +2463,9 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
}
// Update the root path with the correct relative web path
- if ($phpbb_filesystem instanceof \phpbb\filesystem)
+ if ($phpbb_path_helper instanceof \phpbb\path_helper)
{
- $url = $phpbb_filesystem->update_web_root_path($url);
+ $url = $phpbb_path_helper->update_web_root_path($url);
}
$append_sid_overwrite = false;
@@ -5276,8 +5284,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
- $phpbb_filesystem = $phpbb_container->get('filesystem');
- $corrected_path = $phpbb_filesystem->get_web_root_path();
+ $phpbb_path_helper = $phpbb_container->get('path_helper');
+ $corrected_path = $phpbb_path_helper->get_web_root_path();
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
// Send a proper content-language to the output
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 7ecc99b39c..863450a4b2 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -834,7 +834,7 @@ function bbcode_nl2br($text)
*/
function smiley_text($text, $force_option = false)
{
- global $config, $user, $phpbb_filesystem;
+ global $config, $user, $phpbb_path_helper;
if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies'))
{
@@ -842,7 +842,7 @@ function smiley_text($text, $force_option = false)
}
else
{
- $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_filesystem->get_web_root_path();
+ $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path();
return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' . $root_path . $config['smilies_path'] . '/\2 />', $text);
}
}
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index f8b01bc770..5b343e616e 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -626,14 +626,14 @@ class messenger
*/
protected function setup_template()
{
- global $config, $phpbb_filesystem, $user, $phpbb_extension_manager;
+ global $config, $phpbb_path_helper, $user, $phpbb_extension_manager;
if ($this->template instanceof \phpbb\template\template)
{
return;
}
- $this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $user, new \phpbb\template\context(), $phpbb_extension_manager);
+ $this->template = new \phpbb\template\twig\twig($phpbb_path_helper, $config, $user, new \phpbb\template\context(), $phpbb_extension_manager);
}
/**
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 0a0656377c..30891c3fb5 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -2754,8 +2754,8 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
* Event before users are removed from a group
*
* @event core.group_delete_user_before
- * @var int group_id ID of the group from which users are deleted
- * @var string group_name Name of the group
+ * @var int group_id ID of the group from which users are deleted
+ * @var string group_name Name of the group
* @var array user_id_ary IDs of the users which are removed
* @var array username_ary names of the users which are removed
* @since 3.1-A1
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index c7b4489daf..cebbadc7c7 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -254,8 +254,8 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
* @var string mode Active module
* @var int folder_id ID of the folder the message is in
* @var int msg_id ID of the private message
- * var array folder Array with data of user's message folders
- * @var array message_row Array with message data
+ * @var array folder Array with data of user's message folders
+ * @var array message_row Array with message data
* @var array cp_row Array with senders custom profile field data
* @var array msg_data Template array with message data
* @since 3.1-A1
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 2a3bb36bf6..c9bf76bf04 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -244,8 +244,10 @@ $config = new \phpbb\config\config(array(
'load_tplcompile' => '1'
));
+$symfony_request = $phpbb_container->get('symfony_request');
$phpbb_filesystem = $phpbb_container->get('filesystem');
-$template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $user, new \phpbb\template\context());
+$phpbb_path_helper = $phpbb_container->get('path_helper');
+$template = new \phpbb\template\twig\twig($phpbb_path_helper, $config, $user, new \phpbb\template\context());
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
$paths = array_filter($paths, 'is_dir');
$template->set_custom_style('adm', $paths);
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index ead7179732..941d0ca713 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -595,7 +595,7 @@ switch ($mode)
* Modify user data before we display the profile
*
* @event core.memberlist_view_profile
- * @var array member Title of the index page
+ * @var array member Array with user's data
* @var bool user_notes_enabled Is the mcp user notes module
* enabled?
* @var bool warn_user_enabled Is the mcp warnings module
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index bf720957bc..0b351bc9ec 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -556,7 +556,7 @@ class content_visibility
*
* @param $data array Contains information from the topics table about given topic
* @param $sql_data array Populated with the SQL changes, may be empty at call time
- * @return void
+ * @return null
*/
public function add_post_to_statistic($data, &$sql_data)
{
@@ -577,7 +577,7 @@ class content_visibility
*
* @param $data array Contains information from the topics table about given topic
* @param $sql_data array Populated with the SQL changes, may be empty at call time
- * @return void
+ * @return null
*/
public function remove_post_from_statistic($data, &$sql_data)
{
@@ -599,7 +599,7 @@ class content_visibility
* @param $forum_id int Forum where the topic is found
* @param $topic_row array Contains information from the topic, may be empty at call time
* @param $sql_data array Populated with the SQL changes, may be empty at call time
- * @return void
+ * @return null
*/
public function remove_topic_from_statistic($topic_id, $forum_id, &$topic_row, &$sql_data)
{
diff --git a/phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php b/phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php
new file mode 100644
index 0000000000..9f168f4fd6
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v310/acp_style_components_module.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* @package migration
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\db\migration\data\v310;
+
+class acp_style_components_module extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ $sql = 'SELECT module_id
+ FROM ' . MODULES_TABLE . "
+ WHERE module_class = 'acp'
+ AND module_langname = 'ACP_STYLE_COMPONENTS'";
+ $result = $this->db->sql_query($sql);
+ $module_id = $this->db->sql_fetchfield('module_id');
+ $this->db->sql_freeresult($result);
+
+ return $module_id == false;
+ }
+
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v310\dev');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('module.remove', array(
+ 'acp',
+ false,
+ 'ACP_STYLE_COMPONENTS',
+ )),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php
index bd7614e1c2..4195623618 100644
--- a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php
+++ b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php
@@ -19,35 +19,44 @@ class notification_options_reconvert extends \phpbb\db\migration\migration
public function update_data()
{
return array(
+ array('custom', array(array($this, 'purge_notifications'))),
array('custom', array(array($this, 'convert_notifications'))),
);
}
- public function convert_notifications()
+ public function purge_notifications()
{
- $insert_table = $this->table_prefix . 'user_notifications';
- $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $insert_table);
+ $sql = 'DELETE FROM ' . $this->table_prefix . 'user_notifications';
+ $this->sql_query($sql);
+ }
+
+ public function convert_notifications($start)
+ {
+ $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'user_notifications');
- $this->perform_conversion($insert_buffer, $insert_table);
+ return $this->perform_conversion($insert_buffer, $start);
}
/**
* Perform the conversion (separate for testability)
*
- * @param \phpbb\db\sql_insert_buffer $insert_buffer
- * @param string $insert_table
+ * @param \phpbb\db\sql_insert_buffer $insert_buffer
+ * @param int $start Start of staggering step
+ * @return mixed int start of the next step, null if the end was reached
*/
- public function perform_conversion(\phpbb\db\sql_insert_buffer $insert_buffer, $insert_table)
+ public function perform_conversion(\phpbb\db\sql_insert_buffer $insert_buffer, $start)
{
- $sql = 'DELETE FROM ' . $insert_table;
- $this->db->sql_query($sql);
+ $limit = 250;
+ $converted_users = 0;
$sql = 'SELECT user_id, user_notify_type, user_notify_pm
- FROM ' . USERS_TABLE;
- $result = $this->db->sql_query($sql);
+ FROM ' . $this->table_prefix . 'users
+ ORDER BY user_id';
+ $result = $this->db->sql_query_limit($sql, $limit, $start);
while ($row = $this->db->sql_fetchrow($result))
{
+ $converted_users++;
$notification_methods = array();
// In-board notification
@@ -91,6 +100,14 @@ class notification_options_reconvert extends \phpbb\db\migration\migration
$this->db->sql_freeresult($result);
$insert_buffer->flush();
+
+ if ($converted_users < $limit)
+ {
+ // No more users left, we are done...
+ return;
+ }
+
+ return $start + $limit;
}
/**
diff --git a/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php b/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php
index a85e0be01c..6da1cb8009 100644
--- a/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php
+++ b/phpBB/phpbb/db/migration/data/v310/signature_module_auth.php
@@ -27,7 +27,7 @@ class signature_module_auth extends \phpbb\db\migration\migration
static public function depends_on()
{
- return array('\phpbb\db\migration\data\v31x\dev');
+ return array('\phpbb\db\migration\data\v310\dev');
}
public function update_data()
diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
index 2db9780601..d1a31815b2 100644
--- a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
+++ b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
@@ -28,8 +28,8 @@ class softdelete_mcp_modules extends \phpbb\db\migration\migration
static public function depends_on()
{
return array(
- 'phpbb\db\migration\data\v310\dev',
- 'phpbb\db\migration\data\v310\softdelete_p2',
+ '\phpbb\db\migration\data\v310\dev',
+ '\phpbb\db\migration\data\v310\softdelete_p2',
);
}
diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php
index 0418d5cc2b..f080c78c50 100644
--- a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php
+++ b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php
@@ -101,7 +101,8 @@ class softdelete_p1 extends \phpbb\db\migration\migration
return array(
array('custom', array(array($this, 'update_post_visibility'))),
array('custom', array(array($this, 'update_topic_visibility'))),
- array('custom', array(array($this, 'update_topic_forum_counts'))),
+ array('custom', array(array($this, 'update_topics_post_counts'))),
+ array('custom', array(array($this, 'update_forums_topic_and_post_counts'))),
array('permission.add', array('f_softdelete', false)),
array('permission.add', array('m_softdelete', false)),
@@ -122,28 +123,43 @@ class softdelete_p1 extends \phpbb\db\migration\migration
$this->sql_query($sql);
}
- public function update_topic_forum_counts()
+ public function update_topics_post_counts()
{
+ /*
+ * Using sql_case here to avoid "BIGINT UNSIGNED value is out of range" errors.
+ * As we update all topics in 2 queries, one broken topic would stop the conversion
+ * for all topics and the surpressed error will cause the admin to not even notice it.
+ */
$sql = 'UPDATE ' . $this->table_prefix . 'topics
SET topic_posts_approved = topic_replies + 1,
- topic_posts_unapproved = topic_replies_real - topic_replies
+ topic_posts_unapproved = ' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . '
WHERE topic_visibility = ' . ITEM_APPROVED;
$this->sql_query($sql);
$sql = 'UPDATE ' . $this->table_prefix . 'topics
SET topic_posts_approved = 0,
- topic_posts_unapproved = (topic_replies_real - topic_replies) + 1
+ topic_posts_unapproved = (' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ') + 1
WHERE topic_visibility = ' . ITEM_UNAPPROVED;
$this->sql_query($sql);
+ }
+
+ public function update_forums_topic_and_post_counts($start)
+ {
+ $start = (int) $start;
+ $limit = 10;
+ $converted_forums = 0;
$sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts_approved) AS sum_posts_approved, SUM(topic_posts_unapproved) AS sum_posts_unapproved
FROM ' . $this->table_prefix . 'topics
- GROUP BY forum_id, topic_visibility';
- $result = $this->db->sql_query($sql);
+ GROUP BY forum_id, topic_visibility
+ ORDER BY forum_id, topic_visibility';
+ $result = $this->db->sql_query_limit($sql, $limit, $start);
$update_forums = array();
while ($row = $this->db->sql_fetchrow($result))
{
+ $converted_forums++;
+
$forum_id = (int) $row['forum_id'];
if (!isset($update_forums[$forum_id]))
{
@@ -169,5 +185,14 @@ class softdelete_p1 extends \phpbb\db\migration\migration
WHERE forum_id = ' . $forum_id;
$this->sql_query($sql);
}
+
+ if ($converted_forums < $limit)
+ {
+ // There are no more topics, we are done
+ return;
+ }
+
+ // There are still more topics to query, return the next start value
+ return $start + $limit;
}
}
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index d7d2b3df59..9879ff2a85 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -192,6 +192,11 @@ class migrator
foreach ($state['migration_depends_on'] as $depend)
{
+ if ($this->unfulfillable($depend) !== false)
+ {
+ throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $depend);
+ }
+
if (!isset($this->migration_state[$depend]) ||
!$this->migration_state[$depend]['migration_schema_done'] ||
!$this->migration_state[$depend]['migration_data_done'])
@@ -208,7 +213,7 @@ class migrator
if (!isset($this->migration_state[$name]))
{
- if ($migration->effectively_installed())
+ if ($state['migration_start_time'] == 0 && $migration->effectively_installed())
{
$state = array(
'migration_depends_on' => $migration->depends_on(),
@@ -227,6 +232,8 @@ class migrator
}
}
+ $this->set_migration_state($name, $state);
+
if (!$state['migration_schema_done'])
{
$this->apply_schema_changes($migration->update_schema());
diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php
index 662b6b866e..dbfaebe0fa 100644
--- a/phpBB/phpbb/filesystem.php
+++ b/phpBB/phpbb/filesystem.php
@@ -23,151 +23,6 @@ if (!defined('IN_PHPBB'))
*/
class filesystem
{
- /** @var \phpbb\symfony_request */
- protected $symfony_request;
-
- /** @var string */
- protected $phpbb_root_path;
-
- /** @var string */
- protected $adm_relative_path;
-
- /** @var string */
- protected $php_ext;
-
- /** @var string */
- protected $web_root_path;
-
- /**
- * Constructor
- *
- * @param \phpbb\symfony_request $symfony_request
- * @param string $phpbb_root_path Relative path to phpBB root
- * @param string $php_ext PHP extension (php)
- */
- public function __construct(\phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext, $adm_relative_path = null)
- {
- $this->symfony_request = $symfony_request;
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $php_ext;
- $this->adm_relative_path = $adm_relative_path;
- }
-
- /**
- * Get the phpBB root path
- *
- * @return string
- */
- public function get_phpbb_root_path()
- {
- return $this->phpbb_root_path;
- }
-
- /**
- * Get the adm root path
- *
- * @return string
- */
- public function get_adm_relative_path()
- {
- return $this->adm_relative_path;
- }
-
- /**
- * Get the php extension
- *
- * @return string
- */
- public function get_php_ext()
- {
- return $this->php_ext;
- }
-
- /**
- * Update a path to the correct relative root path
- *
- * This replaces $phpbb_root_path . some_url with
- * get_web_root_path() . some_url OR if $phpbb_root_path
- * is not at the beginning of $path, just prepends the
- * web root path
- *
- * @param string $path The path to be updated
- * @return string
- */
- public function update_web_root_path($path)
- {
- $web_root_path = $this->get_web_root_path($this->symfony_request);
-
- if (strpos($path, $this->phpbb_root_path) === 0)
- {
- $path = substr($path, strlen($this->phpbb_root_path));
- }
-
- return $web_root_path . $path;
- }
-
- /**
- * Get a relative root path from the current URL
- *
- * @return string
- */
- public function get_web_root_path()
- {
- if ($this->symfony_request === null)
- {
- return $this->phpbb_root_path;
- }
-
- if (null !== $this->web_root_path)
- {
- return $this->web_root_path;
- }
-
- // Path info (e.g. /foo/bar)
- $path_info = $this->clean_path($this->symfony_request->getPathInfo());
-
- // Full request URI (e.g. phpBB/app.php/foo/bar)
- $request_uri = $this->symfony_request->getRequestUri();
-
- // Script name URI (e.g. phpBB/app.php)
- $script_name = $this->symfony_request->getScriptName();
-
- /*
- * If the path info is empty (single /), then we're not using
- * a route like app.php/foo/bar
- */
- if ($path_info === '/')
- {
- return $this->web_root_path = $this->phpbb_root_path;
- }
-
- // How many corrections might we need?
- $corrections = substr_count($path_info, '/');
-
- /*
- * If the script name (e.g. phpBB/app.php) exists in the
- * requestUri (e.g. phpBB/app.php/foo/template), then we
- * are have a non-rewritten URL.
- */
- if (strpos($request_uri, $script_name) === 0)
- {
- /*
- * Append ../ to the end of the phpbb_root_path as many times
- * as / exists in path_info
- */
- return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections);
- }
-
- /*
- * If we're here it means we're at a re-written path, so we must
- * correct the relative path for web URLs. We must append ../
- * to the end of the root path as many times as / exists in path_info
- * less one time (because the script, e.g. /app.php, doesn't exist in
- * the URL)
- */
- return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections - 1);
- }
-
/**
* Eliminates useless . and .. components from specified path.
*
diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php
index 56cfbc9364..8fb433990e 100644
--- a/phpBB/phpbb/notification/type/quote.php
+++ b/phpBB/phpbb/notification/type/quote.php
@@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
/**
* Post quoting notifications class
-* This class handles notifications for quoting users in a post
+* This class handles notifying users when they have been quoted in a post
*
* @package notifications
*/
diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php
index fd3f754f8a..13330e2932 100644
--- a/phpBB/phpbb/notification/type/report_pm.php
+++ b/phpBB/phpbb/notification/type/report_pm.php
@@ -18,7 +18,7 @@ if (!defined('IN_PHPBB'))
}
/**
-* Private message reproted notifications class
+* Private message reported notifications class
* This class handles notifications for private messages when they are reported
*
* @package notifications
diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php
new file mode 100644
index 0000000000..b2ed11a927
--- /dev/null
+++ b/phpBB/phpbb/path_helper.php
@@ -0,0 +1,175 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* A class with various functions that are related to paths, files and the filesystem
+* @package phpBB3
+*/
+class path_helper
+{
+ /** @var \phpbb\symfony_request */
+ protected $symfony_request;
+
+ /** @var \phpbb\filesystem */
+ protected $filesystem;
+
+ /** @var string */
+ protected $phpbb_root_path;
+
+ /** @var string */
+ protected $adm_relative_path;
+
+ /** @var string */
+ protected $php_ext;
+
+ /** @var string */
+ protected $web_root_path;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\symfony_request $symfony_request
+ * @param \phpbb\filesystem $filesystem
+ * @param string $phpbb_root_path Relative path to phpBB root
+ * @param string $php_ext PHP extension (php)
+ */
+ public function __construct(\phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $adm_relative_path = null)
+ {
+ $this->symfony_request = $symfony_request;
+ $this->filesystem = $filesystem;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->adm_relative_path = $adm_relative_path;
+ }
+
+ /**
+ * Get the phpBB root path
+ *
+ * @return string
+ */
+ public function get_phpbb_root_path()
+ {
+ return $this->phpbb_root_path;
+ }
+
+ /**
+ * Get the adm root path
+ *
+ * @return string
+ */
+ public function get_adm_relative_path()
+ {
+ return $this->adm_relative_path;
+ }
+
+ /**
+ * Get the php extension
+ *
+ * @return string
+ */
+ public function get_php_ext()
+ {
+ return $this->php_ext;
+ }
+
+ /**
+ * Update a path to the correct relative root path
+ *
+ * This replaces $phpbb_root_path . some_url with
+ * get_web_root_path() . some_url OR if $phpbb_root_path
+ * is not at the beginning of $path, just prepends the
+ * web root path
+ *
+ * @param string $path The path to be updated
+ * @return string
+ */
+ public function update_web_root_path($path)
+ {
+ $web_root_path = $this->get_web_root_path($this->symfony_request);
+
+ if (strpos($path, $this->phpbb_root_path) === 0)
+ {
+ $path = substr($path, strlen($this->phpbb_root_path));
+ }
+
+ return $web_root_path . $path;
+ }
+
+ /**
+ * Get a relative root path from the current URL
+ *
+ * @return string
+ */
+ public function get_web_root_path()
+ {
+ if ($this->symfony_request === null)
+ {
+ return $this->phpbb_root_path;
+ }
+
+ if (null !== $this->web_root_path)
+ {
+ return $this->web_root_path;
+ }
+
+ // Path info (e.g. /foo/bar)
+ $path_info = $this->filesystem->clean_path($this->symfony_request->getPathInfo());
+
+ // Full request URI (e.g. phpBB/app.php/foo/bar)
+ $request_uri = $this->symfony_request->getRequestUri();
+
+ // Script name URI (e.g. phpBB/app.php)
+ $script_name = $this->symfony_request->getScriptName();
+
+ /*
+ * If the path info is empty (single /), then we're not using
+ * a route like app.php/foo/bar
+ */
+ if ($path_info === '/')
+ {
+ return $this->web_root_path = $this->phpbb_root_path;
+ }
+
+ // How many corrections might we need?
+ $corrections = substr_count($path_info, '/');
+
+ /*
+ * If the script name (e.g. phpBB/app.php) exists in the
+ * requestUri (e.g. phpBB/app.php/foo/template), then we
+ * are have a non-rewritten URL.
+ */
+ if (strpos($request_uri, $script_name) === 0)
+ {
+ /*
+ * Append ../ to the end of the phpbb_root_path as many times
+ * as / exists in path_info
+ */
+ return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections);
+ }
+
+ /*
+ * If we're here it means we're at a re-written path, so we must
+ * correct the relative path for web URLs. We must append ../
+ * to the end of the root path as many times as / exists in path_info
+ * less one time (because the script, e.g. /app.php, doesn't exist in
+ * the URL)
+ */
+ return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections - 1);
+ }
+}
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php
index 2baf61043d..5e4380bfc8 100644
--- a/phpBB/phpbb/session.php
+++ b/phpBB/phpbb/session.php
@@ -42,13 +42,13 @@ class session
*/
static function extract_current_page($root_path)
{
- global $request;
+ global $request, $symfony_request, $phpbb_filesystem;
$page_array = array();
// First of all, get the request uri...
- $script_name = htmlspecialchars_decode($request->server('PHP_SELF'));
- $args = explode('&', htmlspecialchars_decode($request->server('QUERY_STRING')));
+ $script_name = $symfony_request->getScriptName();
+ $args = explode('&', $symfony_request->getQueryString());
// If we are unable to get the script name we use REQUEST_URI as a failover and note it within the page array for easier support...
if (!$script_name)
@@ -89,6 +89,12 @@ class session
$page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name);
$page_name = urlencode(htmlspecialchars($page_name));
+ $symfony_request_path = $phpbb_filesystem->clean_path($symfony_request->getPathInfo());
+ if ($symfony_request_path !== '/')
+ {
+ $page_name .= $symfony_request_path;
+ }
+
// current directory within the phpBB root (for example: adm)
$root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($root_path)));
$page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath('./')));
@@ -105,10 +111,14 @@ class session
}
// Current page from phpBB root (for example: adm/index.php?i=10&b=2)
- $page = (($page_dir) ? $page_dir . '/' : '') . $page_name . (($query_string) ? "?$query_string" : '');
+ $page = (($page_dir) ? $page_dir . '/' : '') . $page_name;
+ if ($query_string)
+ {
+ $page .= '?' . $query_string;
+ }
// The script path from the webroot to the current directory (for example: /phpBB3/adm/) : always prefixed with / and ends in /
- $script_path = trim(str_replace('\\', '/', dirname($script_name)));
+ $script_path = $symfony_request->getBasePath();
// The script path from the webroot to the phpBB root (for example: /phpBB3/)
$script_dirs = explode('/', $script_path);
diff --git a/phpBB/phpbb/template/asset.php b/phpBB/phpbb/template/asset.php
index 0e0b6b4782..27564bf347 100644
--- a/phpBB/phpbb/template/asset.php
+++ b/phpBB/phpbb/template/asset.php
@@ -21,17 +21,17 @@ class asset
{
protected $components = array();
- /** @var \phpbb\filesystem **/
- protected $phpbb_filesystem;
+ /** @var \phpbb\path_helper **/
+ protected $path_helper;
/**
* Constructor
*
* @param string $url URL
*/
- public function __construct($url, \phpbb\filesystem $phpbb_filesystem)
+ public function __construct($url, \phpbb\path_helper $path_helper)
{
- $this->phpbb_filesystem = $phpbb_filesystem;
+ $this->path_helper = $path_helper;
$this->set_url($url);
}
@@ -119,7 +119,7 @@ class asset
*/
public function get_url()
{
- return $this->phpbb_filesystem->update_web_root_path($this->join_url($this->components));
+ return $this->path_helper->update_web_root_path($this->join_url($this->components));
}
/**
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php
index e0ee23dcd9..a6c0e476f0 100644
--- a/phpBB/phpbb/template/twig/environment.php
+++ b/phpBB/phpbb/template/twig/environment.php
@@ -25,8 +25,8 @@ class environment extends \Twig_Environment
/** @var \phpbb\config\config */
protected $phpbb_config;
- /** @var \phpbb\filesystem */
- protected $phpbb_filesystem;
+ /** @var \phpbb\path_helper */
+ protected $phpbb_path_helper;
/** @var string */
protected $phpbb_root_path;
@@ -42,19 +42,19 @@ class environment extends \Twig_Environment
*
* @param \phpbb\config\config $phpbb_config
* @param array $phpbb_extensions Array of enabled extensions (name => path)
- * @param \phpbb\filesystem
+ * @param \phpbb\path_helper
* @param string $phpbb_root_path
* @param Twig_LoaderInterface $loader
* @param array $options Array of options to pass to Twig
*/
- public function __construct($phpbb_config, $phpbb_extensions, \phpbb\filesystem $phpbb_filesystem, \Twig_LoaderInterface $loader = null, $options = array())
+ public function __construct($phpbb_config, $phpbb_extensions, \phpbb\path_helper $path_helper, \Twig_LoaderInterface $loader = null, $options = array())
{
$this->phpbb_config = $phpbb_config;
$this->phpbb_extensions = $phpbb_extensions;
- $this->phpbb_filesystem = $phpbb_filesystem;
- $this->phpbb_root_path = $this->phpbb_filesystem->get_phpbb_root_path();
- $this->web_root_path = $this->phpbb_filesystem->get_web_root_path();
+ $this->phpbb_path_helper = $path_helper;
+ $this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path();
+ $this->web_root_path = $this->phpbb_path_helper->get_web_root_path();
return parent::__construct($loader, $options);
}
@@ -102,13 +102,13 @@ class environment extends \Twig_Environment
}
/**
- * Get the phpbb_filesystem object
+ * Get the phpbb path helper object
*
- * @return \phpbb\filesystem
+ * @return \phpbb\path_helper
*/
- public function get_filesystem()
+ public function get_path_helper()
{
- return $this->phpbb_filesystem;
+ return $this->phpbb_path_helper;
}
/**
diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php
index f15fd6296b..f6c9dc9c58 100644
--- a/phpBB/phpbb/template/twig/node/includeasset.php
+++ b/phpBB/phpbb/template/twig/node/includeasset.php
@@ -35,7 +35,7 @@ abstract class includeasset extends \Twig_Node
->write("\$asset_file = ")
->subcompile($this->getNode('expr'))
->raw(";\n")
- ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_filesystem());\n")
+ ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper());\n")
->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
->indent()
->write("\$asset_path = \$asset->get_path();")
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index 2da7405743..9df9310427 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -33,10 +33,10 @@ class twig extends \phpbb\template\base
private $cachepath = '';
/**
- * phpBB filesystem
- * @var \phpbb\filesystem
+ * phpBB path helper
+ * @var \phpbb\path_helper
*/
- protected $phpbb_filesystem;
+ protected $path_helper;
/**
* phpBB root path
@@ -79,17 +79,17 @@ class twig extends \phpbb\template\base
/**
* Constructor.
*
- * @param \phpbb\filesystem $phpbb_filesystem
+ * @param \phpbb\path_helper $path_helper
* @param \phpbb\config\config $config
* @param \phpbb\user $user
* @param \phpbb\template\context $context template context
* @param \phpbb\extension\manager $extension_manager extension manager, if null then template events will not be invoked
*/
- public function __construct(\phpbb\filesystem $phpbb_filesystem, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null)
+ public function __construct(\phpbb\path_helper $path_helper, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null)
{
- $this->phpbb_filesystem = $phpbb_filesystem;
- $this->phpbb_root_path = $phpbb_filesystem->get_phpbb_root_path();
- $this->php_ext = $phpbb_filesystem->get_php_ext();
+ $this->path_helper = $path_helper;
+ $this->phpbb_root_path = $path_helper->get_phpbb_root_path();
+ $this->php_ext = $path_helper->get_php_ext();
$this->config = $config;
$this->user = $user;
$this->context = $context;
@@ -103,7 +103,7 @@ class twig extends \phpbb\template\base
$this->twig = new \phpbb\template\twig\environment(
$this->config,
($this->extension_manager) ? $this->extension_manager->all_enabled() : array(),
- $this->phpbb_filesystem,
+ $this->path_helper,
$loader,
array(
'cache' => (defined('IN_INSTALL')) ? false : $this->cachepath,
@@ -125,9 +125,9 @@ class twig extends \phpbb\template\base
$this->twig->setLexer($lexer);
// Add admin namespace
- if ($this->phpbb_filesystem->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/'))
+ if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/'))
{
- $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/', 'admin');
+ $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin');
}
}
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 6880b6882d..69a972ed3e 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1115,8 +1115,8 @@ while ($row = $db->sql_fetchrow($result))
*
* @event core.viewtopic_cache_guest_data
* @var array user_cache_data Array with the user's data
- * @var int poster_id Poster's user id
- * @var array row Array with original user and post data
+ * @var int poster_id Poster's user id
+ * @var array row Array with original user and post data
* @since 3.1-A1
*/
$vars = array('user_cache_data', 'poster_id', 'row');
@@ -1181,8 +1181,8 @@ while ($row = $db->sql_fetchrow($result))
*
* @event core.viewtopic_cache_user_data
* @var array user_cache_data Array with the user's data
- * @var int poster_id Poster's user id
- * @var array row Array with original user and post data
+ * @var int poster_id Poster's user id
+ * @var array row Array with original user and post data
* @since 3.1-A1
*/
$vars = array('user_cache_data', 'poster_id', 'row');
@@ -1673,10 +1673,10 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
* Modify the posts template block
*
* @event core.viewtopic_modify_post_row
- * @var array row Array with original post and user data
- * @var array cp_row Custom profile field data of the poster
+ * @var array row Array with original post and user data
+ * @var array cp_row Custom profile field data of the poster
* @var array user_poster_data Poster's data from user cache
- * @var array post_row Template block array of the post
+ * @var array post_row Template block array of the post
* @since 3.1-A1
*/
$vars = array('row', 'cp_row', 'user_poster_data', 'post_row');
diff --git a/phpunit.xml.all b/phpunit.xml.all
index d18518d3e3..d5ee606ce2 100644
--- a/phpunit.xml.all
+++ b/phpunit.xml.all
@@ -29,8 +29,6 @@
<directory suffix=".php">./phpBB/includes/</directory>
<directory suffix=".php">./phpBB/phpbb/</directory>
<exclude>
- <file>./phpBB/phpbb/search/fulltext_native.php</file>
- <file>./phpBB/phpbb/search/fulltext_mysql.php</file>
<directory suffix=".php">./phpBB/includes/captcha/</directory>
</exclude>
</whitelist>
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index c852f91b50..700af8b2b2 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -36,8 +36,6 @@
<directory suffix=".php">./phpBB/includes/</directory>
<directory suffix=".php">./phpBB/phpbb/</directory>
<exclude>
- <file>./phpBB/phpbb/search/fulltext_native.php</file>
- <file>./phpBB/phpbb/search/fulltext_mysql.php</file>
<directory suffix=".php">./phpBB/includes/captcha/</directory>
</exclude>
</whitelist>
diff --git a/phpunit.xml.functional b/phpunit.xml.functional
index cd9cc8771f..44d060e615 100644
--- a/phpunit.xml.functional
+++ b/phpunit.xml.functional
@@ -35,8 +35,6 @@
<directory suffix=".php">./phpBB/includes/</directory>
<directory suffix=".php">./phpBB/phpbb/</directory>
<exclude>
- <file>./phpBB/phpbb/search/fulltext_native.php</file>
- <file>./phpBB/phpbb/search/fulltext_mysql.php</file>
<directory suffix=".php">./phpBB/includes/captcha/</directory>
</exclude>
</whitelist>
diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php
index 4ea177074f..33fc6c4f1b 100644
--- a/tests/controller/helper_url_test.php
+++ b/tests/controller/helper_url_test.php
@@ -49,14 +49,15 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->user = $this->getMock('\phpbb\user');
- $phpbb_filesystem = new \phpbb\filesystem(
+ $phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
$phpbb_root_path,
$phpEx
);
- $this->template = new phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
+ $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context());
// We don't use mod_rewrite in these tests
$config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
@@ -101,14 +102,15 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->user = $this->getMock('\phpbb\user');
- $phpbb_filesystem = new \phpbb\filesystem(
+ $phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
$phpbb_root_path,
$phpEx
);
- $this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
+ $this->template = new \phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context());
$config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php');
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index ef5d167fc2..c6b4c289d3 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -59,13 +59,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$container,
$this->db,
$this->config,
- new phpbb\filesystem(
- new phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- dirname(__FILE__) . '/../../phpBB/',
- 'php'
- ),
+ new phpbb\filesystem(),
'phpbb_ext',
dirname(__FILE__) . '/../../phpBB/',
'php',
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index c4a32f53ab..b127daf2ed 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -114,13 +114,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$container,
$db,
$config,
- new \phpbb\filesystem(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- $phpbb_root_path,
- $php_ext
- ),
+ new \phpbb\filesystem(),
'phpbb_ext',
dirname(__FILE__) . '/',
$php_ext,
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 2b27a1bae2..242ec38908 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -41,10 +41,11 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->table_prefix = 'phpbb_';
$this->template = new \phpbb\template\twig\twig(
- new \phpbb\filesystem(
+ new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
$this->phpbb_root_path,
$this->phpEx
),
@@ -70,13 +71,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$container,
$this->db,
$this->config,
- new \phpbb\filesystem(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- $this->phpbb_root_path,
- $this->phpEx
- ),
+ new \phpbb\filesystem(),
'phpbb_ext',
$this->phpbb_root_path,
$this->phpEx,
diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php
index 5b9857ef2c..fedadc103b 100644
--- a/tests/filesystem/clean_path_test.php
+++ b/tests/filesystem/clean_path_test.php
@@ -14,13 +14,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case
public function setUp()
{
parent::setUp();
- $this->filesystem = new \phpbb\filesystem(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- dirname(__FILE__) . './../../phpBB/',
- 'php'
- );
+ $this->filesystem = new \phpbb\filesystem();
}
public function clean_path_data()
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
index 0c6b8447f1..7049cbdc50 100644
--- a/tests/mock/extension_manager.php
+++ b/tests/mock/extension_manager.php
@@ -14,12 +14,6 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = 'php';
$this->extensions = $extensions;
- $this->filesystem = new \phpbb\filesystem(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- $this->phpbb_root_path,
- $this->php_ext
- );
+ $this->filesystem = new \phpbb\filesystem();
}
}
diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php
index ed1fa9b1bf..c692f40b57 100644
--- a/tests/notification/convert_test.php
+++ b/tests/notification/convert_test.php
@@ -38,7 +38,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
public function test_convert()
{
$buffer = new phpbb_mock_sql_insert_buffer($this->db, 'phpbb_user_notifications');
- $this->migration->perform_conversion($buffer, 'phpbb_user_notifications');
+ $this->migration->perform_conversion($buffer, 0);
$expected = array_merge(
$this->create_expected('post', 1, 'email'),
diff --git a/tests/filesystem/web_root_path_test.php b/tests/path_helper/web_root_path_test.php
index e0f716cdae..938b58892b 100644
--- a/tests/filesystem/web_root_path_test.php
+++ b/tests/path_helper/web_root_path_test.php
@@ -7,9 +7,9 @@
*
*/
-class phpbb_filesystem_web_root_path_test extends phpbb_test_case
+class phpbb_path_helper_web_root_path_test extends phpbb_test_case
{
- protected $filesystem;
+ protected $path_helper;
protected $phpbb_root_path = '';
public function setUp()
@@ -18,10 +18,11 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
$this->set_phpbb_root_path();
- $this->filesystem = new \phpbb\filesystem(
+ $this->path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
$this->phpbb_root_path,
'php'
);
@@ -43,7 +44,7 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
public function test_get_web_root_path()
{
// Symfony Request = null, so always should return phpbb_root_path
- $this->assertEquals($this->phpbb_root_path, $this->filesystem->get_web_root_path());
+ $this->assertEquals($this->phpbb_root_path, $this->path_helper->get_web_root_path());
}
public function basic_update_web_root_path_data()
@@ -71,7 +72,7 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
*/
public function test_basic_update_web_root_path($input, $expected)
{
- $this->assertEquals($expected, $this->filesystem->update_web_root_path($input, $symfony_request));
+ $this->assertEquals($expected, $this->path_helper->update_web_root_path($input, $symfony_request));
}
public function update_web_root_path_data()
@@ -131,12 +132,13 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
->method('getScriptName')
->will($this->returnValue($getScriptName));
- $filesystem = new \phpbb\filesystem(
+ $path_helper = new \phpbb\path_helper(
$symfony_request,
+ new \phpbb\filesystem(),
$this->phpbb_root_path,
'php'
);
- $this->assertEquals($expected, $filesystem->update_web_root_path($input, $symfony_request));
+ $this->assertEquals($expected, $path_helper->update_web_root_path($input, $symfony_request));
}
}
diff --git a/tests/security/base.php b/tests/security/base.php
index 8cd24ff145..3ab2d1cfec 100644
--- a/tests/security/base.php
+++ b/tests/security/base.php
@@ -14,7 +14,7 @@ abstract class phpbb_security_test_base extends phpbb_test_case
*/
protected function setUp()
{
- global $user, $phpbb_root_path, $request;
+ global $user, $phpbb_root_path, $phpEx, $request, $symfony_request, $phpbb_filesystem;
// Put this into a global function being run by every test to init a proper user session
$server['HTTP_HOST'] = 'localhost';
@@ -37,6 +37,22 @@ abstract class phpbb_security_test_base extends phpbb_test_case
*/
$request = new phpbb_mock_request(array(), array(), array(), $server);
+ $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
+ $request,
+ ));
+ $symfony_request->expects($this->any())
+ ->method('getScriptName')
+ ->will($this->returnValue($server['SCRIPT_NAME']));
+ $symfony_request->expects($this->any())
+ ->method('getQueryString')
+ ->will($this->returnValue($server['QUERY_STRING']));
+ $symfony_request->expects($this->any())
+ ->method('getBasePath')
+ ->will($this->returnValue($server['REQUEST_URI']));
+ $symfony_request->expects($this->any())
+ ->method('getPathInfo')
+ ->will($this->returnValue('/'));
+ $phpbb_filesystem = new \phpbb\filesystem($symfony_request, $phpbb_root_path, $phpEx);
// Set no user and trick a bit to circumvent errors
$user = new \phpbb\user();
diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php
index e42f446b31..1284aab94c 100644
--- a/tests/security/extract_current_page_test.php
+++ b/tests/security/extract_current_page_test.php
@@ -26,13 +26,23 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base
*/
public function test_query_string_php_self($url, $query_string, $expected)
{
- global $request;
+ global $symfony_request, $request;
- $request->merge(\phpbb\request\request_interface::SERVER, array(
- 'PHP_SELF' => $url,
- 'QUERY_STRING' => $query_string,
+ $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
+ $request,
));
-
+ $symfony_request->expects($this->any())
+ ->method('getScriptName')
+ ->will($this->returnValue($url));
+ $symfony_request->expects($this->any())
+ ->method('getQueryString')
+ ->will($this->returnValue($query_string));
+ $symfony_request->expects($this->any())
+ ->method('getBasePath')
+ ->will($this->returnValue($server['REQUEST_URI']));
+ $symfony_request->expects($this->any())
+ ->method('getPathInfo')
+ ->will($this->returnValue('/'));
$result = \phpbb\session::extract_current_page('./');
$label = 'Running extract_current_page on ' . $query_string . ' with PHP_SELF filled.';
@@ -44,12 +54,23 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base
*/
public function test_query_string_request_uri($url, $query_string, $expected)
{
- global $request;
+ global $symfony_request, $request;
- $request->merge(\phpbb\request\request_interface::SERVER, array(
- 'PHP_SELF' => $url,
- 'QUERY_STRING' => $query_string,
+ $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
+ $request,
));
+ $symfony_request->expects($this->any())
+ ->method('getScriptName')
+ ->will($this->returnValue($url));
+ $symfony_request->expects($this->any())
+ ->method('getQueryString')
+ ->will($this->returnValue($query_string));
+ $symfony_request->expects($this->any())
+ ->method('getBasePath')
+ ->will($this->returnValue($server['REQUEST_URI']));
+ $symfony_request->expects($this->any())
+ ->method('getPathInfo')
+ ->will($this->returnValue('/'));
$result = \phpbb\session::extract_current_page('./');
@@ -57,4 +78,3 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base
$this->assertEquals($expected, $result['query_string'], $label);
}
}
-
diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php
index 0c2580c19b..e226365ef3 100644
--- a/tests/security/hash_test.php
+++ b/tests/security/hash_test.php
@@ -17,5 +17,13 @@ class phpbb_security_hash_test extends phpbb_test_case
$this->assertTrue(phpbb_check_hash('test', '$P$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
$this->assertFalse(phpbb_check_hash('foo', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
}
+
+ public function test_check_hash_with_large_input()
+ {
+ // 16 MB password, should be rejected quite fast
+ $start_time = time();
+ $this->assertFalse(phpbb_check_hash(str_repeat('a', 1024 * 1024 * 16), '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
+ $this->assertLessThanOrEqual(5, time() - $start_time);
+ }
}
diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php
index f4ae8de021..6e137e28b8 100644
--- a/tests/session/extract_page_test.php
+++ b/tests/session/extract_page_test.php
@@ -24,6 +24,7 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
'/phpBB/index.php',
'',
'/phpBB/',
+ '/',
array(
'page_name' => 'index.php',
'page_dir' => '',
@@ -38,7 +39,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
'./',
'/phpBB/ucp.php',
'mode=login',
- '/phpBB/ucp.php?mode=login',
+ '/phpBB/',
+ '/',
array(
'page_name' => 'ucp.php',
'page_dir' => '',
@@ -53,7 +55,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
'./',
'/phpBB/ucp.php',
'mode=register',
- '/phpBB/ucp.php?mode=register',
+ '/phpBB/',
+ '/',
array(
'page_name' => 'ucp.php',
'page_dir' => '',
@@ -68,7 +71,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
'./',
'/phpBB/ucp.php',
'mode=register',
- '/phpBB/ucp.php?mode=register',
+ '/phpBB/',
+ '/',
array(
'page_name' => 'ucp.php',
'page_dir' => '',
@@ -83,30 +87,76 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
'./../',
'/phpBB/adm/index.php',
'sid=e7215d958cdd41a6fc13509bebe53e42',
- '/phpBB/adm/index.php?sid=e7215d958cdd41a6fc13509bebe53e42',
+ '/phpBB/adm/',
+ '/',
array(
'page_name' => 'index.php',
//'page_dir' => 'adm',
// ^-- Ignored because .. returns different directory in live vs testing
'query_string' => '',
'script_path' => '/phpBB/adm/',
- 'root_script_path' => '/phpBB/',
+ //'root_script_path' => '/phpBB/',
//'page' => 'adm/index.php',
'forum' => 0,
),
),
+ array(
+ './',
+ '/phpBB/adm/app.php',
+ 'page=1&test=2',
+ '/phpBB/',
+ '/foo/bar',
+ array(
+ 'page_name' => 'app.php/foo/bar',
+ 'page_dir' => '',
+ 'query_string' => 'page=1&test=2',
+ 'script_path' => '/phpBB/',
+ 'root_script_path' => '/phpBB/',
+ 'page' => 'app.php/foo/bar?page=1&test=2',
+ 'forum' => 0,
+ ),
+ ),
+ array(
+ './../phpBB/',
+ '/test/test.php',
+ 'page=1&test=2',
+ '/test/',
+ '',
+ array(
+ 'page_name' => 'test.php',
+ //'page_dir' => '',
+ 'query_string' => 'page=1&test=2',
+ 'script_path' => '/test/',
+ //'root_script_path' => '../phpBB/',
+ //'page' => '../test/test.php/foo/bar?page=1&test=2',
+ 'forum' => 0,
+ ),
+ ),
);
}
/** @dataProvider extract_current_page_data */
- function test_extract_current_page($root_path, $php_self, $query_string, $request_uri, $expected)
+ function test_extract_current_page($root_path, $getScriptName, $getQueryString, $getBasePath, $getPathInfo, $expected)
{
- $output = $this->session_facade->extract_current_page(
- $root_path,
- $php_self,
- $query_string,
- $request_uri
- );
+ global $symfony_request;
+
+ $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
+ new phpbb_mock_request(),
+ ));
+ $symfony_request->expects($this->any())
+ ->method('getScriptName')
+ ->will($this->returnValue($getScriptName));
+ $symfony_request->expects($this->any())
+ ->method('getQueryString')
+ ->will($this->returnValue($getQueryString));
+ $symfony_request->expects($this->any())
+ ->method('getBasePath')
+ ->will($this->returnValue($getBasePath));
+ $symfony_request->expects($this->any())
+ ->method('getPathInfo')
+ ->will($this->returnValue($getPathInfo));
+
+ $output = \phpbb\session::extract_current_page($root_path);
// This compares the result of the output.
// Any keys that are not in the expected array are overwritten by the output (aka not checked).
diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php
index f289c48f69..2600a46cc4 100644
--- a/tests/session/testable_facade.php
+++ b/tests/session/testable_facade.php
@@ -33,21 +33,6 @@ class phpbb_session_testable_facade
$this->session_factory = $session_factory;
}
- function extract_current_page(
- $root_path,
- $php_self,
- $query_string,
- $request_uri
- )
- {
- $this->session_factory->get_session($this->db);
- global $request;
- $request->overwrite('PHP_SELF', $php_self, \phpbb\request\request_interface::SERVER);
- $request->overwrite('QUERY_STRING', $query_string, \phpbb\request\request_interface::SERVER);
- $request->overwrite('REQUEST_URI', $request_uri, \phpbb\request\request_interface::SERVER);
- return \phpbb\session::extract_current_page($root_path);
- }
-
function extract_current_hostname(
$host,
$server_name_config,
@@ -139,4 +124,3 @@ class phpbb_session_testable_facade
return $session->validate_referer($check_script_path);
}
}
-
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index 4155d5fd83..41e00e86a7 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -116,14 +116,15 @@ Zeta test event in all',
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
dirname(__FILE__) . "/datasets/$dataset/"
);
- $phpbb_filesystem = new \phpbb\filesystem(
+ $path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
$phpbb_root_path,
$phpEx
);
- $this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $user, new \phpbb\template\context, $this->extension_manager);
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager);
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
}
}
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index c00aa8e9bb..7424af0c93 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -18,8 +18,8 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
// Prepare correct result
$scripts = array(
- '<link href="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
- '<link href="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ '<link href="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ '<link href="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
);
// Run test
diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php
index 2faeb5fcaa..ab0f4b9ca1 100644
--- a/tests/template/template_includejs_test.php
+++ b/tests/template/template_includejs_test.php
@@ -24,51 +24,51 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
*/
array(
array('TEST' => 1),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=1"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=1"></script>',
),
array(
array('TEST' => 2),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=0"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=0"></script>',
),
array(
array('TEST' => 3),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
),
array(
array('TEST' => 4),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&amp;assets_version=0"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&amp;assets_version=0"></script>',
),
array(
array('TEST' => 6),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?assets_version=1"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 7),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.js?assets_version=1"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 8),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 9),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 10),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 11),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
),
array(
array('TEST' => 12),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=1&amp;test2=2&amp;assets_version=1#test3"></script>',
),
array(
array('TEST' => 14),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=&quot;&amp;assets_version=1#test3"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=&quot;&amp;assets_version=1#test3"></script>',
),
array(
array('TEST' => 15),
@@ -84,7 +84,7 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
),
array(
array('TEST' => 18),
- '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&test2=0&amp;assets_version=1"></script>',
+ '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&test2=0&amp;assets_version=1"></script>',
),
);
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index e9cbdec1d9..c75b1e5065 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -63,16 +63,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
$this->user = new \phpbb\user;
- $phpbb_filesystem = new \phpbb\filesystem(
+ $path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
$phpbb_root_path,
$phpEx
);
$this->template_path = $this->test_path . '/templates';
- $this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context());
$this->template->set_custom_style('tests', $this->template_path);
}
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index 232331d37c..e614c42d73 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -18,17 +18,18 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
- $this->phpbb_filesystem = new \phpbb\filesystem(
+ $this->phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
$phpbb_root_path,
$phpEx
);
$this->template_path = $this->test_path . '/templates';
$this->parent_template_path = $this->test_path . '/parent_templates';
- $this->template = new phpbb\template\twig\twig($this->phpbb_filesystem, $config, $user, new phpbb\template\context());
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, new phpbb\template\context());
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
}
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index f87b3538a1..a0d186e0f2 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -203,13 +203,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$container,
$db,
$config,
- new phpbb\filesystem(
- new phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- $phpbb_root_path,
- $php_ext
- ),
+ new phpbb\filesystem(),
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
$php_ext,
diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php
index e6a2b03bba..0a2f767845 100644
--- a/tests/test_framework/phpbb_session_test_case.php
+++ b/tests/test_framework/phpbb_session_test_case.php
@@ -19,6 +19,19 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case
function setUp()
{
parent::setUp();
+
+ global $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $request, $phpbb_root_path, $phpEx;
+ $symfony_request = new \phpbb\symfony_request(
+ new phpbb_mock_request()
+ );
+ $phpbb_filesystem = new \phpbb\filesystem();
+ $phpbb_path_helper = new \phpbb\path_helper(
+ $symfony_request,
+ $phpbb_filesystem,
+ $phpbb_root_path,
+ $phpEx
+ );
+
$this->session_factory = new phpbb_session_testable_factory;
$this->db = $this->new_dbal();
$this->session_facade =