aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--build/build.xml4
-rw-r--r--phpBB/composer.json2
-rw-r--r--phpBB/config/default/container/services.yml3
-rw-r--r--phpBB/config/default/container/services_language.yml22
-rw-r--r--phpBB/config/default/container/services_twig.yml3
-rw-r--r--phpBB/config/default/container/services_user.yml1
-rw-r--r--phpBB/develop/export_events_for_wiki.php53
-rw-r--r--phpBB/docs/CHANGELOG.html8
-rw-r--r--phpBB/includes/acp/acp_extensions.php22
-rw-r--r--phpBB/includes/acp/acp_language.php38
-rw-r--r--phpBB/includes/bbcode.php1
-rw-r--r--phpBB/includes/functions.php180
-rw-r--r--phpBB/includes/functions_compatibility.php19
-rw-r--r--phpBB/includes/functions_messenger.php1
-rw-r--r--phpBB/includes/functions_user.php2
-rw-r--r--phpBB/includes/mcp/mcp_reports.php1
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php2
-rw-r--r--phpBB/install/index.php9
-rw-r--r--phpBB/install/install_convert.php6
-rw-r--r--phpBB/install/install_install.php6
-rw-r--r--phpBB/install/install_update.php2
-rw-r--r--phpBB/language/en/migrator.php7
-rw-r--r--phpBB/phpbb/cache/driver/dummy.php (renamed from phpBB/phpbb/cache/driver/null.php)4
-rw-r--r--phpBB/phpbb/captcha/plugins/captcha_abstract.php2
-rw-r--r--phpBB/phpbb/controller/exception.php2
-rw-r--r--phpBB/phpbb/controller/resolver.php18
-rw-r--r--phpBB/phpbb/db/extractor/postgres_extractor.php1
-rw-r--r--phpBB/phpbb/db/migration/data/v30x/release_3_0_14.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v314.php32
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v314rc2.php32
-rw-r--r--phpBB/phpbb/event/md_exporter.php50
-rw-r--r--phpBB/phpbb/event/php_exporter.php119
-rw-r--r--phpBB/phpbb/extension/exception.php6
-rw-r--r--phpBB/phpbb/extension/manager.php7
-rw-r--r--phpBB/phpbb/extension/metadata_manager.php26
-rw-r--r--phpBB/phpbb/filesystem/filesystem.php2
-rw-r--r--phpBB/phpbb/language/exception/invalid_plural_rule_exception.php22
-rw-r--r--phpBB/phpbb/language/exception/language_exception.php22
-rw-r--r--phpBB/phpbb/language/exception/language_file_not_found.php22
-rw-r--r--phpBB/phpbb/language/language.php571
-rw-r--r--phpBB/phpbb/language/language_file_helper.php71
-rw-r--r--phpBB/phpbb/language/language_file_loader.php212
-rw-r--r--phpBB/phpbb/log/dummy.php (renamed from phpBB/phpbb/log/null.php)4
-rw-r--r--phpBB/phpbb/notification/exception.php6
-rw-r--r--phpBB/phpbb/notification/manager.php2
-rw-r--r--phpBB/phpbb/template/asset.php27
-rw-r--r--phpBB/phpbb/template/twig/environment.php25
-rw-r--r--phpBB/phpbb/template/twig/extension.php12
-rw-r--r--phpBB/phpbb/template/twig/node/includeasset.php2
-rw-r--r--phpBB/phpbb/user.php336
-rw-r--r--phpBB/viewtopic.php77
-rw-r--r--tests/auth/provider_apache_test.php4
-rw-r--r--tests/auth/provider_db_test.php4
-rw-r--r--tests/auth/provider_oauth_token_storage_test.php4
-rw-r--r--tests/avatar/manager_test.php11
-rw-r--r--tests/cache/dummy_driver_test.php (renamed from tests/cache/null_driver_test.php)4
-rw-r--r--tests/console/cache/purge_test.php9
-rw-r--r--tests/console/config/config_test.php7
-rw-r--r--tests/console/cron/cron_list_test.php7
-rw-r--r--tests/console/cron/run_test.php5
-rw-r--r--tests/content_visibility/delete_post_test.php4
-rw-r--r--tests/content_visibility/get_forums_visibility_sql_test.php4
-rw-r--r--tests/content_visibility/get_global_visibility_sql_test.php4
-rw-r--r--tests/content_visibility/get_visibility_sql_test.php4
-rw-r--r--tests/content_visibility/set_post_visibility_test.php8
-rw-r--r--tests/content_visibility/set_topic_visibility_test.php4
-rw-r--r--tests/controller/common_helper_route.php5
-rw-r--r--tests/controller/controller_test.php2
-rw-r--r--tests/datetime/from_format_test.php12
-rw-r--r--tests/dbal/migrator_test.php2
-rw-r--r--tests/dbal/migrator_tool_module_test.php6
-rw-r--r--tests/dbal/migrator_tool_permission_test.php2
-rw-r--r--tests/event/exception_listener_test.php6
-rw-r--r--tests/extension/manager_test.php2
-rw-r--r--tests/extension/metadata_manager_test.php47
-rw-r--r--tests/functions/generate_string_list.php9
-rw-r--r--tests/functions_user/group_user_attributes_test.php2
-rw-r--r--tests/groupposition/legend_test.php42
-rw-r--r--tests/groupposition/teampage_test.php48
-rw-r--r--tests/language/language_test.php210
-rw-r--r--tests/lint_test.php49
-rw-r--r--tests/log/add_test.php8
-rw-r--r--tests/log/delete_test.php4
-rw-r--r--tests/log/function_add_log_test.php5
-rw-r--r--tests/notification/base.php9
-rw-r--r--tests/notification/group_request_test.php2
-rw-r--r--tests/notification/submit_post_base.php7
-rw-r--r--tests/notification/user_list_trim_test.php16
-rw-r--r--tests/pagination/pagination_test.php7
-rw-r--r--tests/plupload/plupload_test.php6
-rw-r--r--tests/profilefields/type_bool_test.php7
-rw-r--r--tests/profilefields/type_date_test.php7
-rw-r--r--tests/profilefields/type_dropdown_test.php7
-rw-r--r--tests/profilefields/type_googleplus_test.php6
-rw-r--r--tests/profilefields/type_int_test.php7
-rw-r--r--tests/profilefields/type_string_test.php7
-rw-r--r--tests/profilefields/type_url_test.php7
-rw-r--r--tests/security/base.php4
-rw-r--r--tests/template/asset_test.php49
-rw-r--r--tests/template/template_allfolder_test.php10
-rw-r--r--tests/template/template_events_test.php3
-rw-r--r--tests/template/template_includecss_test.php5
-rw-r--r--tests/template/template_test_case.php27
-rw-r--r--tests/template/template_test_case_with_tree.php5
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php18
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php4
-rw-r--r--tests/text_formatter/s9e/renderer_test.php54
-rw-r--r--tests/text_processing/generate_text_for_display_test.php30
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-13425.html1
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-13425.txt1
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-13425.xml23
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-9073.html2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-9073.txt2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-9073.xml14
-rw-r--r--tests/user/lang_test.php119
-rw-r--r--tests/version/version_fetch_test.php4
-rw-r--r--tests/version/version_helper_remote_test.php8
-rw-r--r--tests/version/version_test.php18
-rwxr-xr-xtravis/check-image-icc-profiles.sh2
-rw-r--r--travis/phpunit-mysqli-travis.xml3
-rwxr-xr-xtravis/setup-webserver.sh10
122 files changed, 2337 insertions, 860 deletions
diff --git a/.travis.yml b/.travis.yml
index bbd79d658f..ae61235c72 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -44,6 +44,7 @@ script:
- travis/check-sami-parse-errors.sh $DB $TRAVIS_PHP_VERSION
- travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION
- travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION ./
+ - sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/lint_test.php; fi"
- sh -c "if [ '$SLOWTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml; fi"
- sh -c "if [ '$SLOWTESTS' = '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow; fi"
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3' -a '$DB' = 'mysqli' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi"
diff --git a/build/build.xml b/build/build.xml
index 789e184028..cf617952d0 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -3,8 +3,8 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
<property name="newversion" value="3.2.0-a1-dev" />
- <property name="prevversion" value="3.1.3" />
- <property name="olderversions" value="3.0.12, 3.0.13, 3.0.13-PL1, 3.0.14-RC1, 3.1.0, 3.1.1, 3.1.2" />
+ <property name="prevversion" value="3.1.4" />
+ <property name="olderversions" value="3.0.12, 3.0.13, 3.0.13-PL1, 3.0.14, 3.1.0, 3.1.1, 3.1.2, 3.1.3" />
<!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" />
diff --git a/phpBB/composer.json b/phpBB/composer.json
index 31462b81eb..419779e5f7 100644
--- a/phpBB/composer.json
+++ b/phpBB/composer.json
@@ -35,6 +35,7 @@
"symfony/dependency-injection": "2.8.*@dev",
"symfony/event-dispatcher": "2.8.*@dev",
"symfony/filesystem": "2.8.*@dev",
+ "symfony/finder": "2.8.*@dev",
"symfony/http-kernel": "2.8.*@dev",
"symfony/routing": "2.8.*@dev",
"symfony/security-core": "2.8.*@dev",
@@ -54,7 +55,6 @@
"symfony/css-selector": "2.8.*@dev",
"symfony/debug": "2.8.*@dev",
"symfony/dom-crawler": "2.8.*@dev",
- "symfony/finder": "2.8.*@dev",
"symfony/http-foundation": "2.8.*@dev",
"symfony/process": "2.8.*@dev"
}
diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml
index 682eaeb200..670ea3bd61 100644
--- a/phpBB/config/default/container/services.yml
+++ b/phpBB/config/default/container/services.yml
@@ -9,6 +9,7 @@ imports:
- { resource: services_event.yml }
- { resource: services_feed.yml }
- { resource: services_help.yml }
+ - { resource: services_language.yml }
- { resource: services_mimetype_guesser.yml }
- { resource: services_notification.yml }
- { resource: services_password.yml }
@@ -86,7 +87,6 @@ services:
controller.resolver:
class: phpbb\controller\resolver
arguments:
- - @user
- @service_container
- %core.root_path%
- @template
@@ -98,7 +98,6 @@ services:
- @dbal.conn
- @config
- @filesystem
- - @user
- %tables.ext%
- %core.root_path%
- %core.php_ext%
diff --git a/phpBB/config/default/container/services_language.yml b/phpBB/config/default/container/services_language.yml
new file mode 100644
index 0000000000..aa3631ded1
--- /dev/null
+++ b/phpBB/config/default/container/services_language.yml
@@ -0,0 +1,22 @@
+services:
+ language.helper.language_file:
+ class: phpbb\language\language_file_helper
+ arguments:
+ - %core.root_path%
+
+ language:
+ class: phpbb\language\language
+ arguments:
+ - @language.loader
+
+ language.loader_abstract:
+ abstract: true
+ class: phpbb\language\language_file_loader
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+
+ language.loader:
+ parent: language.loader_abstract
+ calls:
+ - [set_extension_manager, ["@ext.manager"]]
diff --git a/phpBB/config/default/container/services_twig.yml b/phpBB/config/default/container/services_twig.yml
index 5d7bf0eff3..9ab004731e 100644
--- a/phpBB/config/default/container/services_twig.yml
+++ b/phpBB/config/default/container/services_twig.yml
@@ -6,6 +6,7 @@ services:
class: phpbb\template\twig\environment
arguments:
- @config
+ - @filesystem
- @path_helper
- @service_container
- %core.template.cache_path%
@@ -33,7 +34,7 @@ services:
class: phpbb\template\twig\extension
arguments:
- @template_context
- - @user
+ - @language
tags:
- { name: twig.extension }
diff --git a/phpBB/config/default/container/services_user.yml b/phpBB/config/default/container/services_user.yml
index 1ca853ea45..ff114f022a 100644
--- a/phpBB/config/default/container/services_user.yml
+++ b/phpBB/config/default/container/services_user.yml
@@ -8,6 +8,7 @@ services:
user:
class: phpbb\user
arguments:
+ - @language
- %datetime.class%
user_loader:
diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php
index 2096e9c858..be16e5e7cd 100644
--- a/phpBB/develop/export_events_for_wiki.php
+++ b/phpBB/develop/export_events_for_wiki.php
@@ -18,15 +18,19 @@ if (php_sapi_name() != 'cli')
$phpEx = substr(strrchr(__FILE__, '.'), 1);
$phpbb_root_path = __DIR__ . '/../';
+define('IN_PHPBB', true);
function usage()
{
- echo "Usage: export_events_for_wiki.php COMMAND [EXTENSION]\n";
+ echo "Usage: export_events_for_wiki.php COMMAND [VERSION] [EXTENSION]\n";
echo "\n";
echo "COMMAND:\n";
echo " all:\n";
echo " Generate the complete wikipage for https://wiki.phpbb.com/Event_List\n";
echo "\n";
+ echo " diff:\n";
+ echo " Generate the Event Diff for the release highlights\n";
+ echo "\n";
echo " php:\n";
echo " Generate the PHP event section of Event_List\n";
echo "\n";
@@ -36,6 +40,9 @@ function usage()
echo " styles:\n";
echo " Generate the Styles Template event section of Event_List\n";
echo "\n";
+ echo "VERSION (diff only):\n";
+ echo " Filter events (minimum version)\n";
+ echo "\n";
echo "EXTENSION (Optional):\n";
echo " If not given, only core events will be exported.\n";
echo " Otherwise only events from the extension will be exported.\n";
@@ -55,20 +62,32 @@ validate_argument_count($argc, 1);
$action = $argv[1];
$extension = isset($argv[2]) ? $argv[2] : null;
+$min_version = null;
require __DIR__ . '/../phpbb/event/php_exporter.' . $phpEx;
require __DIR__ . '/../phpbb/event/md_exporter.' . $phpEx;
+require __DIR__ . '/../includes/functions.' . $phpEx;
require __DIR__ . '/../phpbb/event/recursive_event_filter_iterator.' . $phpEx;
require __DIR__ . '/../phpbb/recursive_dot_prefix_filter_iterator.' . $phpEx;
switch ($action)
{
+
+ case 'diff':
+ echo '== Event changes ==' . "\n";
+ $min_version = $extension;
+ $extension = isset($argv[3]) ? $argv[3] : null;
+
case 'all':
- echo '__FORCETOC__' . "\n";
+ if ($action === 'all')
+ {
+ echo '__FORCETOC__' . "\n";
+ }
+
case 'php':
- $exporter = new \phpbb\event\php_exporter($phpbb_root_path, $extension);
+ $exporter = new \phpbb\event\php_exporter($phpbb_root_path, $extension, $min_version);
$exporter->crawl_phpbb_directory_php();
- echo $exporter->export_events_for_wiki();
+ echo $exporter->export_events_for_wiki($action);
if ($action === 'php')
{
@@ -78,9 +97,16 @@ switch ($action)
// no break;
case 'styles':
- $exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension);
- $exporter->crawl_phpbb_directory_styles('docs/events.md');
- echo $exporter->export_events_for_wiki();
+ $exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension, $min_version);
+ if ($min_version && $action === 'diff')
+ {
+ $exporter->crawl_eventsmd('docs/events.md', 'styles');
+ }
+ else
+ {
+ $exporter->crawl_phpbb_directory_styles('docs/events.md');
+ }
+ echo $exporter->export_events_for_wiki($action);
if ($action === 'styles')
{
@@ -90,9 +116,16 @@ switch ($action)
// no break;
case 'adm':
- $exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension);
- $exporter->crawl_phpbb_directory_adm('docs/events.md');
- echo $exporter->export_events_for_wiki();
+ $exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension, $min_version);
+ if ($min_version && $action === 'diff')
+ {
+ $exporter->crawl_eventsmd('docs/events.md', 'adm');
+ }
+ else
+ {
+ $exporter->crawl_phpbb_directory_adm('docs/events.md');
+ }
+ echo $exporter->export_events_for_wiki($action);
if ($action === 'all')
{
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 0e6a963f98..88df39a6d5 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -113,6 +113,10 @@
<a name="v313"></a><h3>Changes since 3.1.3</h3>
+ <h4>Security</h4>
+ <ul>
+ <li>[SECURITY-180] - An insufficient check allowed users of the Google Chrome browser to be redirected to external domains (e.g. on login)</li>
+ </ul>
<h4>Bug</h4>
<ul>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-8050">PHPBB3-8050</a>] - Avatar &amp; Long PM recipients list break out of template</li>
@@ -2331,6 +2335,10 @@
<a name="v3013-PL1"></a><h3>Changes since 3.0.13-PL1</h3>
+<h4>Security</h4>
+<ul>
+<li>[SECURITY-180] - An insufficient check allowed users of the Google Chrome browser to be redirected to external domains (e.g. on login)</li>
+</ul>
<h4>Bug</h4>
<ul>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13348">PHPBB3-13348</a>] - sql_freeresult() should be called in feed base class</li>
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index 0c9bc0deab..0373a3b115 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -70,15 +70,16 @@ class acp_extensions
// If they've specified an extension, let's load the metadata manager and validate it.
if ($ext_name)
{
- $md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $template, $user, $phpbb_root_path);
+ $md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $template, $phpbb_root_path);
try
{
$md_manager->get_metadata('all');
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
- trigger_error($e, E_USER_WARNING);
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ trigger_error($message, E_USER_WARNING);
}
}
@@ -352,10 +353,11 @@ class acp_extensions
$enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
$enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&amp;action=details&amp;versioncheck_force=1&amp;ext_name=' . urlencode($md_manager->get_metadata('name'));
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
$this->template->assign_block_vars('disabled', array(
- 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message),
'S_VERSIONCHECK' => false,
));
}
@@ -408,10 +410,11 @@ class acp_extensions
$disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
$disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&amp;action=details&amp;versioncheck_force=1&amp;ext_name=' . urlencode($md_manager->get_metadata('name'));
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
$this->template->assign_block_vars('disabled', array(
- 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message),
'S_VERSIONCHECK' => false,
));
}
@@ -467,10 +470,11 @@ class acp_extensions
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
$available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&amp;action=details&amp;versioncheck_force=1&amp;ext_name=' . urlencode($md_manager->get_metadata('name'));
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
$this->template->assign_block_vars('disabled', array(
- 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $message),
'S_VERSIONCHECK' => false,
));
}
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index 3fd118b0dd..e7ee7f47d6 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -31,7 +31,7 @@ class acp_language
function main($id, $mode)
{
- global $config, $db, $user, $template, $phpbb_log;
+ global $config, $db, $user, $template, $phpbb_log, $phpbb_container;
global $phpbb_root_path, $phpEx, $request;
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
@@ -377,37 +377,19 @@ class acp_language
$db->sql_freeresult($result);
$new_ary = $iso = array();
- $dp = @opendir("{$phpbb_root_path}language");
- if ($dp)
+ /** @var \phpbb\language\language_file_helper $language_helper */
+ $language_helper = $phpbb_container->get('language.helper.language_file');
+ $iso = $language_helper->get_available_languages();
+
+ foreach ($iso as $lang_array)
{
- while (($file = readdir($dp)) !== false)
- {
- if ($file[0] == '.' || !is_dir($phpbb_root_path . 'language/' . $file))
- {
- continue;
- }
+ $lang_iso = $lang_array['iso'];
- if (file_exists("{$phpbb_root_path}language/$file/iso.txt"))
- {
- if (!in_array($file, $installed))
- {
- if ($iso = file("{$phpbb_root_path}language/$file/iso.txt"))
- {
- if (sizeof($iso) == 3)
- {
- $new_ary[$file] = array(
- 'iso' => $file,
- 'name' => trim($iso[0]),
- 'local_name'=> trim($iso[1]),
- 'author' => trim($iso[2])
- );
- }
- }
- }
- }
+ if (!in_array($lang_iso, $installed))
+ {
+ $new_ary[$lang_iso] = $lang_array;
}
- closedir($dp);
}
unset($installed);
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 53675637a0..150157e275 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -142,6 +142,7 @@ class bbcode
new \phpbb\template\context(),
new \phpbb\template\twig\environment(
$phpbb_container->get('config'),
+ $phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'),
$phpbb_container,
$phpbb_container->getParameter('core.root_path') . 'cache/',
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 98b5af372a..2ed0eff81c 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1719,7 +1719,7 @@ function redirect($url, $return = false, $disable_cd_check = false)
$failover_flag = false;
- if (empty($user->lang))
+ if (!$user->is_setup())
{
$user->add_lang('common');
}
@@ -2243,7 +2243,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
$err = '';
// Make sure user->setup() has been called
- if (empty($user->lang))
+ if (!$user->is_setup())
{
$user->setup();
}
@@ -3268,7 +3268,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
case E_USER_ERROR:
- if (!empty($user) && !empty($user->lang))
+ if (!empty($user) && $user->is_setup())
{
$msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
$msg_title = (!isset($msg_title)) ? $user->lang['GENERAL_ERROR'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title);
@@ -3388,7 +3388,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
// We re-init the auth array to get correct results on login/logout
$auth->acl($user->data);
- if (empty($user->lang))
+ if (!$user->is_setup())
{
$user->setup();
}
@@ -3762,178 +3762,6 @@ function phpbb_optionset($bit, $set, $data)
}
/**
-* Determine which plural form we should use.
-* For some languages this is not as simple as for English.
-*
-* @param $rule int ID of the plural rule we want to use, see http://wiki.phpbb.com/Plural_Rules#Plural_Rules
-* @param $number int|float The number we want to get the plural case for. Float numbers are floored.
-* @return int The plural-case we need to use for the number plural-rule combination
-*/
-function phpbb_get_plural_form($rule, $number)
-{
- $number = (int) $number;
-
- if ($rule > 15 || $rule < 0)
- {
- trigger_error('INVALID_PLURAL_RULE');
- }
-
- /**
- * The following plural rules are based on a list published by the Mozilla Developer Network
- * https://developer.mozilla.org/en/Localization_and_Plurals
- */
- switch ($rule)
- {
- case 0:
- /**
- * Families: Asian (Chinese, Japanese, Korean, Vietnamese), Persian, Turkic/Altaic (Turkish), Thai, Lao
- * 1 - everything: 0, 1, 2, ...
- */
- return 1;
-
- case 1:
- /**
- * Families: Germanic (Danish, Dutch, English, Faroese, Frisian, German, Norwegian, Swedish), Finno-Ugric (Estonian, Finnish, Hungarian), Language isolate (Basque), Latin/Greek (Greek), Semitic (Hebrew), Romanic (Italian, Portuguese, Spanish, Catalan)
- * 1 - 1
- * 2 - everything else: 0, 2, 3, ...
- */
- return ($number == 1) ? 1 : 2;
-
- case 2:
- /**
- * Families: Romanic (French, Brazilian Portuguese)
- * 1 - 0, 1
- * 2 - everything else: 2, 3, ...
- */
- return (($number == 0) || ($number == 1)) ? 1 : 2;
-
- case 3:
- /**
- * Families: Baltic (Latvian)
- * 1 - 0
- * 2 - ends in 1, not 11: 1, 21, ... 101, 121, ...
- * 3 - everything else: 2, 3, ... 10, 11, 12, ... 20, 22, ...
- */
- return ($number == 0) ? 1 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 2 : 3);
-
- case 4:
- /**
- * Families: Celtic (Scottish Gaelic)
- * 1 - is 1 or 11: 1, 11
- * 2 - is 2 or 12: 2, 12
- * 3 - others between 3 and 19: 3, 4, ... 10, 13, ... 18, 19
- * 4 - everything else: 0, 20, 21, ...
- */
- return ($number == 1 || $number == 11) ? 1 : (($number == 2 || $number == 12) ? 2 : (($number >= 3 && $number <= 19) ? 3 : 4));
-
- case 5:
- /**
- * Families: Romanic (Romanian)
- * 1 - 1
- * 2 - is 0 or ends in 01-19: 0, 2, 3, ... 19, 101, 102, ... 119, 201, ...
- * 3 - everything else: 20, 21, ...
- */
- return ($number == 1) ? 1 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 2 : 3);
-
- case 6:
- /**
- * Families: Baltic (Lithuanian)
- * 1 - ends in 1, not 11: 1, 21, 31, ... 101, 121, ...
- * 2 - ends in 0 or ends in 10-20: 0, 10, 11, 12, ... 19, 20, 30, 40, ...
- * 3 - everything else: 2, 3, ... 8, 9, 22, 23, ... 29, 32, 33, ...
- */
- return (($number % 10 == 1) && ($number % 100 != 11)) ? 1 : ((($number % 10 < 2) || (($number % 100 >= 10) && ($number % 100 < 20))) ? 2 : 3);
-
- case 7:
- /**
- * Families: Slavic (Croatian, Serbian, Russian, Ukrainian)
- * 1 - ends in 1, not 11: 1, 21, 31, ... 101, 121, ...
- * 2 - ends in 2-4, not 12-14: 2, 3, 4, 22, 23, 24, 32, ...
- * 3 - everything else: 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26, ...
- */
- return (($number % 10 == 1) && ($number % 100 != 11)) ? 1 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 2 : 3);
-
- case 8:
- /**
- * Families: Slavic (Slovak, Czech)
- * 1 - 1
- * 2 - 2, 3, 4
- * 3 - everything else: 0, 5, 6, 7, ...
- */
- return ($number == 1) ? 1 : ((($number >= 2) && ($number <= 4)) ? 2 : 3);
-
- case 9:
- /**
- * Families: Slavic (Polish)
- * 1 - 1
- * 2 - ends in 2-4, not 12-14: 2, 3, 4, 22, 23, 24, 32, ... 104, 122, ...
- * 3 - everything else: 0, 5, 6, ... 11, 12, 13, 14, 15, ... 20, 21, 25, ...
- */
- return ($number == 1) ? 1 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 2 : 3);
-
- case 10:
- /**
- * Families: Slavic (Slovenian, Sorbian)
- * 1 - ends in 01: 1, 101, 201, ...
- * 2 - ends in 02: 2, 102, 202, ...
- * 3 - ends in 03-04: 3, 4, 103, 104, 203, 204, ...
- * 4 - everything else: 0, 5, 6, 7, 8, 9, 10, 11, ...
- */
- return ($number % 100 == 1) ? 1 : (($number % 100 == 2) ? 2 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 3 : 4));
-
- case 11:
- /**
- * Families: Celtic (Irish Gaeilge)
- * 1 - 1
- * 2 - 2
- * 3 - is 3-6: 3, 4, 5, 6
- * 4 - is 7-10: 7, 8, 9, 10
- * 5 - everything else: 0, 11, 12, ...
- */
- return ($number == 1) ? 1 : (($number == 2) ? 2 : (($number >= 3 && $number <= 6) ? 3 : (($number >= 7 && $number <= 10) ? 4 : 5)));
-
- case 12:
- /**
- * Families: Semitic (Arabic)
- * 1 - 1
- * 2 - 2
- * 3 - ends in 03-10: 3, 4, ... 10, 103, 104, ... 110, 203, 204, ...
- * 4 - ends in 11-99: 11, ... 99, 111, 112, ...
- * 5 - everything else: 100, 101, 102, 200, 201, 202, ...
- * 6 - 0
- */
- return ($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : (($number != 0) ? 5 : 6))));
-
- case 13:
- /**
- * Families: Semitic (Maltese)
- * 1 - 1
- * 2 - is 0 or ends in 01-10: 0, 2, 3, ... 9, 10, 101, 102, ...
- * 3 - ends in 11-19: 11, 12, ... 18, 19, 111, 112, ...
- * 4 - everything else: 20, 21, ...
- */
- return ($number == 1) ? 1 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 2 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 3 : 4));
-
- case 14:
- /**
- * Families: Slavic (Macedonian)
- * 1 - ends in 1: 1, 11, 21, ...
- * 2 - ends in 2: 2, 12, 22, ...
- * 3 - everything else: 0, 3, 4, ... 10, 13, 14, ... 20, 23, ...
- */
- return ($number % 10 == 1) ? 1 : (($number % 10 == 2) ? 2 : 3);
-
- case 15:
- /**
- * Families: Icelandic
- * 1 - ends in 1, not 11: 1, 21, 31, ... 101, 121, 131, ...
- * 2 - everything else: 0, 2, 3, ... 10, 11, 12, ... 20, 22, ...
- */
- return (($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2;
- }
-}
-
-/**
* Login using http authenticate.
*
* @param array $param Parameter array, see $param_defaults array.
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php
index 2d064e37cb..8655203754 100644
--- a/phpBB/includes/functions_compatibility.php
+++ b/phpBB/includes/functions_compatibility.php
@@ -482,3 +482,22 @@ function phpbb_realpath($path)
return $phpbb_filesystem->realpath($path);
}
+
+/**
+ * Determine which plural form we should use.
+ * For some languages this is not as simple as for English.
+ *
+ * @param $rule int ID of the plural rule we want to use, see http://wiki.phpbb.com/Plural_Rules#Plural_Rules
+ * @param $number int|float The number we want to get the plural case for. Float numbers are floored.
+ * @return int The plural-case we need to use for the number plural-rule combination
+ *
+ * @deprecated 3.2.0-dev (To be removed: 3.3.0)
+ */
+function phpbb_get_plural_form($rule, $number)
+{
+ global $phpbb_container;
+
+ /** @var \phpbb\language\language $language */
+ $language = $phpbb_container->get('language');
+ return $language->get_plural_form($number, $rule);
+}
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index b0861585ba..4cbe1eb425 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -637,6 +637,7 @@ class messenger
new \phpbb\template\context(),
new \phpbb\template\twig\environment(
$phpbb_container->get('config'),
+ $phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'),
$phpbb_container,
$phpbb_container->getParameter('core.root_path') . 'cache/',
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index c7234bb8e8..e8c2fbcbfa 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -3384,7 +3384,7 @@ function get_group_name($group_id)
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- if (!$row || ($row['group_type'] == GROUP_SPECIAL && empty($user->lang)))
+ if (!$row || ($row['group_type'] == GROUP_SPECIAL && !$user->is_setup()))
{
return '';
}
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index bcfbd25c0f..30319f1a8c 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -491,6 +491,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)
{
$post_id_list[] = $row[$id_column];
}
+ $db->sql_freeresult($result);
$post_id_list = array_unique($post_id_list);
if ($pm)
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index cbaa71c33e..215a870007 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -69,7 +69,7 @@ class ucp_prefs
* @var array data Array with current ucp options data
* @var array error Array with list of errors
* @since 3.1.0-a1
- * @changed 3.1.4-rc1 Added error variable to the event
+ * @changed 3.1.4-RC1 Added error variable to the event
*/
$vars = array('submit', 'data', 'error');
extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_data', compact($vars)));
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index dd3590e854..657825ca39 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -241,7 +241,8 @@ $sub = $request->variable('sub', '');
// Set PHP error handler to ours
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
-$user = new \phpbb\user('\phpbb\datetime');
+$lang_service = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
+$user = new \phpbb\user($lang_service, '\phpbb\datetime');
$auth = new \phpbb\auth\auth();
// Add own hook handler, if present. :o
@@ -279,6 +280,7 @@ $cache_path = $phpbb_root_path . 'cache/';
$twig_environment = new \phpbb\template\twig\environment(
$config,
+ $phpbb_filesystem,
$phpbb_path_helper,
$phpbb_container,
$cache_path,
@@ -287,14 +289,15 @@ $twig_environment = new \phpbb\template\twig\environment(
);
$phpbb_container->set('template.twig.environment', $twig_environment);
+$twig_context = new \phpbb\template\context();
$template = new \phpbb\template\twig\twig(
$phpbb_path_helper,
$config,
$user,
- new \phpbb\template\context(),
+ $twig_context,
$twig_environment,
$cache_path,
- array($phpbb_container->get('template.twig.extensions.phpbb'))
+ array(new \phpbb\template\twig\extension($twig_context, $user))
);
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php
index e268565be3..408c14e981 100644
--- a/phpBB/install/install_convert.php
+++ b/phpBB/install/install_convert.php
@@ -153,7 +153,7 @@ class install_convert extends module
unset($dbpasswd);
// We need to fill the config to let internal functions correctly work
- $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE);
+ $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
// Detect if there is already a conversion in progress at this point and offer to resume
// It's quite possible that the user will get disconnected during a large conversion so they need to be able to resume it
@@ -392,7 +392,7 @@ class install_convert extends module
$this->page_title = $lang['STAGE_SETTINGS'];
// We need to fill the config to let internal functions correctly work
- $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE);
+ $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
$convertor_tag = $request->variable('tag', '');
@@ -639,7 +639,7 @@ class install_convert extends module
unset($dbpasswd);
// We need to fill the config to let internal functions correctly work
- $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE);
+ $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
// Override a couple of config variables for the duration
$config['max_quote_depth'] = 0;
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 3c37a028cb..be6fa40566 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1522,7 +1522,7 @@ class install_install extends module
include_once($phpbb_root_path . 'phpbb/search/fulltext_native.' . $phpEx);
// We need to fill the config to let internal functions correctly work
- $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE);
+ $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
$error = false;
$search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
@@ -1937,7 +1937,7 @@ class install_install extends module
$data = $this->get_submitted_data();
// We need to fill the config to let internal functions correctly work
- $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE);
+ $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
@@ -2009,7 +2009,7 @@ class install_install extends module
$data = $this->get_submitted_data();
// We need to fill the config to let internal functions correctly work
- $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE);
+ $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
$user->session_begin();
$auth->login($data['admin_name'], $data['admin_pass1'], false, true, true);
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index 410a8afb66..288e728fce 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -118,7 +118,7 @@ class install_update extends module
unset($dbpasswd);
// We need to fill the config to let internal functions correctly work
- $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE);
+ $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
// Force template recompile
$config['load_tplcompile'] = 1;
diff --git a/phpBB/language/en/migrator.php b/phpBB/language/en/migrator.php
index f5a56816c2..244a5faadf 100644
--- a/phpBB/language/en/migrator.php
+++ b/phpBB/language/en/migrator.php
@@ -52,6 +52,13 @@ $lang = array_merge($lang, array(
'MIGRATION_SCHEMA_DONE' => 'Installed Schema: %1$s; Time: %2$.2f seconds',
'MIGRATION_SCHEMA_RUNNING' => 'Installing Schema: %s.',
+ 'MIGRATION_INVALID_DATA_MISSING_CONDITION' => 'A migration is invalid. An if statement helper is missing a condition.',
+ 'MIGRATION_INVALID_DATA_MISSING_STEP' => 'A migration is invalid. An if statement helper is missing a valid call to a migration step.',
+ 'MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE' => 'A migration is invalid. A custom callable function could not be called.',
+ 'MIGRATION_INVALID_DATA_UNKNOWN_TYPE' => 'A migration is invalid. An unknown migration tool type was encountered.',
+ 'MIGRATION_INVALID_DATA_UNDEFINED_TOOL' => 'A migration is invalid. An undefined migration tool was encountered.',
+ 'MIGRATION_INVALID_DATA_UNDEFINED_METHOD' => 'A migration is invalid. An undefined migration tool method was encountered.',
+
'MODULE_ERROR' => 'An error occurred while creating a module: %s',
'MODULE_INFO_FILE_NOT_EXIST' => 'A required module info file is missing: %2$s',
'MODULE_NOT_EXIST' => 'A required module does not exist: %s',
diff --git a/phpBB/phpbb/cache/driver/null.php b/phpBB/phpbb/cache/driver/dummy.php
index 298731ea54..1f74f6dd77 100644
--- a/phpBB/phpbb/cache/driver/null.php
+++ b/phpBB/phpbb/cache/driver/dummy.php
@@ -14,9 +14,9 @@
namespace phpbb\cache\driver;
/**
-* ACM Null Caching
+* ACM dummy Caching
*/
-class null extends \phpbb\cache\driver\base
+class dummy extends \phpbb\cache\driver\base
{
/**
* Set cache path
diff --git a/phpBB/phpbb/captcha/plugins/captcha_abstract.php b/phpBB/phpbb/captcha/plugins/captcha_abstract.php
index 799947a84e..b29f144f97 100644
--- a/phpBB/phpbb/captcha/plugins/captcha_abstract.php
+++ b/phpBB/phpbb/captcha/plugins/captcha_abstract.php
@@ -195,7 +195,7 @@ abstract class captcha_abstract
{
global $config, $db, $user;
- if (empty($user->lang))
+ if (!$user->is_setup())
{
$user->setup();
}
diff --git a/phpBB/phpbb/controller/exception.php b/phpBB/phpbb/controller/exception.php
index 437558b06a..e227c7c37b 100644
--- a/phpBB/phpbb/controller/exception.php
+++ b/phpBB/phpbb/controller/exception.php
@@ -16,6 +16,6 @@ namespace phpbb\controller;
/**
* Controller exception class
*/
-class exception extends \RuntimeException
+class exception extends \phpbb\exception\runtime_exception
{
}
diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php
index 948a6a218c..4f432c3323 100644
--- a/phpBB/phpbb/controller/resolver.php
+++ b/phpBB/phpbb/controller/resolver.php
@@ -23,12 +23,6 @@ use Symfony\Component\HttpFoundation\Request;
class resolver implements ControllerResolverInterface
{
/**
- * User object
- * @var \phpbb\user
- */
- protected $user;
-
- /**
* ContainerInterface object
* @var ContainerInterface
*/
@@ -55,14 +49,12 @@ class resolver implements ControllerResolverInterface
/**
* Construct method
*
- * @param \phpbb\user $user User Object
* @param ContainerInterface $container ContainerInterface object
* @param string $phpbb_root_path Relative path to phpBB root
* @param \phpbb\template\template $template
*/
- public function __construct(\phpbb\user $user, ContainerInterface $container, $phpbb_root_path, \phpbb\template\template $template = null)
+ public function __construct(ContainerInterface $container, $phpbb_root_path, \phpbb\template\template $template = null)
{
- $this->user = $user;
$this->container = $container;
$this->template = $template;
$this->type_cast_helper = new \phpbb\request\type_cast_helper();
@@ -82,20 +74,20 @@ class resolver implements ControllerResolverInterface
if (!$controller)
{
- throw new \phpbb\controller\exception($this->user->lang['CONTROLLER_NOT_SPECIFIED']);
+ throw new \phpbb\controller\exception('CONTROLLER_NOT_SPECIFIED');
}
// Require a method name along with the service name
if (stripos($controller, ':') === false)
{
- throw new \phpbb\controller\exception($this->user->lang['CONTROLLER_METHOD_NOT_SPECIFIED']);
+ throw new \phpbb\controller\exception('CONTROLLER_METHOD_NOT_SPECIFIED');
}
list($service, $method) = explode(':', $controller);
if (!$this->container->has($service))
{
- throw new \phpbb\controller\exception($this->user->lang('CONTROLLER_SERVICE_UNDEFINED', $service));
+ throw new \phpbb\controller\exception('CONTROLLER_SERVICE_UNDEFINED', array($service));
}
$controller_object = $this->container->get($service);
@@ -166,7 +158,7 @@ class resolver implements ControllerResolverInterface
}
else
{
- throw new \phpbb\controller\exception($this->user->lang('CONTROLLER_ARGUMENT_VALUE_MISSING', $param->getPosition() + 1, get_class($object) . ':' . $method, $param->name));
+ throw new \phpbb\controller\exception('CONTROLLER_ARGUMENT_VALUE_MISSING', array($param->getPosition() + 1, get_class($object) . ':' . $method, $param->name));
}
}
diff --git a/phpBB/phpbb/db/extractor/postgres_extractor.php b/phpBB/phpbb/db/extractor/postgres_extractor.php
index 9eff1f568d..a98e39621c 100644
--- a/phpBB/phpbb/db/extractor/postgres_extractor.php
+++ b/phpBB/phpbb/db/extractor/postgres_extractor.php
@@ -72,6 +72,7 @@ class postgres_extractor extends base_extractor
$this->flush($sql_data . ";\n");
}
}
+ $this->db->sql_freeresult($result);
$sql_data = '-- Table: ' . $table_name . "\n";
$sql_data .= "DROP TABLE $table_name;\n";
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_14.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_14.php
new file mode 100644
index 0000000000..51475f5a05
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_14.php
@@ -0,0 +1,37 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v30x;
+
+class release_3_0_14 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.0.14', '>=') && phpbb_version_compare($this->config['version'], '3.1.0-dev', '<');
+ }
+
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v30x\release_3_0_14_rc1');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('if', array(
+ phpbb_version_compare($this->config['version'], '3.0.14', '<'),
+ array('config.update', array('version', '3.0.14')),
+ )),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v314.php b/phpBB/phpbb/db/migration/data/v31x/v314.php
new file mode 100644
index 0000000000..b7793ca569
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v314.php
@@ -0,0 +1,32 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v31x;
+
+class v314 extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v30x\release_3_0_14',
+ '\phpbb\db\migration\data\v31x\v314rc2',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.4')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v314rc2.php b/phpBB/phpbb/db/migration/data/v31x/v314rc2.php
new file mode 100644
index 0000000000..b75b7a9be8
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v314rc2.php
@@ -0,0 +1,32 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\migration\data\v31x;
+
+class v314rc2 extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v30x\release_3_0_14_rc1',
+ '\phpbb\db\migration\data\v31x\v314rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.4-RC2')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php
index 84b10e79c1..05e898a157 100644
--- a/phpBB/phpbb/event/md_exporter.php
+++ b/phpBB/phpbb/event/md_exporter.php
@@ -24,6 +24,12 @@ class md_exporter
/** @var string phpBB Root Path */
protected $root_path;
+ /** @var string The minimum version for the events to return */
+ protected $min_version;
+
+ /** @var string The maximum version for the events to return */
+ protected $max_version;
+
/** @var string */
protected $filter;
@@ -36,8 +42,10 @@ class md_exporter
/**
* @param string $phpbb_root_path
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
+ * @param string $min_version
+ * @param string $max_version
*/
- public function __construct($phpbb_root_path, $extension = null)
+ public function __construct($phpbb_root_path, $extension = null, $min_version = null, $max_version = null)
{
$this->root_path = $phpbb_root_path;
$this->path = $this->root_path;
@@ -49,6 +57,8 @@ class md_exporter
$this->events = array();
$this->events_by_file = array();
$this->filter = $this->current_event = '';
+ $this->min_version = $min_version;
+ $this->max_version = $max_version;
}
/**
@@ -152,6 +162,11 @@ class md_exporter
$files = $this->validate_file_list($file_details);
$since = $this->validate_since($since);
+ if (!$this->version_is_filtered($since))
+ {
+ continue;
+ }
+
$this->events[$event_name] = array(
'event' => $this->current_event,
'files' => $files,
@@ -164,20 +179,47 @@ class md_exporter
}
/**
+ * The version to check
+ *
+ * @param string $version
+ */
+ protected function version_is_filtered($version)
+ {
+ return (!$this->min_version || phpbb_version_compare($this->min_version, $version, '<='))
+ && (!$this->max_version || phpbb_version_compare($this->max_version, $version, '>='));
+ }
+
+ /**
* Format the php events as a wiki table
+ *
+ * @param string $action
* @return string Number of events found
*/
- public function export_events_for_wiki()
+ public function export_events_for_wiki($action = '')
{
if ($this->filter === 'adm')
{
- $wiki_page = '= ACP Template Events =' . "\n";
+ if ($action === 'diff')
+ {
+ $wiki_page = '=== ACP Template Events ===' . "\n";
+ }
+ else
+ {
+ $wiki_page = '= ACP Template Events =' . "\n";
+ }
$wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n";
$wiki_page .= '! Identifier !! Placement !! Added in Release !! Explanation' . "\n";
}
else
{
- $wiki_page = '= Template Events =' . "\n";
+ if ($action === 'diff')
+ {
+ $wiki_page = '=== Template Events ===' . "\n";
+ }
+ else
+ {
+ $wiki_page = '= Template Events =' . "\n";
+ }
$wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n";
$wiki_page .= '! Identifier !! Prosilver Placement (If applicable) !! Added in Release !! Explanation' . "\n";
}
diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php
index 35144eeeec..8cffa4620f 100644
--- a/phpBB/phpbb/event/php_exporter.php
+++ b/phpBB/phpbb/event/php_exporter.php
@@ -25,6 +25,12 @@ class php_exporter
/** @var string phpBB Root Path */
protected $root_path;
+ /** @var string The minimum version for the events to return */
+ protected $min_version;
+
+ /** @var string The maximum version for the events to return */
+ protected $max_version;
+
/** @var string */
protected $current_file;
@@ -43,14 +49,18 @@ class php_exporter
/**
* @param string $phpbb_root_path
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
+ * @param string $min_version
+ * @param string $max_version
*/
- public function __construct($phpbb_root_path, $extension = null)
+ public function __construct($phpbb_root_path, $extension = null, $min_version = null, $max_version = null)
{
$this->root_path = $phpbb_root_path;
$this->path = $phpbb_root_path;
$this->events = $this->file_lines = array();
$this->current_file = $this->current_event = '';
$this->current_event_line = 0;
+ $this->min_version = $min_version;
+ $this->max_version = $max_version;
$this->path = $this->root_path;
if ($extension)
@@ -148,11 +158,20 @@ class php_exporter
/**
* Format the php events as a wiki table
+ *
+ * @param string $action
* @return string
*/
- public function export_events_for_wiki()
+ public function export_events_for_wiki($action = '')
{
- $wiki_page = '= PHP Events (Hook Locations) =' . "\n";
+ if ($action === 'diff')
+ {
+ $wiki_page = '=== PHP Events (Hook Locations) ===' . "\n";
+ }
+ else
+ {
+ $wiki_page = '= PHP Events (Hook Locations) =' . "\n";
+ }
$wiki_page .= '{| class="sortable zebra" cellspacing="0" cellpadding="5"' . "\n";
$wiki_page .= '! Identifier !! Placement !! Arguments !! Added in Release !! Explanation' . "\n";
foreach ($this->events as $event)
@@ -215,6 +234,34 @@ class php_exporter
$since_line_num = $this->find_since();
$since = $this->validate_since($this->file_lines[$since_line_num]);
+ $changed_line_nums = $this->find_changed('changed');
+ if (empty($changed_line_nums))
+ {
+ $changed_line_nums = $this->find_changed('change');
+ }
+ $changed_versions = array();
+ if (!empty($changed_line_nums))
+ {
+ foreach ($changed_line_nums as $changed_line_num)
+ {
+ $changed_versions[] = $this->validate_changed($this->file_lines[$changed_line_num]);
+ }
+ }
+
+ if (!$this->version_is_filtered($since))
+ {
+ $valid_version = false;
+ foreach ($changed_versions as $changed)
+ {
+ $valid_version = $valid_version || $this->version_is_filtered($changed);
+ }
+
+ if (!$valid_version)
+ {
+ continue;
+ }
+ }
+
// Find event description line
$description_line_num = $this->find_description();
$description = substr(trim($this->file_lines[$description_line_num]), strlen('* '));
@@ -243,6 +290,17 @@ class php_exporter
}
/**
+ * The version to check
+ *
+ * @param string $version
+ */
+ protected function version_is_filtered($version)
+ {
+ return (!$this->min_version || phpbb_version_compare($this->min_version, $version, '<='))
+ && (!$this->max_version || phpbb_version_compare($this->max_version, $version, '>='));
+ }
+
+ /**
* Find the name of the event inside the dispatch() line
*
* @param int $event_line
@@ -449,6 +507,33 @@ class php_exporter
}
/**
+ * Find the "@changed" Information lines
+ *
+ * @param string $tag_name Should be 'changed' or 'change'
+ * @return array Absolute line numbers
+ * @throws \LogicException
+ */
+ public function find_changed($tag_name)
+ {
+ $lines = array();
+ $last_line = 0;
+ try
+ {
+ while ($line = $this->find_tag($tag_name, array('since'), $last_line))
+ {
+ $lines[] = $line;
+ $last_line = $line;
+ }
+ }
+ catch (\LogicException $e)
+ {
+ // Not changed? No problem!
+ }
+
+ return $lines;
+ }
+
+ /**
* Find the "@event" Information line
*
* @return int Absolute line number
@@ -464,13 +549,14 @@ class php_exporter
* @param string $find_tag Name of the tag we are trying to find
* @param array $disallowed_tags List of tags that must not appear between
* the tag and the actual event
+ * @param int $skip_to_line Skip lines until this one
* @return int Absolute line number
* @throws \LogicException
*/
- public function find_tag($find_tag, $disallowed_tags)
+ public function find_tag($find_tag, $disallowed_tags, $skip_to_line = 0)
{
- $find_tag_line = 0;
- $found_comment_end = false;
+ $find_tag_line = $skip_to_line ? $this->current_event_line - $skip_to_line + 1 : 0;
+ $found_comment_end = ($skip_to_line) ? true : false;
while (strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t "), '* @' . $find_tag . ' ') !== 0)
{
if ($found_comment_end && ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '/**')
@@ -561,6 +647,27 @@ class php_exporter
}
/**
+ * Validate "@changed" Information
+ *
+ * @param string $line
+ * @return string
+ * @throws \LogicException
+ */
+ public function validate_changed($line)
+ {
+ $match = array();
+ $line = str_replace("\t", ' ', ltrim($line, "\t "));
+ preg_match('#^\* @change(d)? (\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?)( (?:.*))?$#', $line, $match);
+ if (!isset($match[2]))
+ {
+ throw new \LogicException("Invalid '@changed' information for event "
+ . "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'");
+ }
+
+ return $match[2];
+ }
+
+ /**
* Validate "@event" Information
*
* @param string $event_name
diff --git a/phpBB/phpbb/extension/exception.php b/phpBB/phpbb/extension/exception.php
index 3f7d251a4e..9050449bf1 100644
--- a/phpBB/phpbb/extension/exception.php
+++ b/phpBB/phpbb/extension/exception.php
@@ -16,10 +16,6 @@ namespace phpbb\extension;
/**
* Exception class for metadata
*/
-class exception extends \UnexpectedValueException
+class exception extends \phpbb\exception\runtime_exception
{
- public function __toString()
- {
- return $this->getMessage();
- }
}
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index 40fda74065..98d2d27278 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -26,7 +26,6 @@ class manager
protected $db;
protected $config;
protected $cache;
- protected $user;
protected $php_ext;
protected $extensions;
protected $extension_table;
@@ -40,14 +39,13 @@ class manager
* @param \phpbb\db\driver\driver_interface $db A database connection
* @param \phpbb\config\config $config Config object
* @param \phpbb\filesystem\filesystem_interface $filesystem
- * @param \phpbb\user $user User object
* @param string $extension_table The name of the table holding extensions
* @param string $phpbb_root_path Path to the phpbb includes directory.
* @param string $php_ext php file extension, defaults to php
* @param \phpbb\cache\driver\driver_interface $cache A cache instance or null
* @param string $cache_name The name of the cache variable, defaults to _ext
*/
- public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem\filesystem_interface $filesystem, \phpbb\user $user, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null, $cache_name = '_ext')
+ public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem\filesystem_interface $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null, $cache_name = '_ext')
{
$this->cache = $cache;
$this->cache_name = $cache_name;
@@ -58,7 +56,6 @@ class manager
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
- $this->user = $user;
$this->extensions = ($this->cache) ? $this->cache->get($this->cache_name) : false;
@@ -154,7 +151,7 @@ class manager
*/
public function create_extension_metadata_manager($name, \phpbb\template\template $template)
{
- return new \phpbb\extension\metadata_manager($name, $this->config, $this, $template, $this->user, $this->phpbb_root_path);
+ return new \phpbb\extension\metadata_manager($name, $this->config, $this, $template, $this->phpbb_root_path);
}
/**
diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php
index a64d88fe39..4f080647c8 100644
--- a/phpBB/phpbb/extension/metadata_manager.php
+++ b/phpBB/phpbb/extension/metadata_manager.php
@@ -37,12 +37,6 @@ class metadata_manager
protected $template;
/**
- * phpBB User instance
- * @var \phpbb\user
- */
- protected $user;
-
- /**
* phpBB root path
* @var string
*/
@@ -73,15 +67,13 @@ class metadata_manager
* @param \phpbb\config\config $config phpBB Config instance
* @param \phpbb\extension\manager $extension_manager An instance of the phpBB extension manager
* @param \phpbb\template\template $template phpBB Template instance
- * @param \phpbb\user $user User instance
* @param string $phpbb_root_path Path to the phpbb includes directory.
*/
- public function __construct($ext_name, \phpbb\config\config $config, \phpbb\extension\manager $extension_manager, \phpbb\template\template $template, \phpbb\user $user, $phpbb_root_path)
+ public function __construct($ext_name, \phpbb\config\config $config, \phpbb\extension\manager $extension_manager, \phpbb\template\template $template, $phpbb_root_path)
{
$this->config = $config;
$this->extension_manager = $extension_manager;
$this->template = $template;
- $this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
$this->ext_name = $ext_name;
@@ -149,7 +141,7 @@ class metadata_manager
if (!file_exists($this->metadata_file))
{
- throw new \phpbb\extension\exception($this->user->lang('FILE_NOT_FOUND', $this->metadata_file));
+ throw new \phpbb\extension\exception('FILE_NOT_FOUND', array($this->metadata_file));
}
}
@@ -163,18 +155,18 @@ class metadata_manager
{
if (!file_exists($this->metadata_file))
{
- throw new \phpbb\extension\exception($this->user->lang('FILE_NOT_FOUND', $this->metadata_file));
+ throw new \phpbb\extension\exception('FILE_NOT_FOUND', array($this->metadata_file));
}
else
{
if (!($file_contents = file_get_contents($this->metadata_file)))
{
- throw new \phpbb\extension\exception($this->user->lang('FILE_CONTENT_ERR', $this->metadata_file));
+ throw new \phpbb\extension\exception('FILE_CONTENT_ERR', array($this->metadata_file));
}
if (($metadata = json_decode($file_contents, true)) === null)
{
- throw new \phpbb\extension\exception($this->user->lang('FILE_JSON_DECODE_ERR', $this->metadata_file));
+ throw new \phpbb\extension\exception('FILE_JSON_DECODE_ERR', array($this->metadata_file));
}
array_walk_recursive($metadata, array($this, 'sanitize_json'));
@@ -246,12 +238,12 @@ class metadata_manager
{
if (!isset($this->metadata[$name]))
{
- throw new \phpbb\extension\exception($this->user->lang('META_FIELD_NOT_SET', $name));
+ throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array($name));
}
if (!preg_match($fields[$name], $this->metadata[$name]))
{
- throw new \phpbb\extension\exception($this->user->lang('META_FIELD_INVALID', $name));
+ throw new \phpbb\extension\exception('META_FIELD_INVALID', array($name));
}
}
break;
@@ -270,14 +262,14 @@ class metadata_manager
{
if (empty($this->metadata['authors']))
{
- throw new \phpbb\extension\exception($this->user->lang('META_FIELD_NOT_SET', 'authors'));
+ throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array('authors'));
}
foreach ($this->metadata['authors'] as $author)
{
if (!isset($author['name']))
{
- throw new \phpbb\extension\exception($this->user->lang('META_FIELD_NOT_SET', 'author name'));
+ throw new \phpbb\extension\exception('META_FIELD_NOT_SET', array('author name'));
}
}
diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php
index 370dff77e5..2112882d1d 100644
--- a/phpBB/phpbb/filesystem/filesystem.php
+++ b/phpBB/phpbb/filesystem/filesystem.php
@@ -613,7 +613,7 @@ class filesystem implements filesystem_interface
}
else
{
- $handle = @fopen($file, 'w');
+ $handle = @fopen($file, 'c');
if (is_resource($handle))
{
diff --git a/phpBB/phpbb/language/exception/invalid_plural_rule_exception.php b/phpBB/phpbb/language/exception/invalid_plural_rule_exception.php
new file mode 100644
index 0000000000..94e3466208
--- /dev/null
+++ b/phpBB/phpbb/language/exception/invalid_plural_rule_exception.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\language\exception;
+
+/**
+ * Thrown when nonexistent plural rule is specified
+ */
+class invalid_plural_rule_exception extends language_exception
+{
+
+}
diff --git a/phpBB/phpbb/language/exception/language_exception.php b/phpBB/phpbb/language/exception/language_exception.php
new file mode 100644
index 0000000000..b1258414aa
--- /dev/null
+++ b/phpBB/phpbb/language/exception/language_exception.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\language\exception;
+
+/**
+ * Base exception class for language exceptions
+ */
+class language_exception extends \phpbb\exception\runtime_exception
+{
+
+}
diff --git a/phpBB/phpbb/language/exception/language_file_not_found.php b/phpBB/phpbb/language/exception/language_file_not_found.php
new file mode 100644
index 0000000000..89364267eb
--- /dev/null
+++ b/phpBB/phpbb/language/exception/language_file_not_found.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\language\exception;
+
+/**
+ * This exception is thrown when the language file is not found
+ */
+class language_file_not_found extends language_exception
+{
+
+}
diff --git a/phpBB/phpbb/language/language.php b/phpBB/phpbb/language/language.php
new file mode 100644
index 0000000000..3298908365
--- /dev/null
+++ b/phpBB/phpbb/language/language.php
@@ -0,0 +1,571 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\language;
+
+use phpbb\language\exception\invalid_plural_rule_exception;
+
+/**
+ * Wrapper class for loading translations
+ */
+class language
+{
+ /**
+ * Global fallback language
+ *
+ * ISO code of the language to fallback to when the specified language entries
+ * cannot be found.
+ *
+ * @var string
+ */
+ const FALLBACK_LANGUAGE = 'en';
+
+ /**
+ * @var array List of common language files
+ */
+ protected $common_language_files;
+
+ /**
+ * @var bool
+ */
+ protected $common_language_files_loaded;
+
+ /**
+ * @var string ISO code of the default board language
+ */
+ protected $default_language;
+
+ /**
+ * @var string ISO code of the User's language
+ */
+ protected $user_language;
+
+ /**
+ * @var array Language fallback array (the order is important)
+ */
+ protected $language_fallback;
+
+ /**
+ * @var array Array of language variables
+ */
+ protected $lang;
+
+ /**
+ * @var array Loaded language sets
+ */
+ protected $loaded_language_sets;
+
+ /**
+ * @var \phpbb\language\language_file_loader Language file loader
+ */
+ protected $loader;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\language\language_file_loader $loader Language file loader
+ * @param array|null $common_modules Array of common language modules to load (optional)
+ */
+ public function __construct(language_file_loader $loader, $common_modules = null)
+ {
+ $this->loader = $loader;
+
+ // Set up default information
+ $this->user_language = false;
+ $this->default_language = false;
+ $this->lang = array(
+ // For BC with user::help array
+ '__help' => array(),
+ );
+ $this->loaded_language_sets = array(
+ 'core' => array(),
+ 'ext' => array(),
+ );
+
+ // Common language files
+ if (is_array($common_modules))
+ {
+ $this->common_language_files = $common_modules;
+ }
+ else
+ {
+ $this->common_language_files = array(
+ 'common',
+ );
+ }
+
+ $this->common_language_files_loaded = false;
+
+ $this->language_fallback = array(self::FALLBACK_LANGUAGE);
+ }
+
+ /**
+ * Function to set user's language to display.
+ *
+ * @param string $user_lang_iso ISO code of the User's language
+ */
+ public function set_user_language($user_lang_iso)
+ {
+ $this->user_language = $user_lang_iso;
+
+ $this->set_fallback_array();
+ }
+
+ /**
+ * Function to set the board's default language to display.
+ *
+ * @param string $default_lang_iso ISO code of the board's default language
+ */
+ public function set_default_language($default_lang_iso)
+ {
+ $this->default_language = $default_lang_iso;
+
+ $this->set_fallback_array();
+ }
+
+ /**
+ * Returns language array
+ *
+ * Note: This function is needed for the BC purposes, until \phpbb\user::lang[] is
+ * not removed.
+ *
+ * @return array Array of loaded language strings
+ */
+ public function get_lang_array()
+ {
+ // Load common language files if they not loaded yet
+ if (!$this->common_language_files_loaded)
+ {
+ $this->load_common_language_files();
+ }
+
+ return $this->lang;
+ }
+
+ /**
+ * Add Language Items
+ *
+ * Note: $use_help is assigned where needed (only use them to force inclusion).
+ *
+ * Examples:
+ * <code>
+ * $component = array('posting');
+ * $component = array('posting', 'viewtopic')
+ * $component = 'posting'
+ * </code>
+ *
+ * @param string|array $component The name of the language component to load
+ * @param string|null $extension_name Name of the extension to load component from, or null for core file
+ */
+ public function add_lang($component, $extension_name = null)
+ {
+ // Load common language files if they not loaded yet
+ // This needs to be here to correctly merge language arrays
+ if (!$this->common_language_files_loaded)
+ {
+ $this->load_common_language_files();
+ }
+
+ if (!is_array($component))
+ {
+ if (!is_null($extension_name))
+ {
+ $this->load_extension($extension_name, $component);
+ }
+ else
+ {
+ $this->load_core_file($component);
+ }
+ }
+ else
+ {
+ foreach ($component as $lang_file)
+ {
+ $this->add_lang($lang_file, $extension_name);
+ }
+ }
+ }
+
+ /**
+ * Advanced language substitution
+ *
+ * Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms.
+ * Params are the language key and the parameters to be substituted.
+ * This function/functionality is inspired by SHS` and Ashe.
+ *
+ * Example call: <samp>$user->lang('NUM_POSTS_IN_QUEUE', 1);</samp>
+ *
+ * If the first parameter is an array, the elements are used as keys and subkeys to get the language entry:
+ * Example: <samp>$user->lang(array('datetime', 'AGO'), 1)</samp> uses $user->lang['datetime']['AGO'] as language entry.
+ *
+ * @return string Return localized string or the language key if the translation is not available
+ */
+ public function lang()
+ {
+ // Load common language files if they not loaded yet
+ if (!$this->common_language_files_loaded)
+ {
+ $this->load_common_language_files();
+ }
+
+ $args = func_get_args();
+ $key = $args[0];
+
+ if (is_array($key))
+ {
+ $lang = &$this->lang[array_shift($key)];
+
+ foreach ($key as $_key)
+ {
+ $lang = &$lang[$_key];
+ }
+ }
+ else
+ {
+ $lang = &$this->lang[$key];
+ }
+
+ // Return if language string does not exist
+ if (!isset($lang) || (!is_string($lang) && !is_array($lang)))
+ {
+ return $key;
+ }
+
+ // If the language entry is a string, we simply mimic sprintf() behaviour
+ if (is_string($lang))
+ {
+ if (sizeof($args) == 1)
+ {
+ return $lang;
+ }
+
+ // Replace key with language entry and simply pass along...
+ $args[0] = $lang;
+ return call_user_func_array('sprintf', $args);
+ }
+ else if (sizeof($lang) == 0)
+ {
+ // If the language entry is an empty array, we just return the language key
+ return $args[0];
+ }
+
+ // It is an array... now handle different nullar/singular/plural forms
+ $key_found = false;
+
+ // We now get the first number passed and will select the key based upon this number
+ for ($i = 1, $num_args = sizeof($args); $i < $num_args; $i++)
+ {
+ if (is_int($args[$i]) || is_float($args[$i]))
+ {
+ if ($args[$i] == 0 && isset($lang[0]))
+ {
+ // We allow each translation using plural forms to specify a version for the case of 0 things,
+ // so that "0 users" may be displayed as "No users".
+ $key_found = 0;
+ break;
+ }
+ else
+ {
+ $use_plural_form = $this->get_plural_form($args[$i]);
+ if (isset($lang[$use_plural_form]))
+ {
+ // The key we should use exists, so we use it.
+ $key_found = $use_plural_form;
+ }
+ else
+ {
+ // If the key we need to use does not exist, we fall back to the previous one.
+ $numbers = array_keys($lang);
+
+ foreach ($numbers as $num)
+ {
+ if ($num > $use_plural_form)
+ {
+ break;
+ }
+
+ $key_found = $num;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ // Ok, let's check if the key was found, else use the last entry (because it is mostly the plural form)
+ if ($key_found === false)
+ {
+ $numbers = array_keys($lang);
+ $key_found = end($numbers);
+ }
+
+ // Use the language string we determined and pass it to sprintf()
+ $args[0] = $lang[$key_found];
+ return call_user_func_array('sprintf', $args);
+ }
+
+ /**
+ * Loads common language files
+ */
+ protected function load_common_language_files()
+ {
+ if (!$this->common_language_files_loaded)
+ {
+ foreach ($this->common_language_files as $lang_file)
+ {
+ $this->load_core_file($lang_file);
+ }
+
+ $this->common_language_files_loaded = true;
+ }
+ }
+
+ /**
+ * Determine which plural form we should use.
+ *
+ * For some languages this is not as simple as for English.
+ *
+ * @param int|float $number The number we want to get the plural case for. Float numbers are floored.
+ * @param int|bool $force_rule False to use the plural rule of the language package
+ * or an integer to force a certain plural rule
+ *
+ * @return int The plural-case we need to use for the number plural-rule combination
+ *
+ * @throws \phpbb\language\exception\invalid_plural_rule_exception When $force_rule has an invalid value
+ */
+ public function get_plural_form($number, $force_rule = false)
+ {
+ $number = (int) $number;
+ $plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1);
+
+ if ($plural_rule > 15 || $plural_rule < 0)
+ {
+ throw new invalid_plural_rule_exception('INVALID_PLURAL_RULE', array(
+ 'plural_rule' => $plural_rule,
+ ));
+ }
+
+ /**
+ * The following plural rules are based on a list published by the Mozilla Developer Network
+ * https://developer.mozilla.org/en/Localization_and_Plurals
+ */
+ switch ($plural_rule)
+ {
+ case 0:
+ /**
+ * Families: Asian (Chinese, Japanese, Korean, Vietnamese), Persian, Turkic/Altaic (Turkish), Thai, Lao
+ * 1 - everything: 0, 1, 2, ...
+ */
+ return 1;
+
+ case 1:
+ /**
+ * Families: Germanic (Danish, Dutch, English, Faroese, Frisian, German, Norwegian, Swedish), Finno-Ugric (Estonian, Finnish, Hungarian), Language isolate (Basque), Latin/Greek (Greek), Semitic (Hebrew), Romanic (Italian, Portuguese, Spanish, Catalan)
+ * 1 - 1
+ * 2 - everything else: 0, 2, 3, ...
+ */
+ return ($number === 1) ? 1 : 2;
+
+ case 2:
+ /**
+ * Families: Romanic (French, Brazilian Portuguese)
+ * 1 - 0, 1
+ * 2 - everything else: 2, 3, ...
+ */
+ return (($number === 0) || ($number === 1)) ? 1 : 2;
+
+ case 3:
+ /**
+ * Families: Baltic (Latvian)
+ * 1 - 0
+ * 2 - ends in 1, not 11: 1, 21, ... 101, 121, ...
+ * 3 - everything else: 2, 3, ... 10, 11, 12, ... 20, 22, ...
+ */
+ return ($number === 0) ? 1 : ((($number % 10 === 1) && ($number % 100 != 11)) ? 2 : 3);
+
+ case 4:
+ /**
+ * Families: Celtic (Scottish Gaelic)
+ * 1 - is 1 or 11: 1, 11
+ * 2 - is 2 or 12: 2, 12
+ * 3 - others between 3 and 19: 3, 4, ... 10, 13, ... 18, 19
+ * 4 - everything else: 0, 20, 21, ...
+ */
+ return ($number === 1 || $number === 11) ? 1 : (($number === 2 || $number === 12) ? 2 : (($number >= 3 && $number <= 19) ? 3 : 4));
+
+ case 5:
+ /**
+ * Families: Romanic (Romanian)
+ * 1 - 1
+ * 2 - is 0 or ends in 01-19: 0, 2, 3, ... 19, 101, 102, ... 119, 201, ...
+ * 3 - everything else: 20, 21, ...
+ */
+ return ($number === 1) ? 1 : ((($number === 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 2 : 3);
+
+ case 6:
+ /**
+ * Families: Baltic (Lithuanian)
+ * 1 - ends in 1, not 11: 1, 21, 31, ... 101, 121, ...
+ * 2 - ends in 0 or ends in 10-20: 0, 10, 11, 12, ... 19, 20, 30, 40, ...
+ * 3 - everything else: 2, 3, ... 8, 9, 22, 23, ... 29, 32, 33, ...
+ */
+ return (($number % 10 === 1) && ($number % 100 != 11)) ? 1 : ((($number % 10 < 2) || (($number % 100 >= 10) && ($number % 100 < 20))) ? 2 : 3);
+
+ case 7:
+ /**
+ * Families: Slavic (Croatian, Serbian, Russian, Ukrainian)
+ * 1 - ends in 1, not 11: 1, 21, 31, ... 101, 121, ...
+ * 2 - ends in 2-4, not 12-14: 2, 3, 4, 22, 23, 24, 32, ...
+ * 3 - everything else: 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26, ...
+ */
+ return (($number % 10 === 1) && ($number % 100 != 11)) ? 1 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 2 : 3);
+
+ case 8:
+ /**
+ * Families: Slavic (Slovak, Czech)
+ * 1 - 1
+ * 2 - 2, 3, 4
+ * 3 - everything else: 0, 5, 6, 7, ...
+ */
+ return ($number === 1) ? 1 : ((($number >= 2) && ($number <= 4)) ? 2 : 3);
+
+ case 9:
+ /**
+ * Families: Slavic (Polish)
+ * 1 - 1
+ * 2 - ends in 2-4, not 12-14: 2, 3, 4, 22, 23, 24, 32, ... 104, 122, ...
+ * 3 - everything else: 0, 5, 6, ... 11, 12, 13, 14, 15, ... 20, 21, 25, ...
+ */
+ return ($number === 1) ? 1 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 2 : 3);
+
+ case 10:
+ /**
+ * Families: Slavic (Slovenian, Sorbian)
+ * 1 - ends in 01: 1, 101, 201, ...
+ * 2 - ends in 02: 2, 102, 202, ...
+ * 3 - ends in 03-04: 3, 4, 103, 104, 203, 204, ...
+ * 4 - everything else: 0, 5, 6, 7, 8, 9, 10, 11, ...
+ */
+ return ($number % 100 === 1) ? 1 : (($number % 100 === 2) ? 2 : ((($number % 100 === 3) || ($number % 100 === 4)) ? 3 : 4));
+
+ case 11:
+ /**
+ * Families: Celtic (Irish Gaeilge)
+ * 1 - 1
+ * 2 - 2
+ * 3 - is 3-6: 3, 4, 5, 6
+ * 4 - is 7-10: 7, 8, 9, 10
+ * 5 - everything else: 0, 11, 12, ...
+ */
+ return ($number === 1) ? 1 : (($number === 2) ? 2 : (($number >= 3 && $number <= 6) ? 3 : (($number >= 7 && $number <= 10) ? 4 : 5)));
+
+ case 12:
+ /**
+ * Families: Semitic (Arabic)
+ * 1 - 1
+ * 2 - 2
+ * 3 - ends in 03-10: 3, 4, ... 10, 103, 104, ... 110, 203, 204, ...
+ * 4 - ends in 11-99: 11, ... 99, 111, 112, ...
+ * 5 - everything else: 100, 101, 102, 200, 201, 202, ...
+ * 6 - 0
+ */
+ return ($number === 1) ? 1 : (($number === 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : (($number != 0) ? 5 : 6))));
+
+ case 13:
+ /**
+ * Families: Semitic (Maltese)
+ * 1 - 1
+ * 2 - is 0 or ends in 01-10: 0, 2, 3, ... 9, 10, 101, 102, ...
+ * 3 - ends in 11-19: 11, 12, ... 18, 19, 111, 112, ...
+ * 4 - everything else: 20, 21, ...
+ */
+ return ($number === 1) ? 1 : ((($number === 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 2 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 3 : 4));
+
+ case 14:
+ /**
+ * Families: Slavic (Macedonian)
+ * 1 - ends in 1: 1, 11, 21, ...
+ * 2 - ends in 2: 2, 12, 22, ...
+ * 3 - everything else: 0, 3, 4, ... 10, 13, 14, ... 20, 23, ...
+ */
+ return ($number % 10 === 1) ? 1 : (($number % 10 === 2) ? 2 : 3);
+
+ case 15:
+ /**
+ * Families: Icelandic
+ * 1 - ends in 1, not 11: 1, 21, 31, ... 101, 121, 131, ...
+ * 2 - everything else: 0, 2, 3, ... 10, 11, 12, ... 20, 22, ...
+ */
+ return (($number % 10 === 1) && ($number % 100 != 11)) ? 1 : 2;
+ }
+ }
+
+ /**
+ * Returns language fallback data
+ *
+ * @return array
+ */
+ protected function set_fallback_array()
+ {
+ $fallback_array = array();
+
+ if ($this->user_language !== false)
+ {
+ $fallback_array[] = $this->user_language;
+ }
+
+ if ($this->default_language !== false)
+ {
+ $fallback_array[] = $this->default_language;
+ }
+
+ $fallback_array[] = self::FALLBACK_LANGUAGE;
+
+ $this->language_fallback = $fallback_array;
+ }
+
+ /**
+ * Load core language file
+ *
+ * @param string $component Name of the component to load
+ */
+ protected function load_core_file($component)
+ {
+ // Check if the component is already loaded
+ if (isset($this->loaded_language_sets['core'][$component]))
+ {
+ return;
+ }
+
+ $this->loader->load($component, $this->language_fallback, $this->lang);
+ $this->loaded_language_sets['core'][$component] = true;
+ }
+
+ /**
+ * Load extension language file
+ *
+ * @param string $extension_name Name of the extension to load language from
+ * @param string $component Name of the component to load
+ */
+ protected function load_extension($extension_name, $component)
+ {
+ // Check if the component is already loaded
+ if (isset($this->loaded_language_sets['ext'][$extension_name][$component]))
+ {
+ return;
+ }
+
+ $this->loader->load_extension($extension_name, $component, $this->language_fallback, $this->lang);
+ $this->loaded_language_sets['ext'][$extension_name][$component] = true;
+ }
+}
diff --git a/phpBB/phpbb/language/language_file_helper.php b/phpBB/phpbb/language/language_file_helper.php
new file mode 100644
index 0000000000..18d7b62e21
--- /dev/null
+++ b/phpBB/phpbb/language/language_file_helper.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\language;
+
+use Symfony\Component\Finder\Finder;
+
+/**
+ * Helper class for language file related functions
+ */
+class language_file_helper
+{
+ /**
+ * @var string Path to phpBB's root
+ */
+ protected $phpbb_root_path;
+
+ /**
+ * Constructor
+ *
+ * @param string $phpbb_root_path Path to phpBB's root
+ */
+ public function __construct($phpbb_root_path)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ }
+
+ /**
+ * Returns available languages
+ *
+ * @return array
+ */
+ public function get_available_languages()
+ {
+ // Find available language packages
+ $finder = new Finder();
+ $finder->files()
+ ->name('iso.txt')
+ ->depth('== 1')
+ ->in($this->phpbb_root_path . 'language');
+
+ $available_languages = array();
+ foreach ($finder as $file)
+ {
+ $path = $file->getRelativePath();
+ $info = explode("\n", $file->getContents());
+
+ $available_languages[] = array(
+ // Get the name of the directory containing iso.txt
+ 'iso' => $path,
+
+ // Recover data from file
+ 'name' => trim($info[0]),
+ 'local_name' => trim($info[1]),
+ 'author' => trim($info[2])
+ );
+ }
+
+ return $available_languages;
+ }
+}
diff --git a/phpBB/phpbb/language/language_file_loader.php b/phpBB/phpbb/language/language_file_loader.php
new file mode 100644
index 0000000000..510a29279a
--- /dev/null
+++ b/phpBB/phpbb/language/language_file_loader.php
@@ -0,0 +1,212 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\language;
+
+use \phpbb\language\exception\language_file_not_found;
+
+/**
+ * Language file loader
+ */
+class language_file_loader
+{
+ /**
+ * @var string Path to phpBB's root
+ */
+ protected $phpbb_root_path;
+
+ /**
+ * @var string Extension of PHP files
+ */
+ protected $php_ext;
+
+ /**
+ * @var \phpbb\extension\manager Extension manager
+ */
+ protected $extension_manager;
+
+ /**
+ * Constructor
+ *
+ * @param string $phpbb_root_path Path to phpBB's root
+ * @param string $php_ext Extension of PHP files
+ */
+ public function __construct($phpbb_root_path, $php_ext)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+
+ $this->extension_manager = null;
+ }
+
+ /**
+ * Extension manager setter
+ *
+ * @param \phpbb\extension\manager $extension_manager Extension manager
+ */
+ public function set_extension_manager(\phpbb\extension\manager $extension_manager)
+ {
+ $this->extension_manager = $extension_manager;
+ }
+
+ /**
+ * Loads language array for the given component
+ *
+ * @param string $component Name of the language component
+ * @param string|array $locale ISO code of the language to load, or array of ISO codes if you want to
+ * specify additional language fallback steps
+ * @param array $lang Array reference containing language strings
+ */
+ public function load($component, $locale, &$lang)
+ {
+ $locale = (array) $locale;
+
+ // Determine path to language directory
+ $path = $this->phpbb_root_path . 'language/';
+
+ $this->load_file($path, $component, $locale, $lang);
+ }
+
+ /**
+ * Loads language array for the given extension component
+ *
+ * @param string $extension Name of the extension
+ * @param string $component Name of the language component
+ * @param string|array $locale ISO code of the language to load, or array of ISO codes if you want to
+ * specify additional language fallback steps
+ * @param array $lang Array reference containing language strings
+ */
+ public function load_extension($extension, $component, $locale, &$lang)
+ {
+ // Check if extension manager was loaded
+ if ($this->extension_manager === null)
+ {
+ // If not, let's return
+ return;
+ }
+
+ $locale = (array) $locale;
+
+ // Determine path to language directory
+ $path = $this->extension_manager->get_extension_path($extension, true) . 'language/';
+
+ $this->load_file($path, $component, $locale, $lang);
+ }
+
+ /**
+ * Prepares language file loading
+ *
+ * @param string $path Path to search for file in
+ * @param string $component Name of the language component
+ * @param array $locale Array containing language fallback options
+ * @param array $lang Array reference of language strings
+ */
+ protected function load_file($path, $component, $locale, &$lang)
+ {
+ // This is BC stuff and not the best idea as it makes language fallback
+ // implementation quite hard like below.
+ if (strpos($this->phpbb_root_path . $component, $path) === 0)
+ {
+ // Filter out the path
+ $path_diff = str_replace($path, '', dirname($this->phpbb_root_path . $component));
+ $language_file = basename($component, '.' . $this->php_ext);
+ $component = '';
+
+ // This step is needed to resolve language/en/subdir style $component
+ // $path already points to the language base directory so we need to eliminate
+ // the first directory from the path (that should be the language directory)
+ $path_diff_parts = explode('/', $path_diff);
+
+ if (sizeof($path_diff_parts) > 1)
+ {
+ array_shift($path_diff_parts);
+ $component = implode('/', $path_diff_parts) . '/';
+ }
+
+ $component .= $language_file;
+ }
+
+ // Determine filename
+ $filename = $component . '.' . $this->php_ext;
+
+ // Determine path to file
+ $file_path = $this->get_language_file_path($path, $filename, $locale);
+
+ // Load language array
+ $this->load_language_file($file_path, $lang);
+ }
+
+ /**
+ * This function implements language fallback logic
+ *
+ * @param string $path Path to language directory
+ * @param string $filename Filename to load language strings from
+ *
+ * @return string Relative path to language file
+ *
+ * @throws \phpbb\language\exception\language_file_not_exists When the path to the file cannot be resolved
+ */
+ protected function get_language_file_path($path, $filename, $locales)
+ {
+ // Language fallback logic
+ foreach ($locales as $locale)
+ {
+ $language_file_path = $path . $locale . '/' . $filename;
+
+ // If we are in install, try to use the updated version, when available
+ if (defined('IN_INSTALL'))
+ {
+ $install_language_path = str_replace('language/', 'install/update/new/language/', $language_file_path);
+ if (file_exists($install_language_path))
+ {
+ return $install_language_path;
+ }
+ }
+
+ if (file_exists($language_file_path))
+ {
+ return $language_file_path;
+ }
+ }
+
+ // The language file is not exist
+ throw new language_file_not_found('Language file ' . $language_file_path . ' couldn\'t be opened.');
+ }
+
+ /**
+ * Loads language file
+ *
+ * @param string $path Path to language file to load
+ * @param array $lang Reference of the array of language strings
+ */
+ protected function load_language_file($path, &$lang)
+ {
+ // BC code for language files with help
+ $help = array();
+
+ // Do not suppress error if in DEBUG mode
+ if (defined('DEBUG'))
+ {
+ include $path;
+ }
+ else
+ {
+ @include $path;
+ }
+
+ if (!empty($help))
+ {
+ $lang['__help'] = array_merge($lang['__help'], $help);
+ }
+ }
+}
diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/dummy.php
index baa78895ea..5c2d145e15 100644
--- a/phpBB/phpbb/log/null.php
+++ b/phpBB/phpbb/log/dummy.php
@@ -14,9 +14,9 @@
namespace phpbb\log;
/**
-* Null logger
+* Dummy logger
*/
-class null implements log_interface
+class dummy implements log_interface
{
/**
* {@inheritdoc}
diff --git a/phpBB/phpbb/notification/exception.php b/phpBB/phpbb/notification/exception.php
index 83c4526df7..e416438061 100644
--- a/phpBB/phpbb/notification/exception.php
+++ b/phpBB/phpbb/notification/exception.php
@@ -17,10 +17,6 @@ namespace phpbb\notification;
* Notifications exception
*/
-class exception extends \Exception
+class exception extends \phpbb\exception\runtime_exception
{
- public function __toString()
- {
- return $this->getMessage();
- }
}
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index db92170dd8..38d7a13165 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -943,7 +943,7 @@ class manager
{
if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name]))
{
- throw new \phpbb\notification\exception($this->user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name));
+ throw new \phpbb\notification\exception('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name));
}
$sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array(
diff --git a/phpBB/phpbb/template/asset.php b/phpBB/phpbb/template/asset.php
index 4729685459..cb00f16549 100644
--- a/phpBB/phpbb/template/asset.php
+++ b/phpBB/phpbb/template/asset.php
@@ -20,15 +20,20 @@ class asset
/** @var \phpbb\path_helper **/
protected $path_helper;
+ /** @var \phpbb\filesystem\filesystem */
+ protected $filesystem;
+
/**
* Constructor
*
* @param string $url URL
* @param \phpbb\path_helper $path_helper Path helper object
+ * @param \phpbb\filesystem\filesystem $filesystem
*/
- public function __construct($url, \phpbb\path_helper $path_helper)
+ public function __construct($url, \phpbb\path_helper $path_helper, \phpbb\filesystem\filesystem $filesystem)
{
$this->path_helper = $path_helper;
+ $this->filesystem = $filesystem;
$this->set_url($url);
}
@@ -152,10 +157,22 @@ class asset
*/
public function set_path($path, $urlencode = false)
{
- // Since 1.7.0 Twig returns the real path of the file. We need it to be relative to the working directory.
- $real_root_path = realpath('.') . DIRECTORY_SEPARATOR;
- if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) {
- $path = str_replace('\\', '/', substr($path, strlen($real_root_path)));
+ // Since 1.7.0 Twig returns the real path of the file. We need it to be relative.
+ $real_root_path = $this->filesystem->realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR;
+
+ // If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path
+ if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path)
+ {
+ $path = $this->path_helper->get_phpbb_root_path() . str_replace('\\', '/', substr($path, strlen($real_root_path)));
+ }
+ else
+ {
+ // Else we make the path relative to the current working directory
+ $real_root_path = $this->filesystem->realpath('.') . DIRECTORY_SEPARATOR;
+ if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path)
+ {
+ $path = str_replace('\\', '/', substr($path, strlen($real_root_path)));
+ }
}
if ($urlencode)
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php
index 0ba7a265e4..e7b8aeab89 100644
--- a/phpBB/phpbb/template/twig/environment.php
+++ b/phpBB/phpbb/template/twig/environment.php
@@ -18,6 +18,9 @@ class environment extends \Twig_Environment
/** @var \phpbb\config\config */
protected $phpbb_config;
+ /** @var \phpbb\filesystem\filesystem */
+ protected $filesystem;
+
/** @var \phpbb\path_helper */
protected $phpbb_path_helper;
@@ -40,6 +43,7 @@ class environment extends \Twig_Environment
* Constructor
*
* @param \phpbb\config\config $phpbb_config The phpBB configuration
+ * @param \phpbb\filesystem\filesystem $filesystem
* @param \phpbb\path_helper $path_helper phpBB path helper
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container The dependency injection container
* @param string $cache_path The path to the cache directory
@@ -47,10 +51,11 @@ class environment extends \Twig_Environment
* @param \Twig_LoaderInterface $loader Twig loader interface
* @param array $options Array of options to pass to Twig
*/
- public function __construct($phpbb_config, \phpbb\path_helper $path_helper, \Symfony\Component\DependencyInjection\ContainerInterface $container, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array())
+ public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, \Symfony\Component\DependencyInjection\ContainerInterface $container, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array())
{
$this->phpbb_config = $phpbb_config;
+ $this->filesystem = $filesystem;
$this->phpbb_path_helper = $path_helper;
$this->extension_manager = $extension_manager;
$this->container = $container;
@@ -106,16 +111,26 @@ class environment extends \Twig_Environment
}
/**
- * Get the phpBB root path
- *
- * @return string
- */
+ * Get the phpBB root path
+ *
+ * @return string
+ */
public function get_phpbb_root_path()
{
return $this->phpbb_root_path;
}
/**
+ * Get the filesystem object
+ *
+ * @return \phpbb\filesystem\filesystem
+ */
+ public function get_filesystem()
+ {
+ return $this->filesystem;
+ }
+
+ /**
* Get the web root path
*
* @return string
diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php
index 14d1258c09..92f87a0331 100644
--- a/phpBB/phpbb/template/twig/extension.php
+++ b/phpBB/phpbb/template/twig/extension.php
@@ -18,20 +18,20 @@ class extension extends \Twig_Extension
/** @var \phpbb\template\context */
protected $context;
- /** @var \phpbb\user */
- protected $user;
+ /** @var \phpbb\language\language */
+ protected $language;
/**
* Constructor
*
* @param \phpbb\template\context $context
- * @param \phpbb\user $user
+ * @param \phpbb\language\language $language
* @return \phpbb\template\twig\extension
*/
- public function __construct(\phpbb\template\context $context, $user)
+ public function __construct(\phpbb\template\context $context, $language)
{
$this->context = $context;
- $this->user = $user;
+ $this->language = $language;
}
/**
@@ -181,6 +181,6 @@ class extension extends \Twig_Extension
// LA_ is transformed into lang(\'$1\')|escape('js'), so we should not
// need to check for it
- return call_user_func_array(array($this->user, 'lang'), $args);
+ return call_user_func_array(array($this->language, 'lang'), $args);
}
}
diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php
index 15195a226b..324823b8d7 100644
--- a/phpBB/phpbb/template/twig/node/includeasset.php
+++ b/phpBB/phpbb/template/twig/node/includeasset.php
@@ -39,7 +39,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_path_helper());\n")
+ ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper(), \$this->getEnvironment()->get_filesystem());\n")
->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
->indent()
->write("\$asset_path = \$asset->get_path();")
diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php
index 882e9cef26..c33070d6f4 100644
--- a/phpBB/phpbb/user.php
+++ b/phpBB/phpbb/user.php
@@ -21,8 +21,11 @@ namespace phpbb;
*/
class user extends \phpbb\session
{
- var $lang = array();
- var $help = array();
+ /**
+ * @var \phpbb\language\language
+ */
+ protected $language;
+
var $style = array();
var $date_format;
@@ -42,35 +45,63 @@ class user extends \phpbb\session
var $img_lang;
var $img_array = array();
+ /** @var bool */
+ protected $is_setup_flag;
+
// Able to add new options (up to id 31)
var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17);
/**
* Constructor to set the lang path
+ *
* @param string $datetime_class Class name of datetime class
+ * @param \phpbb\language\language $lang phpBB's Language loader
*/
- function __construct($datetime_class)
+ function __construct(\phpbb\language\language $lang, $datetime_class)
{
global $phpbb_root_path;
$this->lang_path = $phpbb_root_path . 'language/';
+ $this->language = $lang;
$this->datetime = $datetime_class;
+
+ $this->is_setup_flag = false;
}
/**
- * Function to set custom language path (able to use directory outside of phpBB)
- *
- * @param string $lang_path New language path used.
- * @access public
- */
- function set_custom_lang_path($lang_path)
+ * Returns whether user::setup was called
+ *
+ * @return bool
+ */
+ public function is_setup()
{
- $this->lang_path = $lang_path;
+ return $this->is_setup_flag;
+ }
- if (substr($this->lang_path, -1) != '/')
+ /**
+ * Magic getter for BC compatibility
+ *
+ * Implement array access for user::lang.
+ *
+ * @param string $param_name Name of the BC component the user want to access
+ *
+ * @return array The appropriate array
+ *
+ * @deprecated 3.2.0-dev (To be removed: 4.0.0)
+ */
+ public function __get($param_name)
+ {
+ if ($param_name === 'lang')
+ {
+ return $this->language->get_lang_array();
+ }
+ else if ($param_name === 'help')
{
- $this->lang_path .= '/';
+ $help_array = $this->language->get_lang_array();
+ return $help_array['__help'];
}
+
+ return array();
}
/**
@@ -81,6 +112,8 @@ class user extends \phpbb\session
global $db, $request, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
global $phpbb_dispatcher;
+ $this->language->set_default_language($config['default_lang']);
+
if ($this->data['user_id'] != ANONYMOUS)
{
$user_lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
@@ -98,6 +131,7 @@ class user extends \phpbb\session
{
$lang_override = $request->variable($config['cookie_name'] . '_lang', '', true, \phpbb\request\request_interface::COOKIE);
}
+
if ($lang_override)
{
$use_lang = basename($lang_override);
@@ -108,6 +142,7 @@ class user extends \phpbb\session
{
$user_lang_name = basename($config['default_lang']);
}
+
$user_date_format = $config['default_dateformat'];
$user_timezone = $config['board_timezone'];
@@ -187,6 +222,8 @@ class user extends \phpbb\session
$this->lang_name = $user_lang_name;
$this->date_format = $user_date_format;
+ $this->language->set_user_language($user_lang_name);
+
try
{
$this->timezone = new \DateTimeZone($user_timezone);
@@ -197,17 +234,6 @@ class user extends \phpbb\session
$this->timezone = new \DateTimeZone('UTC');
}
- // We include common language file here to not load it every time a custom language file is included
- $lang = &$this->lang;
-
- // Do not suppress error if in DEBUG mode
- $include_result = (defined('DEBUG')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx");
-
- if ($include_result === false)
- {
- die('Language file ' . $this->lang_path . $this->lang_name . "/common.$phpEx" . " couldn't be opened.");
- }
-
$this->add_lang($lang_set);
unset($lang_set);
@@ -393,6 +419,8 @@ class user extends \phpbb\session
}
}
+ $this->is_setup_flag = true;
+
return;
}
@@ -406,103 +434,13 @@ class user extends \phpbb\session
*
* If the first parameter is an array, the elements are used as keys and subkeys to get the language entry:
* Example: <samp>$user->lang(array('datetime', 'AGO'), 1)</samp> uses $user->lang['datetime']['AGO'] as language entry.
+ *
+ * @deprecated 3.2.0-dev (To be removed 4.0.0)
*/
function lang()
{
$args = func_get_args();
- $key = $args[0];
-
- if (is_array($key))
- {
- $lang = &$this->lang[array_shift($key)];
-
- foreach ($key as $_key)
- {
- $lang = &$lang[$_key];
- }
- }
- else
- {
- $lang = &$this->lang[$key];
- }
-
- // Return if language string does not exist
- if (!isset($lang) || (!is_string($lang) && !is_array($lang)))
- {
- return $key;
- }
-
- // If the language entry is a string, we simply mimic sprintf() behaviour
- if (is_string($lang))
- {
- if (sizeof($args) == 1)
- {
- return $lang;
- }
-
- // Replace key with language entry and simply pass along...
- $args[0] = $lang;
- return call_user_func_array('sprintf', $args);
- }
- else if (sizeof($lang) == 0)
- {
- // If the language entry is an empty array, we just return the language key
- return $args[0];
- }
-
- // It is an array... now handle different nullar/singular/plural forms
- $key_found = false;
-
- // We now get the first number passed and will select the key based upon this number
- for ($i = 1, $num_args = sizeof($args); $i < $num_args; $i++)
- {
- if (is_int($args[$i]) || is_float($args[$i]))
- {
- if ($args[$i] == 0 && isset($lang[0]))
- {
- // We allow each translation using plural forms to specify a version for the case of 0 things,
- // so that "0 users" may be displayed as "No users".
- $key_found = 0;
- break;
- }
- else
- {
- $use_plural_form = $this->get_plural_form($args[$i]);
- if (isset($lang[$use_plural_form]))
- {
- // The key we should use exists, so we use it.
- $key_found = $use_plural_form;
- }
- else
- {
- // If the key we need to use does not exist, we fall back to the previous one.
- $numbers = array_keys($lang);
-
- foreach ($numbers as $num)
- {
- if ($num > $use_plural_form)
- {
- break;
- }
-
- $key_found = $num;
- }
- }
- break;
- }
- }
- }
-
- // Ok, let's check if the key was found, else use the last entry (because it is mostly the plural form)
- if ($key_found === false)
- {
- $numbers = array_keys($lang);
- $key_found = end($numbers);
- }
-
- // Use the language string we determined and pass it to sprintf()
- $args[0] = $lang[$key_found];
- return call_user_func_array('sprintf', $args);
+ return call_user_func_array(array($this->language, 'lang'), $args);
}
/**
@@ -512,24 +450,22 @@ class user extends \phpbb\session
* @param $number int|float The number we want to get the plural case for. Float numbers are floored.
* @param $force_rule mixed False to use the plural rule of the language package
* or an integer to force a certain plural rule
- * @return int The plural-case we need to use for the number plural-rule combination
+ * @return int|bool The plural-case we need to use for the number plural-rule combination, false if $force_rule
+ * was invalid.
+ *
+ * @deprecated: 3.2.0-dev (To be removed: 3.3.0)
*/
function get_plural_form($number, $force_rule = false)
{
- $number = (int) $number;
-
- // Default to English system
- $plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1);
-
- return phpbb_get_plural_form($plural_rule, $number);
+ return $this->language->get_plural_form($number, $force_rule);
}
/**
* Add Language Items - use_db and use_help are assigned where needed (only use them to force inclusion)
*
* @param mixed $lang_set specifies the language entries to include
- * @param bool $use_db internal variable for recursion, do not use
- * @param bool $use_help internal variable for recursion, do not use
+ * @param bool $use_db internal variable for recursion, do not use @deprecated 3.2.0-dev (To be removed: 3.3.0)
+ * @param bool $use_help internal variable for recursion, do not use @deprecated 3.2.0-dev (To be removed: 3.3.0)
* @param string $ext_name The extension to load language from, or empty for core files
*
* Examples:
@@ -540,11 +476,14 @@ class user extends \phpbb\session
* $lang_set = 'posting'
* $lang_set = array('help' => 'faq', 'db' => array('help:faq', 'posting'))
* </code>
+ *
+ * Note: $use_db and $use_help should be removed. The old function was kept for BC purposes,
+ * so the BC logic is handled here.
+ *
+ * @deprecated: 3.2.0-dev (To be removed: 3.3.0)
*/
function add_lang($lang_set, $use_db = false, $use_help = false, $ext_name = '')
{
- global $phpEx;
-
if (is_array($lang_set))
{
foreach ($lang_set as $key => $lang_file)
@@ -555,6 +494,7 @@ class user extends \phpbb\session
if ($key == 'db')
{
+ // This is never used
$this->add_lang($lang_file, true, $use_help, $ext_name);
}
else if ($key == 'help')
@@ -563,7 +503,7 @@ class user extends \phpbb\session
}
else if (!is_array($lang_file))
{
- $this->set_lang($this->lang, $this->help, $lang_file, $use_db, $use_help, $ext_name);
+ $this->set_lang($lang_file, $use_help, $ext_name);
}
else
{
@@ -574,8 +514,37 @@ class user extends \phpbb\session
}
else if ($lang_set)
{
- $this->set_lang($this->lang, $this->help, $lang_set, $use_db, $use_help, $ext_name);
+ $this->set_lang($lang_set, $use_help, $ext_name);
+ }
+ }
+
+ /**
+ * BC function for loading language files
+ *
+ * @deprecated 3.2.0-dev (To be removed: 3.3.0)
+ */
+ private function set_lang($lang_set, $use_help, $ext_name)
+ {
+ if (empty($ext_name))
+ {
+ $ext_name = null;
+ }
+
+ if ($use_help && strpos($lang_set, '/') !== false)
+ {
+ $component = dirname($lang_set) . '/help_' . basename($lang_set);
+
+ if ($component[0] === '/')
+ {
+ $component = substr($component, 1);
+ }
+ }
+ else
+ {
+ $component = (($use_help) ? 'help_' : '') . $lang_set;
}
+
+ $this->language->add_lang($component, $ext_name);
}
/**
@@ -585,6 +554,10 @@ class user extends \phpbb\session
* @param mixed $lang_set specifies the language entries to include
* @param bool $use_db internal variable for recursion, do not use
* @param bool $use_help internal variable for recursion, do not use
+ *
+ * Note: $use_db and $use_help should be removed. Kept for BC purposes.
+ *
+ * @deprecated: 3.2.0-dev (To be removed: 3.3.0)
*/
function add_lang_ext($ext_name, $lang_set, $use_db = false, $use_help = false)
{
@@ -597,109 +570,6 @@ class user extends \phpbb\session
}
/**
- * Set language entry (called by add_lang)
- * @access private
- */
- function set_lang(&$lang, &$help, $lang_file, $use_db = false, $use_help = false, $ext_name = '')
- {
- global $phpbb_root_path, $phpEx;
-
- // Make sure the language name is set (if the user setup did not happen it is not set)
- if (!$this->lang_name)
- {
- global $config;
- $this->lang_name = basename($config['default_lang']);
- }
-
- // $lang == $this->lang
- // $help == $this->help
- // - add appropriate variables here, name them as they are used within the language file...
- if (!$use_db)
- {
- if ($use_help && strpos($lang_file, '/') !== false)
- {
- $filename = dirname($lang_file) . '/help_' . basename($lang_file);
- }
- else
- {
- $filename = (($use_help) ? 'help_' : '') . $lang_file;
- }
-
- if ($ext_name)
- {
- global $phpbb_extension_manager;
- $ext_path = $phpbb_extension_manager->get_extension_path($ext_name, true);
-
- $lang_path = $ext_path . 'language/';
- }
- else
- {
- $lang_path = $this->lang_path;
- }
-
- if (strpos($phpbb_root_path . $filename, $lang_path . $this->lang_name . '/') === 0)
- {
- $language_filename = $phpbb_root_path . $filename;
- }
- else
- {
- $language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx;
- }
-
- // If we are in install, try to use the updated version, when available
- $install_language_filename = str_replace('language/', 'install/update/new/language/', $language_filename);
- if (defined('IN_INSTALL') && file_exists($install_language_filename))
- {
- $language_filename = $install_language_filename;
- }
-
- if (!file_exists($language_filename))
- {
- global $config;
-
- if ($this->lang_name == 'en')
- {
- // The user's selected language is missing the file, the board default's language is missing the file, and the file doesn't exist in /en.
- $language_filename = str_replace($lang_path . 'en', $lang_path . $this->data['user_lang'], $language_filename);
- trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR);
- }
- else if ($this->lang_name == basename($config['default_lang']))
- {
- // Fall back to the English Language
- $reset_lang_name = $this->lang_name;
- $this->lang_name = 'en';
- $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name);
- $this->lang_name = $reset_lang_name;
- }
- else if ($this->lang_name == $this->data['user_lang'])
- {
- // Fall back to the board default language
- $reset_lang_name = $this->lang_name;
- $this->lang_name = basename($config['default_lang']);
- $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name);
- $this->lang_name = $reset_lang_name;
- }
-
- return;
- }
-
- // Do not suppress error if in DEBUG mode
- $include_result = (defined('DEBUG')) ? (include $language_filename) : (@include $language_filename);
-
- if ($include_result === false)
- {
- trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR);
- }
- }
- else if ($use_db)
- {
- // Get Database Language Strings
- // Put them into $lang if nothing is prefixed, put them into $help if help: is prefixed
- // For example: help:faq, posting
- }
- }
-
- /**
* Format user date
*
* @param int $gmepoch unix timestamp
@@ -808,7 +678,7 @@ class user extends \phpbb\session
if ($alt)
{
- $alt = $this->lang($alt);
+ $alt = $this->language->lang($alt);
$title = ' title="' . $alt . '"';
}
return '<span class="imageset ' . $img . '"' . $title . '>' . $alt . '</span>';
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 7b225ef3db..faf5768edf 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -806,6 +806,36 @@ if (!empty($topic_data['poll_start']))
($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;
+ /**
+ * Event to manipulate the poll data
+ *
+ * @event core.viewtopic_modify_poll_data
+ * @var array cur_voted_id Array with options' IDs current user has voted for
+ * @var int forum_id The topic's forum id
+ * @var array poll_info Array with the poll information
+ * @var bool s_can_vote Flag indicating if a user can vote
+ * @var bool s_display_results Flag indicating if results or poll options should be displayed
+ * @var int topic_id The id of the topic the user tries to access
+ * @var array topic_data All the information from the topic and forum tables for this topic
+ * @var string viewtopic_url URL to the topic page
+ * @var array vote_counts Array with the vote counts for every poll option
+ * @var array voted_id Array with updated options' IDs current user is voting for
+ * @since 3.1.5-RC1
+ */
+ $vars = array(
+ 'cur_voted_id',
+ 'forum_id',
+ 'poll_info',
+ 's_can_vote',
+ 's_display_results',
+ 'topic_id',
+ 'topic_data',
+ 'viewtopic_url',
+ 'vote_counts',
+ 'voted_id',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_data', compact($vars)));
+
if ($update && $s_can_vote)
{
@@ -939,6 +969,7 @@ if (!empty($topic_data['poll_start']))
$topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_flags, true);
+ $poll_template_data = $poll_options_template_data = array();
foreach ($poll_info as $poll_option)
{
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
@@ -947,7 +978,7 @@ if (!empty($topic_data['poll_start']))
$option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100));
$option_most_votes = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false;
- $template->assign_block_vars('poll_option', array(
+ $poll_options_template_data[] = array(
'POLL_OPTION_ID' => $poll_option['poll_option_id'],
'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
@@ -957,12 +988,12 @@ if (!empty($topic_data['poll_start']))
'POLL_OPTION_WIDTH' => round($option_pct * 250),
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false,
'POLL_OPTION_MOST_VOTES' => $option_most_votes,
- ));
+ );
}
$poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
- $template->assign_vars(array(
+ $poll_template_data = array(
'POLL_QUESTION' => $topic_data['poll_title'],
'TOTAL_VOTES' => $poll_total,
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
@@ -978,9 +1009,45 @@ if (!empty($topic_data['poll_start']))
'S_POLL_ACTION' => $viewtopic_url,
'U_VIEW_RESULTS' => $viewtopic_url . '&amp;view=viewpoll',
- ));
+ );
+
+ /**
+ * Event to add/modify poll template data
+ *
+ * @event core.viewtopic_modify_poll_template_data
+ * @var array cur_voted_id Array with options' IDs current user has voted for
+ * @var int poll_end The poll end time
+ * @var array poll_info Array with the poll information
+ * @var array poll_options_template_data Array with the poll options template data
+ * @var array poll_template_data Array with the common poll template data
+ * @var int poll_total Total poll votes count
+ * @var int poll_most Mostly voted option votes count
+ * @var array topic_data All the information from the topic and forum tables for this topic
+ * @var string viewtopic_url URL to the topic page
+ * @var array vote_counts Array with the vote counts for every poll option
+ * @var array voted_id Array with updated options' IDs current user is voting for
+ * @since 3.1.5-RC1
+ */
+ $vars = array(
+ 'cur_voted_id',
+ 'poll_end',
+ 'poll_info',
+ 'poll_options_template_data',
+ 'poll_template_data',
+ 'poll_total',
+ 'poll_most',
+ 'topic_data',
+ 'viewtopic_url',
+ 'vote_counts',
+ 'voted_id',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_poll_template_data', compact($vars)));
+
+ $template->assign_block_vars_array('poll_option', $poll_options_template_data);
+
+ $template->assign_vars($poll_template_data);
- unset($poll_end, $poll_info, $voted_id);
+ unset($poll_end, $poll_info, $poll_options_template_data, $poll_template_data, $voted_id);
}
// If the user is trying to reach the second half of the topic, fetch it starting from the end
diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index 68ad7b2c19..60423acbc1 100644
--- a/tests/auth/provider_apache_test.php
+++ b/tests/auth/provider_apache_test.php
@@ -28,8 +28,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
$db = $this->new_dbal();
$config = new \phpbb\config\config(array());
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
$this->request = $this->getMock('\phpbb\request\request');
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');
$driver_helper = new \phpbb\passwords\driver\helper($config);
$passwords_drivers = array(
'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper),
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php
index 09ca0816bf..38dbfa1fcb 100644
--- a/tests/auth/provider_db_test.php
+++ b/tests/auth/provider_db_test.php
@@ -38,8 +38,10 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
'ip_login_limit_use_forwarded' => 0,
'max_login_attempts' => 0,
));
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
$request = $this->getMock('\phpbb\request\request');
- $user = new \phpbb\user('\phpbb\datetime');
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$driver_helper = new \phpbb\passwords\driver\helper($config);
$passwords_drivers = array(
'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper),
diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php
index 71b49ff439..78b936ee8e 100644
--- a/tests/auth/provider_oauth_token_storage_test.php
+++ b/tests/auth/provider_oauth_token_storage_test.php
@@ -31,7 +31,9 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
global $phpbb_root_path, $phpEx;
$this->db = $this->new_dbal();
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');
$this->service_name = 'auth.provider.oauth.service.testing';
$this->token_storage_table = 'phpbb_oauth_tokens';
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index 638ba0aaff..71f40c0b13 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -94,7 +94,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
// Set up avatar manager
$this->manager = new \phpbb\avatar\manager($this->config, $avatar_drivers, $phpbb_container);
$this->db = $this->new_dbal();
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');
}
protected function avatar_drivers()
@@ -277,7 +279,12 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
public function test_localize_errors()
{
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ global $phpbb_root_path, $phpEx;
+
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime')
+ );
$lang_array = array(
array('FOOBAR_OFF', 'foobar_off'),
array('FOOBAR_EXPLAIN', 'FOOBAR_EXPLAIN %s'),
diff --git a/tests/cache/null_driver_test.php b/tests/cache/dummy_driver_test.php
index b9f96732f5..6cb6b73729 100644
--- a/tests/cache/null_driver_test.php
+++ b/tests/cache/dummy_driver_test.php
@@ -11,7 +11,7 @@
*
*/
-class phpbb_cache_null_driver_test extends phpbb_database_test_case
+class phpbb_cache_dummy_driver_test extends phpbb_database_test_case
{
protected $driver;
@@ -24,7 +24,7 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case
{
parent::setUp();
- $this->driver = new \phpbb\cache\driver\null;
+ $this->driver = new \phpbb\cache\driver\dummy;
}
public function test_get_put()
diff --git a/tests/console/cache/purge_test.php b/tests/console/cache/purge_test.php
index 96988c1028..6c92660580 100644
--- a/tests/console/cache/purge_test.php
+++ b/tests/console/cache/purge_test.php
@@ -32,6 +32,8 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
protected function setUp()
{
+ global $phpbb_root_path, $phpEx;
+
if (file_exists($this->cache_dir))
{
// cache directory possibly left after aborted
@@ -45,7 +47,10 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
$this->db = $this->getMock('\phpbb\db\driver\driver_interface');
$this->config = new \phpbb\config\config(array('assets_version' => 1));
- $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $this->user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime')
+ );
}
public function test_purge()
@@ -86,7 +91,7 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
public function get_command_tester()
{
$application = new Application();
- $application->add(new purge($this->user, $this->cache, $this->db, $this->getMock('\phpbb\auth\auth'), new \phpbb\log\null(), $this->config));
+ $application->add(new purge($this->user, $this->cache, $this->db, $this->getMock('\phpbb\auth\auth'), new \phpbb\log\dummy(), $this->config));
$command = $application->find('cache:purge');
$this->command_name = $command->getName();
diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php
index 7c098af004..076316217d 100644
--- a/tests/console/config/config_test.php
+++ b/tests/console/config/config_test.php
@@ -22,9 +22,14 @@ class phpbb_console_command_config_test extends phpbb_test_case
public function setUp()
{
+ global $phpbb_root_path, $phpEx;
+
$this->config = new \phpbb\config\config(array());
- $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $this->user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime')
+ );
$this->user->method('lang')->will($this->returnArgument(0));
}
diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php
index 22423304be..3bbe2078ba 100644
--- a/tests/console/cron/cron_list_test.php
+++ b/tests/console/cron/cron_list_test.php
@@ -32,7 +32,12 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
protected function setUp()
{
- $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ global $phpbb_root_path, $phpEx;
+
+ $this->user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$this->user->method('lang')->will($this->returnArgument(0));
}
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php
index 8638648898..51ea49b282 100644
--- a/tests/console/cron/run_test.php
+++ b/tests/console/cron/run_test.php
@@ -41,7 +41,10 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$config = $this->config = new \phpbb\config\config(array('cron_lock' => '0'));
$this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db);
- $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $this->user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$this->user->method('lang')->will($this->returnArgument(0));
$this->task = new phpbb_cron_task_simple();
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index dc966c37ae..b59b6493d4 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -309,7 +309,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
->will($this->returnValueMap(array(
array('m_approve', 1, true),
)));
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php
index 28e463ecb5..6c5066119e 100644
--- a/tests/content_visibility/get_forums_visibility_sql_test.php
+++ b/tests/content_visibility/get_forums_visibility_sql_test.php
@@ -134,7 +134,9 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data
->method('acl_getf')
->with($this->stringContains('_'), $this->anything())
->will($this->returnValueMap($permissions));
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$config = new phpbb\config\config(array());
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php
index 586bae8668..9ae4182673 100644
--- a/tests/content_visibility/get_global_visibility_sql_test.php
+++ b/tests/content_visibility/get_global_visibility_sql_test.php
@@ -134,7 +134,9 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data
->method('acl_getf')
->with($this->stringContains('_'), $this->anything())
->will($this->returnValueMap($permissions));
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$config = new phpbb\config\config(array());
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php
index 9ae2d2fdc4..aaaf64330e 100644
--- a/tests/content_visibility/get_visibility_sql_test.php
+++ b/tests/content_visibility/get_visibility_sql_test.php
@@ -81,7 +81,9 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
->method('acl_get')
->with($this->stringContains('_'), $this->anything())
->will($this->returnValueMap($permissions));
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$config = new phpbb\config\config(array());
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php
index 36ebf58374..6375ce8f6d 100644
--- a/tests/content_visibility/set_post_visibility_test.php
+++ b/tests/content_visibility/set_post_visibility_test.php
@@ -124,7 +124,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$auth = $this->getMock('\phpbb\auth\auth');
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$config = new phpbb\config\config(array());
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
@@ -175,7 +177,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$auth = $this->getMock('\phpbb\auth\auth');
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$config = new phpbb\config\config(array());
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php
index 6c34f42167..f4d65f9ce3 100644
--- a/tests/content_visibility/set_topic_visibility_test.php
+++ b/tests/content_visibility/set_topic_visibility_test.php
@@ -88,7 +88,9 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$auth = $this->getMock('\phpbb\auth\auth');
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$config = new phpbb\config\config(array());
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index f1f369cce6..b01241e105 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -84,7 +84,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
);
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');;
$container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig';
@@ -92,6 +94,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$loader = new \phpbb\template\twig\loader($this->filesystem, '');
$twig = new \phpbb\template\twig\environment(
$this->config,
+ $this->filesystem,
$this->phpbb_path_helper,
$container,
$cache_path,
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index a837e25f66..5c0290ee6f 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -82,7 +82,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
include(__DIR__.'/phpbb/controller/foo.php');
}
- $resolver = new \phpbb\controller\resolver(new \phpbb\user('\phpbb\datetime'), $container, dirname(__FILE__) . '/');
+ $resolver = new \phpbb\controller\resolver($container, dirname(__FILE__) . '/');
$symfony_request = new Request();
$symfony_request->attributes->set('_controller', 'foo.controller:handle');
diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php
index 8968619bb5..7ecb546768 100644
--- a/tests/datetime/from_format_test.php
+++ b/tests/datetime/from_format_test.php
@@ -37,7 +37,11 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
*/
public function test_from_format($timezone, $format, $expected)
{
- $user = new \phpbb\user('\phpbb\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->timezone = new DateTimeZone($timezone);
$user->lang['datetime'] = array(
'TODAY' => 'Today',
@@ -107,7 +111,11 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
*/
public function test_relative_format_date($timestamp, $forcedate, $expected)
{
- $user = new \phpbb\user('\phpbb\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->timezone = new DateTimeZone('UTC');
$user->lang['datetime'] = array(
'TODAY' => 'Today',
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index d550ca55a2..f52e6ea63d 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -63,14 +63,12 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
);
$container->set('migrator', $this->migrator);
$container->set('dispatcher', new phpbb_mock_event_dispatcher());
- $user = new \phpbb\user('\phpbb\datetime');
$this->extension_manager = new \phpbb\extension\manager(
$container,
$this->db,
$this->config,
new phpbb\filesystem\filesystem(),
- $user,
'phpbb_ext',
dirname(__FILE__) . '/../../phpBB/',
'php',
diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php
index fa2a8c33df..695a7e7a7f 100644
--- a/tests/dbal/migrator_tool_module_test.php
+++ b/tests/dbal/migrator_tool_module_test.php
@@ -31,8 +31,10 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$skip_add_log = true;
$db = $this->db = $this->new_dbal();
- $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx);
- $user = $this->user = new \phpbb\user('\phpbb\user');
+ $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx);
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = $this->user = new \phpbb\user($lang, '\phpbb\datetime');
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php
index 4453fbf123..3d190e7a11 100644
--- a/tests/dbal/migrator_tool_permission_test.php
+++ b/tests/dbal/migrator_tool_permission_test.php
@@ -28,7 +28,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
parent::setup();
$db = $this->db = $this->new_dbal();
- $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx);
+ $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx);
$this->auth = new \phpbb\auth\auth();
$this->tool = new \phpbb\db\migration\tool\permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx);
diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php
index 4d3453cd83..608cde4f9b 100644
--- a/tests/event/exception_listener_test.php
+++ b/tests/event/exception_listener_test.php
@@ -79,7 +79,11 @@ class exception_listener extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
- $user = new \phpbb\user('\phpbb\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->add_lang('common');
$exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $user);
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index b76203b32a..a24b0cf178 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -155,7 +155,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$phpbb_root_path = __DIR__ . './../../phpBB/';
$php_ext = 'php';
$table_prefix = 'phpbb_';
- $user = new \phpbb\user('\phpbb\user');
$container = new phpbb_mock_container_builder();
@@ -178,7 +177,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$db,
$config,
new \phpbb\filesystem\filesystem(),
- $user,
'phpbb_ext',
dirname(__FILE__) . '/',
$php_ext,
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index db573ae0c3..aaaee3b2e5 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -45,24 +45,25 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->db_tools = $factory->get($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/';
$this->phpEx = 'php';
- $this->user = new \phpbb\user('\phpbb\datetime');
$this->table_prefix = 'phpbb_';
$container = new phpbb_mock_container_builder();
$cache_path = $this->phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
- $phpbb_path_helper =new \phpbb\path_helper(
+ $filesystem = new \phpbb\filesystem\filesystem();
+ $phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem\filesystem(),
+ $filesystem,
$this->getMock('\phpbb\request\request'),
$this->phpbb_root_path,
$this->phpEx
);
$twig = new \phpbb\template\twig\environment(
$this->config,
+ $filesystem,
$phpbb_path_helper,
$container,
$cache_path,
@@ -75,8 +76,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
- $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$container = new phpbb_mock_container_builder();
@@ -99,12 +98,21 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->db,
$this->config,
new \phpbb\filesystem\filesystem(),
- $this->user,
'phpbb_ext',
$this->phpbb_root_path,
$this->phpEx,
$this->cache
);
+
+ global $phpbb_root_path;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $this->phpEx);
+ $lang_loader->set_extension_manager($this->extension_manager);
+ $lang = new \phpbb\language\language($lang_loader);
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');
+
+ $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
}
// Should fail from missing composer.json
@@ -120,7 +128,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
catch (\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $this->assertEquals($message, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
}
}
@@ -137,7 +146,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
catch (\phpbb\extension\exception $e)
{
- $this->fail($e);
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $this->fail($message);
}
$json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/vendor2/foo/composer.json'), true);
@@ -167,9 +177,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$manager->validate($field_name);
$this->fail('Exception not triggered');
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', $field_name));
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', $field_name));
}
}
@@ -183,7 +194,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
catch (\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'authors'));
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', 'authors'));
}
$manager->merge_metadata(array(
@@ -199,7 +211,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
catch (\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'author name'));
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $this->assertEquals($message, $this->user->lang('META_FIELD_NOT_SET', 'author name'));
}
}
@@ -230,9 +243,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$manager->validate($field_name);
$this->fail('Exception not triggered');
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', $field_name));
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $this->assertEquals($message, $this->user->lang('META_FIELD_INVALID', $field_name));
}
}
@@ -254,9 +268,9 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
$this->assertEquals(true, $manager->validate('enable'));
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
- $this->fail($e);
+ $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
}
}
@@ -352,7 +366,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->config,
$this->extension_manager,
$this->template,
- $this->user,
$this->phpbb_root_path
);
}
diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php
index cd1e37618a..bcf0c09fe4 100644
--- a/tests/functions/generate_string_list.php
+++ b/tests/functions/generate_string_list.php
@@ -22,7 +22,12 @@ class phpbb_generate_string_list_test extends phpbb_test_case
{
parent::setUp();
- $this->user = new \phpbb\user('\phpbb\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
+ $this->user = $user;
$this->user->data = array('user_lang' => 'en');
$this->user->add_lang('common');
}
@@ -36,7 +41,7 @@ class phpbb_generate_string_list_test extends phpbb_test_case
),
array(
array('A'),
- 'A',
+ 'A',
),
array(
array(2 => 'A', 3 => 'B'),
diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php
index 99a15b32bf..6ccada44f8 100644
--- a/tests/functions_user/group_user_attributes_test.php
+++ b/tests/functions_user/group_user_attributes_test.php
@@ -139,7 +139,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
$auth = $this->getMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_clear_prefetch');
- $cache_driver = new \phpbb\cache\driver\null();
+ $cache_driver = new \phpbb\cache\driver\dummy();
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container
->expects($this->any())
diff --git a/tests/groupposition/legend_test.php b/tests/groupposition/legend_test.php
index fe003e93a7..566a8a2935 100644
--- a/tests/groupposition/legend_test.php
+++ b/tests/groupposition/legend_test.php
@@ -33,11 +33,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/
public function test_get_group_value($group_id, $expected, $throws_exception)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
if ($throws_exception)
@@ -51,11 +53,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
public function test_get_group_count()
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -91,11 +95,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/
public function test_add_group($group_id, $expected_added, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -179,11 +185,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/
public function test_delete_group($group_id, $skip_group, $expected_deleted, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -234,11 +242,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/
public function test_move_up($group_id, $excepted_moved, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -289,11 +299,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/
public function test_move_down($group_id, $excepted_moved, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -387,11 +399,13 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/
public function test_move($group_id, $increment, $excepted_moved, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
diff --git a/tests/groupposition/teampage_test.php b/tests/groupposition/teampage_test.php
index 1e61e3ebfb..dff52f7a43 100644
--- a/tests/groupposition/teampage_test.php
+++ b/tests/groupposition/teampage_test.php
@@ -35,11 +35,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_get_group_value($group_id, $expected, $throws_exception)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
if ($throws_exception)
@@ -53,11 +55,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
public function test_get_group_count()
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -137,11 +141,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_add_group_teampage($group_id, $parent_id, $expected_added, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -180,11 +186,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_add_category_teampage($group_name, $expected_added, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -247,11 +255,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_delete_group($group_id, $expected_deleted, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -299,11 +309,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_delete_teampage($teampage_id, $expected_deleted, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -462,11 +474,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_move($group_id, $move_delta, $excepted_moved, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -625,11 +639,13 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_move_teampage($teampage_id, $move_delta, $excepted_moved, $expected)
{
- global $cache;
+ global $cache, $phpbb_root_path, $phpEx;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
diff --git a/tests/language/language_test.php b/tests/language/language_test.php
new file mode 100644
index 0000000000..95de403bd4
--- /dev/null
+++ b/tests/language/language_test.php
@@ -0,0 +1,210 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+class phpbb_language_test extends phpbb_test_case
+{
+ /** @var \phpbb\language\language */
+ protected $lang;
+
+ public function setUp()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ // Set up language service
+ $this->lang = new \phpbb\language\language(
+ new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
+ );
+
+ // Set up language data for testing
+ $reflection_class = new ReflectionClass('\phpbb\language\language');
+
+ // Set default language files loaded flag to true
+ $loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
+ $loaded_flag->setAccessible(true);
+ $loaded_flag->setValue($this->lang, true);
+
+ // Set up test language data
+ $lang_array = $reflection_class->getProperty('lang');
+ $lang_array->setAccessible(true);
+ $lang_array->setValue($this->lang, $this->get_test_data_set());
+ }
+
+ public function test_lang()
+ {
+ // No param
+ $this->assertEquals($this->lang->lang('FOO'), 'BAR');
+ $this->assertEquals($this->lang->lang('EMPTY'), '');
+ $this->assertEquals($this->lang->lang('ZERO'), '0');
+
+ // Invalid index
+ $this->assertEquals($this->lang->lang('VOID'), 'VOID');
+
+ // Unnecessary param
+ $this->assertEquals($this->lang->lang('FOO', 2), 'BAR');
+ $this->assertEquals($this->lang->lang('FOO', 2, 3), 'BAR');
+ $this->assertEquals($this->lang->lang('FOO', 2, 3, 'BARZ'), 'BAR');
+
+ // String
+ $this->assertEquals($this->lang->lang('STR', 24, 'x', 42), '24 x, 42 topics');
+ $this->assertEquals($this->lang->lang('STR2', 64), '64 foos');
+
+ // Array
+ $this->assertEquals($this->lang->lang('ARRY', 0), 'No posts');
+ $this->assertEquals($this->lang->lang('ARRY', 1), '1 post');
+ $this->assertEquals($this->lang->lang('ARRY', 2), '2 posts');
+ $this->assertEquals($this->lang->lang('ARRY', 123), '123 posts');
+
+ // Empty array returns the language key
+ $this->assertEquals($this->lang->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY');
+
+ // No 0 key defined
+ $this->assertEquals($this->lang->lang('ARRY_NO_ZERO', 0), '0 posts');
+ $this->assertEquals($this->lang->lang('ARRY_NO_ZERO', 1), '1 post');
+ $this->assertEquals($this->lang->lang('ARRY_NO_ZERO', 2), '2 posts');
+
+ // Array with missing keys
+ $this->assertEquals($this->lang->lang('ARRY_MISSING', 2), '2 post');
+
+ // Floats as array key
+ $this->assertEquals($this->lang->lang('ARRY_FLOAT', 1.3), '1 post');
+ $this->assertEquals($this->lang->lang('ARRY_FLOAT', 2.0), '2.0 posts');
+ $this->assertEquals($this->lang->lang('ARRY_FLOAT', 2.51), '2.5 posts');
+
+ // Use sub key, if first paramenter is an array
+ $this->assertEquals($this->lang->lang(array('dateformat', 'AGO'), 2), '2 seconds');
+
+ // ticket PHPBB3-9949 - use first int to determinate the plural-form to use
+ $this->assertEquals($this->lang->lang('ARRY', 1, 2), '1 post');
+ $this->assertEquals($this->lang->lang('ARRY', 1, 's', 2), '1 post');
+ }
+
+ public function test_lang_plural_rules()
+ {
+ $this->assertEquals($this->lang->lang('PLURAL_ARRY', 0), '0 is 0');
+ $this->assertEquals($this->lang->lang('PLURAL_ARRY', 1), '1 is 1');
+ $this->assertEquals($this->lang->lang('PLURAL_ARRY', 103), '103 ends with 01-10');
+ $this->assertEquals($this->lang->lang('PLURAL_ARRY', 15), '15 ends with 11-19');
+ $this->assertEquals($this->lang->lang('PLURAL_ARRY', 300), '300 is part of the last rule');
+ }
+
+ public function test_lang_bc()
+ {
+ $user = new \phpbb\user($this->lang, '\phpbb\datetime');
+
+ // Test lang array access
+ $this->assertEquals($user->lang['FOO'], 'BAR');
+
+ // No param
+ $this->assertEquals($user->lang('FOO'), 'BAR');
+ $this->assertEquals($user->lang('EMPTY'), '');
+ $this->assertEquals($user->lang('ZERO'), '0');
+
+ // Invalid index
+ $this->assertEquals($user->lang('VOID'), 'VOID');
+
+ // Unnecessary param
+ $this->assertEquals($user->lang('FOO', 2), 'BAR');
+ $this->assertEquals($user->lang('FOO', 2, 3), 'BAR');
+ $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR');
+
+ // String
+ $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics');
+ $this->assertEquals($user->lang('STR2', 64), '64 foos');
+
+ // Array
+ $this->assertEquals($user->lang('ARRY', 0), 'No posts');
+ $this->assertEquals($user->lang('ARRY', 1), '1 post');
+ $this->assertEquals($user->lang('ARRY', 2), '2 posts');
+ $this->assertEquals($user->lang('ARRY', 123), '123 posts');
+
+ // Empty array returns the language key
+ $this->assertEquals($user->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY');
+
+ // No 0 key defined
+ $this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts');
+ $this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post');
+ $this->assertEquals($user->lang('ARRY_NO_ZERO', 2), '2 posts');
+
+ // Array with missing keys
+ $this->assertEquals($user->lang('ARRY_MISSING', 2), '2 post');
+
+ // Floats as array key
+ $this->assertEquals($user->lang('ARRY_FLOAT', 1.3), '1 post');
+ $this->assertEquals($user->lang('ARRY_FLOAT', 2.0), '2.0 posts');
+ $this->assertEquals($user->lang('ARRY_FLOAT', 2.51), '2.5 posts');
+
+ // Use sub key, if first paramenter is an array
+ $this->assertEquals($user->lang(array('dateformat', 'AGO'), 2), '2 seconds');
+
+ // ticket PHPBB3-9949 - use first int to determinate the plural-form to use
+ $this->assertEquals($user->lang('ARRY', 1, 2), '1 post');
+ $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post');
+ }
+
+ public function test_lang_plural_rules_bc()
+ {
+ $user = new \phpbb\user($this->lang, '\phpbb\datetime');
+
+ // ticket PHPBB3-10345 - different plural rules, not just 0/1/2+
+ $this->assertEquals($user->lang('PLURAL_ARRY', 0), '0 is 0');
+ $this->assertEquals($user->lang('PLURAL_ARRY', 1), '1 is 1');
+ $this->assertEquals($user->lang('PLURAL_ARRY', 103), '103 ends with 01-10');
+ $this->assertEquals($user->lang('PLURAL_ARRY', 15), '15 ends with 11-19');
+ $this->assertEquals($user->lang('PLURAL_ARRY', 300), '300 is part of the last rule');
+ }
+
+ protected function get_test_data_set()
+ {
+ return array(
+ 'FOO' => 'BAR',
+ 'BARZ' => 'PENG',
+ 'EMPTY' => '',
+ 'ZERO' => '0',
+ 'STR' => '%d %s, %d topics',
+ 'STR2' => '%d foos',
+ 'ARRY' => array(
+ 0 => 'No posts', // 0
+ 1 => '1 post', // 1
+ 2 => '%d posts', // 2+
+ ),
+ 'ARRY_NO_ZERO' => array(
+ 1 => '1 post', // 1
+ 2 => '%d posts', // 0, 2+
+ ),
+ 'ARRY_MISSING' => array(
+ 1 => '%d post', // 1
+ //Missing second plural
+ ),
+ 'ARRY_FLOAT' => array(
+ 1 => '1 post', // 1.x
+ 2 => '%1$.1f posts', // 0.x, 2+.x
+ ),
+ 'ARRY_EMPTY' => array(
+ ),
+ 'dateformat' => array(
+ 'AGO' => array(
+ 1 => '%d second',
+ 2 => '%d seconds',
+ ),
+ ),
+ 'PLURAL_RULE' => 13,
+ 'PLURAL_ARRY' => array(
+ 0 => '%d is 0', // 0
+ 1 => '%d is 1', // 1
+ 2 => '%d ends with 01-10', // ending with 01-10
+ 3 => '%d ends with 11-19', // ending with 11-19
+ 4 => '%d is part of the last rule', // everything else
+ ),
+ );
+ }
+}
diff --git a/tests/lint_test.php b/tests/lint_test.php
index 9fb1c7624c..fb43196bae 100644
--- a/tests/lint_test.php
+++ b/tests/lint_test.php
@@ -38,31 +38,34 @@ class phpbb_lint_test extends phpbb_test_case
self::markTestSkipped(sprintf('Could not run PHP_BINARY %s. Output: %s', self::$php_binary, $output));
}
}
-
- self::$exclude = array(
- dirname(__FILE__) . '/../.git',
- dirname(__FILE__) . '/../build/new_version',
- dirname(__FILE__) . '/../build/old_versions',
- dirname(__FILE__) . '/../phpBB/cache',
- // PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20
- // https://gist.github.com/e003913ffd493da63cbc
- dirname(__FILE__) . '/../phpBB/vendor',
- );
}
- public function test_lint()
+ /**
+ * @dataProvider lint_data
+ */
+ public function test_lint($path)
{
if (version_compare(PHP_VERSION, '5.3.0', '<'))
{
$this->markTestSkipped('phpBB uses PHP 5.3 syntax in some files, linting on PHP < 5.3 will fail');
}
- $root = dirname(__FILE__) . '/..';
- $this->check($root);
+ $cmd = sprintf('(%s -l %s) 2>&1', self::$php_binary, escapeshellarg($path));
+ $output = array();
+ $status = 1;
+ exec($cmd, $output, $status);
+ $output = implode("\n", $output);
+ $this->assertEquals(0, $status, "PHP lint failed for $path:\n$output");
+ }
+
+ public function lint_data()
+ {
+ return $this->check(dirname(__FILE__) . '/..');
}
protected function check($root)
{
+ $files = array();
$dh = opendir($root);
while (($filename = readdir($dh)) !== false)
{
@@ -76,19 +79,23 @@ class phpbb_lint_test extends phpbb_test_case
{
continue;
}
- if (is_dir($path) && !in_array($path, self::$exclude))
+ if (is_dir($path) && !in_array($path, array(
+ dirname(__FILE__) . '/../.git',
+ dirname(__FILE__) . '/../build/new_version',
+ dirname(__FILE__) . '/../build/old_versions',
+ dirname(__FILE__) . '/../phpBB/cache',
+ // PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20
+ // https://gist.github.com/e003913ffd493da63cbc
+ dirname(__FILE__) . '/../phpBB/vendor',
+ )))
{
- $this->check($path);
+ $files = array_merge($files, $this->check($path));
}
else if (substr($filename, strlen($filename)-4) == '.php')
{
- $cmd = sprintf('(%s -l %s) 2>&1', self::$php_binary, escapeshellarg($path));
- $output = array();
- $status = 1;
- exec($cmd, $output, $status);
- $output = implode("\n", $output);
- $this->assertEquals(0, $status, "PHP lint failed for $path:\n$output");
+ $files[] = array($path);
}
}
+ return $files;
}
}
diff --git a/tests/log/add_test.php b/tests/log/add_test.php
index bacc0c76f7..cfc592a464 100644
--- a/tests/log/add_test.php
+++ b/tests/log/add_test.php
@@ -27,7 +27,9 @@ class phpbb_log_add_test extends phpbb_database_test_case
$db = $this->new_dbal();
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$auth = $this->getMock('\phpbb\auth\auth');
$log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
@@ -56,7 +58,9 @@ class phpbb_log_add_test extends phpbb_database_test_case
$db = $this->new_dbal();
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$auth = $this->getMock('\phpbb\auth\auth');
$log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/log/delete_test.php b/tests/log/delete_test.php
index ec43182a0c..fe4c3835cb 100644
--- a/tests/log/delete_test.php
+++ b/tests/log/delete_test.php
@@ -30,7 +30,9 @@ class phpbb_log_delete_test extends phpbb_database_test_case
$db = $this->new_dbal();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->data['user_id'] = 1;
$auth = $this->getMock('\phpbb\auth\auth');
diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php
index 78949734a9..cdfeb52996 100644
--- a/tests/log/function_add_log_test.php
+++ b/tests/log/function_add_log_test.php
@@ -161,7 +161,10 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case
$db = $this->new_dbal();
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$auth = $this->getMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/notification/base.php b/tests/notification/base.php
index 162feae557..a1ebecd6f9 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -56,17 +56,20 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
'allow_topic_notify' => true,
'allow_forum_notify' => true,
));
- $user = $this->user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
+ $this->user = $user;
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
$auth = $this->auth = new phpbb_mock_notifications_auth();
$cache = $this->cache = new \phpbb\cache\service(
- new \phpbb\cache\driver\null(),
+ new \phpbb\cache\driver\dummy(),
$this->config,
$this->db,
$phpbb_root_path,
$phpEx
);
-
+
$this->phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = $this->container = new phpbb_mock_container_builder();
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index 6a56a38c45..a24808fbbd 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -50,7 +50,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
$this->cache->get_driver()
));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $phpbb_log = new \phpbb\log\null();
+ $phpbb_log = new \phpbb\log\dummy();
$this->get_test_case_helpers()->set_s9e_services();
// Now on to the actual test
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 2d621f82d3..d7a711e007 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -72,7 +72,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,));
$cache = new \phpbb\cache\service(
- new \phpbb\cache\driver\null(),
+ new \phpbb\cache\driver\dummy(),
$config,
$db,
$phpbb_root_path,
@@ -83,7 +83,10 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
// User
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$user->ip = '';
$user->data = array(
'user_id' => 2,
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index 5886c49512..f7b4fcb215 100644
--- a/tests/notification/user_list_trim_test.php
+++ b/tests/notification/user_list_trim_test.php
@@ -35,7 +35,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
$config = new \phpbb\config\config(array());
$cache = new \phpbb\cache\service(
- new \phpbb\cache\driver\null(),
+ new \phpbb\cache\driver\dummy(),
$config,
$db,
$phpbb_root_path,
@@ -51,7 +51,9 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('u_viewprofile', 1, false),
)));
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->data = array('user_lang' => 'en');
$user->add_lang('common');
@@ -71,7 +73,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
'topic_title' => 'Test',
'poster_id' => 2,
'post_username' => 'A',
- 'responders' => null,
+ 'responders' => null,
),
'<strong>Reply</strong> from A in topic:',
),
@@ -82,7 +84,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
'post_username' => 'A',
'responders' => array(
array('username' => '', 'poster_id' => 3),
- ),
+ ),
),
'<strong>Reply</strong> from A and <span class="username">B</span> in topic:',
),
@@ -94,7 +96,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
'responders' => array(
array('username' => '', 'poster_id' => 3),
array('username' => '', 'poster_id' => 4),
- ),
+ ),
),
'<strong>Reply</strong> from A, <span class="username">B</span>, and <span class="username">C</span> in topic:',
),
@@ -107,7 +109,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('username' => '', 'poster_id' => 3),
array('username' => '', 'poster_id' => 4),
array('username' => '', 'poster_id' => 5),
- ),
+ ),
),
'<strong>Reply</strong> from A, <span class="username">B</span>, <span class="username">C</span>, and <span class="username">D</span> in topic:',
),
@@ -121,7 +123,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('username' => '', 'poster_id' => 4),
array('username' => '', 'poster_id' => 5),
array('username' => '', 'poster_id' => 6),
- ),
+ ),
),
'<strong>Reply</strong> from A, <span class="username">B</span>, <span class="username">C</span>, and 2 others in topic:',
),
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index c705e67135..4916665a72 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -26,10 +26,13 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
{
parent::setUp();
- global $phpbb_dispatcher;
+ global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $this->user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$this->user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php
index 2f47bf2b39..aa7793567d 100644
--- a/tests/plupload/plupload_test.php
+++ b/tests/plupload/plupload_test.php
@@ -34,6 +34,10 @@ class phpbb_plupload_test extends phpbb_test_case
*/
public function test_generate_resize_string($config_width, $config_height, $expected)
{
+ global $phpbb_root_path, $phpEx;
+
+ $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
+
$config = new \phpbb\config\config(array(
'img_max_width' => $config_width,
'img_max_height' => $config_height,
@@ -43,7 +47,7 @@ class phpbb_plupload_test extends phpbb_test_case
'',
$config,
new phpbb_mock_request,
- new \phpbb\user('\phpbb\datetime'),
+ new \phpbb\user($lang, '\phpbb\datetime'),
new \phpbb\php\ini,
new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser))
);
diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php
index 41c40ddb4b..10239172c3 100644
--- a/tests/profilefields/type_bool_test.php
+++ b/tests/profilefields/type_bool_test.php
@@ -25,7 +25,12 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ global $phpbb_root_path, $phpEx;
+
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php
index 123955198e..e0807b2f9b 100644
--- a/tests/profilefields/type_date_test.php
+++ b/tests/profilefields/type_date_test.php
@@ -25,7 +25,12 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
*/
public function setUp()
{
- $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ global $phpbb_root_path, $phpEx;
+
+ $this->user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$this->user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php
index 3845a8e96b..ab02353fb9 100644
--- a/tests/profilefields/type_dropdown_test.php
+++ b/tests/profilefields/type_dropdown_test.php
@@ -25,7 +25,12 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ global $phpbb_root_path, $phpEx;
+
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php
index f3db6ef01f..6faf939231 100644
--- a/tests/profilefields/type_googleplus_test.php
+++ b/tests/profilefields/type_googleplus_test.php
@@ -21,7 +21,11 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
{
parent::setUp();
- $user = new \phpbb\user('\phpbb\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->add_lang('ucp');
$request = $this->getMock('\phpbb\request\request');
$template = $this->getMock('\phpbb\template\template');
diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php
index 07b22525e2..33f3f575c8 100644
--- a/tests/profilefields/type_int_test.php
+++ b/tests/profilefields/type_int_test.php
@@ -24,7 +24,12 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ global $phpbb_root_path, $phpEx;
+
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index 0417afbfab..447ab32a00 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -28,9 +28,12 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
*/
public function setUp()
{
- global $request, $user, $cache;
+ global $request, $user, $cache, $phpbb_root_path, $phpEx;
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$cache = new phpbb_mock_cache;
$user->expects($this->any())
->method('lang')
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index cc37f04f30..a0f93fe1f6 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -26,7 +26,12 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ global $phpbb_root_path, $phpEx;
+
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/security/base.php b/tests/security/base.php
index 5888a2bf2a..d2abdbc362 100644
--- a/tests/security/base.php
+++ b/tests/security/base.php
@@ -49,7 +49,9 @@ abstract class phpbb_security_test_base extends phpbb_test_case
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
// Set no user and trick a bit to circumvent errors
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->lang = true;
$user->browser = $this->server['HTTP_USER_AGENT'];
$user->referer = '';
diff --git a/tests/template/asset_test.php b/tests/template/asset_test.php
new file mode 100644
index 0000000000..f6ce0fe241
--- /dev/null
+++ b/tests/template/asset_test.php
@@ -0,0 +1,49 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+use phpbb\template\asset;
+
+class phpbb_template_asset_test extends phpbb_test_case
+{
+ public function set_path_data()
+ {
+ return array(
+ // array(phpbb_root_path, given path, expected path),
+ array('.', 'foo/bar', 'foo/bar'),
+ array('../', 'foo/bar', 'foo/bar'),
+ array('./phpBB/', 'foo/bar', 'foo/bar'),
+ array('../', __DIR__ . '/foo/bar', '../phpbb/tests/template/foo/bar'),
+ array('./', __DIR__ . '/foo/bar', './tests/template/foo/bar'),
+ array('./phpBB/', __DIR__ . '/foo/bar', 'tests/template/foo/bar'),
+ );
+ }
+
+ /**
+ * @dataProvider set_path_data
+ */
+ public function test_set_path($phpbb_root_path, $path, $expected)
+ {
+ $path_helper = $this->getMockBuilder('\phpbb\path_helper')
+ ->disableOriginalConstructor()
+ ->setMethods(array())
+ ->getMock();
+
+ $path_helper->method('get_phpbb_root_path')
+ ->willReturn($phpbb_root_path);
+
+ $asset = new asset('', $path_helper, new phpbb\filesystem\filesystem());
+
+ $asset->set_path($path, true);
+ $this->assertEquals($expected, $asset->get_path());
+ }
+}
diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php
index f739a78d84..14a8e9d463 100644
--- a/tests/template/template_allfolder_test.php
+++ b/tests/template/template_allfolder_test.php
@@ -28,13 +28,18 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
$defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
+ $this->user = $user;
+
+ $filesystem = new \phpbb\filesystem\filesystem();
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem\filesystem(),
+ $filesystem,
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -57,6 +62,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
+ $filesystem,
$path_helper,
$container,
$cache_path,
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index 6d1b7253e3..285e82188b 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -138,6 +138,8 @@ Zeta test event in all',
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
dirname(__FILE__) . "/datasets/$dataset/"
);
+
+ $filesystem = new \phpbb\filesystem\filesystem();
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
@@ -154,6 +156,7 @@ Zeta test event in all',
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
+ $filesystem,
$path_helper,
$container,
$cache_path,
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index 7a73d1f888..8c398d992b 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -28,11 +28,13 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
+ $filesystem = new \phpbb\filesystem\filesystem();
+
$this->phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem\filesystem(),
+ $filesystem,
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -46,6 +48,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
+ $filesystem,
$this->phpbb_path_helper,
$container,
$cache_path,
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 29ff669efc..b1826571af 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -15,6 +15,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_template_template_test_case extends phpbb_test_case
{
+ protected $lang;
protected $template;
protected $template_path;
protected $user;
@@ -24,6 +25,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
// Keep the contents of the cache for debugging?
const PRESERVE_CACHE = true;
+ static protected $language_reflection_lang;
+
+ static public function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+
+ $reflection = new ReflectionClass('\phpbb\language\language');
+ self::$language_reflection_lang = $reflection->getProperty('lang');
+ self::$language_reflection_lang->setAccessible(true);
+ }
+
protected function display($handle)
{
ob_start();
@@ -65,13 +77,18 @@ class phpbb_template_template_test_case extends phpbb_test_case
$defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $this->lang = $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
+ $this->user = $user;
+
+ $filesystem = new \phpbb\filesystem\filesystem();
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem\filesystem(),
+ $filesystem,
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -85,6 +102,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
+ $filesystem,
$path_helper,
$container,
$cache_path,
@@ -145,7 +163,10 @@ class phpbb_template_template_test_case extends phpbb_test_case
{
foreach ($lang_vars as $name => $value)
{
- $this->user->lang[$name] = $value;
+ self::$language_reflection_lang->setValue($this->lang, array_merge(
+ self::$language_reflection_lang->getValue($this->lang),
+ array($name => $value)
+ ));
}
}
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index eab83f379a..d0c49006fd 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -22,11 +22,13 @@ 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));
+ $filesystem = new \phpbb\filesystem\filesystem();
+
$this->phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem\filesystem(),
+ $filesystem,
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -41,6 +43,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
+ $filesystem,
$this->phpbb_path_helper,
$container,
$cache_path,
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index daa570caf6..0fec3c2dff 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -248,14 +248,12 @@ class phpbb_functional_test_case extends phpbb_test_case
);
$container->set('migrator', $migrator);
$container->set('dispatcher', new phpbb_mock_event_dispatcher());
- $user = new \phpbb\user('\phpbb\datetime');
$extension_manager = new \phpbb\extension\manager(
$container,
$db,
$config,
new phpbb\filesystem\filesystem(),
- $user,
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
$phpEx,
@@ -576,7 +574,7 @@ class phpbb_functional_test_case extends phpbb_test_case
}
$cache = new phpbb_mock_null_cache;
- $cache_driver = new \phpbb\cache\driver\null();
+ $cache_driver = new \phpbb\cache\driver\dummy();
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_notifications = new phpbb_mock_notification_manager();
@@ -616,13 +614,16 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$auth = $this->getMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
$cache = new phpbb_mock_null_cache;
- $cache_driver = new \phpbb\cache\driver\null();
+ $cache_driver = new \phpbb\cache\driver\dummy();
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
@@ -655,13 +656,16 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime'
+ ));
$auth = $this->getMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
$cache = new phpbb_mock_null_cache;
- $cache_driver = new \phpbb\cache\driver\null();
+ $cache_driver = new \phpbb\cache\driver\dummy();
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container
->expects($this->any())
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index 0f9b049f44..685014d3e4 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -474,7 +474,9 @@ class phpbb_test_case_helpers
}
else
{
- $user = new \phpbb\user('\phpbb\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewcensors', true);
$user->optionset('viewflash', true);
$user->optionset('viewimg', true);
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php
index 91458541d3..3c0bbb96c7 100644
--- a/tests/text_formatter/s9e/renderer_test.php
+++ b/tests/text_formatter/s9e/renderer_test.php
@@ -157,7 +157,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
'banana',
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewcensors', false);
$phpbb_container->set('user', $user);
@@ -168,7 +172,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
'banana',
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewcensors', false);
$config = new \phpbb\config\config(array('allow_nocensors' => true));
@@ -182,7 +190,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
'apple',
function ($phpbb_container, $test)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewcensors', false);
$config = new \phpbb\config\config(array('allow_nocensors' => true));
@@ -207,7 +219,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
'http://localhost/foo.swf',
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewflash', false);
$phpbb_container->set('user', $user);
@@ -222,7 +238,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
'<a href="http://localhost/mrgreen.gif" class="postlink">http://localhost/mrgreen.gif</a>',
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewimg', false);
$phpbb_container->set('user', $user);
@@ -237,7 +257,11 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
':)',
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('smilies', false);
$phpbb_container->set('user', $user);
@@ -291,9 +315,13 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
2 => '<b>bold</b>'
);
+ global $phpbb_root_path, $phpEx;
+
foreach ($tests as $style_id => $expected)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->style = array('style_id' => $style_id);
$phpbb_container = new phpbb_mock_container_builder;
@@ -311,10 +339,12 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
public function test_style_inheritance1()
{
- global $phpbb_container;
+ global $phpbb_container, $phpbb_root_path, $phpEx;
// Style 3 inherits from 2 which inherits from 1. Only style 1 has a bbcode.html
- $user = new \phpbb\user('\\phpbb\\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->style = array('style_id' => 3);
$phpbb_container = new phpbb_mock_container_builder;
@@ -331,7 +361,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
public function test_style_inheritance2()
{
- global $phpbb_container;
+ global $phpbb_container, $phpbb_root_path, $phpEx;
// Style 5 inherits from 4, but both have a bbcode.html
$tests = array(
@@ -341,7 +371,9 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
foreach ($tests as $style_id => $expected)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->style = array('style_id' => $style_id);
$phpbb_container = new phpbb_mock_container_builder;
diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php
index fe83938c0b..f2b0d6c78b 100644
--- a/tests/text_processing/generate_text_for_display_test.php
+++ b/tests/text_processing/generate_text_for_display_test.php
@@ -34,8 +34,12 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
{
global $cache, $user;
+ global $phpbb_root_path, $phpEx;
+
$cache = new phpbb_mock_cache;
- $user = new \phpbb\user('\\phpbb\\datetime');
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewcensors', true);
$user->optionset('viewflash', true);
$user->optionset('viewimg', true);
@@ -66,7 +70,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$phpbb_container = new phpbb_mock_container_builder;
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewcensors', false);
$config = new \phpbb\config\config(array('allow_nocensors' => true));
@@ -153,7 +161,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
true,
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewflash', false);
$phpbb_container->set('user', $user);
@@ -169,7 +181,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
true,
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('viewimg', false);
$phpbb_container->set('user', $user);
@@ -185,7 +201,11 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
true,
function ($phpbb_container)
{
- $user = new \phpbb\user('\\phpbb\\datetime');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
$user->optionset('smilies', false);
$phpbb_container->set('user', $user);
diff --git a/tests/text_processing/tickets_data/PHPBB3-13425.html b/tests/text_processing/tickets_data/PHPBB3-13425.html
new file mode 100644
index 0000000000..9a042dc558
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-13425.html
@@ -0,0 +1 @@
+<blockquote class="uncited"><div><img class="smilies" src="phpBB/images/smilies/icon_lol.gif" alt=":lol:" title="Laughing"> starts with a smiley</div></blockquote> \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-13425.txt b/tests/text_processing/tickets_data/PHPBB3-13425.txt
new file mode 100644
index 0000000000..8456410df5
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-13425.txt
@@ -0,0 +1 @@
+[quote]:lol: starts with a smiley[/quote] \ No newline at end of file
diff --git a/tests/text_processing/tickets_data/PHPBB3-13425.xml b/tests/text_processing/tickets_data/PHPBB3-13425.xml
new file mode 100644
index 0000000000..cbdcaa7fb7
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-13425.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_smilies">
+ <column>smiley_id</column>
+ <column>code</column>
+ <column>emotion</column>
+ <column>smiley_url</column>
+ <column>smiley_width</column>
+ <column>smiley_height</column>
+ <column>smiley_order</column>
+ <column>display_on_posting</column>
+ <row>
+ <value>22</value>
+ <value>:lol:</value>
+ <value>Laughing</value>
+ <value>icon_lol.gif</value>
+ <value>15</value>
+ <value>17</value>
+ <value>22</value>
+ <value>1</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/text_processing/tickets_data/PHPBB3-9073.html b/tests/text_processing/tickets_data/PHPBB3-9073.html
new file mode 100644
index 0000000000..ff1f9fd0ce
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-9073.html
@@ -0,0 +1,2 @@
+<a href="http://www.xxxx-xx-xxxx.com/" class="postlink">http://www.xxxx-xx-xxxx.com/</a><br>
+<a href="http://www.xxxx-xx-xxxx.com/" class="postlink">http://www.xxxx-xx-xxxx.com/</a><br>
diff --git a/tests/text_processing/tickets_data/PHPBB3-9073.txt b/tests/text_processing/tickets_data/PHPBB3-9073.txt
new file mode 100644
index 0000000000..2c271173ce
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-9073.txt
@@ -0,0 +1,2 @@
+http://www.some-ad-site.com/
+[url]http://www.some-ad-site.com/[/url]
diff --git a/tests/text_processing/tickets_data/PHPBB3-9073.xml b/tests/text_processing/tickets_data/PHPBB3-9073.xml
new file mode 100644
index 0000000000..d635d51ed1
--- /dev/null
+++ b/tests/text_processing/tickets_data/PHPBB3-9073.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_words">
+ <column>word_id</column>
+ <column>word</column>
+ <column>replacement</column>
+
+ <row>
+ <value>1</value>
+ <value>http://www.some-ad-site.com*</value>
+ <value>http://www.xxxx-xx-xxxx.com</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php
deleted file mode 100644
index bb11bb63cb..0000000000
--- a/tests/user/lang_test.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
-class phpbb_user_lang_test extends phpbb_test_case
-{
- public function test_user_lang_sprintf()
- {
- $user = new \phpbb\user('\phpbb\datetime');
- $user->lang = array(
- 'FOO' => 'BAR',
- 'BARZ' => 'PENG',
- 'EMPTY' => '',
- 'ZERO' => '0',
- 'STR' => '%d %s, %d topics',
- 'STR2' => '%d foos',
- 'ARRY' => array(
- 0 => 'No posts', // 0
- 1 => '1 post', // 1
- 2 => '%d posts', // 2+
- ),
- 'ARRY_NO_ZERO' => array(
- 1 => '1 post', // 1
- 2 => '%d posts', // 0, 2+
- ),
- 'ARRY_MISSING' => array(
- 1 => '%d post', // 1
- //Missing second plural
- ),
- 'ARRY_FLOAT' => array(
- 1 => '1 post', // 1.x
- 2 => '%1$.1f posts', // 0.x, 2+.x
- ),
- 'ARRY_EMPTY' => array(
- ),
- 'dateformat' => array(
- 'AGO' => array(
- 1 => '%d second',
- 2 => '%d seconds',
- ),
- ),
- );
-
- // No param
- $this->assertEquals($user->lang('FOO'), 'BAR');
- $this->assertEquals($user->lang('EMPTY'), '');
- $this->assertEquals($user->lang('ZERO'), '0');
-
- // Invalid index
- $this->assertEquals($user->lang('VOID'), 'VOID');
-
- // Unnecessary param
- $this->assertEquals($user->lang('FOO', 2), 'BAR');
- $this->assertEquals($user->lang('FOO', 2, 3), 'BAR');
- $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR');
-
- // String
- $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics');
- $this->assertEquals($user->lang('STR2', 64), '64 foos');
-
- // Array
- $this->assertEquals($user->lang('ARRY', 0), 'No posts');
- $this->assertEquals($user->lang('ARRY', 1), '1 post');
- $this->assertEquals($user->lang('ARRY', 2), '2 posts');
- $this->assertEquals($user->lang('ARRY', 123), '123 posts');
-
- // Empty array returns the language key
- $this->assertEquals($user->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY');
-
- // No 0 key defined
- $this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts');
- $this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post');
- $this->assertEquals($user->lang('ARRY_NO_ZERO', 2), '2 posts');
-
- // Array with missing keys
- $this->assertEquals($user->lang('ARRY_MISSING', 2), '2 post');
-
- // Floats as array key
- $this->assertEquals($user->lang('ARRY_FLOAT', 1.3), '1 post');
- $this->assertEquals($user->lang('ARRY_FLOAT', 2.0), '2.0 posts');
- $this->assertEquals($user->lang('ARRY_FLOAT', 2.51), '2.5 posts');
-
- // Use sub key, if first paramenter is an array
- $this->assertEquals($user->lang(array('dateformat', 'AGO'), 2), '2 seconds');
-
- // ticket PHPBB3-9949 - use first int to determinate the plural-form to use
- $this->assertEquals($user->lang('ARRY', 1, 2), '1 post');
- $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post');
-
- // ticket PHPBB3-10345 - different plural rules, not just 0/1/2+
- $user = new \phpbb\user('\phpbb\datetime');
- $user->lang = array(
- 'PLURAL_RULE' => 13,
- 'ARRY' => array(
- 0 => '%d is 0', // 0
- 1 => '%d is 1', // 1
- 2 => '%d ends with 01-10', // ending with 01-10
- 3 => '%d ends with 11-19', // ending with 11-19
- 4 => '%d is part of the last rule', // everything else
- ),
- );
- $this->assertEquals($user->lang('ARRY', 0), '0 is 0');
- $this->assertEquals($user->lang('ARRY', 1), '1 is 1');
- $this->assertEquals($user->lang('ARRY', 103), '103 ends with 01-10');
- $this->assertEquals($user->lang('ARRY', 15), '15 ends with 11-19');
- $this->assertEquals($user->lang('ARRY', 300), '300 is part of the last rule');
- }
-}
diff --git a/tests/version/version_fetch_test.php b/tests/version/version_fetch_test.php
index cfc87183cf..6ecc9b7223 100644
--- a/tests/version/version_fetch_test.php
+++ b/tests/version/version_fetch_test.php
@@ -28,13 +28,15 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+
$this->version_helper = new \phpbb\version_helper(
$this->cache,
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
new \phpbb\file_downloader(),
- new \phpbb\user('\phpbb\datetime')
+ new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
);
}
diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php
index 65ae7646b9..724c4c970c 100644
--- a/tests/version/version_helper_remote_test.php
+++ b/tests/version/version_helper_remote_test.php
@@ -30,20 +30,22 @@ class version_helper_remote_test extends \phpbb_test_case
));
$container = new \phpbb_mock_container_builder();
$db = new \phpbb\db\driver\factory($container);
- $this->cache = $this->getMock('\phpbb\cache\service', array('get'), array(new \phpbb\cache\driver\null(), $config, $db, '../../', 'php'));
+ $this->cache = $this->getMock('\phpbb\cache\service', array('get'), array(new \phpbb\cache\driver\dummy(), $config, $db, '../../', 'php'));
$this->cache->expects($this->any())
->method('get')
->with($this->anything())
->will($this->returnValue(false));
$this->file_downloader = new phpbb_mock_file_downloader();
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+
$this->version_helper = new \phpbb\version_helper(
$this->cache,
$config,
$this->file_downloader,
- new \phpbb\user('\phpbb\datetime')
+ new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
);
- $this->user = new \phpbb\user('\phpbb\datetime');
+ $this->user = new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime');
$this->user->add_lang('acp/common');
}
diff --git a/tests/version/version_test.php b/tests/version/version_test.php
index 528f1602d6..05577f6a18 100644
--- a/tests/version/version_test.php
+++ b/tests/version/version_test.php
@@ -25,13 +25,15 @@ class phpbb_version_helper_test extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+
$this->version_helper = new \phpbb\version_helper(
$this->cache,
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
new \phpbb\file_downloader(),
- new \phpbb\user('\phpbb\datetime')
+ new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
);
}
@@ -199,6 +201,11 @@ class phpbb_version_helper_test extends phpbb_test_case
*/
public function test_get_suggested_updates($current_version, $versions, $expected)
{
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+
$version_helper = $this
->getMockBuilder('\phpbb\version_helper')
->setMethods(array(
@@ -210,7 +217,7 @@ class phpbb_version_helper_test extends phpbb_test_case
'version' => $current_version,
)),
new \phpbb\file_downloader(),
- new \phpbb\user('\phpbb\datetime'),
+ new \phpbb\user($lang, '\phpbb\datetime'),
))
->getMock()
;
@@ -310,6 +317,11 @@ class phpbb_version_helper_test extends phpbb_test_case
*/
public function test_get_latest_on_current_branch($current_version, $versions, $expected)
{
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+
$version_helper = $this
->getMockBuilder('\phpbb\version_helper')
->setMethods(array(
@@ -321,7 +333,7 @@ class phpbb_version_helper_test extends phpbb_test_case
'version' => $current_version,
)),
new \phpbb\file_downloader(),
- new \phpbb\user('\phpbb\datetime'),
+ new \phpbb\user($lang, '\phpbb\datetime'),
))
->getMock()
;
diff --git a/travis/check-image-icc-profiles.sh b/travis/check-image-icc-profiles.sh
index d10c4cac40..df13c5f4e2 100755
--- a/travis/check-image-icc-profiles.sh
+++ b/travis/check-image-icc-profiles.sh
@@ -15,6 +15,6 @@ TRAVIS_PHP_VERSION=$2
if [ "$TRAVIS_PHP_VERSION" == "5.3" -a "$DB" == "mysqli" ]
then
- find . -type f -not -path './phpBB/vendor/*' -iregex '.*\.\(gif\|jpg\|jpeg\|png\)$' | \
+ find . -type f -a -iregex '.*\.\(gif\|jpg\|jpeg\|png\)$' -a -not -wholename '*vendor/*' | \
parallel --gnu --keep-order 'phpBB/develop/strip_icc_profiles.sh {}'
fi
diff --git a/travis/phpunit-mysqli-travis.xml b/travis/phpunit-mysqli-travis.xml
index 4c963895fc..b12ae6fe8b 100644
--- a/travis/phpunit-mysqli-travis.xml
+++ b/travis/phpunit-mysqli-travis.xml
@@ -18,9 +18,6 @@
<exclude>../tests/lint_test.php</exclude>
<exclude>../tests/ui</exclude>
</testsuite>
- <testsuite name="phpBB Lint Test">
- <file>../tests/lint_test.php</file>
- </testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh
index ab045431cc..911ba12f3c 100755
--- a/travis/setup-webserver.sh
+++ b/travis/setup-webserver.sh
@@ -11,12 +11,6 @@
set -e
set -x
-if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ]
-then
- # Add PPA providing dependencies for recent HHVM on Ubuntu 12.04.
- sudo add-apt-repository -y ppa:mapnik/boost
-fi
-
sudo apt-get update
sudo apt-get install -y nginx realpath
@@ -30,11 +24,9 @@ APP_SOCK=$(realpath "$DIR")/php-app.sock
if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ]
then
- # Upgrade to a recent stable version of HHVM
- sudo apt-get -o Dpkg::Options::="--force-confnew" install -y hhvm-nightly
-
HHVM_LOG=$(realpath "$DIR")/hhvm.log
+ sudo service hhvm stop
sudo hhvm \
--mode daemon \
--user "$USER" \