aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/config/default/container/services_console.yml37
-rw-r--r--phpBB/docs/CHANGELOG.html63
-rw-r--r--phpBB/language/en/cli.php19
-rw-r--r--phpBB/language/en/install.php22
-rw-r--r--phpBB/phpbb/console/command/user/activate.php218
-rw-r--r--phpBB/phpbb/console/command/user/add.php32
-rw-r--r--phpBB/phpbb/console/command/user/delete.php170
-rw-r--r--phpBB/phpbb/console/command/user/reclean.php198
-rw-r--r--phpBB/phpbb/controller/helper.php18
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v319rc1.php36
-rw-r--r--phpBB/phpbb/di/container_builder.php16
-rw-r--r--phpBB/phpbb/install/module/requirements/task/check_filesystem.php8
-rw-r--r--phpBB/phpbb/install/module_base.php2
-rw-r--r--phpBB/phpbb/routing/helper.php11
-rw-r--r--phpBB/posting.php3
-rw-r--r--phpBB/web.config7
-rw-r--r--tests/console/user/activate_test.php86
-rw-r--r--tests/console/user/add_test.php121
-rw-r--r--tests/console/user/base.php121
-rw-r--r--tests/console/user/delete_test.php93
-rw-r--r--tests/console/user/fixtures/config.xml20
-rw-r--r--tests/console/user/reclean_test.php49
-rw-r--r--tests/controller/common_helper_route.php66
23 files changed, 1257 insertions, 159 deletions
diff --git a/phpBB/config/default/container/services_console.yml b/phpBB/config/default/container/services_console.yml
index 0a28c0ed1f..3f27ee666a 100644
--- a/phpBB/config/default/container/services_console.yml
+++ b/phpBB/config/default/container/services_console.yml
@@ -220,6 +220,21 @@ services:
tags:
- { name: console.command }
+ console.command.user.activate:
+ class: phpbb\console\command\user\activate
+ arguments:
+ - '@user'
+ - '@dbal.conn'
+ - '@config'
+ - '@language'
+ - '@log'
+ - '@notification_manager'
+ - '@user_loader'
+ - '%core.root_path%'
+ - '%core.php_ext%'
+ tags:
+ - { name: console.command }
+
console.command.user.add:
class: phpbb\console\command\user\add
arguments:
@@ -232,3 +247,25 @@ services:
- '%core.php_ext%'
tags:
- { name: console.command }
+
+ console.command.user.delete:
+ class: phpbb\console\command\user\delete
+ arguments:
+ - '@user'
+ - '@dbal.conn'
+ - '@language'
+ - '@log'
+ - '@user_loader'
+ - '%core.root_path%'
+ - '%core.php_ext%'
+ tags:
+ - { name: console.command }
+
+ console.command.user.reclean:
+ class: phpbb\console\command\user\reclean
+ arguments:
+ - '@user'
+ - '@dbal.conn'
+ - '@language'
+ tags:
+ - { name: console.command }
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 10dc48b801..08c582b896 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -53,6 +53,7 @@
<li><a href="#v320a2">Changes since 3.2.0-a2</a></li>
<li><a href="#v320a1">Changes since 3.2.0-a1</a></li>
<li><a href="#v31x">Changes since 3.1.x</a></li>
+ <li><a href="#v318">Changes since 3.1.8</a></li>
<li><a href="#v317pl1">Changes since 3.1.7-PL1</a></li>
<li><a href="#v317">Changes since 3.1.7</a></li>
<li><a href="#v316">Changes since 3.1.6</a></li>
@@ -439,6 +440,68 @@
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14265">PHPBB3-14265</a>] - Make all tables available in the container</li>
</ul>
+ <a name="v318"></a><h3>Changes since 3.1.8</h3>
+
+ <h4>Bug</h4>
+ <ul>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-8058">PHPBB3-8058</a>] - Default style in ACP-&gt;Board Settings not observing offset</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13028">PHPBB3-13028</a>] - &quot;View unanswered posts&quot; link should be called instead &quot;View unanswered topics&quot;</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13264">PHPBB3-13264</a>] - Editing an unapproved post as a moderator/admin approves it</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13521">PHPBB3-13521</a>] - Q&amp;A Captcha ACP, required fields error corrupts inputted data</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13630">PHPBB3-13630</a>] - NULL value parsed into $select_single can cause 403 Forbidden on certain restrictive hosting environments for &quot;Find a Member&quot; function within Private Message composition</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13681">PHPBB3-13681</a>] - Email queue shouldn't be cached by opcache</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13683">PHPBB3-13683</a>] - Controller generates urls with absolute path of phpbb's root</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13842">PHPBB3-13842</a>] - Missing rewrite module on IIS7 leads to an error</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-13977">PHPBB3-13977</a>] - Fatal error entering UCP if bookmarked topic was deleted</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14132">PHPBB3-14132</a>] - SQL Error when creating a new subject on fresh installation</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14136">PHPBB3-14136</a>] - IE compatibility meta is missing in overall_header.html</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14241">PHPBB3-14241</a>] - Security bug into Spambot control Questions</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14272">PHPBB3-14272</a>] - Use valid html5 input elements in forms</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14290">PHPBB3-14290</a>] - Function set_modified_headers() never sends 304 'Not Modified' header</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14408">PHPBB3-14408</a>] - Remove span corners</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14422">PHPBB3-14422</a>] - Support cmd+enter &amp; ctrl+enter for submitting message</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14437">PHPBB3-14437</a>] - Place Inline Images on Post get scrambled up -- not follow the order you place them in.</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14443">PHPBB3-14443</a>] - jabber notification-template prefix &quot;short&quot; breaks resolution of paths in extensions</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14475">PHPBB3-14475</a>] - Do not log upon automatically removing users form newly registered users group</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14481">PHPBB3-14481</a>] - phpBB does not obey HTTP_X_FORWARDED_PORT header</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14483">PHPBB3-14483</a>] - call to header(arg, arg) function sendHeaders() in Response.php causes Error 500 in app.php generated links</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14496">PHPBB3-14496</a>] - Automatic update relies on cache creating files in cache folder</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14500">PHPBB3-14500</a>] - Duplicate newversion in build.xml</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14514">PHPBB3-14514</a>] - Users get skipped in passwords_convert_p1 migration</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14519">PHPBB3-14519</a>] - Do not query database for unread notifications if all are retrieved</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14532">PHPBB3-14532</a>] - Database column default incorrectly escaped on MSSQL</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14533">PHPBB3-14533</a>] - &quot;U_NOTIFICATION_SETTINGS&quot; doesn't return the correct URL</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14536">PHPBB3-14536</a>] - Force timestamp to be integer in user::format_date()</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14559">PHPBB3-14559</a>] - Attachments' behaviour in quotes</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14562">PHPBB3-14562</a>] - Extension's permissions don't have language fallback</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14570">PHPBB3-14570</a>] - Board versions for 3.2.x can be accidentally downgraded to 3.1.x</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14577">PHPBB3-14577</a>] - Stop using sizeof() inside for() loop</li>
+ </ul>
+ <h4>Improvement</h4>
+ <ul>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10356">PHPBB3-10356</a>] - Username search should find all users for administrators instead of NORMALs and FOUNDERs only</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-12305">PHPBB3-12305</a>] - Add new event core.viewforum_get_topic_id_sql to control forum topic listing</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14134">PHPBB3-14134</a>] - Send warning notification PM in user's language.</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14316">PHPBB3-14316</a>] - Add memberlist_view.html template events before/after the custom fields and zebra links</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14365">PHPBB3-14365</a>] - Add core event to the function topic_review() </li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14366">PHPBB3-14366</a>] - Add core events to the function decode_message()</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14395">PHPBB3-14395</a>] - Add event core.viewtopic_add_quickmod_option_after</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14471">PHPBB3-14471</a>] - Add filedata var to the core.avatar_driver_upload_move_file_before event</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14486">PHPBB3-14486</a>] - Add an event and fix an event in login_box()</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14508">PHPBB3-14508</a>] - Change language notice on account activation</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14540">PHPBB3-14540</a>] - Adjust class recursive_dot_prefix_filter_iterator to increase performance</li>
+ </ul>
+ <h4>New Feature</h4>
+ <ul>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-12684">PHPBB3-12684</a>] - Add a command to add a user from the CLI</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14189">PHPBB3-14189</a>] - [PHP] - core.gen_sort_selects_after</li>
+ </ul>
+ <h4>Task</h4>
+ <ul>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14538">PHPBB3-14538</a>] - Update composer dependencies</li>
+ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-14565">PHPBB3-14565</a>] - Updates composer to 1.0.0-b2</li>
+ </ul>
+
<a name="v317pl1"></a><h3>Changes since 3.1.7-PL1</h3>
<h4>Bug</h4>
diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php
index 6cb516ebfd..db4b5f9ec6 100644
--- a/phpBB/language/en/cli.php
+++ b/phpBB/language/en/cli.php
@@ -82,11 +82,20 @@ $lang = array_merge($lang, array(
'CLI_DESCRIPTION_THUMBNAIL_GENERATE' => 'Generate all missing thumbnails.',
'CLI_DESCRIPTION_THUMBNAIL_RECREATE' => 'Recreate all thumbnails.',
+ 'CLI_DESCRIPTION_USER_ACTIVATE' => 'Activate (or deactivate) a user account.',
+ 'CLI_DESCRIPTION_USER_ACTIVATE_USERNAME' => 'Username of the account to activate.',
+ 'CLI_DESCRIPTION_USER_ACTIVATE_DEACTIVATE' => 'Deactivate the user’s account',
+ 'CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE' => 'The user is already active.',
+ 'CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE' => 'The user is already inactive.',
'CLI_DESCRIPTION_USER_ADD' => 'Add a new user.',
'CLI_DESCRIPTION_USER_ADD_OPTION_USERNAME' => 'Username of the new user',
'CLI_DESCRIPTION_USER_ADD_OPTION_PASSWORD' => 'Password of the new user',
'CLI_DESCRIPTION_USER_ADD_OPTION_EMAIL' => 'E-mail address of the new user',
'CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY' => 'Send account activation email to the new user (not sent by default)',
+ 'CLI_DESCRIPTION_USER_DELETE' => 'Delete a user account.',
+ 'CLI_DESCRIPTION_USER_DELETE_USERNAME' => 'Username of the user to delete',
+ 'CLI_DESCRIPTION_USER_DELETE_OPTION_POSTS' => 'Delete all posts by the user. Without this option, the user’s posts will be retained.',
+ 'CLI_DESCRIPTION_USER_RECLEAN' => 'Re-clean usernames.',
'CLI_EXTENSION_DISABLE_FAILURE' => 'Could not disable extension %s',
'CLI_EXTENSION_DISABLE_SUCCESS' => 'Successfully disabled extension %s',
@@ -126,12 +135,22 @@ $lang = array_merge($lang, array(
'CLI_THUMBNAIL_NOTHING_TO_DELETE' => 'No thumbnails to delete.',
'CLI_USER_ADD_SUCCESS' => 'Successfully added user %s.',
+ 'CLI_USER_DELETE_CONFIRM' => 'Are you sure you want to delete ‘%s’? [y/N]',
+ 'CLI_USER_RECLEAN_START' => 'Re-cleaning usernames',
+ 'CLI_USER_RECLEAN_DONE' => [
+ 0 => 'Re-cleaning complete. No usernames needed to be cleaned.',
+ 1 => 'Re-cleaning complete. %d username was cleaned.',
+ 2 => 'Re-cleaning complete. %d usernames were cleaned.',
+ ],
));
// Additional help for commands.
$lang = array_merge($lang, array(
'CLI_HELP_CRON_RUN' => $lang['CLI_DESCRIPTION_CRON_RUN'] . ' Optionally you can specify a cron task name to run only the specified cron task.',
+ 'CLI_HELP_USER_ACTIVATE' => 'Activate a user account, or deactivate an account using the <info>--deactivate</info> option.
+To optionally send an activation email to the user, use the <info>--send-email</info> option.',
'CLI_HELP_USER_ADD' => 'The <info>%command.name%</info> command adds a new user:
If this command is run without options, you will be prompted to enter them.
To optionally send an email to the new user, use the <info>--send-email</info> option.',
+ 'CLI_HELP_USER_RECLEAN' => 'Re-clean usernames will check all stored usernames and ensure clean versions are also stored. Cleaned usernames are a case insensitive form, NFC normalized and transformed to ASCII.',
));
diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php
index 9a727be649..88cbaf1533 100644
--- a/phpBB/language/en/install.php
+++ b/phpBB/language/en/install.php
@@ -90,15 +90,19 @@ $lang = array_merge($lang, array(
// Requirements translation
$lang = array_merge($lang, array(
// Filesystem requirements
- 'FILE_NOT_EXISTS' => 'File not exists',
- 'FILE_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to exist.',
- 'FILE_NOT_WRITABLE' => 'File not writable',
- 'FILE_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to be writable.',
-
- 'DIRECTORY_NOT_EXISTS' => 'Directory not exists',
- 'DIRECTORY_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to exist.',
- 'DIRECTORY_NOT_WRITABLE' => 'Directory not writable',
- 'DIRECTORY_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to be writable.',
+ 'FILE_NOT_EXISTS' => 'File does not exist',
+ 'FILE_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to exist.',
+ 'FILE_NOT_EXISTS_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s file exist for a better forum user experience.',
+ 'FILE_NOT_WRITABLE' => 'File is not writable',
+ 'FILE_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s file needs to be writable.',
+ 'FILE_NOT_WRITABLE_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s file be writable for a better forum user experience.',
+
+ 'DIRECTORY_NOT_EXISTS' => 'Directory does not exist',
+ 'DIRECTORY_NOT_EXISTS_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to exist.',
+ 'DIRECTORY_NOT_EXISTS_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s directory exist for a better forum user experience.',
+ 'DIRECTORY_NOT_WRITABLE' => 'Directory is not writable',
+ 'DIRECTORY_NOT_WRITABLE_EXPLAIN' => 'To be able to install phpBB the %1$s directory needs to be writable.',
+ 'DIRECTORY_NOT_WRITABLE_EXPLAIN_OPTIONAL' => 'It is recommended that the %1$s directory be writable for a better forum user experience.',
// Server requirements
'PHP_VERSION_REQD' => 'PHP version',
diff --git a/phpBB/phpbb/console/command/user/activate.php b/phpBB/phpbb/console/command/user/activate.php
new file mode 100644
index 0000000000..9c85718b4c
--- /dev/null
+++ b/phpBB/phpbb/console/command/user/activate.php
@@ -0,0 +1,218 @@
+<?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\console\command\user;
+
+use phpbb\config\config;
+use phpbb\console\command\command;
+use phpbb\db\driver\driver_interface;
+use phpbb\language\language;
+use phpbb\log\log_interface;
+use phpbb\notification\manager;
+use phpbb\user;
+use phpbb\user_loader;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+
+class activate extends command
+{
+ /** @var driver_interface */
+ protected $db;
+
+ /** @var config */
+ protected $config;
+
+ /** @var language */
+ protected $language;
+
+ /** @var log_interface */
+ protected $log;
+
+ /** @var manager */
+ protected $notifications;
+
+ /** @var user_loader */
+ protected $user_loader;
+
+ /**
+ * phpBB root path
+ *
+ * @var string
+ */
+ protected $phpbb_root_path;
+
+ /**
+ * PHP extension.
+ *
+ * @var string
+ */
+ protected $php_ext;
+
+ /**
+ * Construct method
+ *
+ * @param user $user
+ * @param driver_interface $db
+ * @param config $config
+ * @param language $language
+ * @param log_interface $log
+ * @param manager $notifications
+ * @param user_loader $user_loader
+ * @param string $phpbb_root_path
+ * @param string $php_ext
+ */
+ public function __construct(user $user, driver_interface $db, config $config, language $language, log_interface $log, manager $notifications, user_loader $user_loader, $phpbb_root_path, $php_ext)
+ {
+ $this->db = $db;
+ $this->config = $config;
+ $this->language = $language;
+ $this->log = $log;
+ $this->notifications = $notifications;
+ $this->user_loader = $user_loader;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+
+ $this->language->add_lang('acp/users');
+ parent::__construct($user);
+ }
+
+ /**
+ * Sets the command name and description
+ *
+ * @return null
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('user:activate')
+ ->setDescription($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE'))
+ ->setHelp($this->language->lang('CLI_HELP_USER_ACTIVATE'))
+ ->addArgument(
+ 'username',
+ InputArgument::REQUIRED,
+ $this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_USERNAME')
+ )
+ ->addOption(
+ 'deactivate',
+ 'd',
+ InputOption::VALUE_NONE,
+ $this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_DEACTIVATE')
+ )
+ ->addOption(
+ 'send-email',
+ null,
+ InputOption::VALUE_NONE,
+ $this->language->lang('CLI_DESCRIPTION_USER_ADD_OPTION_NOTIFY')
+ )
+ ;
+ }
+
+ /**
+ * Executes the command user:activate
+ *
+ * Activate (or deactivate) a user account
+ *
+ * @param InputInterface $input The input stream used to get the options
+ * @param OutputInterface $output The output stream, used to print messages
+ *
+ * @return int 0 if all is well, 1 if any errors occurred
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $io = new SymfonyStyle($input, $output);
+
+ $name = $input->getArgument('username');
+ $mode = ($input->getOption('deactivate')) ? 'deactivate' : 'activate';
+
+ $user_id = $this->user_loader->load_user_by_username($name);
+ $user_row = $this->user_loader->get_user($user_id);
+
+ if ($user_row['user_id'] == ANONYMOUS)
+ {
+ $io->error($this->language->lang('NO_USER'));
+ return 1;
+ }
+
+ // Check if the user is already active (or inactive)
+ if ($mode == 'activate' && $user_row['user_type'] != USER_INACTIVE)
+ {
+ $io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE'));
+ return 1;
+ }
+ else if ($mode == 'deactivate' && $user_row['user_type'] == USER_INACTIVE)
+ {
+ $io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE'));
+ return 1;
+ }
+
+ // Activate the user account
+ if (!function_exists('user_active_flip'))
+ {
+ require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
+ }
+
+ user_active_flip($mode, $user_row['user_id']);
+
+ // Notify the user upon activation
+ if ($mode == 'activate' && $this->config['require_activation'] == USER_ACTIVATION_ADMIN)
+ {
+ $this->send_notification($user_row, $input);
+ }
+
+ // Log and display the result
+ $msg = ($mode == 'activate') ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
+ $log = ($mode == 'activate') ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
+
+ $this->log->add('admin', ANONYMOUS, '', $log, false, array($user_row['username']));
+ $this->log->add('user', ANONYMOUS, '', $log . '_USER', false, array(
+ 'reportee_id' => $user_row['user_id']
+ ));
+
+ $io->success($this->language->lang($msg));
+
+ return 0;
+ }
+
+ /**
+ * Send account activation notification to user
+ *
+ * @param array $user_row The user data array
+ * @param InputInterface $input The input stream used to get the options
+ * @return null
+ */
+ protected function send_notification($user_row, InputInterface $input)
+ {
+ $this->notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']);
+
+ if ($input->getOption('send-email'))
+ {
+ if (!class_exists('messenger'))
+ {
+ require($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
+ }
+
+ $messenger = new \messenger(false);
+ $messenger->template('admin_welcome_activated', $user_row['user_lang']);
+ $messenger->set_addresses($user_row);
+ $messenger->anti_abuse_headers($this->config, $this->user);
+ $messenger->assign_vars(array(
+ 'USERNAME' => htmlspecialchars_decode($user_row['username']))
+ );
+
+ $messenger->send(NOTIFY_EMAIL);
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/user/add.php b/phpBB/phpbb/console/command/user/add.php
index df1f4aa54a..c60a059251 100644
--- a/phpBB/phpbb/console/command/user/add.php
+++ b/phpBB/phpbb/console/command/user/add.php
@@ -13,28 +13,34 @@
namespace phpbb\console\command\user;
+use phpbb\config\config;
+use phpbb\console\command\command;
+use phpbb\db\driver\driver_interface;
use phpbb\exception\runtime_exception;
+use phpbb\language\language;
+use phpbb\passwords\manager;
+use phpbb\user;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
-class add extends \phpbb\console\command\command
+class add extends command
{
/** @var array Array of interactively acquired options */
protected $data;
- /** @var \phpbb\db\driver\driver_interface */
+ /** @var driver_interface */
protected $db;
- /** @var \phpbb\config\config */
+ /** @var config */
protected $config;
- /** @var \phpbb\language\language */
+ /** @var language */
protected $language;
- /** @var \phpbb\passwords\manager */
+ /** @var manager */
protected $password_manager;
/**
@@ -54,15 +60,15 @@ class add extends \phpbb\console\command\command
/**
* Construct method
*
- * @param \phpbb\user $user
- * @param \phpbb\db\driver\driver_interface $db
- * @param \phpbb\config\config $config
- * @param \phpbb\language\language $language
- * @param \phpbb\passwords\manager $password_manager
- * @param string $phpbb_root_path
- * @param string $php_ext
+ * @param user $user
+ * @param driver_interface $db
+ * @param config $config
+ * @param language $language
+ * @param manager $password_manager
+ * @param string $phpbb_root_path
+ * @param string $php_ext
*/
- public function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\language\language $language, \phpbb\passwords\manager $password_manager, $phpbb_root_path, $php_ext)
+ public function __construct(user $user, driver_interface $db, config $config, language $language, manager $password_manager, $phpbb_root_path, $php_ext)
{
$this->db = $db;
$this->config = $config;
diff --git a/phpBB/phpbb/console/command/user/delete.php b/phpBB/phpbb/console/command/user/delete.php
new file mode 100644
index 0000000000..8593541c1a
--- /dev/null
+++ b/phpBB/phpbb/console/command/user/delete.php
@@ -0,0 +1,170 @@
+<?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\console\command\user;
+
+use phpbb\console\command\command;
+use phpbb\db\driver\driver_interface;
+use phpbb\language\language;
+use phpbb\log\log_interface;
+use phpbb\user;
+use phpbb\user_loader;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
+use Symfony\Component\Console\Style\SymfonyStyle;
+
+class delete extends command
+{
+ /** @var driver_interface */
+ protected $db;
+
+ /** @var language */
+ protected $language;
+
+ /** @var log_interface */
+ protected $log;
+
+ /** @var user_loader */
+ protected $user_loader;
+
+ /**
+ * phpBB root path
+ *
+ * @var string
+ */
+ protected $phpbb_root_path;
+
+ /**
+ * PHP extension.
+ *
+ * @var string
+ */
+ protected $php_ext;
+
+ /**
+ * Construct method
+ *
+ * @param user $user
+ * @param driver_interface $db
+ * @param language $language
+ * @param log_interface $log
+ * @param user_loader $user_loader
+ * @param string $phpbb_root_path
+ * @param string $php_ext
+ */
+ public function __construct(user $user, driver_interface $db, language $language, log_interface $log, user_loader $user_loader, $phpbb_root_path, $php_ext)
+ {
+ $this->db = $db;
+ $this->language = $language;
+ $this->log = $log;
+ $this->user_loader = $user_loader;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+
+ $this->language->add_lang('acp/users');
+ parent::__construct($user);
+ }
+
+ /**
+ * Sets the command name and description
+ *
+ * @return null
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('user:delete')
+ ->setDescription($this->language->lang('CLI_DESCRIPTION_USER_DELETE'))
+ ->addArgument(
+ 'username',
+ InputArgument::REQUIRED,
+ $this->language->lang('CLI_DESCRIPTION_USER_DELETE_USERNAME')
+ )
+ ->addOption(
+ 'delete-posts',
+ null,
+ InputOption::VALUE_NONE,
+ $this->language->lang('CLI_DESCRIPTION_USER_DELETE_OPTION_POSTS')
+ )
+ ;
+ }
+
+ /**
+ * Executes the command user:delete
+ *
+ * Deletes a user from the database. An option to delete the user's posts
+ * is available, by default posts will be retained.
+ *
+ * @param InputInterface $input The input stream used to get the options
+ * @param OutputInterface $output The output stream, used to print messages
+ *
+ * @return int 0 if all is well, 1 if any errors occurred
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $name = $input->getArgument('username');
+ $mode = ($input->getOption('delete-posts')) ? 'remove' : 'retain';
+
+ if ($name)
+ {
+ $io = new SymfonyStyle($input, $output);
+
+ $user_id = $this->user_loader->load_user_by_username($name);
+ $user_row = $this->user_loader->get_user($user_id);
+
+ if ($user_row['user_id'] == ANONYMOUS)
+ {
+ $io->error($this->language->lang('NO_USER'));
+ return 1;
+ }
+
+ if (!function_exists('user_delete'))
+ {
+ require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
+ }
+
+ user_delete($mode, $user_row['user_id'], $user_row['username']);
+
+ $this->log->add('admin', ANONYMOUS, '', 'LOG_USER_DELETED', false, array($user_row['username']));
+
+ $io->success($this->language->lang('USER_DELETED'));
+ }
+
+ return 0;
+ }
+
+ /**
+ * Interacts with the user.
+ * Confirm they really want to delete the account...last chance!
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ */
+ protected function interact(InputInterface $input, OutputInterface $output)
+ {
+ $helper = $this->getHelper('question');
+
+ $question = new ConfirmationQuestion(
+ $this->language->lang('CLI_USER_DELETE_CONFIRM', $input->getArgument('username')),
+ false
+ );
+
+ if (!$helper->ask($input, $output, $question))
+ {
+ $input->setArgument('username', false);
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/user/reclean.php b/phpBB/phpbb/console/command/user/reclean.php
new file mode 100644
index 0000000000..e298c285be
--- /dev/null
+++ b/phpBB/phpbb/console/command/user/reclean.php
@@ -0,0 +1,198 @@
+<?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\console\command\user;
+
+use phpbb\console\command\command;
+use phpbb\db\driver\driver_interface;
+use phpbb\language\language;
+use phpbb\user;
+use Symfony\Component\Console\Helper\ProgressBar;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+
+class reclean extends command
+{
+ /** @var driver_interface */
+ protected $db;
+
+ /** @var language */
+ protected $language;
+
+ /** @var int A count of the number of re-cleaned user names */
+ protected $processed;
+
+ /** @var ProgressBar */
+ protected $progress;
+
+ /**
+ * Construct method
+ *
+ * @param user $user
+ * @param driver_interface $db
+ * @param language $language
+ */
+ public function __construct(user $user, driver_interface $db, language $language)
+ {
+ $this->db = $db;
+ $this->language = $language;
+
+ parent::__construct($user);
+ }
+
+ /**
+ * Sets the command name and description
+ *
+ * @return null
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('user:reclean')
+ ->setDescription($this->language->lang('CLI_DESCRIPTION_USER_RECLEAN'))
+ ->setHelp($this->language->lang('CLI_HELP_USER_RECLEAN'))
+ ;
+ }
+
+ /**
+ * Executes the command user:reclean
+ *
+ * Cleans user names that are unclean.
+ *
+ * @param InputInterface $input The input stream used to get the options
+ * @param OutputInterface $output The output stream, used to print messages
+ *
+ * @return int 0 if all is well, 1 if any errors occurred
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $io = new SymfonyStyle($input, $output);
+
+ $io->section($this->language->lang('CLI_USER_RECLEAN_START'));
+
+ $this->processed = 0;
+
+ $this->progress = $this->create_progress_bar($this->get_count(), $io, $output);
+ $this->progress->setMessage($this->language->lang('CLI_USER_RECLEAN_START'));
+ $this->progress->start();
+
+ $stage = 0;
+ while ($stage !== true)
+ {
+ $stage = $this->reclean_usernames($stage);
+ }
+
+ $this->progress->finish();
+
+ $io->newLine(2);
+ $io->success($this->language->lang('CLI_USER_RECLEAN_DONE', $this->processed));
+
+ return 0;
+ }
+
+ /**
+ * Re-clean user names
+ * Only user names that are unclean will be re-cleaned
+ *
+ * @param int $start An offset index
+ * @return bool|int Return the next offset index or true if all records have been processed.
+ */
+ protected function reclean_usernames($start = 0)
+ {
+ $limit = 500;
+ $i = 0;
+
+ $this->db->sql_transaction('begin');
+
+ $sql = 'SELECT user_id, username, username_clean FROM ' . USERS_TABLE;
+ $result = $this->db->sql_query_limit($sql, $limit, $start);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $i++;
+ $username_clean = $this->db->sql_escape(utf8_clean_string($row['username']));
+
+ if ($username_clean != $row['username_clean'])
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET username_clean = '$username_clean'
+ WHERE user_id = {$row['user_id']}";
+ $this->db->sql_query($sql);
+
+ $this->processed++;
+ }
+
+ $this->progress->advance();
+ }
+ $this->db->sql_freeresult($result);
+
+ $this->db->sql_transaction('commit');
+
+ return ($i < $limit) ? true : $start + $i;
+ }
+
+ /**
+ * Create a styled progress bar
+ *
+ * @param integer $max Max value for the progress bar
+ * @param SymfonyStyle $io
+ * @param OutputInterface $output The output stream, used to print messages
+ * @return ProgressBar
+ */
+ protected function create_progress_bar($max, SymfonyStyle $io, OutputInterface $output)
+ {
+ $progress = $io->createProgressBar($max);
+ if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE)
+ {
+ $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
+ $progress->setOverwrite(false);
+ }
+ else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE)
+ {
+ $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
+ $progress->setOverwrite(false);
+ }
+ else
+ {
+ $io->newLine(2);
+ $progress->setFormat(
+ " %current:s%/%max:s% %bar% %percent:3s%%\n" .
+ " %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
+ $progress->setBarWidth(60);
+ }
+
+ if (!defined('PHP_WINDOWS_VERSION_BUILD'))
+ {
+ $progress->setEmptyBarCharacter('░'); // light shade character \u2591
+ $progress->setProgressCharacter('');
+ $progress->setBarCharacter('▓'); // dark shade character \u2593
+ }
+
+ return $progress;
+ }
+
+ /**
+ * Get the count of users in the database
+ *
+ * @return int
+ */
+ protected function get_count()
+ {
+ $sql = 'SELECT COUNT(user_id) AS count FROM ' . USERS_TABLE;
+ $result = $this->db->sql_query($sql);
+ $count = (int) $this->db->sql_fetchfield('count');
+ $this->db->sql_freeresult($result);
+
+ return $count;
+ }
+}
diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php
index 9dbc3737f7..664b4f4e0f 100644
--- a/phpBB/phpbb/controller/helper.php
+++ b/phpBB/phpbb/controller/helper.php
@@ -52,15 +52,15 @@ class helper
protected $routing_helper;
/**
- * Constructor
- *
- * @param \phpbb\template\template $template Template object
- * @param \phpbb\user $user User object
- * @param \phpbb\config\config $config Config object
- * @param \phpbb\symfony_request $symfony_request Symfony Request object
- * @param \phpbb\request\request_interface $request phpBB request object
- * @param \phpbb\routing\helper $routing_helper Helper to generate the routes
- */
+ * Constructor
+ *
+ * @param \phpbb\template\template $template Template object
+ * @param \phpbb\user $user User object
+ * @param \phpbb\config\config $config Config object
+ * @param \phpbb\symfony_request $symfony_request Symfony Request object
+ * @param \phpbb\request\request_interface $request phpBB request object
+ * @param \phpbb\routing\helper $routing_helper Helper to generate the routes
+ */
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\routing\helper $routing_helper)
{
$this->template = $template;
diff --git a/phpBB/phpbb/db/migration/data/v31x/v319rc1.php b/phpBB/phpbb/db/migration/data/v31x/v319rc1.php
new file mode 100644
index 0000000000..9805b45572
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v319rc1.php
@@ -0,0 +1,36 @@
+<?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 v319rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.9-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v318',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.9-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 0462fb60c2..b6854673c2 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -562,7 +562,13 @@ class container_builder
*/
protected function get_container_filename()
{
- return $this->get_cache_dir() . 'container_' . md5($this->phpbb_root_path) . '.' . $this->php_ext;
+ $container_params = [
+ 'phpbb_root_path' => $this->phpbb_root_path,
+ 'use_extensions' => $this->use_extensions,
+ 'config_path' => $this->config_path,
+ ];
+
+ return $this->get_cache_dir() . 'container_' . md5(implode(',', $container_params)) . '.' . $this->php_ext;
}
/**
@@ -572,7 +578,13 @@ class container_builder
*/
protected function get_autoload_filename()
{
- return $this->get_cache_dir() . 'autoload_' . md5($this->phpbb_root_path) . '.' . $this->php_ext;
+ $container_params = [
+ 'phpbb_root_path' => $this->phpbb_root_path,
+ 'use_extensions' => $this->use_extensions,
+ 'config_path' => $this->config_path,
+ ];
+
+ return $this->get_cache_dir() . 'autoload_' . md5(implode(',', $container_params)) . '.' . $this->php_ext;
}
/**
diff --git a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php
index 2aec3915e0..868af39433 100644
--- a/phpBB/phpbb/install/module/requirements/task/check_filesystem.php
+++ b/phpBB/phpbb/install/module/requirements/task/check_filesystem.php
@@ -177,7 +177,9 @@ class check_filesystem extends \phpbb\install\task_base
if (!($exists && $writable))
{
$title = ($exists) ? 'FILE_NOT_WRITABLE' : 'FILE_NOT_EXISTS';
- $description = array($title . '_EXPLAIN', $file);
+ $lang_suffix = '_EXPLAIN';
+ $lang_suffix .= ($failable) ? '_OPTIONAL' : '';
+ $description = array($title . $lang_suffix, $file);
if ($failable)
{
@@ -244,7 +246,9 @@ class check_filesystem extends \phpbb\install\task_base
if (!($exists && $writable))
{
$title = ($exists) ? 'DIRECTORY_NOT_WRITABLE' : 'DIRECTORY_NOT_EXISTS';
- $description = array($title . '_EXPLAIN', $dir);
+ $lang_suffix = '_EXPLAIN';
+ $lang_suffix .= ($failable) ? '_OPTIONAL' : '';
+ $description = array($title . $lang_suffix, $dir);
if ($failable)
{
diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php
index 527447b4a1..93c10bd656 100644
--- a/phpBB/phpbb/install/module_base.php
+++ b/phpBB/phpbb/install/module_base.php
@@ -172,7 +172,7 @@ abstract class module_base implements module_interface
$this->iohandler->send_response();
// Stop execution if resource limit is reached
- if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
+ if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0))
{
throw new resource_limit_reached_exception();
}
diff --git a/phpBB/phpbb/routing/helper.php b/phpBB/phpbb/routing/helper.php
index f56974a354..c15608dce5 100644
--- a/phpBB/phpbb/routing/helper.php
+++ b/phpBB/phpbb/routing/helper.php
@@ -104,6 +104,15 @@ class helper
$context = new RequestContext();
$context->fromRequest($this->symfony_request);
+ if ($this->config['force_server_vars'])
+ {
+ $context->setHost($this->config['server_name']);
+ $context->setScheme(substr($this->config['server_protocol'], 0, -3));
+ $context->setHttpPort($this->config['server_port']);
+ $context->setHttpsPort($this->config['server_port']);
+ $context->setBaseUrl(rtrim($this->config['script_path'], '/'));
+ }
+
$script_name = $this->symfony_request->getScriptName();
$page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name);
@@ -119,7 +128,7 @@ class helper
$base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);
// We need to update the base url to move to the directory of the app.php file if the current script is not app.php
- if ($page_name !== 'app.php')
+ if ($page_name !== 'app.php' && !$this->config['force_server_vars'])
{
if (empty($this->config['enable_mod_rewrite']))
{
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 9bd4acf99b..4986909148 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1593,6 +1593,9 @@ $message_parser->decode_message($post_data['bbcode_uid']);
if ($generate_quote)
{
+ // Remove attachment bbcode tags from the quoted message to avoid mixing with the new post attachments if any
+ $message_parser->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#uis', '\\2', $message_parser->message);
+
if ($config['allow_bbcode'])
{
$message_parser->message = $phpbb_container->get('text_formatter.utils')->generate_quote(
diff --git a/phpBB/web.config b/phpBB/web.config
index c7a1240453..99a1fe6023 100644
--- a/phpBB/web.config
+++ b/phpBB/web.config
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
- <configSections>
- <sectionGroup name="system.webServer" >
- <sectionGroup name="rewrite">
- <section name="rules" overrideModeDefault="Allow" />
- </sectionGroup>
- </sectionGroup>
- </configSections>
<system.webServer>
<rewrite>
<rules>
diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php
new file mode 100644
index 0000000000..1588a76e47
--- /dev/null
+++ b/tests/console/user/activate_test.php
@@ -0,0 +1,86 @@
+<?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 Symfony\Component\Console\Application;
+use Symfony\Component\Console\Tester\CommandTester;
+use phpbb\console\command\user\activate;
+
+require_once dirname(__FILE__) . '/base.php';
+
+class phpbb_console_user_activate_test extends phpbb_console_user_base
+{
+ protected $notifications;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->notifications = $this->getMockBuilder('\phpbb\notification\manager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ public function get_command_tester()
+ {
+ $application = new Application();
+ $application->add(new activate(
+ $this->user,
+ $this->db,
+ $this->config,
+ $this->language,
+ $this->log,
+ $this->notifications,
+ $this->user_loader,
+ $this->phpbb_root_path,
+ $this->php_ext
+ ));
+
+ $command = $application->find('user:activate');
+ $this->command_name = $command->getName();
+
+ return new CommandTester($command);
+ }
+
+ public function activate_test_data()
+ {
+ return array(
+ // Test an inactive user
+ array('Test', false, 'USER_ADMIN_ACTIVATED'),
+ array('Test', true, 'CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE'),
+
+ // Test an active user
+ array('Test 2', false, 'CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE'),
+ array('Test 2', true, 'USER_ADMIN_DEACTIVED'),
+
+ // Test a non existent user
+ array('Foo', false, 'NO_USER'),
+ array('Foo', true, 'NO_USER'),
+ );
+ }
+
+ /**
+ * @dataProvider activate_test_data
+ */
+ public function test_activate($username, $deactivate, $expected)
+ {
+ $command_tester = $this->get_command_tester();
+
+ $command_tester->execute(array(
+ 'command' => $this->command_name,
+ 'username' => $username,
+ '--deactivate' => $deactivate,
+ ));
+
+ $this->assertContains($expected, $command_tester->getDisplay());
+ }
+}
diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php
index ee6eee8491..8641bf87b6 100644
--- a/tests/console/user/add_test.php
+++ b/tests/console/user/add_test.php
@@ -15,75 +15,27 @@ use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use phpbb\console\command\user\add;
-require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_user.php';
+require_once dirname(__FILE__) . '/base.php';
-class phpbb_console_command_user_add_test extends phpbb_database_test_case
+class phpbb_console_user_add_test extends phpbb_console_user_base
{
- protected $db;
- protected $config;
- protected $user;
- protected $language;
- protected $passwords_manager;
- protected $command_name;
- protected $question;
- protected $phpbb_root_path;
- protected $php_ext;
-
- public function getDataSet()
- {
- return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
- }
-
- public function setUp()
+ public function get_command_tester()
{
- global $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
-
- $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $phpbb_container = new phpbb_mock_container_builder();
- $phpbb_container->set('cache.driver', new phpbb_mock_cache());
- $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
-
- $cache = $phpbb_container->get('cache.driver');
-
- $config = $this->config = new \phpbb\config\config(array(
- 'board_timezone' => 'UTC',
- 'default_lang' => 'en',
- 'email_enable' => false,
- 'min_name_chars' => 3,
- 'max_name_chars' => 10,
- 'min_pass_chars' => 3,
- 'max_pass_chars' => 10,
- 'pass_complex' => 'PASS_TYPE_ANY',
- ));
-
- $db = $this->db = $this->new_dbal();
-
- $this->language = $this->getMockBuilder('\phpbb\language\language')
- ->disableOriginalConstructor()
- ->getMock();
- $this->language->expects($this->any())
- ->method('lang')
- ->will($this->returnArgument(0));
- $user = $this->user = $this->getMock('\phpbb\user', array(), array(
+ $application = new Application();
+ $application->add(new add(
+ $this->user,
+ $this->db,
+ $this->config,
$this->language,
- '\phpbb\datetime'
+ $this->passwords_manager,
+ $this->phpbb_root_path,
+ $this->php_ext
));
- $driver_helper = new \phpbb\passwords\driver\helper($this->config);
- $passwords_drivers = array(
- 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper),
- 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper),
- 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper),
- 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper),
- );
-
- $passwords_helper = new \phpbb\passwords\helper;
- $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
-
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $phpEx;
-
- parent::setUp();
+ $command = $application->find('user:add');
+ $this->command_name = $command->getName();
+ $this->question = $command->getHelper('question');
+ return new CommandTester($command);
}
public function test_add_no_dialog()
@@ -137,47 +89,4 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case
$this->assertContains('TOO_SHORT', $command_tester->getDisplay());
$this->assertContains('EMAIL_INVALID', $command_tester->getDisplay());
}
-
- public function get_command_tester()
- {
- $application = new Application();
- $application->add(new add(
- $this->user,
- $this->db,
- $this->config,
- $this->language,
- $this->passwords_manager,
- $this->phpbb_root_path,
- $this->php_ext
- ));
-
- $command = $application->find('user:add');
- $this->command_name = $command->getName();
- $this->question = $command->getHelper('question');
- return new CommandTester($command);
- }
-
- public function get_user_id($username)
- {
- $sql = 'SELECT user_id
- FROM ' . USERS_TABLE . '
- WHERE ' . 'username = ' . "'" . $username . "'";
-
- $result = $this->db->sql_query($sql);
-
- $row = $this->db->sql_fetchrow($result);
-
- $this->db->sql_freeresult($result);
-
- return $row['user_id'];
- }
-
- public function getInputStream($input)
- {
- $stream = fopen('php://memory', 'r+', false);
- fputs($stream, $input);
- rewind($stream);
-
- return $stream;
- }
}
diff --git a/tests/console/user/base.php b/tests/console/user/base.php
new file mode 100644
index 0000000000..b84c0bb267
--- /dev/null
+++ b/tests/console/user/base.php
@@ -0,0 +1,121 @@
+<?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.
+*
+*/
+
+abstract class phpbb_console_user_base extends phpbb_database_test_case
+{
+ protected $db;
+ protected $config;
+ protected $user;
+ protected $language;
+ protected $log;
+ protected $passwords_manager;
+ protected $command_name;
+ protected $question;
+ protected $user_loader;
+ protected $phpbb_root_path;
+ protected $php_ext;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
+ public function setUp()
+ {
+ global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->set('cache.driver', new phpbb_mock_cache());
+ $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
+
+ $auth = $this->getMock('\phpbb\auth\auth');
+
+ $cache = $phpbb_container->get('cache.driver');
+
+ $config = $this->config = new \phpbb\config\config(array(
+ 'board_timezone' => 'UTC',
+ 'default_lang' => 'en',
+ 'email_enable' => false,
+ 'min_name_chars' => 3,
+ 'max_name_chars' => 10,
+ 'min_pass_chars' => 3,
+ 'max_pass_chars' => 10,
+ 'pass_complex' => 'PASS_TYPE_ANY',
+ ));
+
+ $db = $this->db = $this->new_dbal();
+
+ $this->language = $this->getMockBuilder('\phpbb\language\language')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->language->expects($this->any())
+ ->method('lang')
+ ->will($this->returnArgument(0));
+ $user = $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->language,
+ '\phpbb\datetime'
+ ));
+
+ $this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
+
+ $driver_helper = new \phpbb\passwords\driver\helper($this->config);
+ $passwords_drivers = array(
+ 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper),
+ 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper),
+ 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper),
+ 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper),
+ );
+
+ $passwords_helper = new \phpbb\passwords\helper;
+ $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
+
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $phpEx;
+
+ $this->log = $this->getMockBuilder('\phpbb\log\log')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $phpbb_container->set('auth.provider.db', new phpbb_mock_auth_provider());
+ $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
+ $provider_collection->add('auth.provider.db');
+ $phpbb_container->set(
+ 'auth.provider_collection',
+ $provider_collection
+ );
+
+ parent::setUp();
+ }
+
+ public function get_user_id($username)
+ {
+ $sql = 'SELECT user_id
+ FROM ' . USERS_TABLE . '
+ WHERE ' . 'username = ' . "'" . $username . "'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ return $row['user_id'];
+ }
+
+ public function getInputStream($input)
+ {
+ $stream = fopen('php://memory', 'r+', false);
+ fputs($stream, $input);
+ rewind($stream);
+
+ return $stream;
+ }
+}
diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php
new file mode 100644
index 0000000000..88f91afab1
--- /dev/null
+++ b/tests/console/user/delete_test.php
@@ -0,0 +1,93 @@
+<?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 Symfony\Component\Console\Application;
+use Symfony\Component\Console\Tester\CommandTester;
+use phpbb\console\command\user\delete;
+
+require_once dirname(__FILE__) . '/base.php';
+
+class phpbb_console_user_delete_test extends phpbb_console_user_base
+{
+ public function get_command_tester()
+ {
+ $application = new Application();
+ $application->add(new delete(
+ $this->user,
+ $this->db,
+ $this->language,
+ $this->log,
+ $this->user_loader,
+ $this->phpbb_root_path,
+ $this->php_ext
+ ));
+
+ $command = $application->find('user:delete');
+ $this->command_name = $command->getName();
+ $this->question = $command->getHelper('question');
+
+ return new CommandTester($command);
+ }
+
+ public function test_delete()
+ {
+ $command_tester = $this->get_command_tester();
+
+ $this->assertEquals(3, $this->get_user_id('Test'));
+
+ $this->question->setInputStream($this->getInputStream("yes\n"));
+
+ $command_tester->execute(array(
+ 'command' => $this->command_name,
+ 'username' => 'Test',
+ '--delete-posts' => false,
+ ));
+
+ $this->assertNull($this->get_user_id('Test'));
+ $this->assertContains('USER_DELETED', $command_tester->getDisplay());
+ }
+
+ public function test_delete_non_user()
+ {
+ $command_tester = $this->get_command_tester();
+
+ $this->assertNull($this->get_user_id('Foo'));
+
+ $this->question->setInputStream($this->getInputStream("yes\n"));
+
+ $command_tester->execute(array(
+ 'command' => $this->command_name,
+ 'username' => 'Foo',
+ '--delete-posts' => false,
+ ));
+
+ $this->assertContains('NO_USER', $command_tester->getDisplay());
+ }
+
+ public function test_delete_cancel()
+ {
+ $command_tester = $this->get_command_tester();
+
+ $this->assertEquals(3, $this->get_user_id('Test'));
+
+ $this->question->setInputStream($this->getInputStream("no\n"));
+
+ $command_tester->execute(array(
+ 'command' => $this->command_name,
+ 'username' => 'Test',
+ '--delete-posts' => false,
+ ));
+
+ $this->assertNotNull($this->get_user_id('Test'));
+ }
+}
diff --git a/tests/console/user/fixtures/config.xml b/tests/console/user/fixtures/config.xml
index fed30dc20d..a988ba463f 100644
--- a/tests/console/user/fixtures/config.xml
+++ b/tests/console/user/fixtures/config.xml
@@ -6,12 +6,14 @@
<column>username</column>
<column>username_clean</column>
<column>user_sig</column>
+ <column>user_type</column>
<row>
<value>1</value>
<value></value>
<value>Guest</value>
<value>guest</value>
<value></value>
+ <value>0</value>
</row>
<row>
<value>2</value>
@@ -19,6 +21,7 @@
<value>Admin</value>
<value>admin</value>
<value></value>
+ <value>3</value>
</row>
<row>
<value>3</value>
@@ -26,6 +29,23 @@
<value>Test</value>
<value>test</value>
<value></value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value></value>
+ <value>Test 2</value>
+ <value>test 2</value>
+ <value></value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value></value>
+ <value>Test Unclean</value>
+ <value>Test Unclean</value>
+ <value></value>
+ <value>0</value>
</row>
</table>
<table name="phpbb_groups">
diff --git a/tests/console/user/reclean_test.php b/tests/console/user/reclean_test.php
new file mode 100644
index 0000000000..1bf0b8ef5a
--- /dev/null
+++ b/tests/console/user/reclean_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 Symfony\Component\Console\Application;
+use Symfony\Component\Console\Tester\CommandTester;
+use phpbb\console\command\user\reclean;
+
+require_once dirname(__FILE__) . '/base.php';
+
+class phpbb_console_user_reclean_test extends phpbb_console_user_base
+{
+ public function get_command_tester()
+ {
+ $application = new Application();
+ $application->add(new reclean(
+ $this->user,
+ $this->db,
+ $this->language
+ ));
+
+ $command = $application->find('user:reclean');
+ $this->command_name = $command->getName();
+
+ return new CommandTester($command);
+ }
+
+ public function test_reclean()
+ {
+ $command_tester = $this->get_command_tester();
+
+ $exit_status = $command_tester->execute(array('command' => $this->command_name));
+ $this->assertSame(0, $exit_status);
+
+ $result = $this->db->sql_query('SELECT user_id FROM ' . USERS_TABLE . " WHERE username_clean = 'test unclean'");
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+ $this->assertNotNull($row['user_id']);
+ }
+}
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index 21397d0f77..367c15a667 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -16,6 +16,18 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
abstract class phpbb_controller_common_helper_route extends phpbb_test_case
{
protected $root_path;
+ private $user;
+ private $config;
+ private $template;
+ private $extension_manager;
+ private $request;
+ private $symfony_request;
+ private $provider;
+ private $filesystem;
+ private $phpbb_path_helper;
+ private $helper;
+ private $router;
+ private $routing_helper;
public function setUp()
{
@@ -62,6 +74,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
protected function generate_route_objects()
{
+ global $request;
+
$this->request = new phpbb_mock_request();
$this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER);
$this->request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER);
@@ -69,6 +83,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER);
$this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER);
+ $request = $this->request;
+
$this->symfony_request = new \phpbb\symfony_request(
$this->request
);
@@ -170,7 +186,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
}
public function helper_url_data_with_rewrite()
@@ -214,7 +230,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
}
public function helper_url_data_absolute()
@@ -258,7 +274,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
}
public function helper_url_data_relative_path()
@@ -302,7 +318,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
}
public function helper_url_data_network()
@@ -346,7 +362,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
}
public function helper_url_data_absolute_with_rewrite()
@@ -390,7 +406,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
}
public function helper_url_data_relative_path_with_rewrite()
@@ -431,7 +447,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
}
public function helper_url_data_network_with_rewrite()
@@ -472,9 +488,41 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
*/
public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{
- $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
+ $this->config = new \phpbb\config\config(['enable_mod_rewrite' => '1']);
+ $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
+ static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
+ }
+
+ public function helper_url_data_force_server_vars()
+ {
+ return array(
+ array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'),
+ array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::ABSOLUTE_URL, 'https://my_server:444/my/board/foo'),
+ array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/app.php/foo'),
+ array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:444/my/board/foo'),
+ array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/app.php/foo'),
+ array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/foo'),
+ array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'app.php/foo'),
+ array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'foo'), );
+ }
+
+ /**
+ * @dataProvider helper_url_data_force_server_vars()
+ */
+ public function test_helper_url_force_server_vars($enable_mod_rewrite, $force_server_vars, $server_name, $server_port, $script_path, $server_protocol, $type, $expected)
+ {
+ $this->config = new \phpbb\config\config(array(
+ 'enable_mod_rewrite' => $enable_mod_rewrite,
+ 'force_server_vars' => $force_server_vars,
+ 'server_name' => $server_name,
+ 'server_port' => $server_port,
+ 'script_path' => $script_path,
+ 'server_protocol' => $server_protocol,
+ ));
+
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
+ static::assertEquals($expected, $this->helper->route('controller1', array(), false, false, $type));
}
}