aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/auth/auth.php19
-rw-r--r--phpBB/phpbb/auth/provider/oauth/oauth.php43
-rw-r--r--phpBB/phpbb/avatar/driver/driver.php16
-rw-r--r--phpBB/phpbb/avatar/driver/driver_interface.php14
-rw-r--r--phpBB/phpbb/avatar/driver/gravatar.php17
-rw-r--r--phpBB/phpbb/avatar/driver/local.php6
-rw-r--r--phpBB/phpbb/avatar/driver/remote.php4
-rw-r--r--phpBB/phpbb/avatar/driver/upload.php16
-rw-r--r--phpBB/phpbb/avatar/manager.php16
-rw-r--r--phpBB/phpbb/cache/driver/base.php5
-rw-r--r--phpBB/phpbb/cache/driver/file.php5
-rw-r--r--phpBB/phpbb/captcha/plugins/qa.php44
-rw-r--r--phpBB/phpbb/composer.json7
-rw-r--r--phpBB/phpbb/console/command/cron/run.php1
-rw-r--r--phpBB/phpbb/content_visibility.php122
-rw-r--r--phpBB/phpbb/controller/helper.php25
-rw-r--r--phpBB/phpbb/cron/manager.php2
-rw-r--r--phpBB/phpbb/db/driver/driver.php1
-rw-r--r--phpBB/phpbb/db/driver/sqlite3.php1
-rw-r--r--phpBB/phpbb/db/migration/data/v310/alpha1.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/alpha2.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/alpha3.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/beta1.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/beta2.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/beta3.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/beta4.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/gold.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php13
-rw-r--r--phpBB/phpbb/db/migration/data/v310/rc1.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/rc2.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/rc3.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/rc4.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/rc5.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v310/rc6.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/add_log_time_index.php46
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/increase_size_of_dateformat.php35
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/m_pm_report.php64
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php77
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v311.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v3110.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v3110rc1.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v312.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v312rc1.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v313.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v313rc1.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v313rc2.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v314.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v314rc1.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v314rc2.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v315.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v315rc1.php5
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v316.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v316rc1.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v317.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v317pl1.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v317rc1.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v318.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v318rc1.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v319.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v319rc1.php36
-rw-r--r--phpBB/phpbb/db/migration/helper.php32
-rw-r--r--phpBB/phpbb/db/migration/tool/config.php5
-rw-r--r--phpBB/phpbb/db/migration/tool/config_text.php5
-rw-r--r--phpBB/phpbb/db/migration/tool/module.php201
-rw-r--r--phpBB/phpbb/db/migration/tool/permission.php5
-rw-r--r--phpBB/phpbb/db/migrator.php205
-rw-r--r--phpBB/phpbb/db/migrator_output_handler_interface.php10
-rw-r--r--phpBB/phpbb/db/tools.php7
-rw-r--r--phpBB/phpbb/event/kernel_exception_subscriber.php8
-rw-r--r--phpBB/phpbb/feed/base.php37
-rw-r--r--phpBB/phpbb/feed/helper.php6
-rw-r--r--phpBB/phpbb/file_downloader.php2
-rw-r--r--phpBB/phpbb/log/log.php6
-rw-r--r--phpBB/phpbb/notification/manager.php40
-rw-r--r--phpBB/phpbb/notification/method/messenger_base.php4
-rw-r--r--phpBB/phpbb/notification/type/approve_post.php2
-rw-r--r--phpBB/phpbb/notification/type/approve_topic.php2
-rw-r--r--phpBB/phpbb/notification/type/bookmark.php2
-rw-r--r--phpBB/phpbb/notification/type/post.php2
-rw-r--r--phpBB/phpbb/notification/type/post_in_queue.php2
-rw-r--r--phpBB/phpbb/notification/type/quote.php6
-rw-r--r--phpBB/phpbb/notification/type/report_pm.php4
-rw-r--r--phpBB/phpbb/notification/type/topic_in_queue.php2
-rw-r--r--phpBB/phpbb/passwords/driver/salted_md5.php2
-rw-r--r--phpBB/phpbb/permissions.php27
-rw-r--r--phpBB/phpbb/plupload/plupload.php2
-rw-r--r--phpBB/phpbb/profilefields/type/type_int.php6
-rw-r--r--phpBB/phpbb/profilefields/type/type_string.php6
-rw-r--r--phpBB/phpbb/profilefields/type/type_text.php6
-rw-r--r--phpBB/phpbb/profilefields/type/type_url.php6
-rw-r--r--phpBB/phpbb/recursive_dot_prefix_filter_iterator.php2
-rw-r--r--phpBB/phpbb/request/request.php4
-rw-r--r--phpBB/phpbb/search/base.php46
-rw-r--r--phpBB/phpbb/search/fulltext_mysql.php76
-rw-r--r--phpBB/phpbb/search/fulltext_native.php88
-rw-r--r--phpBB/phpbb/search/fulltext_postgres.php76
-rw-r--r--phpBB/phpbb/search/fulltext_sphinx.php56
-rw-r--r--phpBB/phpbb/session.php100
-rw-r--r--phpBB/phpbb/template/asset.php19
-rw-r--r--phpBB/phpbb/template/twig/twig.php2
-rw-r--r--phpBB/phpbb/user.php2
-rw-r--r--phpBB/phpbb/user_loader.php7
-rw-r--r--phpBB/phpbb/version_helper.php13
103 files changed, 1900 insertions, 363 deletions
diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php
index b59f0e60ec..b7634e04ce 100644
--- a/phpBB/phpbb/auth/auth.php
+++ b/phpBB/phpbb/auth/auth.php
@@ -928,6 +928,7 @@ class auth
function login($username, $password, $autologin = false, $viewonline = 1, $admin = 0)
{
global $db, $user, $phpbb_root_path, $phpEx, $phpbb_container;
+ global $phpbb_dispatcher;
$provider_collection = $phpbb_container->get('auth.provider_collection');
@@ -982,6 +983,24 @@ class auth
redirect($url);
}
+ /**
+ * Event is triggered after checking for valid username and password, and before the actual session creation.
+ *
+ * @event core.auth_login_session_create_before
+ * @var array login Variable containing login array
+ * @var bool admin Boolean variable whether user is logging into the ACP
+ * @var string username Username of user to log in
+ * @var bool autologin Boolean variable signaling whether login is triggered via auto login
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'login',
+ 'admin',
+ 'username',
+ 'autologin',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.auth_login_session_create_before', compact($vars)));
+
// If login succeeded, we will log the user in... else we pass the login array through...
if ($login['status'] == LOGIN_SUCCESS)
{
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php
index be0fbf5831..bd2a414033 100644
--- a/phpBB/phpbb/auth/provider/oauth/oauth.php
+++ b/phpBB/phpbb/auth/provider/oauth/oauth.php
@@ -98,6 +98,13 @@ class oauth extends \phpbb\auth\provider\base
protected $phpbb_container;
/**
+ * phpBB event dispatcher
+ *
+ * @var \phpbb\event\dispatcher_interface
+ */
+ protected $dispatcher;
+
+ /**
* phpBB root path
*
* @var string
@@ -124,10 +131,11 @@ class oauth extends \phpbb\auth\provider\base
* @param \phpbb\di\service_collection $service_providers Contains \phpbb\auth\provider\oauth\service_interface
* @param string $users_table
* @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container
+ * @param \phpbb\event\dispatcher_interface $dispatcher phpBB event dispatcher
* @param string $phpbb_root_path
* @param string $php_ext
*/
- public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext)
+ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $php_ext)
{
$this->db = $db;
$this->config = $config;
@@ -139,6 +147,7 @@ class oauth extends \phpbb\auth\provider\base
$this->service_providers = $service_providers;
$this->users_table = $users_table;
$this->phpbb_container = $phpbb_container;
+ $this->dispatcher = $dispatcher;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
}
@@ -238,6 +247,18 @@ class oauth extends \phpbb\auth\provider\base
// Update token storage to store the user_id
$storage->set_user_id($row['user_id']);
+ /**
+ * Event is triggered after user is successfuly logged in via OAuth.
+ *
+ * @event core.auth_oauth_login_after
+ * @var array row User row
+ * @since 3.1.11-RC1
+ */
+ $vars = array(
+ 'row',
+ );
+ extract($this->dispatcher->trigger_event('core.auth_oauth_login_after', compact($vars)));
+
// The user is now authenticated and can be logged in
return array(
'status' => LOGIN_SUCCESS,
@@ -271,7 +292,13 @@ class oauth extends \phpbb\auth\provider\base
}
$uri_factory = new \OAuth\Common\Http\Uri\UriFactory();
- $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(\phpbb\request\request_interface::SERVER));
+ $super_globals = $this->request->get_super_global(\phpbb\request\request_interface::SERVER);
+ if (!empty($super_globals['HTTP_X_FORWARDED_PROTO']) && $super_globals['HTTP_X_FORWARDED_PROTO'] === 'https')
+ {
+ $super_globals['HTTPS'] = 'on';
+ $super_globals['SERVER_PORT'] = 443;
+ }
+ $current_uri = $uri_factory->createFromSuperGlobalArray($super_globals);
$current_uri->setQuery($query);
$this->current_uri = $current_uri;
@@ -536,6 +563,18 @@ class oauth extends \phpbb\auth\provider\base
$sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . '
' . $this->db->sql_build_array('INSERT', $data);
$this->db->sql_query($sql);
+
+ /**
+ * Event is triggered after user links account.
+ *
+ * @event core.auth_oauth_link_after
+ * @var array data User row
+ * @since 3.1.11-RC1
+ */
+ $vars = array(
+ 'data',
+ );
+ extract($this->dispatcher->trigger_event('core.auth_oauth_link_after', compact($vars)));
}
/**
diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php
index b3ced7edf7..ad186635f2 100644
--- a/phpBB/phpbb/avatar/driver/driver.php
+++ b/phpBB/phpbb/avatar/driver/driver.php
@@ -120,6 +120,22 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
}
/**
+ * {@inheritdoc}
+ */
+ public function get_config_name()
+ {
+ return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_acp_template_name()
+ {
+ return 'acp_avatar_options_' . $this->get_config_name() . '.html';
+ }
+
+ /**
* Sets the name of the driver.
*
* @param string $name Driver name
diff --git a/phpBB/phpbb/avatar/driver/driver_interface.php b/phpBB/phpbb/avatar/driver/driver_interface.php
index 835609745a..7d6c2cff8a 100644
--- a/phpBB/phpbb/avatar/driver/driver_interface.php
+++ b/phpBB/phpbb/avatar/driver/driver_interface.php
@@ -26,6 +26,13 @@ interface driver_interface
public function get_name();
/**
+ * Returns the config name of the driver. To be used in accessing the CONFIG variables.
+ *
+ * @return string Config name of driver.
+ */
+ public function get_config_name();
+
+ /**
* Get the avatar url and dimensions
*
* @param array $row User data or group data that has been cleaned with
@@ -110,4 +117,11 @@ interface driver_interface
* @return string Avatar driver's template name
*/
public function get_template_name();
+
+ /**
+ * Get the avatar driver's template name (ACP)
+ *
+ * @return string Avatar driver's template name
+ */
+ public function get_acp_template_name();
}
diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php
index 2082e0fd02..7a43b55852 100644
--- a/phpBB/phpbb/avatar/driver/gravatar.php
+++ b/phpBB/phpbb/avatar/driver/gravatar.php
@@ -52,8 +52,8 @@ class gravatar extends \phpbb\avatar\driver\driver
public function prepare_form($request, $template, $user, $row, &$error)
{
$template->assign_vars(array(
- 'AVATAR_GRAVATAR_WIDTH' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_gravatar_width', 0),
- 'AVATAR_GRAVATAR_HEIGHT' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_gravatar_width', 0),
+ 'AVATAR_GRAVATAR_WIDTH' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_gravatar_width', ''),
+ 'AVATAR_GRAVATAR_HEIGHT' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_gravatar_width', ''),
'AVATAR_GRAVATAR_EMAIL' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar']) ? $row['avatar'] : '',
));
@@ -172,6 +172,8 @@ class gravatar extends \phpbb\avatar\driver\driver
*/
protected function get_gravatar_url($row)
{
+ global $phpbb_dispatcher;
+
$url = self::GRAVATAR_URL;
$url .= md5(strtolower(trim($row['avatar'])));
@@ -180,6 +182,17 @@ class gravatar extends \phpbb\avatar\driver\driver
$url .= '?s=' . max($row['avatar_width'], $row['avatar_height']);
}
+ /**
+ * Modify gravatar url
+ *
+ * @event core.get_gravatar_url_after
+ * @var string row User data or group data
+ * @var string url Gravatar URL
+ * @since 3.1.7-RC1
+ */
+ $vars = array('row', 'url');
+ extract($phpbb_dispatcher->trigger_event('core.get_gravatar_url_after', compact($vars)));
+
return $url;
}
}
diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php
index 36087f8ba0..75c384f31e 100644
--- a/phpBB/phpbb/avatar/driver/local.php
+++ b/phpBB/phpbb/avatar/driver/local.php
@@ -84,11 +84,13 @@ class local extends \phpbb\avatar\driver\driver
'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'],
'AVATAR_NAME' => $img['name'],
'AVATAR_FILE' => $img['filename'],
+ 'CHECKED' => $img['file'] === $row['avatar'],
));
$template->assign_block_vars('avatar_local_row.avatar_local_option', array(
'AVATAR_FILE' => $img['filename'],
- 'S_OPTIONS_AVATAR' => $img['filename']
+ 'S_OPTIONS_AVATAR' => $img['filename'],
+ 'CHECKED' => $img['file'] === $row['avatar'],
));
$col_count = ($col_count + 1) % $table_cols;
@@ -182,7 +184,7 @@ class local extends \phpbb\avatar\driver\driver
}
$cat = ($path == $file_path) ? $user->lang['NO_AVATAR_CATEGORY'] : str_replace("$path/", '', $file_path);
$avatar_list[$cat][$image] = array(
- 'file' => ($cat != $user->lang['NO_AVATAR_CATEGORY']) ? rawurlencode($cat) . '/' . rawurlencode($image) : rawurlencode($image),
+ 'file' => ($cat != $user->lang['NO_AVATAR_CATEGORY']) ? str_replace('%2F', '/', rawurlencode($cat)) . '/' . rawurlencode($image) : rawurlencode($image),
'filename' => rawurlencode($image),
'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))),
'width' => $dims[0],
diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php
index 4b0ee3f06f..bec54897b2 100644
--- a/phpBB/phpbb/avatar/driver/remote.php
+++ b/phpBB/phpbb/avatar/driver/remote.php
@@ -36,8 +36,8 @@ class remote extends \phpbb\avatar\driver\driver
public function prepare_form($request, $template, $user, $row, &$error)
{
$template->assign_vars(array(
- 'AVATAR_REMOTE_WIDTH' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_remote_width', 0),
- 'AVATAR_REMOTE_HEIGHT' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_remote_width', 0),
+ 'AVATAR_REMOTE_WIDTH' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_remote_width', ''),
+ 'AVATAR_REMOTE_HEIGHT' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_remote_width', ''),
'AVATAR_REMOTE_URL' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar']) ? $row['avatar'] : '',
));
diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php
index a1d84345e1..cb8dfcad4f 100644
--- a/phpBB/phpbb/avatar/driver/upload.php
+++ b/phpBB/phpbb/avatar/driver/upload.php
@@ -53,7 +53,7 @@ class upload extends \phpbb\avatar\driver\driver
/**
* {@inheritdoc}
*/
- public function get_data($row, $ignore_config = false)
+ public function get_data($row)
{
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $this->path_helper->get_web_root_path();
@@ -167,17 +167,29 @@ class upload extends \phpbb\avatar\driver\driver
$destination = '';
}
+ $filedata = array(
+ 'filename' => $file->get('filename'),
+ 'filesize' => $file->get('filesize'),
+ 'mimetype' => $file->get('mimetype'),
+ 'extension' => $file->get('extension'),
+ 'physical_filename' => $file->get('realname'),
+ 'real_filename' => $file->get('uploadname'),
+ );
+
/**
* Before moving new file in place (and eventually overwriting the existing avatar with the newly uploaded avatar)
*
* @event core.avatar_driver_upload_move_file_before
+ * @var array filedata Array containing uploaded file data
* @var string destination Destination directory where the file is going to be moved
* @var string prefix Prefix for the avatar filename
* @var array row Array with avatar row data
* @var array error Array of errors, if filled in by this event file will not be moved
* @since 3.1.6-RC1
+ * @changed 3.1.9-RC1 Added filedata
*/
$vars = array(
+ 'filedata',
'destination',
'prefix',
'row',
@@ -185,6 +197,8 @@ class upload extends \phpbb\avatar\driver\driver
);
extract($this->dispatcher->trigger_event('core.avatar_driver_upload_move_file_before', compact($vars)));
+ unset($filedata);
+
if (!sizeof($error))
{
// Move file and overwrite any existing image
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php
index 8d83152ed6..26eb17c265 100644
--- a/phpBB/phpbb/avatar/manager.php
+++ b/phpBB/phpbb/avatar/manager.php
@@ -246,7 +246,7 @@ class manager
*/
public function is_enabled($driver)
{
- $config_name = $this->get_driver_config_name($driver);
+ $config_name = $driver->get_config_name();
return $this->config["allow_avatar_{$config_name}"];
}
@@ -260,7 +260,7 @@ class manager
*/
public function get_avatar_settings($driver)
{
- $config_name = $this->get_driver_config_name($driver);
+ $config_name = $driver->get_config_name();
return array(
'allow_avatar_' . $config_name => array('lang' => 'ALLOW_' . strtoupper(str_replace('\\', '_', $config_name)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
@@ -268,18 +268,6 @@ class manager
}
/**
- * Get the config name of an avatar driver
- *
- * @param object $driver Avatar driver object
- *
- * @return string Avatar driver config name
- */
- public function get_driver_config_name($driver)
- {
- return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($driver));
- }
-
- /**
* Replace "error" strings with their real, localized form
*
* @param \phpbb\user phpBB User object
diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php
index 4c20ad916d..53c50eeda3 100644
--- a/phpBB/phpbb/cache/driver/base.php
+++ b/phpBB/phpbb/cache/driver/base.php
@@ -61,6 +61,11 @@ abstract class base implements \phpbb\cache\driver\driver_interface
unset($this->sql_rowset);
unset($this->sql_row_pointer);
+ if (function_exists('opcache_reset'))
+ {
+ @opcache_reset();
+ }
+
$this->vars = array();
$this->sql_rowset = array();
$this->sql_row_pointer = array();
diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php
index 9a7c4aec7f..fae4614039 100644
--- a/phpBB/phpbb/cache/driver/file.php
+++ b/phpBB/phpbb/cache/driver/file.php
@@ -568,6 +568,11 @@ class file extends \phpbb\cache\driver\base
fclose($handle);
+ if (function_exists('opcache_invalidate'))
+ {
+ @opcache_invalidate($file);
+ }
+
if (!function_exists('phpbb_chmod'))
{
global $phpbb_root_path;
diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php
index 2771369e57..a9d133d8f2 100644
--- a/phpBB/phpbb/captcha/plugins/qa.php
+++ b/phpBB/phpbb/captcha/plugins/qa.php
@@ -100,6 +100,28 @@ class qa
$db->sql_freeresult($result);
}
+ // final fallback to any language
+ if (!sizeof($this->question_ids))
+ {
+ $this->question_lang = '';
+
+ $sql = 'SELECT q.question_id, q.lang_iso
+ FROM ' . $this->table_captcha_questions . ' q, ' . $this->table_captcha_answers . ' a
+ WHERE q.question_id = a.question_id
+ GROUP BY lang_iso';
+ $result = $db->sql_query($sql, 7200);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (empty($this->question_lang))
+ {
+ $this->question_lang = $row['lang_iso'];
+ }
+ $this->question_ids[$row['question_id']] = $row['question_id'];
+ }
+ $db->sql_freeresult($result);
+ }
+
// okay, if there is a confirm_id, we try to load that confirm's state. If not, we try to find one
if (!$this->load_answer() && (!$this->load_confirm_id() || !$this->load_answer()))
{
@@ -198,19 +220,25 @@ class qa
*/
function get_template()
{
- global $template;
+ global $phpbb_log, $template, $user;
if ($this->is_solved())
{
return false;
}
+ else if (empty($this->question_text) || !count($this->question_ids))
+ {
+ /** @var \phpbb\log\log_interface $phpbb_log */
+ $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING')));
+ return false;
+ }
else
{
$template->assign_vars(array(
- 'QA_CONFIRM_QUESTION' => $this->question_text,
- 'QA_CONFIRM_ID' => $this->confirm_id,
- 'S_CONFIRM_CODE' => true,
- 'S_TYPE' => $this->type,
+ 'QA_CONFIRM_QUESTION' => $this->question_text,
+ 'QA_CONFIRM_ID' => $this->confirm_id,
+ 'S_CONFIRM_CODE' => true,
+ 'S_TYPE' => $this->type,
));
return 'captcha_qa.html';
@@ -364,13 +392,15 @@ class qa
*/
function validate()
{
- global $user;
+ global $phpbb_log, $user;
$error = '';
if (!sizeof($this->question_ids))
{
- return false;
+ /** @var \phpbb\log\log_interface $phpbb_log */
+ $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING')));
+ return $user->lang('CONFIRM_QUESTION_MISSING');
}
if (!$this->confirm_id)
diff --git a/phpBB/phpbb/composer.json b/phpBB/phpbb/composer.json
index 513d7e4559..6b3888ef64 100644
--- a/phpBB/phpbb/composer.json
+++ b/phpBB/phpbb/composer.json
@@ -23,5 +23,10 @@
},
"require": {
"php": ">=5.3.3"
- }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.1.x-dev"
+ }
+ }
}
diff --git a/phpBB/phpbb/console/command/cron/run.php b/phpBB/phpbb/console/command/cron/run.php
index 72ad1205ef..a9648fcd41 100644
--- a/phpBB/phpbb/console/command/cron/run.php
+++ b/phpBB/phpbb/console/command/cron/run.php
@@ -50,6 +50,7 @@ class run extends \phpbb\console\command\command
$this
->setName('cron:run')
->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_RUN'))
+ ->setHelp($this->user->lang('CLI_HELP_CRON_RUN'))
->addArgument('name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1'))
;
}
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 0ba0489cb7..bf7dc2c703 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -417,13 +417,46 @@ class content_visibility
return array();
}
+ if (!function_exists('truncate_string'))
+ {
+ include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext);
+ }
+
$data = array(
'post_visibility' => (int) $visibility,
'post_delete_user' => (int) $user_id,
'post_delete_time' => ((int) $time) ?: time(),
'post_delete_reason' => truncate_string($reason, 255, 255, false),
);
-
+ /**
+ * Perform actions right before the query to change post visibility
+ *
+ * @event core.set_post_visibility_before_sql
+ * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
+ * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified.
+ * @var int topic_id Topic of the post IDs to be modified.
+ * @var int forum_id Forum ID that the topic_id resides in.
+ * @var int user_id User ID doing this action.
+ * @var int timestamp Timestamp of this action.
+ * @var string reason Reason specified by the user for this change.
+ * @var bool is_starter Are we changing the topic's starter?
+ * @var bool is_latest Are we changing the topic's latest post?
+ * @var array data The data array for this action.
+ * @since 3.1.10-RC1
+ */
+ $vars = array(
+ 'visibility',
+ 'post_id',
+ 'topic_id',
+ 'forum_id',
+ 'user_id',
+ 'timestamp',
+ 'reason',
+ 'is_starter',
+ 'is_latest',
+ 'data',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_before_sql', compact($vars)));
$sql = 'UPDATE ' . $this->posts_table . '
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
WHERE ' . $this->db->sql_in_set('post_id', $post_ids);
@@ -580,7 +613,35 @@ class content_visibility
WHERE topic_id = ' . (int) $topic_id;
$this->db->sql_query($sql);
}
-
+ /**
+ * Perform actions after all steps to changing post visibility
+ *
+ * @event core.set_post_visibility_after
+ * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
+ * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified.
+ * @var int topic_id Topic of the post IDs to be modified.
+ * @var int forum_id Forum ID that the topic_id resides in.
+ * @var int user_id User ID doing this action.
+ * @var int timestamp Timestamp of this action.
+ * @var string reason Reason specified by the user for this change.
+ * @var bool is_starter Are we changing the topic's starter?
+ * @var bool is_latest Are we changing the topic's latest post?
+ * @var array data The data array for this action.
+ * @since 3.1.10-RC1
+ */
+ $vars = array(
+ 'visibility',
+ 'post_id',
+ 'topic_id',
+ 'forum_id',
+ 'user_id',
+ 'timestamp',
+ 'reason',
+ 'is_starter',
+ 'is_latest',
+ 'data',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_after', compact($vars)));
return $data;
}
@@ -628,6 +689,11 @@ class content_visibility
}
}
+ if (!function_exists('truncate_string'))
+ {
+ include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext);
+ }
+
// Note, we do not set a reason for the posts, just for the topic
$data = array(
'topic_visibility' => (int) $visibility,
@@ -635,7 +701,31 @@ class content_visibility
'topic_delete_time' => ((int) $time) ?: time(),
'topic_delete_reason' => truncate_string($reason, 255, 255, false),
);
-
+ /**
+ * Perform actions right before the query to change topic visibility
+ *
+ * @event core.set_topic_visibility_before_sql
+ * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
+ * @var int topic_id Topic of the post IDs to be modified.
+ * @var int forum_id Forum ID that the topic_id resides in.
+ * @var int user_id User ID doing this action.
+ * @var int timestamp Timestamp of this action.
+ * @var string reason Reason specified by the user for this change.
+ * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state.
+ * @var array data The data array for this action.
+ * @since 3.1.10-RC1
+ */
+ $vars = array(
+ 'visibility',
+ 'topic_id',
+ 'forum_id',
+ 'user_id',
+ 'timestamp',
+ 'reason',
+ 'force_update_all',
+ 'data',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_before_sql', compact($vars)));
$sql = 'UPDATE ' . $this->topics_table . '
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
WHERE topic_id = ' . (int) $topic_id;
@@ -660,7 +750,31 @@ class content_visibility
{
$this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true);
}
-
+ /**
+ * Perform actions after all steps to changing topic visibility
+ *
+ * @event core.set_topic_visibility_after
+ * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE}
+ * @var int topic_id Topic of the post IDs to be modified.
+ * @var int forum_id Forum ID that the topic_id resides in.
+ * @var int user_id User ID doing this action.
+ * @var int timestamp Timestamp of this action.
+ * @var string reason Reason specified by the user for this change.
+ * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state.
+ * @var array data The data array for this action.
+ * @since 3.1.10-RC1
+ */
+ $vars = array(
+ 'visibility',
+ 'topic_id',
+ 'forum_id',
+ 'user_id',
+ 'timestamp',
+ 'reason',
+ 'force_update_all',
+ 'data',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_after', compact($vars)));
return $data;
}
diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php
index a07a396e73..ce6bfba981 100644
--- a/phpBB/phpbb/controller/helper.php
+++ b/phpBB/phpbb/controller/helper.php
@@ -71,7 +71,8 @@ class helper
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param \phpbb\config\config $config Config object
- * @param \phpbb\controller\provider $provider Path provider
+ *
+ * @param \phpbb\controller\provider $provider Path provider
* @param \phpbb\extension\manager $manager Extension manager object
* @param \phpbb\symfony_request $symfony_request Symfony Request object
* @param \phpbb\request\request_interface $request phpBB request object
@@ -100,12 +101,15 @@ class helper
* @param string $page_title The title of the page to output
* @param int $status_code The status code to be sent to the page header
* @param bool $display_online_list Do we display online users list
+ * @param int $item_id Restrict online users to item id
+ * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id
+ * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers.
*
* @return Response object containing rendered page
*/
- public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false)
+ public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false)
{
- page_header($page_title, $display_online_list);
+ page_header($page_title, $display_online_list, $item_id, $item, $send_headers);
$this->template->set_filenames(array(
'body' => $template_file,
@@ -113,7 +117,9 @@ class helper
page_footer(true, false, false);
- return new Response($this->template->assign_display('body'), $status_code);
+ $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array();
+
+ return new Response($this->template->assign_display('body'), $status_code, $headers);
}
/**
@@ -138,6 +144,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);
@@ -153,7 +168,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/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php
index 079ce8107e..9bd30a0a5b 100644
--- a/phpBB/phpbb/cron/manager.php
+++ b/phpBB/phpbb/cron/manager.php
@@ -110,7 +110,7 @@ class manager
* Web runner uses this method to resolve names to tasks.
*
* @param string $name Name of the task to look up.
- * @return \phpbb\cron\task\task A task corresponding to the given name, or null.
+ * @return \phpbb\cron\task\wrapper A wrapped task corresponding to the given name, or null.
*/
public function find_task($name)
{
diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php
index 1b49775b32..01dd66cd6e 100644
--- a/phpBB/phpbb/db/driver/driver.php
+++ b/phpBB/phpbb/db/driver/driver.php
@@ -897,6 +897,7 @@ abstract class driver implements driver_interface
<html dir="ltr">
<head>
<meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>SQL Report</title>
<link href="' . htmlspecialchars($phpbb_path_helper->update_web_root_path($phpbb_root_path) . $phpbb_path_helper->get_adm_relative_path()) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php
index 4e3e0d3329..cc3352af34 100644
--- a/phpBB/phpbb/db/driver/sqlite3.php
+++ b/phpBB/phpbb/db/driver/sqlite3.php
@@ -48,6 +48,7 @@ class sqlite3 extends \phpbb\db\driver\driver
try
{
$this->dbo = new \SQLite3($this->server, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
+ $this->dbo->busyTimeout(60000);
$this->db_connect_id = true;
}
catch (\Exception $e)
diff --git a/phpBB/phpbb/db/migration/data/v310/alpha1.php b/phpBB/phpbb/db/migration/data/v310/alpha1.php
index 1df85bc64c..4a48d2830a 100644
--- a/phpBB/phpbb/db/migration/data/v310/alpha1.php
+++ b/phpBB/phpbb/db/migration/data/v310/alpha1.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class alpha1 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-a1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/alpha2.php b/phpBB/phpbb/db/migration/data/v310/alpha2.php
index 78bc755ec9..bfbcc4f6f5 100644
--- a/phpBB/phpbb/db/migration/data/v310/alpha2.php
+++ b/phpBB/phpbb/db/migration/data/v310/alpha2.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class alpha2 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-a2', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/alpha3.php b/phpBB/phpbb/db/migration/data/v310/alpha3.php
index 574d19d2f4..bb0f904fd4 100644
--- a/phpBB/phpbb/db/migration/data/v310/alpha3.php
+++ b/phpBB/phpbb/db/migration/data/v310/alpha3.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class alpha3 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-a3', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/beta1.php b/phpBB/phpbb/db/migration/data/v310/beta1.php
index 84887bd58e..9feba5235d 100644
--- a/phpBB/phpbb/db/migration/data/v310/beta1.php
+++ b/phpBB/phpbb/db/migration/data/v310/beta1.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class beta1 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-b1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/beta2.php b/phpBB/phpbb/db/migration/data/v310/beta2.php
index 458e305c7b..d5e31ce4cb 100644
--- a/phpBB/phpbb/db/migration/data/v310/beta2.php
+++ b/phpBB/phpbb/db/migration/data/v310/beta2.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class beta2 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-b2', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/beta3.php b/phpBB/phpbb/db/migration/data/v310/beta3.php
index a6c62bf936..78c61e8e90 100644
--- a/phpBB/phpbb/db/migration/data/v310/beta3.php
+++ b/phpBB/phpbb/db/migration/data/v310/beta3.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class beta3 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-b3', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/beta4.php b/phpBB/phpbb/db/migration/data/v310/beta4.php
index 3e91d95178..e634785c38 100644
--- a/phpBB/phpbb/db/migration/data/v310/beta4.php
+++ b/phpBB/phpbb/db/migration/data/v310/beta4.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class beta4 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-b4', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/gold.php b/phpBB/phpbb/db/migration/data/v310/gold.php
index e84c7ee951..188851f87d 100644
--- a/phpBB/phpbb/db/migration/data/v310/gold.php
+++ b/phpBB/phpbb/db/migration/data/v310/gold.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class gold extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php
index aad8e44681..295f2d2a14 100644
--- a/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php
+++ b/phpBB/phpbb/db/migration/data/v310/passwords_convert_p1.php
@@ -56,19 +56,16 @@ class passwords_convert_p1 extends \phpbb\db\migration\migration
{
// Use $CP$ prefix for passwords that need to
// be converted and set pass convert to false.
- $update_users[$user_id] = array(
- 'user_password' => '$CP$' . $row['user_password'],
- 'user_pass_convert' => 0,
- );
+ $update_users[$user_id] = '$CP$' . $row['user_password'];
}
}
$this->db->sql_freeresult($result);
- foreach ($update_users as $user_id => $user_data)
+ foreach ($update_users as $user_id => $user_password)
{
- $sql = 'UPDATE ' . $this->table_prefix . 'users
- SET ' . $this->db->sql_build_array('UPDATE', $user_data) . '
- WHERE user_id = ' . $user_id;
+ $sql = 'UPDATE ' . $this->table_prefix . "users
+ SET user_password = '" . $this->db->sql_escape($user_password) . "'
+ WHERE user_id = $user_id";
$this->sql_query($sql);
}
diff --git a/phpBB/phpbb/db/migration/data/v310/rc1.php b/phpBB/phpbb/db/migration/data/v310/rc1.php
index 10ba7fefff..751208c6ca 100644
--- a/phpBB/phpbb/db/migration/data/v310/rc1.php
+++ b/phpBB/phpbb/db/migration/data/v310/rc1.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class rc1 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-RC1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/rc2.php b/phpBB/phpbb/db/migration/data/v310/rc2.php
index e1323659da..5cd0393a13 100644
--- a/phpBB/phpbb/db/migration/data/v310/rc2.php
+++ b/phpBB/phpbb/db/migration/data/v310/rc2.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class rc2 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-RC2', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/rc3.php b/phpBB/phpbb/db/migration/data/v310/rc3.php
index 0e6a452251..9fb483ef6a 100644
--- a/phpBB/phpbb/db/migration/data/v310/rc3.php
+++ b/phpBB/phpbb/db/migration/data/v310/rc3.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class rc3 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-RC3', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/rc4.php b/phpBB/phpbb/db/migration/data/v310/rc4.php
index 47de8291c1..0d756c762c 100644
--- a/phpBB/phpbb/db/migration/data/v310/rc4.php
+++ b/phpBB/phpbb/db/migration/data/v310/rc4.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class rc4 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-RC4', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/rc5.php b/phpBB/phpbb/db/migration/data/v310/rc5.php
index 5b6f70e32e..d92537d877 100644
--- a/phpBB/phpbb/db/migration/data/v310/rc5.php
+++ b/phpBB/phpbb/db/migration/data/v310/rc5.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class rc5 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-RC5', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v310/rc6.php b/phpBB/phpbb/db/migration/data/v310/rc6.php
index b84f2edcc9..1df502a1e4 100644
--- a/phpBB/phpbb/db/migration/data/v310/rc6.php
+++ b/phpBB/phpbb/db/migration/data/v310/rc6.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v310;
class rc6 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.0-RC6', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/add_log_time_index.php b/phpBB/phpbb/db/migration/data/v31x/add_log_time_index.php
new file mode 100644
index 0000000000..f53eedcd49
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/add_log_time_index.php
@@ -0,0 +1,46 @@
+<?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 add_log_time_index extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v319',
+ );
+ }
+
+ public function update_schema()
+ {
+ return array(
+ 'add_index' => array(
+ $this->table_prefix . 'log' => array(
+ 'log_time' => array('log_time'),
+ ),
+ ),
+ );
+ }
+
+ public function revert_schema()
+ {
+ return array(
+ 'drop_keys' => array(
+ $this->table_prefix . 'log' => array(
+ 'log_time',
+ ),
+ ),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/increase_size_of_dateformat.php b/phpBB/phpbb/db/migration/data/v31x/increase_size_of_dateformat.php
new file mode 100644
index 0000000000..bdf83f3d62
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/increase_size_of_dateformat.php
@@ -0,0 +1,35 @@
+<?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 increase_size_of_dateformat extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v317',
+ );
+ }
+
+ public function update_schema()
+ {
+ return array(
+ 'change_columns' => array(
+ $this->table_prefix . 'users' => array(
+ 'user_dateformat' => array('VCHAR_UNI:64', 'd M Y H:i'),
+ ),
+ ),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/m_pm_report.php b/phpBB/phpbb/db/migration/data/v31x/m_pm_report.php
new file mode 100644
index 0000000000..9b5710c639
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/m_pm_report.php
@@ -0,0 +1,64 @@
+<?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 m_pm_report extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v31x\v316rc1');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('permission.add', array('m_pm_report', true, 'm_report')),
+ array('custom', array(
+ array($this, 'update_module_auth'),
+ ),
+ ),
+ );
+ }
+
+ public function revert_data()
+ {
+ return array(
+ array('permission.remove', array('m_pm_report')),
+ array('custom', array(
+ array($this, 'revert_module_auth'),
+ ),
+ ),
+ );
+ }
+
+ public function update_module_auth()
+ {
+ $sql = 'UPDATE ' . MODULES_TABLE . "
+ SET module_auth = 'acl_m_pm_report'
+ WHERE module_class = 'mcp'
+ AND module_basename = 'mcp_pm_reports'
+ AND module_auth = 'aclf_m_report'";
+ $this->db->sql_query($sql);
+ }
+
+ public function revert_module_auth()
+ {
+ $sql = 'UPDATE ' . MODULES_TABLE . "
+ SET module_auth = 'aclf_m_report'
+ WHERE module_class = 'mcp'
+ AND module_basename = 'mcp_pm_reports'
+ AND module_auth = 'acl_m_pm_report'";
+ $this->db->sql_query($sql);
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php b/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php
new file mode 100644
index 0000000000..417d569a09
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php
@@ -0,0 +1,77 @@
+<?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 remove_duplicate_migrations extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v31x\v3110');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'deduplicate_entries'))),
+ );
+ }
+
+ public function deduplicate_entries()
+ {
+ $migration_state = array();
+ $duplicate_migrations = array();
+
+ $sql = "SELECT *
+ FROM " . $this->table_prefix . 'migrations';
+ $result = $this->db->sql_query($sql);
+
+ if (!$this->db->get_sql_error_triggered())
+ {
+ while ($migration = $this->db->sql_fetchrow($result))
+ {
+ $migration_state[$migration['migration_name']] = $migration;
+
+ $migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']);
+ }
+ }
+
+ $this->db->sql_freeresult($result);
+
+ foreach ($migration_state as $name => $migration)
+ {
+ $prepended_name = ($name[0] == '\\' ? '' : '\\') . $name;
+ $prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name;
+
+ if ($prepended_name != $name && isset($migration_state[$prepended_name]) && $migration_state[$prepended_name]['migration_depends_on'] == $migration_state[$name]['migration_depends_on'])
+ {
+ $duplicate_migrations[] = $name;
+ unset($migration_state[$prepended_name]);
+ }
+ else if ($prefixless_name != $name && isset($migration_state[$prefixless_name]) && $migration_state[$prefixless_name]['migration_depends_on'] == $migration_state[$name]['migration_depends_on'])
+ {
+ $duplicate_migrations[] = $prefixless_name;
+ unset($migration_state[$prefixless_name]);
+ }
+ }
+
+ if (count($duplicate_migrations))
+ {
+ $sql = 'DELETE
+ FROM ' . $this->table_prefix . 'migrations
+ WHERE ' . $this->db->sql_in_set('migration_name', $duplicate_migrations);
+ $this->db->sql_query($sql);
+ }
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v311.php b/phpBB/phpbb/db/migration/data/v31x/v311.php
index 00844dd4c0..b9d6ed3053 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v311.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v311.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v311 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v3110.php b/phpBB/phpbb/db/migration/data/v31x/v3110.php
new file mode 100644
index 0000000000..b89b4cc6e6
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v3110.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 v3110 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.10', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v3110rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.10')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v3110rc1.php b/phpBB/phpbb/db/migration/data/v31x/v3110rc1.php
new file mode 100644
index 0000000000..da69f2384e
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v3110rc1.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 v3110rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.10-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v319',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.10-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v312.php b/phpBB/phpbb/db/migration/data/v31x/v312.php
index bf49935f4d..114c2b959b 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v312.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v312.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v312 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.2', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v312rc1.php b/phpBB/phpbb/db/migration/data/v31x/v312rc1.php
index d4b133fc01..e2408d432b 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v312rc1.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v312rc1.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v312rc1 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.2-RC1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v313.php b/phpBB/phpbb/db/migration/data/v31x/v313.php
index 5a4e21a9b7..b86788da16 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v313.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v313.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v313 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.3', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v313rc1.php b/phpBB/phpbb/db/migration/data/v31x/v313rc1.php
index e50754f805..b1dcc03364 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v313rc1.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v313rc1.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v313rc1 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.3-RC1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v313rc2.php b/phpBB/phpbb/db/migration/data/v31x/v313rc2.php
index d832d6f502..b701dca5ed 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v313rc2.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v313rc2.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v313rc2 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.3-RC2', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v314.php b/phpBB/phpbb/db/migration/data/v31x/v314.php
index b7793ca569..82dbbf29c9 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v314.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v314.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v314 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.4', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v314rc1.php b/phpBB/phpbb/db/migration/data/v31x/v314rc1.php
index 10cdbe3f9c..e7baf0c2ce 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v314rc1.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v314rc1.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v314rc1 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.4-RC1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v314rc2.php b/phpBB/phpbb/db/migration/data/v31x/v314rc2.php
index b75b7a9be8..3fc5bf2ad5 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v314rc2.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v314rc2.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v314rc2 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.4-RC2', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v315.php b/phpBB/phpbb/db/migration/data/v31x/v315.php
index 778cdf717e..d5eacf8dd3 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v315.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v315.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v315 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.5', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v315rc1.php b/phpBB/phpbb/db/migration/data/v31x/v315rc1.php
index 4cf4472aa7..a58b6a0f2a 100644
--- a/phpBB/phpbb/db/migration/data/v31x/v315rc1.php
+++ b/phpBB/phpbb/db/migration/data/v31x/v315rc1.php
@@ -15,6 +15,11 @@ namespace phpbb\db\migration\data\v31x;
class v315rc1 extends \phpbb\db\migration\migration
{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.5-RC1', '>=');
+ }
+
static public function depends_on()
{
return array(
diff --git a/phpBB/phpbb/db/migration/data/v31x/v316.php b/phpBB/phpbb/db/migration/data/v31x/v316.php
new file mode 100644
index 0000000000..b3e0060ced
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v316.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 v316 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.6', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v316rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.6')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v316rc1.php b/phpBB/phpbb/db/migration/data/v31x/v316rc1.php
new file mode 100644
index 0000000000..6badfb68d4
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v316rc1.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 v316rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.6-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v315',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.6-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v317.php b/phpBB/phpbb/db/migration/data/v31x/v317.php
new file mode 100644
index 0000000000..d95be06ba6
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v317.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 v317 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.7', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v317rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.7')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v317pl1.php b/phpBB/phpbb/db/migration/data/v31x/v317pl1.php
new file mode 100644
index 0000000000..1cb39b03f0
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v317pl1.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 v317pl1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.7-pl1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v317',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.7-pl1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v317rc1.php b/phpBB/phpbb/db/migration/data/v31x/v317rc1.php
new file mode 100644
index 0000000000..77759daa66
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v317rc1.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\v31x;
+
+class v317rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.7-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\m_pm_report',
+ '\phpbb\db\migration\data\v31x\v316',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.7-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v318.php b/phpBB/phpbb/db/migration/data/v31x/v318.php
new file mode 100644
index 0000000000..7663529d3a
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v318.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 v318 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.8', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v318rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.8')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v318rc1.php b/phpBB/phpbb/db/migration/data/v31x/v318rc1.php
new file mode 100644
index 0000000000..2cab5c96d4
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v318rc1.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\v31x;
+
+class v318rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.8-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\increase_size_of_dateformat',
+ '\phpbb\db\migration\data\v31x\v317pl1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.8-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v319.php b/phpBB/phpbb/db/migration/data/v31x/v319.php
new file mode 100644
index 0000000000..f773814028
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v319.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 v319 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.9', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v319rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.9')),
+ );
+ }
+}
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/db/migration/helper.php b/phpBB/phpbb/db/migration/helper.php
index e40deeb37b..bce2efff51 100644
--- a/phpBB/phpbb/db/migration/helper.php
+++ b/phpBB/phpbb/db/migration/helper.php
@@ -81,4 +81,36 @@ class helper
return $steps;
}
+
+ /**
+ * Reverse the update steps from an array of data changes
+ *
+ * 'If' statements and custom methods will be skipped, for all
+ * other calls the reverse method of the tool class will be called
+ *
+ * @param array $steps Update changes from migration
+ *
+ * @return array
+ */
+ public function reverse_update_data($steps)
+ {
+ $reversed_array = array();
+
+ foreach ($steps as $step)
+ {
+ $parts = explode('.', $step[0]);
+ $parameters = $step[1];
+
+ $class = $parts[0];
+ $method = isset($parts[1]) ? $parts[1] : false;
+
+ if ($class !== 'if' && $class !== 'custom')
+ {
+ array_unshift($parameters, $method);
+ $reversed_array[] = array($class . '.reverse', $parameters);
+ }
+ }
+
+ return array_reverse($reversed_array);
+ }
}
diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php
index f93e7118c4..33aa8ff026 100644
--- a/phpBB/phpbb/db/migration/tool/config.php
+++ b/phpBB/phpbb/db/migration/tool/config.php
@@ -150,6 +150,11 @@ class config implements \phpbb\db\migration\tool\tool_interface
$arguments[0],
);
break;
+
+ case 'reverse':
+ // Reversing a reverse is just the call itself
+ $call = array_shift($arguments);
+ break;
}
if ($call)
diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php
index bf8ac55023..54b45f6f6d 100644
--- a/phpBB/phpbb/db/migration/tool/config_text.php
+++ b/phpBB/phpbb/db/migration/tool/config_text.php
@@ -115,6 +115,11 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
$arguments[] = '';
}
break;
+
+ case 'reverse':
+ // Reversing a reverse is just the call itself
+ $call = array_shift($arguments);
+ break;
}
if ($call)
diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index 035625b095..7ea7d1dac1 100644
--- a/phpBB/phpbb/db/migration/tool/module.php
+++ b/phpBB/phpbb/db/migration/tool/module.php
@@ -36,6 +36,9 @@ class module implements \phpbb\db\migration\tool\tool_interface
/** @var string */
protected $modules_table;
+ /** @var array */
+ protected $module_categories = array();
+
/**
* Constructor
*
@@ -87,30 +90,13 @@ class module implements \phpbb\db\migration\tool\tool_interface
$parent_sql = '';
if ($parent !== false)
{
- // Allows '' to be sent as 0
- $parent = $parent ?: 0;
-
- if (!is_numeric($parent))
+ $parent = $this->get_parent_module_id($parent, $module, false);
+ if ($parent === false)
{
- $sql = 'SELECT module_id
- FROM ' . $this->modules_table . "
- WHERE module_langname = '" . $this->db->sql_escape($parent) . "'
- AND module_class = '" . $this->db->sql_escape($class) . "'";
- $result = $this->db->sql_query($sql);
- $module_id = $this->db->sql_fetchfield('module_id');
- $this->db->sql_freeresult($result);
-
- if (!$module_id)
- {
- return false;
- }
-
- $parent_sql = 'AND parent_id = ' . (int) $module_id;
- }
- else
- {
- $parent_sql = 'AND parent_id = ' . (int) $parent;
+ return false;
}
+
+ $parent_sql = 'AND parent_id = ' . (int) $parent;
}
$sql = 'SELECT module_id
@@ -171,15 +157,14 @@ class module implements \phpbb\db\migration\tool\tool_interface
*/
public function add($class, $parent = 0, $data = array())
{
- // Allows '' to be sent as 0
- $parent = $parent ?: 0;
-
// allow sending the name as a string in $data to create a category
if (!is_array($data))
{
$data = array('module_langname' => $data);
}
+ $parent = $data['parent_id'] = $this->get_parent_module_id($parent, $data);
+
if (!isset($data['module_langname']))
{
// The "automatic" way
@@ -210,31 +195,14 @@ class module implements \phpbb\db\migration\tool\tool_interface
}
// The "manual" way
- if (!is_numeric($parent))
- {
- $sql = 'SELECT module_id
- FROM ' . $this->modules_table . "
- WHERE module_langname = '" . $this->db->sql_escape($parent) . "'
- AND module_class = '" . $this->db->sql_escape($class) . "'";
- $result = $this->db->sql_query($sql);
- $module_id = $this->db->sql_fetchfield('module_id');
- $this->db->sql_freeresult($result);
-
- if (!$module_id)
- {
- throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent);
- }
-
- $parent = $data['parent_id'] = $module_id;
- }
- else if (!$this->exists($class, false, $parent))
+ if (!$this->exists($class, false, $parent))
{
throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent);
}
if ($this->exists($class, $parent, $data['module_langname']))
{
- return;
+ throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']);
}
if (!class_exists('acp_modules'))
@@ -373,26 +341,8 @@ class module implements \phpbb\db\migration\tool\tool_interface
$parent_sql = '';
if ($parent !== false)
{
- // Allows '' to be sent as 0
- $parent = ($parent) ?: 0;
-
- if (!is_numeric($parent))
- {
- $sql = 'SELECT module_id
- FROM ' . $this->modules_table . "
- WHERE module_langname = '" . $this->db->sql_escape($parent) . "'
- AND module_class = '" . $this->db->sql_escape($class) . "'";
- $result = $this->db->sql_query($sql);
- $module_id = $this->db->sql_fetchfield('module_id');
- $this->db->sql_freeresult($result);
-
- // we know it exists from the module_exists check
- $parent_sql = 'AND parent_id = ' . (int) $module_id;
- }
- else
- {
- $parent_sql = 'AND parent_id = ' . (int) $parent;
- }
+ $parent = $this->get_parent_module_id($parent, $module);
+ $parent_sql = 'AND parent_id = ' . (int) $parent;
}
$module_ids = array();
@@ -454,6 +404,11 @@ class module implements \phpbb\db\migration\tool\tool_interface
case 'remove':
$call = 'add';
break;
+
+ case 'reverse':
+ // Reversing a reverse is just the call itself
+ $call = array_shift($arguments);
+ break;
}
if ($call)
@@ -487,4 +442,122 @@ class module implements \phpbb\db\migration\tool\tool_interface
return array_pop($module);
}
+
+ /**
+ * Get the list of installed module categories
+ * key - module_id
+ * value - module_langname
+ *
+ * @return null
+ */
+ protected function get_categories_list()
+ {
+ // Select the top level categories
+ // and 2nd level [sub]categories
+ $sql = 'SELECT m2.module_id, m2.module_langname
+ FROM ' . $this->modules_table . ' m1, ' . $this->modules_table . " m2
+ WHERE m1.parent_id = 0
+ AND (m1.module_id = m2.module_id OR m2.parent_id = m1.module_id)
+ ORDER BY m1.module_id, m2.module_id ASC";
+
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $this->module_categories[(int) $row['module_id']] = $row['module_langname'];
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ /**
+ * Get parent module id
+ *
+ * @param string|int $parent_id The parent module_id|module_langname
+ * @param int|string|array $data The module_id, module_langname for existance checking or module data array for adding
+ * @param bool $throw_exception The flag indicating if exception should be thrown on error
+ * @return mixed The int parent module_id or false
+ * @throws \phpbb\db\migration\exception
+ */
+ public function get_parent_module_id($parent_id, $data = '', $throw_exception = true)
+ {
+ // Initialize exception object placeholder
+ $exception = false;
+
+ // Allow '' to be sent as 0
+ $parent_id = $parent_id ?: 0;
+
+ // If automatic adding is in action, convert array back to string to simplify things
+ if (is_array($data) && sizeof($data) == 1)
+ {
+ $data = $data['module_langname'];
+ }
+
+ if (!is_numeric($parent_id))
+ {
+ // Refresh the $module_categories array
+ $this->get_categories_list();
+
+ // Search for the parent module_langname
+ $ids = array_keys($this->module_categories, $parent_id);
+
+ switch (sizeof($ids))
+ {
+ // No parent with the given module_langname exist
+ case 0:
+ $exception = new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id);
+ break;
+
+ // Return the module id
+ case 1:
+ $parent_id = (int) $ids[0];
+ break;
+
+ // Several modules with the given module_langname were found
+ // Try to determine the parent_id by the neighbour module parent
+ default:
+ if (is_array($data) && (isset($data['before']) || isset($data['after'])))
+ {
+ $neighbour_module_langname = isset($data['before']) ? $data['before'] : $data['after'];
+ $sql = 'SELECT parent_id
+ FROM ' . $this->modules_table . "
+ WHERE module_langname = '" . $this->db->sql_escape($neighbour_module_langname) . "'
+ AND " . $this->db->sql_in_set('parent_id', $ids);
+ $result = $this->db->sql_query($sql);
+ $parent_id = (int) $this->db->sql_fetchfield('parent_id');
+ if (!$parent_id)
+ {
+ $exception = new \phpbb\db\migration\exception('PARENT_MODULE_FIND_ERROR', $data['parent_id']);
+ }
+ }
+ else if (!empty($data) && !is_array($data))
+ {
+ // The module_langname is set, checking for the module existance
+ // As more than 1 parents were found already, there's no way for null parent_id here
+ $sql = 'SELECT m2.module_id as module_parent_id
+ FROM ' . $this->modules_table . ' m1, ' . $this->modules_table . " m2
+ WHERE " . ((is_numeric($data)) ? 'm1.module_id = ' . (int) $data : "m1.module_langname = '" . $this->db->sql_escape($data)) . "'
+ AND m2.module_id = m1.parent_id
+ AND " . $this->db->sql_in_set('m2.module_id', $ids);
+ $result = $this->db->sql_query($sql);
+ $parent_id = (int) $this->db->sql_fetchfield('module_parent_id');
+ }
+ else
+ {
+ //Unable to get the parent module id, throwing an exception
+ $exception = new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id);
+ }
+ break;
+ }
+ }
+
+ if ($exception !== false)
+ {
+ if ($throw_exception)
+ {
+ throw $exception;
+ }
+ return false;
+ }
+
+ return $parent_id;
+ }
}
diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php
index ceff6d7d5a..9688420025 100644
--- a/phpBB/phpbb/db/migration/tool/permission.php
+++ b/phpBB/phpbb/db/migration/tool/permission.php
@@ -637,6 +637,11 @@ class permission implements \phpbb\db\migration\tool\tool_interface
$arguments[0],
);
break;
+
+ case 'reverse':
+ // Reversing a reverse is just the call itself
+ $call = array_shift($arguments);
+ break;
}
if ($call)
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index 7fc3e787e2..45a333ac94 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -80,14 +80,14 @@ class migrator
*
* @var array
*/
- public $last_run_migration = false;
+ protected $last_run_migration = false;
/**
* The output handler. A null handler is configured by default.
*
* @var migrator_output_handler_interface
*/
- public $output_handler;
+ protected $output_handler;
/**
* Constructor of the database migrator
@@ -152,6 +152,7 @@ class migrator
$this->migration_state[$migration['migration_name']] = $migration;
$this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']);
+ $this->migration_state[$migration['migration_name']]['migration_data_state'] = !empty($migration['migration_data_state']) ? unserialize($migration['migration_data_state']) : '';
}
}
@@ -161,6 +162,19 @@ class migrator
}
/**
+ * Get an array with information about the last migration run.
+ *
+ * The array contains 'name', 'class' and 'state'. 'effectively_installed' is set
+ * and set to true if the last migration was effectively_installed.
+ *
+ * @return array
+ */
+ public function get_last_run_migration()
+ {
+ return $this->last_run_migration;
+ }
+
+ /**
* Sets the list of available migration class names to the given array.
*
* @param array $class_names An array of migration class names
@@ -187,6 +201,34 @@ class migrator
}
/**
+ * Get a valid migration name from the migration state array in case the
+ * supplied name is not in the migration state list.
+ *
+ * @param string $name Migration name
+ * @return string Migration name
+ */
+ protected function get_valid_name($name)
+ {
+ // Try falling back to a valid migration name with or without leading backslash
+ if (!isset($this->migration_state[$name]))
+ {
+ $prepended_name = ($name[0] == '\\' ? '' : '\\') . $name;
+ $prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name;
+
+ if (isset($this->migration_state[$prepended_name]))
+ {
+ $name = $prepended_name;
+ }
+ else if (isset($this->migration_state[$prefixless_name]))
+ {
+ $name = $prefixless_name;
+ }
+ }
+
+ return $name;
+ }
+
+ /**
* Effectively runs a single update step from the next migration to be applied.
*
* @return null
@@ -195,6 +237,8 @@ class migrator
{
foreach ($this->migrations as $name)
{
+ $name = $this->get_valid_name($name);
+
if (!isset($this->migration_state[$name]) ||
!$this->migration_state[$name]['migration_schema_done'] ||
!$this->migration_state[$name]['migration_data_done'])
@@ -250,6 +294,9 @@ class migrator
foreach ($state['migration_depends_on'] as $depend)
{
+ $depend = $this->get_valid_name($depend);
+
+ // Test all possible namings before throwing exception
if ($this->unfulfillable($depend) !== false)
{
throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $depend);
@@ -297,38 +344,70 @@ class migrator
if (!$state['migration_schema_done'])
{
- $this->output_handler->write(array('MIGRATION_SCHEMA_RUNNING', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE);
+ $verbosity = empty($state['migration_data_state']) ?
+ migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG;
+ $this->output_handler->write(array('MIGRATION_SCHEMA_RUNNING', $name), $verbosity);
$this->last_run_migration['task'] = 'process_schema_step';
+
+ $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ?
+ $state['migration_data_state']['_total_time'] : 0.0;
$elapsed_time = microtime(true);
+
$steps = $this->helper->get_schema_steps($migration->update_schema());
$result = $this->process_data_step($steps, $state['migration_data_state']);
+
$elapsed_time = microtime(true) - $elapsed_time;
+ $total_time += $elapsed_time;
+
+ if (is_array($result))
+ {
+ $result['_total_time'] = $total_time;
+ }
$state['migration_data_state'] = ($result === true) ? '' : $result;
$state['migration_schema_done'] = ($result === true);
- $this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
+ if ($state['migration_schema_done'])
+ {
+ $this->output_handler->write(array('MIGRATION_SCHEMA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
+ }
+ else
+ {
+ $this->output_handler->write(array('MIGRATION_SCHEMA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE);
+ }
}
else if (!$state['migration_data_done'])
{
try
{
- $this->output_handler->write(array('MIGRATION_DATA_RUNNING', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE);
+ $verbosity = empty($state['migration_data_state']) ?
+ migrator_output_handler_interface::VERBOSITY_VERBOSE : migrator_output_handler_interface::VERBOSITY_DEBUG;
+ $this->output_handler->write(array('MIGRATION_DATA_RUNNING', $name), $verbosity);
$this->last_run_migration['task'] = 'process_data_step';
+ $total_time = (is_array($state['migration_data_state']) && isset($state['migration_data_state']['_total_time'])) ?
+ $state['migration_data_state']['_total_time'] : 0.0;
$elapsed_time = microtime(true);
+
$result = $this->process_data_step($migration->update_data(), $state['migration_data_state']);
+
$elapsed_time = microtime(true) - $elapsed_time;
+ $total_time += $elapsed_time;
+
+ if (is_array($result))
+ {
+ $result['_total_time'] = $total_time;
+ }
$state['migration_data_state'] = ($result === true) ? '' : $result;
$state['migration_data_done'] = ($result === true);
$state['migration_end_time'] = ($result === true) ? time() : 0;
- if ($state['migration_schema_done'])
+ if ($state['migration_data_done'])
{
- $this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
+ $this->output_handler->write(array('MIGRATION_DATA_DONE', $name, $total_time), migrator_output_handler_interface::VERBOSITY_NORMAL);
}
else
{
@@ -337,10 +416,12 @@ class migrator
}
catch (\phpbb\db\migration\exception $e)
{
- // Revert the schema changes
+ // Reset data state and revert the schema changes
+ $state['migration_data_state'] = '';
+ $this->set_migration_state($name, $state);
+
$this->revert_do($name);
- // Rethrow exception
throw $e;
}
}
@@ -416,19 +497,11 @@ class migrator
if ($state['migration_data_done'])
{
- if ($state['migration_data_state'] !== 'revert_data')
- {
- $result = $this->process_data_step($migration->update_data(), $state['migration_data_state'], true);
-
- $state['migration_data_state'] = ($result === true) ? 'revert_data' : $result;
- }
- else
- {
- $result = $this->process_data_step($migration->revert_data(), '', false);
+ $steps = array_merge($this->helper->reverse_update_data($migration->update_data()), $migration->revert_data());
+ $result = $this->process_data_step($steps, $state['migration_data_state']);
- $state['migration_data_state'] = ($result === true) ? '' : $result;
- $state['migration_data_done'] = ($result === true) ? false : true;
- }
+ $state['migration_data_state'] = ($result === true) ? '' : $result;
+ $state['migration_data_done'] = ($result === true) ? false : true;
$this->set_migration_state($name, $state);
}
@@ -446,8 +519,13 @@ class migrator
WHERE migration_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
+ $this->last_run_migration = false;
unset($this->migration_state[$name]);
}
+ else
+ {
+ $this->set_migration_state($name, $state);
+ }
}
return true;
@@ -464,7 +542,12 @@ class migrator
*/
protected function process_data_step($steps, $state, $revert = false)
{
- $state = ($state) ? unserialize($state) : false;
+ if (sizeof($steps) === 0)
+ {
+ return true;
+ }
+
+ $state = is_array($state) ? $state : false;
// reverse order of steps if reverting
if ($revert === true)
@@ -472,54 +555,45 @@ class migrator
$steps = array_reverse($steps);
}
- foreach ($steps as $step_identifier => $step)
+ $step = $last_result = 0;
+ if ($state)
{
- $last_result = 0;
- if ($state)
- {
- // Continue until we reach the step that matches the last step called
- if ($state['step'] != $step_identifier)
- {
- continue;
- }
+ $step = $state['step'];
- // We send the result from last time to the callable function
- $last_result = $state['result'];
-
- // Set state to false since we reached the point we were at
- $state = false;
- }
+ // We send the result from last time to the callable function
+ $last_result = $state['result'];
+ }
- try
+ try
+ {
+ // Result will be null or true if everything completed correctly
+ // Stop after each update step, to let the updater control the script runtime
+ $result = $this->run_step($steps[$step], $last_result, $revert);
+ if (($result !== null && $result !== true) || $step + 1 < sizeof($steps))
{
- // Result will be null or true if everything completed correctly
- $result = $this->run_step($step, $last_result, $revert);
- if ($result !== null && $result !== true)
- {
- return serialize(array(
- 'result' => $result,
- 'step' => $step_identifier,
- ));
- }
+ return array(
+ 'result' => $result,
+ // Move on if the last call finished
+ 'step' => ($result !== null && $result !== true) ? $step : $step + 1,
+ );
}
- catch (\phpbb\db\migration\exception $e)
+ }
+ catch (\phpbb\db\migration\exception $e)
+ {
+ // We should try rolling back here
+ foreach ($steps as $reverse_step_identifier => $reverse_step)
{
- // We should try rolling back here
- foreach ($steps as $reverse_step_identifier => $reverse_step)
+ // If we've reached the current step we can break because we reversed everything that was run
+ if ($reverse_step_identifier == $step)
{
- // If we've reached the current step we can break because we reversed everything that was run
- if ($reverse_step_identifier == $step_identifier)
- {
- break;
- }
-
- // Reverse the step that was run
- $result = $this->run_step($reverse_step, false, !$revert);
+ break;
}
- // rethrow the exception
- throw $e;
+ // Reverse the step that was run
+ $result = $this->run_step($reverse_step, false, !$revert);
}
+
+ throw $e;
}
return true;
@@ -587,6 +661,13 @@ class migrator
throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step);
}
+ if ($reverse)
+ {
+ // We might get unexpected results when trying
+ // to revert this, so just avoid it
+ return false;
+ }
+
$condition = $parameters[0];
if (!$condition)
@@ -664,6 +745,7 @@ class migrator
{
$migration_row = $state;
$migration_row['migration_depends_on'] = serialize($state['migration_depends_on']);
+ $migration_row['migration_data_state'] = !empty($state['migration_data_state']) ? serialize($state['migration_data_state']) : '';
if (isset($this->migration_state[$name]))
{
@@ -693,6 +775,8 @@ class migrator
*/
public function unfulfillable($name)
{
+ $name = $this->get_valid_name($name);
+
if (isset($this->migration_state[$name]) || isset($this->fulfillable_migrations[$name]))
{
return false;
@@ -708,6 +792,7 @@ class migrator
foreach ($depends as $depend)
{
+ $depend = $this->get_valid_name($depend);
$unfulfillable = $this->unfulfillable($depend);
if ($unfulfillable !== false)
{
diff --git a/phpBB/phpbb/db/migrator_output_handler_interface.php b/phpBB/phpbb/db/migrator_output_handler_interface.php
index a923af99f6..9947b51dcc 100644
--- a/phpBB/phpbb/db/migrator_output_handler_interface.php
+++ b/phpBB/phpbb/db/migrator_output_handler_interface.php
@@ -15,11 +15,11 @@ namespace phpbb\db;
interface migrator_output_handler_interface
{
- const VERBOSITY_QUIET = 0;
- const VERBOSITY_NORMAL = 1;
- const VERBOSITY_VERBOSE = 2;
- const VERBOSITY_VERY_VERBOSE = 3;
- const VERBOSITY_DEBUG = 4;
+ const VERBOSITY_QUIET = 16;
+ const VERBOSITY_NORMAL = 32;
+ const VERBOSITY_VERBOSE = 64;
+ const VERBOSITY_VERY_VERBOSE = 128;
+ const VERBOSITY_DEBUG = 256;
/**
* Write output using the configured closure.
diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php
index 775deccc30..832a0c510c 100644
--- a/phpBB/phpbb/db/tools.php
+++ b/phpBB/phpbb/db/tools.php
@@ -1533,6 +1533,11 @@ class tools
}
}
+ if (isset($column_data['after']))
+ {
+ $return_array['after'] = $column_data['after'];
+ }
+
break;
case 'oracle':
@@ -2335,7 +2340,7 @@ class tools
if (!empty($column_data['default']))
{
// Add new default value constraint
- $statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $this->db->sql_escape($column_data['default']) . ' FOR [' . $column_name . ']';
+ $statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $column_data['default'] . ' FOR [' . $column_name . ']';
}
if (!empty($indexes))
diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php
index eb7831ad34..9d15f9370e 100644
--- a/phpBB/phpbb/event/kernel_exception_subscriber.php
+++ b/phpBB/phpbb/event/kernel_exception_subscriber.php
@@ -34,6 +34,9 @@ class kernel_exception_subscriber implements EventSubscriberInterface
*/
protected $user;
+ /** @var \phpbb\request\type_cast_helper */
+ protected $type_caster;
+
/**
* Construct method
*
@@ -44,6 +47,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface
{
$this->template = $template;
$this->user = $user;
+ $this->type_caster = new \phpbb\request\type_cast_helper();
}
/**
@@ -57,12 +61,16 @@ class kernel_exception_subscriber implements EventSubscriberInterface
$exception = $event->getException();
$message = $exception->getMessage();
+ $this->type_caster->set_var($message, $message, 'string', false, false);
if ($exception instanceof \phpbb\exception\exception_interface)
{
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($message), $exception->get_parameters()));
}
+ // Show <strong> text in bold
+ $message = preg_replace('#&lt;(/?strong)&gt;#i', '<$1>', $message);
+
if (!$event->getRequest()->isXmlHttpRequest())
{
page_header($this->user->lang('INFORMATION'));
diff --git a/phpBB/phpbb/feed/base.php b/phpBB/phpbb/feed/base.php
index 322e2ee9f1..eeea0a55df 100644
--- a/phpBB/phpbb/feed/base.php
+++ b/phpBB/phpbb/feed/base.php
@@ -39,6 +39,12 @@ abstract class base
/** @var \phpbb\auth\auth */
protected $auth;
+ /** @var \phpbb\content_visibility */
+ protected $content_visibility;
+
+ /** @var \phpbb\event\dispatcher_interface */
+ protected $phpbb_dispatcher;
+
/** @var string */
protected $phpEx;
@@ -79,10 +85,21 @@ abstract class base
* @param \phpbb\cache\driver\driver_interface $cache Cache object
* @param \phpbb\user $user User object
* @param \phpbb\auth\auth $auth Auth object
- * @param \phpbb\content_visibility $content_visibility Auth object
+ * @param \phpbb\content_visibility $content_visibility Content visibility object
+ * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object
* @param string $phpEx php file extension
*/
- function __construct(\phpbb\feed\helper $helper, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, $phpEx)
+ function __construct(
+ \phpbb\feed\helper $helper,
+ \phpbb\config\config $config,
+ \phpbb\db\driver\driver_interface $db,
+ \phpbb\cache\driver\driver_interface $cache,
+ \phpbb\user $user,
+ \phpbb\auth\auth $auth,
+ \phpbb\content_visibility $content_visibility,
+ \phpbb\event\dispatcher_interface $phpbb_dispatcher,
+ $phpEx
+ )
{
$this->config = $config;
$this->helper = $helper;
@@ -91,6 +108,7 @@ abstract class base
$this->user = $user;
$this->auth = $auth;
$this->content_visibility = $content_visibility;
+ $this->phpbb_dispatcher = $phpbb_dispatcher;
$this->phpEx = $phpEx;
$this->set_keys();
@@ -239,6 +257,21 @@ abstract class base
return false;
}
+ $sql_ary = $this->sql;
+
+ /**
+ * Event to modify the feed item sql
+ *
+ * @event core.feed_base_modify_item_sql
+ * @var array sql_ary The SQL array to get the feed item data
+ *
+ * @since 3.1.10-RC1
+ */
+ $vars = array('sql_ary');
+ extract($this->phpbb_dispatcher->trigger_event('core.feed_base_modify_item_sql', compact($vars)));
+ $this->sql = $sql_ary;
+ unset($sql_ary);
+
// Query database
$sql = $this->db->sql_build_query('SELECT', $this->sql);
$this->result = $this->db->sql_query_limit($sql, $this->num_items);
diff --git a/phpBB/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php
index 198134cdcf..f2030f5ced 100644
--- a/phpBB/phpbb/feed/helper.php
+++ b/phpBB/phpbb/feed/helper.php
@@ -149,12 +149,10 @@ class helper
{
$update_count = array();
parse_attachments($forum_id, $content, $post_attachments, $update_count);
- $post_attachments = implode('<br />', $post_attachments);
+ $content .= implode('<br />', $post_attachments);
// Convert attachments' relative path to absolute path
- $post_attachments = str_replace($this->phpbb_root_path . 'download/file.' . $this->phpEx, $this->get_board_url() . '/download/file.' . $this->phpEx, $post_attachments);
-
- $content .= $post_attachments;
+ $content = str_replace($this->phpbb_root_path . 'download/file.' . $this->phpEx, $this->get_board_url() . '/download/file.' . $this->phpEx, $content);
}
// Remove Comments from inline attachments [ia]
diff --git a/phpBB/phpbb/file_downloader.php b/phpBB/phpbb/file_downloader.php
index 462b87ca51..ab9505a14c 100644
--- a/phpBB/phpbb/file_downloader.php
+++ b/phpBB/phpbb/file_downloader.php
@@ -42,7 +42,7 @@ class file_downloader
$this->error_number = 0;
$this->error_string = '';
- if ($socket = @fsockopen($host, $port, $this->error_number, $this->error_string, $timeout))
+ if ($socket = @fsockopen(($port == 443 ? 'tls://' : '') . $host, $port, $this->error_number, $this->error_string, $timeout))
{
@fputs($socket, "GET $directory/$filename HTTP/1.0\r\n");
@fputs($socket, "HOST: $host\r\n");
diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php
index 3d995b4e4a..094ff78abe 100644
--- a/phpBB/phpbb/log/log.php
+++ b/phpBB/phpbb/log/log.php
@@ -229,8 +229,8 @@ class log implements \phpbb\log\log_interface
}
$sql_ary = array(
- 'user_id' => $user_id,
- 'log_ip' => $log_ip,
+ 'user_id' => !empty($user_id) ? $user_id : ANONYMOUS,
+ 'log_ip' => !empty($log_ip) ? $log_ip : '',
'log_time' => $log_time,
'log_operation' => $log_operation,
);
@@ -402,7 +402,7 @@ class log implements \phpbb\log\log_interface
}
}
- $sql = 'DELETE FROM ' . LOG_TABLE . "
+ $sql = 'DELETE FROM ' . $this->log_table . "
$sql_where";
$this->db->sql_query($sql);
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index db92170dd8..f5663f4b34 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -186,12 +186,13 @@ class manager
if (!$options['count_total'] || $total_count)
{
$rowset = array();
+ $selected_unread_count = 0;
// Get the main notifications
$sql = 'SELECT n.*, nt.notification_type_name
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
WHERE n.user_id = ' . (int) $options['user_id'] .
- (($options['notification_id']) ? ((is_array($options['notification_id'])) ? ' AND ' . $this->db->sql_in_set('n.notification_id', $options['notification_id']) : ' AND n.notification_id = ' . (int) $options['notification_id']) : '') . '
+ (($options['notification_id']) ? ' AND ' . $this->db->sql_in_set('n.notification_id', $options['notification_id']) : '') . '
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1
ORDER BY n.' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']);
@@ -200,11 +201,12 @@ class manager
while ($row = $this->db->sql_fetchrow($result))
{
$rowset[$row['notification_id']] = $row;
+ $selected_unread_count += (int) !$row['notification_read'];
}
$this->db->sql_freeresult($result);
// Get all unread notifications
- if ($unread_count && $options['all_unread'] && !empty($rowset))
+ if ($selected_unread_count < $unread_count && $options['all_unread'] && !empty($rowset))
{
$sql = 'SELECT n.*, nt.notification_type_name
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
@@ -273,10 +275,9 @@ class manager
$sql = 'UPDATE ' . $this->notifications_table . "
SET notification_read = 1
WHERE notification_time <= " . (int) $time .
- (($notification_type_name !== false) ? ' AND ' .
- (is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name)) : '') .
- (($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') .
- (($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : '');
+ (($notification_type_name !== false) ? ' AND ' . $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : '') .
+ (($user_id !== false) ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '') .
+ (($item_id !== false) ? ' AND ' . $this->db->sql_in_set('item_id', $item_id) : '');
$this->db->sql_query($sql);
}
@@ -295,10 +296,9 @@ class manager
$sql = 'UPDATE ' . $this->notifications_table . "
SET notification_read = 1
WHERE notification_time <= " . (int) $time .
- (($notification_type_name !== false) ? ' AND ' .
- (is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name)) : '') .
- (($item_parent_id !== false) ? ' AND ' . (is_array($item_parent_id) ? $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : 'item_parent_id = ' . (int) $item_parent_id) : '') .
- (($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '');
+ (($notification_type_name !== false) ? ' AND ' . $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : '') .
+ (($item_parent_id !== false) ? ' AND ' . $this->db->sql_in_set('item_parent_id', $item_parent_id, false, true) : '') .
+ (($user_id !== false) ? ' AND ' . $this->db->sql_in_set('user_id', $user_id) : '');
$this->db->sql_query($sql);
}
@@ -315,7 +315,7 @@ class manager
$sql = 'UPDATE ' . $this->notifications_table . "
SET notification_read = 1
WHERE notification_time <= " . (int) $time . '
- AND ' . ((is_array($notification_id)) ? $this->db->sql_in_set('notification_id', $notification_id) : 'notification_id = ' . (int) $notification_id);
+ AND ' . $this->db->sql_in_set('notification_id', $notification_id);
$this->db->sql_query($sql);
}
@@ -540,8 +540,8 @@ class manager
$sql = 'DELETE FROM ' . $this->notifications_table . '
WHERE notification_type_id = ' . (int) $notification_type_id . '
- AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) .
- (($parent_id !== false) ? ' AND ' . ((is_array($parent_id) ? $this->db->sql_in_set('item_parent_id', $parent_id) : 'item_parent_id = ' . (int) $parent_id)) : '');
+ AND ' . $this->db->sql_in_set('item_id', $item_id) .
+ (($parent_id !== false) ? ' AND ' . $this->db->sql_in_set('item_parent_id', $parent_id) : '');
$this->db->sql_query($sql);
}
@@ -923,6 +923,8 @@ class manager
{
$notification_type_ids = $this->cache->get('notification_type_ids');
+ $this->db->sql_transaction('begin');
+
if ($notification_type_ids === false)
{
$notification_type_ids = array();
@@ -943,6 +945,7 @@ class manager
{
if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name]))
{
+ $this->db->sql_transaction('rollback');
throw new \phpbb\notification\exception($this->user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name));
}
@@ -957,17 +960,24 @@ class manager
$this->cache->put('notification_type_ids', $notification_type_ids);
}
+ $this->db->sql_transaction('commit');
+
return $notification_type_ids[$notification_type_name];
}
/**
* Get notification type ids (as an array)
*
- * @param array $notification_type_names Array of strings
+ * @param string|array $notification_type_names Notification type names
* @return array Array of integers
*/
- public function get_notification_type_ids(array $notification_type_names)
+ public function get_notification_type_ids($notification_type_names)
{
+ if (!is_array($notification_type_names))
+ {
+ $notification_type_names = array($notification_type_names);
+ }
+
$notification_type_ids = array();
foreach ($notification_type_names as $name)
diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php
index c3aee088f9..0bfbfd6b02 100644
--- a/phpBB/phpbb/notification/method/messenger_base.php
+++ b/phpBB/phpbb/notification/method/messenger_base.php
@@ -74,14 +74,14 @@ abstract class messenger_base extends \phpbb\notification\method\base
continue;
}
- $messenger->template($template_dir_prefix . $notification->get_email_template(), $user['user_lang']);
+ $messenger->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix);
$messenger->set_addresses($user);
$messenger->assign_vars(array_merge(array(
'USERNAME' => $user['username'],
- 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications',
+ 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options',
), $notification->get_email_template_variables()));
$messenger->send($notify_method);
diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php
index a9e635b41a..5760c12166 100644
--- a/phpBB/phpbb/notification/type/approve_post.php
+++ b/phpBB/phpbb/notification/type/approve_post.php
@@ -82,7 +82,7 @@ class approve_post extends \phpbb\notification\type\post
$users[$post['poster_id']] = array('');
return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array(
- 'item_type' => self::$notification_option['id'],
+ 'item_type' => static::$notification_option['id'],
)));
}
diff --git a/phpBB/phpbb/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php
index 2f4678359c..26e51bf9cd 100644
--- a/phpBB/phpbb/notification/type/approve_topic.php
+++ b/phpBB/phpbb/notification/type/approve_topic.php
@@ -82,7 +82,7 @@ class approve_topic extends \phpbb\notification\type\topic
$users[$post['poster_id']] = array('');
return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array(
- 'item_type' => self::$notification_option['id'],
+ 'item_type' => static::$notification_option['id'],
)));
}
diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php
index 4f2d34cb60..1626add22c 100644
--- a/phpBB/phpbb/notification/type/bookmark.php
+++ b/phpBB/phpbb/notification/type/bookmark.php
@@ -95,7 +95,7 @@ class bookmark extends \phpbb\notification\type\post
$sql = 'SELECT n.*
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
- AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . '
+ AND n.item_parent_id = ' . (int) static::get_item_parent_id($post) . '
AND n.notification_read = 0
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1';
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php
index e25fdcd808..2969da550d 100644
--- a/phpBB/phpbb/notification/type/post.php
+++ b/phpBB/phpbb/notification/type/post.php
@@ -135,7 +135,7 @@ class post extends \phpbb\notification\type\base
$sql = 'SELECT n.*
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
- AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . '
+ AND n.item_parent_id = ' . (int) static::get_item_parent_id($post) . '
AND n.notification_read = 0
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1';
diff --git a/phpBB/phpbb/notification/type/post_in_queue.php b/phpBB/phpbb/notification/type/post_in_queue.php
index 315b8b0243..5832c99cd2 100644
--- a/phpBB/phpbb/notification/type/post_in_queue.php
+++ b/phpBB/phpbb/notification/type/post_in_queue.php
@@ -108,7 +108,7 @@ class post_in_queue extends \phpbb\notification\type\post
}
return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array(
- 'item_type' => self::$notification_option['id'],
+ 'item_type' => static::$notification_option['id'],
)));
}
diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php
index 508ca92fa0..2732cb84e4 100644
--- a/phpBB/phpbb/notification/type/quote.php
+++ b/phpBB/phpbb/notification/type/quote.php
@@ -78,7 +78,7 @@ class quote extends \phpbb\notification\type\post
), $options);
$usernames = false;
- preg_match_all(self::$regular_expression_match, $post['post_text'], $usernames);
+ preg_match_all(static::$regular_expression_match, $post['post_text'], $usernames);
if (empty($usernames[1]))
{
@@ -116,7 +116,7 @@ class quote extends \phpbb\notification\type\post
$sql = 'SELECT n.user_id
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
- AND n.item_id = ' . self::get_item_id($post) . '
+ AND n.item_id = ' . static::get_item_id($post) . '
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1';
$result = $this->db->sql_query($sql);
@@ -147,7 +147,7 @@ class quote extends \phpbb\notification\type\post
{
$sql = 'DELETE FROM ' . $this->notifications_table . '
WHERE notification_type_id = ' . (int) $this->notification_type_id . '
- AND item_id = ' . self::get_item_id($post) . '
+ AND item_id = ' . static::get_item_id($post) . '
AND ' . $this->db->sql_in_set('user_id', $remove_notifications);
$this->db->sql_query($sql);
}
diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php
index 749cfe0b8e..cc32984ac6 100644
--- a/phpBB/phpbb/notification/type/report_pm.php
+++ b/phpBB/phpbb/notification/type/report_pm.php
@@ -52,7 +52,7 @@ class report_pm extends \phpbb\notification\type\pm
*
* @var string Permission name
*/
- protected $permission = 'm_report';
+ protected $permission = 'm_pm_report';
/**
* Notification option data (for outputting to the user)
@@ -120,7 +120,7 @@ class report_pm extends \phpbb\notification\type\pm
}
return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, array(
- 'item_type' => self::$notification_option['id'],
+ 'item_type' => static::$notification_option['id'],
)));
}
diff --git a/phpBB/phpbb/notification/type/topic_in_queue.php b/phpBB/phpbb/notification/type/topic_in_queue.php
index 4c60c6b858..6e57b9ac0c 100644
--- a/phpBB/phpbb/notification/type/topic_in_queue.php
+++ b/phpBB/phpbb/notification/type/topic_in_queue.php
@@ -108,7 +108,7 @@ class topic_in_queue extends \phpbb\notification\type\topic
}
return $this->check_user_notification_options($auth_read[$topic['forum_id']]['f_read'], array_merge($options, array(
- 'item_type' => self::$notification_option['id'],
+ 'item_type' => static::$notification_option['id'],
)));
}
diff --git a/phpBB/phpbb/passwords/driver/salted_md5.php b/phpBB/phpbb/passwords/driver/salted_md5.php
index 81ac010785..38d6d9cd2c 100644
--- a/phpBB/phpbb/passwords/driver/salted_md5.php
+++ b/phpBB/phpbb/passwords/driver/salted_md5.php
@@ -75,7 +75,7 @@ class salted_md5 extends base
// happen if pre-determined settings are
// directly passed to the driver. The manager
// will not do this. Same as the old hashing
- // implementatio in phpBB 3.0
+ // implementation in phpBB 3.0
return md5($password);
}
}
diff --git a/phpBB/phpbb/permissions.php b/phpBB/phpbb/permissions.php
index 82f59b5c20..e75476f59b 100644
--- a/phpBB/phpbb/permissions.php
+++ b/phpBB/phpbb/permissions.php
@@ -160,6 +160,28 @@ class permissions
}
/**
+ * Checks if a category has been defined
+ *
+ * @param string $category Identifier of the category
+ * @return bool True if the category is defined, false otherwise
+ */
+ public function category_defined($category)
+ {
+ return isset($this->categories[$category]);
+ }
+
+ /**
+ * Checks if a permission has been defined
+ *
+ * @param string $permission Identifier of the permission
+ * @return bool True if the permission is defined, false otherwise
+ */
+ public function permission_defined($permission)
+ {
+ return isset($this->permissions[$permission]);
+ }
+
+ /**
* Returns the language string of a permission
*
* @param string $permission Identifier of the permission
@@ -285,8 +307,9 @@ class permissions
'm_split' => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'),
'm_merge' => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'),
- 'm_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'),
- 'm_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'),
+ 'm_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'),
+ 'm_pm_report' => array('lang' => 'ACL_M_PM_REPORT', 'cat' => 'misc'),
+ 'm_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'),
// Admin Permissions
'a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'),
diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php
index ca78167ec0..7f6267ed32 100644
--- a/phpBB/phpbb/plupload/plupload.php
+++ b/phpBB/phpbb/plupload/plupload.php
@@ -125,7 +125,7 @@ class plupload
// Need to modify some of the $_FILES values to reflect the new file
return array(
'tmp_name' => $file_path,
- 'name' => $this->request->variable('real_filename', ''),
+ 'name' => $this->request->variable('real_filename', '', true),
'size' => filesize($file_path),
'type' => $this->mimetype_guesser->guess($file_path, $file_name),
);
diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php
index dd08df94c1..9dc0181cb8 100644
--- a/phpBB/phpbb/profilefields/type/type_int.php
+++ b/phpBB/phpbb/profilefields/type/type_int.php
@@ -61,9 +61,9 @@ class type_int extends type_base
public function get_options($default_lang_id, $field_data)
{
$options = array(
- 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" size="5" value="' . $field_data['field_length'] . '" />'),
- 1 => array('TITLE' => $this->user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" size="5" value="' . $field_data['field_minlen'] . '" />'),
- 2 => array('TITLE' => $this->user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" size="5" value="' . $field_data['field_maxlen'] . '" />'),
+ 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" value="' . $field_data['field_length'] . '" />'),
+ 1 => array('TITLE' => $this->user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" value="' . $field_data['field_minlen'] . '" />'),
+ 2 => array('TITLE' => $this->user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" value="' . $field_data['field_maxlen'] . '" />'),
3 => array('TITLE' => $this->user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="number" name="field_default_value" value="' . $field_data['field_default_value'] . '" />'),
);
diff --git a/phpBB/phpbb/profilefields/type/type_string.php b/phpBB/phpbb/profilefields/type/type_string.php
index 67befc457d..a8432eaae5 100644
--- a/phpBB/phpbb/profilefields/type/type_string.php
+++ b/phpBB/phpbb/profilefields/type/type_string.php
@@ -61,9 +61,9 @@ class type_string extends type_string_common
public function get_options($default_lang_id, $field_data)
{
$options = array(
- 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" name="field_length" size="5" value="' . $field_data['field_length'] . '" />'),
- 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_minlen" size="5" value="' . $field_data['field_minlen'] . '" />'),
- 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_maxlen" size="5" value="' . $field_data['field_maxlen'] . '" />'),
+ 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" value="' . $field_data['field_length'] . '" />'),
+ 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" value="' . $field_data['field_minlen'] . '" />'),
+ 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0 max="99999"" name="field_maxlen" value="' . $field_data['field_maxlen'] . '" />'),
3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options($field_data) . '</select>'),
);
diff --git a/phpBB/phpbb/profilefields/type/type_text.php b/phpBB/phpbb/profilefields/type/type_text.php
index bacf60a213..79ee82351a 100644
--- a/phpBB/phpbb/profilefields/type/type_text.php
+++ b/phpBB/phpbb/profilefields/type/type_text.php
@@ -61,9 +61,9 @@ class type_text extends type_string_common
public function get_options($default_lang_id, $field_data)
{
$options = array(
- 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="rows" size="5" value="' . $field_data['rows'] . '" /> ' . $this->user->lang['ROWS'] . '</dd><dd><input type="number" min="0" max="99999" name="columns" size="5" value="' . $field_data['columns'] . '" /> ' . $this->user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $field_data['field_length'] . '" />'),
- 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_minlen" size="10" value="' . $field_data['field_minlen'] . '" />'),
- 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_maxlen" size="10" value="' . $field_data['field_maxlen'] . '" />'),
+ 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="rows" value="' . $field_data['rows'] . '" /> ' . $this->user->lang['ROWS'] . '</dd><dd><input type="number" min="0" max="99999" name="columns" value="' . $field_data['columns'] . '" /> ' . $this->user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $field_data['field_length'] . '" />'),
+ 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_minlen" value="' . $field_data['field_minlen'] . '" />'),
+ 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_maxlen" value="' . $field_data['field_maxlen'] . '" />'),
3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options($field_data) . '</select>'),
);
diff --git a/phpBB/phpbb/profilefields/type/type_url.php b/phpBB/phpbb/profilefields/type/type_url.php
index fe0bffd582..375cf5b19a 100644
--- a/phpBB/phpbb/profilefields/type/type_url.php
+++ b/phpBB/phpbb/profilefields/type/type_url.php
@@ -29,9 +29,9 @@ class type_url extends type_string
public function get_options($default_lang_id, $field_data)
{
$options = array(
- 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" name="field_length" size="5" value="' . $field_data['field_length'] . '" />'),
- 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_minlen" size="5" value="' . $field_data['field_minlen'] . '" />'),
- 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" name="field_maxlen" size="5" value="' . $field_data['field_maxlen'] . '" />'),
+ 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" value="' . $field_data['field_length'] . '" />'),
+ 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" value="' . $field_data['field_minlen'] . '" />'),
+ 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" value="' . $field_data['field_maxlen'] . '" />'),
);
return $options;
diff --git a/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php b/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php
index 2500ba0cf8..1446551b8b 100644
--- a/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php
+++ b/phpBB/phpbb/recursive_dot_prefix_filter_iterator.php
@@ -25,6 +25,6 @@ class recursive_dot_prefix_filter_iterator extends \RecursiveFilterIterator
public function accept()
{
$filename = $this->current()->getFilename();
- return !$this->current()->isDir() || $filename[0] !== '.';
+ return $filename[0] !== '.' || !$this->current()->isDir();
}
}
diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php
index 56ce3999ed..4cac6fbaea 100644
--- a/phpBB/phpbb/request/request.php
+++ b/phpBB/phpbb/request/request.php
@@ -325,7 +325,9 @@ class request implements \phpbb\request\request_interface
*/
public function is_secure()
{
- return $this->server('HTTPS') == 'on';
+ $https = $this->server('HTTPS');
+ $https = $this->server('HTTP_X_FORWARDED_PROTO') === 'https' ? 'on' : $https;
+ return !empty($https) && $https !== 'off';
}
/**
diff --git a/phpBB/phpbb/search/base.php b/phpBB/phpbb/search/base.php
index 30781975d8..d9313dddab 100644
--- a/phpBB/phpbb/search/base.php
+++ b/phpBB/phpbb/search/base.php
@@ -37,52 +37,6 @@ class base
}
/**
- * Retrieves a language dependend list of words that should be ignored by the search
- */
- function get_ignore_words()
- {
- if (!sizeof($this->ignore_words))
- {
- global $user, $phpEx;
-
- $words = array();
-
- if (file_exists("{$user->lang_path}{$user->lang_name}/search_ignore_words.$phpEx"))
- {
- // include the file containing ignore words
- include("{$user->lang_path}{$user->lang_name}/search_ignore_words.$phpEx");
- }
-
- $this->ignore_words = $words;
- unset($words);
- }
- }
-
- /**
- * Stores a list of synonyms that should be replaced in $this->match_synonym and $this->replace_synonym and caches them
- */
- function get_synonyms()
- {
- if (!sizeof($this->match_synonym))
- {
- global $user, $phpEx;
-
- $synonyms = array();
-
- if (file_exists("{$user->lang_path}{$user->lang_name}/search_synonyms.$phpEx"))
- {
- // include the file containing synonyms
- include("{$user->lang_path}{$user->lang_name}/search_synonyms.$phpEx");
- }
-
- $this->match_synonym = array_keys($synonyms);
- $this->replace_synonym = array_values($synonyms);
-
- unset($synonyms);
- }
- }
-
- /**
* Retrieves cached search results
*
* @param string $search_key an md5 string generated from all the passed search options to identify the results
diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php
index bad2003000..9faf5ca08b 100644
--- a/phpBB/phpbb/search/fulltext_mysql.php
+++ b/phpBB/phpbb/search/fulltext_mysql.php
@@ -177,8 +177,10 @@ class fulltext_mysql extends \phpbb\search\base
$engine === 'MyISAM' ||
// FULLTEXT is supported on InnoDB since MySQL 5.6.4 according to
// http://dev.mysql.com/doc/refman/5.6/en/innodb-storage-engine.html
+ // We also require https://bugs.mysql.com/bug.php?id=67004 to be
+ // fixed for proper overall operation. Hence we require 5.6.8.
$engine === 'InnoDB' &&
- phpbb_version_compare($this->db->sql_server_info(true), '5.6.4', '>=');
+ phpbb_version_compare($this->db->sql_server_info(true), '5.6.8', '>=');
if (!$fulltext_supported)
{
@@ -379,7 +381,7 @@ class fulltext_mysql extends \phpbb\search\base
}
// generate a search_key from all the options to identify the results
- $search_key = md5(implode('#', array(
+ $search_key_array = array(
implode(', ', $this->split_words),
$type,
$fields,
@@ -390,7 +392,39 @@ class fulltext_mysql extends \phpbb\search\base
implode(',', $ex_fid_ary),
$post_visibility,
implode(',', $author_ary)
- )));
+ );
+
+ /**
+ * Allow changing the search_key for cached results
+ *
+ * @event core.search_mysql_by_keyword_modify_search_key
+ * @var array search_key_array Array with search parameters to generate the search_key
+ * @var string type Searching type ('posts', 'topics')
+ * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all')
+ * @var string terms Searching terms ('all', 'any')
+ * @var int sort_days Time, in days, of the oldest possible post to list
+ * @var string sort_key The sort type used from the possible sort types
+ * @var int topic_id Limit the search to this topic_id only
+ * @var array ex_fid_ary Which forums not to search on
+ * @var string post_visibility Post visibility data
+ * @var array author_ary Array of user_id containing the users to filter the results to
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'search_key_array',
+ 'type',
+ 'fields',
+ 'terms',
+ 'sort_days',
+ 'sort_key',
+ 'topic_id',
+ 'ex_fid_ary',
+ 'post_visibility',
+ 'author_ary',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_by_keyword_modify_search_key', compact($vars)));
+
+ $search_key = md5(implode('#', $search_key_array));
if ($start < 0)
{
@@ -610,7 +644,7 @@ class fulltext_mysql extends \phpbb\search\base
}
// generate a search_key from all the options to identify the results
- $search_key = md5(implode('#', array(
+ $search_key_array = array(
'',
$type,
($firstpost_only) ? 'firstpost' : '',
@@ -623,7 +657,39 @@ class fulltext_mysql extends \phpbb\search\base
$post_visibility,
implode(',', $author_ary),
$author_name,
- )));
+ );
+
+ /**
+ * Allow changing the search_key for cached results
+ *
+ * @event core.search_mysql_by_author_modify_search_key
+ * @var array search_key_array Array with search parameters to generate the search_key
+ * @var string type Searching type ('posts', 'topics')
+ * @var boolean firstpost_only Flag indicating if only topic starting posts are considered
+ * @var int sort_days Time, in days, of the oldest possible post to list
+ * @var string sort_key The sort type used from the possible sort types
+ * @var int topic_id Limit the search to this topic_id only
+ * @var array ex_fid_ary Which forums not to search on
+ * @var string post_visibility Post visibility data
+ * @var array author_ary Array of user_id containing the users to filter the results to
+ * @var string author_name The username to search on
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'search_key_array',
+ 'type',
+ 'firstpost_only',
+ 'sort_days',
+ 'sort_key',
+ 'topic_id',
+ 'ex_fid_ary',
+ 'post_visibility',
+ 'author_ary',
+ 'author_name',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_by_author_modify_search_key', compact($vars)));
+
+ $search_key = md5(implode('#', $search_key_array));
if ($start < 0)
{
diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php
index 02337cbf98..63b0b24edf 100644
--- a/phpBB/phpbb/search/fulltext_native.php
+++ b/phpBB/phpbb/search/fulltext_native.php
@@ -57,7 +57,7 @@ class fulltext_native extends \phpbb\search\base
protected $must_not_contain_ids = array();
/**
- * Post ids of posts containing atleast one word that needs to be excluded
+ * Post ids of posts containing at least one word that needs to be excluded
* @var array
*/
protected $must_exclude_one_ids = array();
@@ -530,7 +530,7 @@ class fulltext_native extends \phpbb\search\base
sort($must_exclude_one_ids);
// generate a search_key from all the options to identify the results
- $search_key = md5(implode('#', array(
+ $search_key_array = array(
serialize($must_contain_ids),
serialize($must_not_contain_ids),
serialize($must_exclude_one_ids),
@@ -544,7 +544,45 @@ class fulltext_native extends \phpbb\search\base
$post_visibility,
implode(',', $author_ary),
$author_name,
- )));
+ );
+
+ /**
+ * Allow changing the search_key for cached results
+ *
+ * @event core.search_native_by_keyword_modify_search_key
+ * @var array search_key_array Array with search parameters to generate the search_key
+ * @var array must_contain_ids Array with post ids of posts containing words that are to be included
+ * @var array must_not_contain_ids Array with post ids of posts containing words that should not be included
+ * @var array must_exclude_one_ids Array with post ids of posts containing at least one word that needs to be excluded
+ * @var string type Searching type ('posts', 'topics')
+ * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all')
+ * @var string terms Searching terms ('all', 'any')
+ * @var int sort_days Time, in days, of the oldest possible post to list
+ * @var string sort_key The sort type used from the possible sort types
+ * @var int topic_id Limit the search to this topic_id only
+ * @var array ex_fid_ary Which forums not to search on
+ * @var string post_visibility Post visibility data
+ * @var array author_ary Array of user_id containing the users to filter the results to
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'search_key_array',
+ 'must_contain_ids',
+ 'must_not_contain_ids',
+ 'must_exclude_one_ids',
+ 'type',
+ 'fields',
+ 'terms',
+ 'sort_days',
+ 'sort_key',
+ 'topic_id',
+ 'ex_fid_ary',
+ 'post_visibility',
+ 'author_ary',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_native_by_keyword_modify_search_key', compact($vars)));
+
+ $search_key = md5(implode('#', $search_key_array));
// try reading the results from cache
$total_results = 0;
@@ -980,7 +1018,7 @@ class fulltext_native extends \phpbb\search\base
}
// generate a search_key from all the options to identify the results
- $search_key = md5(implode('#', array(
+ $search_key_array = array(
'',
$type,
($firstpost_only) ? 'firstpost' : '',
@@ -993,7 +1031,39 @@ class fulltext_native extends \phpbb\search\base
$post_visibility,
implode(',', $author_ary),
$author_name,
- )));
+ );
+
+ /**
+ * Allow changing the search_key for cached results
+ *
+ * @event core.search_native_by_author_modify_search_key
+ * @var array search_key_array Array with search parameters to generate the search_key
+ * @var string type Searching type ('posts', 'topics')
+ * @var boolean firstpost_only Flag indicating if only topic starting posts are considered
+ * @var int sort_days Time, in days, of the oldest possible post to list
+ * @var string sort_key The sort type used from the possible sort types
+ * @var int topic_id Limit the search to this topic_id only
+ * @var array ex_fid_ary Which forums not to search on
+ * @var string post_visibility Post visibility data
+ * @var array author_ary Array of user_id containing the users to filter the results to
+ * @var string author_name The username to search on
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'search_key_array',
+ 'type',
+ 'firstpost_only',
+ 'sort_days',
+ 'sort_key',
+ 'topic_id',
+ 'ex_fid_ary',
+ 'post_visibility',
+ 'author_ary',
+ 'author_name',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_native_by_author_modify_search_key', compact($vars)));
+
+ $search_key = md5(implode('#', $search_key_array));
// try reading the results from cache
$total_results = 0;
@@ -1192,7 +1262,7 @@ class fulltext_native extends \phpbb\search\base
if (!$total_results && $is_mysql)
{
// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
- $sql_calc = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql);
+ $sql_calc = str_replace('SELECT ' . $select, 'SELECT SQL_CALC_FOUND_ROWS ' . $select, $sql);
$result = $this->db->sql_query($sql_calc);
$this->db->sql_freeresult($result);
@@ -1905,15 +1975,15 @@ class fulltext_native extends \phpbb\search\base
</dl>
<dl>
<dt><label for="fulltext_native_min_chars">' . $this->user->lang['MIN_SEARCH_CHARS'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_native_min_chars" type="number" size="3" maxlength="3" min="0" max="255" name="config[fulltext_native_min_chars]" value="' . (int) $this->config['fulltext_native_min_chars'] . '" /></dd>
+ <dd><input id="fulltext_native_min_chars" type="number" min="0" max="255" name="config[fulltext_native_min_chars]" value="' . (int) $this->config['fulltext_native_min_chars'] . '" /></dd>
</dl>
<dl>
<dt><label for="fulltext_native_max_chars">' . $this->user->lang['MAX_SEARCH_CHARS'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_native_max_chars" type="number" size="3" maxlength="3" min="0" max="255" name="config[fulltext_native_max_chars]" value="' . (int) $this->config['fulltext_native_max_chars'] . '" /></dd>
+ <dd><input id="fulltext_native_max_chars" type="number" min="0" max="255" name="config[fulltext_native_max_chars]" value="' . (int) $this->config['fulltext_native_max_chars'] . '" /></dd>
</dl>
<dl>
<dt><label for="fulltext_native_common_thres">' . $this->user->lang['COMMON_WORD_THRESHOLD'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['COMMON_WORD_THRESHOLD_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_native_common_thres" type="text" size="3" maxlength="3" name="config[fulltext_native_common_thres]" value="' . (double) $this->config['fulltext_native_common_thres'] . '" /> %</dd>
+ <dd><input id="fulltext_native_common_thres" type="text" name="config[fulltext_native_common_thres]" value="' . (double) $this->config['fulltext_native_common_thres'] . '" /> %</dd>
</dl>
';
diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php
index d17b26be8f..04441e6226 100644
--- a/phpBB/phpbb/search/fulltext_postgres.php
+++ b/phpBB/phpbb/search/fulltext_postgres.php
@@ -341,7 +341,7 @@ class fulltext_postgres extends \phpbb\search\base
}
// generate a search_key from all the options to identify the results
- $search_key = md5(implode('#', array(
+ $search_key_array = array(
implode(', ', $this->split_words),
$type,
$fields,
@@ -352,7 +352,39 @@ class fulltext_postgres extends \phpbb\search\base
implode(',', $ex_fid_ary),
$post_visibility,
implode(',', $author_ary)
- )));
+ );
+
+ /**
+ * Allow changing the search_key for cached results
+ *
+ * @event core.search_postgres_by_keyword_modify_search_key
+ * @var array search_key_array Array with search parameters to generate the search_key
+ * @var string type Searching type ('posts', 'topics')
+ * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all')
+ * @var string terms Searching terms ('all', 'any')
+ * @var int sort_days Time, in days, of the oldest possible post to list
+ * @var string sort_key The sort type used from the possible sort types
+ * @var int topic_id Limit the search to this topic_id only
+ * @var array ex_fid_ary Which forums not to search on
+ * @var string post_visibility Post visibility data
+ * @var array author_ary Array of user_id containing the users to filter the results to
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'search_key_array',
+ 'type',
+ 'fields',
+ 'terms',
+ 'sort_days',
+ 'sort_key',
+ 'topic_id',
+ 'ex_fid_ary',
+ 'post_visibility',
+ 'author_ary',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_by_keyword_modify_search_key', compact($vars)));
+
+ $search_key = md5(implode('#', $search_key_array));
if ($start < 0)
{
@@ -585,7 +617,7 @@ class fulltext_postgres extends \phpbb\search\base
}
// generate a search_key from all the options to identify the results
- $search_key = md5(implode('#', array(
+ $search_key_array = array(
'',
$type,
($firstpost_only) ? 'firstpost' : '',
@@ -598,7 +630,39 @@ class fulltext_postgres extends \phpbb\search\base
$post_visibility,
implode(',', $author_ary),
$author_name,
- )));
+ );
+
+ /**
+ * Allow changing the search_key for cached results
+ *
+ * @event core.search_postgres_by_author_modify_search_key
+ * @var array search_key_array Array with search parameters to generate the search_key
+ * @var string type Searching type ('posts', 'topics')
+ * @var boolean firstpost_only Flag indicating if only topic starting posts are considered
+ * @var int sort_days Time, in days, of the oldest possible post to list
+ * @var string sort_key The sort type used from the possible sort types
+ * @var int topic_id Limit the search to this topic_id only
+ * @var array ex_fid_ary Which forums not to search on
+ * @var string post_visibility Post visibility data
+ * @var array author_ary Array of user_id containing the users to filter the results to
+ * @var string author_name The username to search on
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'search_key_array',
+ 'type',
+ 'firstpost_only',
+ 'sort_days',
+ 'sort_key',
+ 'topic_id',
+ 'ex_fid_ary',
+ 'post_visibility',
+ 'author_ary',
+ 'author_name',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_by_author_modify_search_key', compact($vars)));
+
+ $search_key = md5(implode('#', $search_key_array));
if ($start < 0)
{
@@ -1025,11 +1089,11 @@ class fulltext_postgres extends \phpbb\search\base
</dl>
<dl>
<dt><label for="fulltext_postgres_min_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_postgres_min_word_len" type="number" size="3" maxlength="3" min="0" max="255" name="config[fulltext_postgres_min_word_len]" value="' . (int) $this->config['fulltext_postgres_min_word_len'] . '" /></dd>
+ <dd><input id="fulltext_postgres_min_word_len" type="number" min="0" max="255" name="config[fulltext_postgres_min_word_len]" value="' . (int) $this->config['fulltext_postgres_min_word_len'] . '" /></dd>
</dl>
<dl>
<dt><label for="fulltext_postgres_max_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_postgres_max_word_len" type="number" size="3" maxlength="3" min="0" max="255" name="config[fulltext_postgres_max_word_len]" value="' . (int) $this->config['fulltext_postgres_max_word_len'] . '" /></dd>
+ <dd><input id="fulltext_postgres_max_word_len" type="number" min="0" max="255" name="config[fulltext_postgres_max_word_len]" value="' . (int) $this->config['fulltext_postgres_max_word_len'] . '" /></dd>
</dl>
';
diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php
index cd7add72f0..0dbc6e33df 100644
--- a/phpBB/phpbb/search/fulltext_sphinx.php
+++ b/phpBB/phpbb/search/fulltext_sphinx.php
@@ -358,6 +358,23 @@ class fulltext_sphinx
$non_unique = array('sql_query_pre' => true, 'sql_attr_uint' => true, 'sql_attr_timestamp' => true, 'sql_attr_str2ordinal' => true, 'sql_attr_bool' => true);
$delete = array('sql_group_column' => true, 'sql_date_column' => true, 'sql_str2ordinal_column' => true);
+
+ /**
+ * Allow adding/changing the Sphinx configuration data
+ *
+ * @event core.search_sphinx_modify_config_data
+ * @var array config_data Array with the Sphinx configuration data
+ * @var array non_unique Array with the Sphinx non-unique variables to delete
+ * @var array delete Array with the Sphinx variables to delete
+ * @since 3.1.7-RC1
+ */
+ $vars = array(
+ 'config_data',
+ 'non_unique',
+ 'delete',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_modify_config_data', compact($vars)));
+
foreach ($config_data as $section_name => $section_data)
{
$section = $config_object->get_section_by_name($section_name);
@@ -531,6 +548,41 @@ class fulltext_sphinx
$this->sphinx->SetFilter('topic_id', array($topic_id));
}
+ /**
+ * Allow modifying the Sphinx search options
+ *
+ * @event core.search_sphinx_keywords_modify_options
+ * @var string type Searching type ('posts', 'topics')
+ * @var string fields Searching fields ('titleonly', 'msgonly', 'firstpost', 'all')
+ * @var string terms Searching terms ('all', 'any')
+ * @var int sort_days Time, in days, of the oldest possible post to list
+ * @var string sort_key The sort type used from the possible sort types
+ * @var int topic_id Limit the search to this topic_id only
+ * @var array ex_fid_ary Which forums not to search on
+ * @var string post_visibility Post visibility data
+ * @var array author_ary Array of user_id containing the users to filter the results to
+ * @var string author_name The username to search on
+ * @var object sphinx The Sphinx searchd client object
+ * @since 3.1.7-RC1
+ */
+ $sphinx = $this->sphinx;
+ $vars = array(
+ 'type',
+ 'fields',
+ 'terms',
+ 'sort_days',
+ 'sort_key',
+ 'topic_id',
+ 'ex_fid_ary',
+ 'post_visibility',
+ 'author_ary',
+ 'author_name',
+ 'sphinx',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_keywords_modify_options', compact($vars)));
+ $this->sphinx = $sphinx;
+ unset($sphinx);
+
$search_query_prefix = '';
switch ($fields)
@@ -900,11 +952,11 @@ class fulltext_sphinx
</dl>
<dl>
<dt><label for="fulltext_sphinx_port">' . $this->user->lang['FULLTEXT_SPHINX_PORT'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_PORT_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_sphinx_port" type="number" size="4" maxlength="10" name="config[fulltext_sphinx_port]" value="' . $this->config['fulltext_sphinx_port'] . '" /></dd>
+ <dd><input id="fulltext_sphinx_port" type="number" min="0" max="9999999999" name="config[fulltext_sphinx_port]" value="' . $this->config['fulltext_sphinx_port'] . '" /></dd>
</dl>
<dl>
<dt><label for="fulltext_sphinx_indexer_mem_limit">' . $this->user->lang['FULLTEXT_SPHINX_INDEXER_MEM_LIMIT'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_INDEXER_MEM_LIMIT_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_sphinx_indexer_mem_limit" type="number" size="4" maxlength="10" name="config[fulltext_sphinx_indexer_mem_limit]" value="' . $this->config['fulltext_sphinx_indexer_mem_limit'] . '" /> ' . $this->user->lang['MIB'] . '</dd>
+ <dd><input id="fulltext_sphinx_indexer_mem_limit" type="number" min="0" max="9999999999" name="config[fulltext_sphinx_indexer_mem_limit]" value="' . $this->config['fulltext_sphinx_indexer_mem_limit'] . '" /> ' . $this->user->lang['MIB'] . '</dd>
</dl>
<dl>
<dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</span></dt>
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php
index a5c8f264e0..eb5543b50b 100644
--- a/phpBB/phpbb/session.php
+++ b/phpBB/phpbb/session.php
@@ -219,7 +219,7 @@ class session
function session_begin($update_session_page = true)
{
global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path;
- global $request, $phpbb_container;
+ global $request, $phpbb_container, $phpbb_dispatcher;
// Give us some basic information
$this->time_now = time();
@@ -281,11 +281,21 @@ class session
// Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests
// it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip.
- $this->ip = htmlspecialchars_decode($request->server('REMOTE_ADDR'));
- $this->ip = preg_replace('# {2,}#', ' ', str_replace(',', ' ', $this->ip));
+ $ip = htmlspecialchars_decode($request->server('REMOTE_ADDR'));
+ $ip = preg_replace('# {2,}#', ' ', str_replace(',', ' ', $ip));
+
+ /**
+ * Event to alter user IP address
+ *
+ * @event core.session_ip_after
+ * @var string ip REMOTE_ADDR
+ * @since 3.1.10-RC1
+ */
+ $vars = array('ip');
+ extract($phpbb_dispatcher->trigger_event('core.session_ip_after', compact($vars)));
// split the list of IPs
- $ips = explode(' ', trim($this->ip));
+ $ips = explode(' ', trim($ip));
// Default IP if REMOTE_ADDR is invalid
$this->ip = '127.0.0.1';
@@ -446,39 +456,6 @@ class session
if (!$session_expired)
{
- // Only update session DB a minute or so after last update or if page changes
- if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page']))
- {
- $sql_ary = array('session_time' => $this->time_now);
-
- // Do not update the session page for ajax requests, so the view online still works as intended
- if ($this->update_session_page && !$request->is_ajax())
- {
- $sql_ary['session_page'] = substr($this->page['page'], 0, 199);
- $sql_ary['session_forum_id'] = $this->page['forum'];
- }
-
- $db->sql_return_on_error(true);
-
- $this->update_session($sql_ary);
-
- $db->sql_return_on_error(false);
-
- // If the database is not yet updated, there will be an error due to the session_forum_id
- // @todo REMOVE for 3.0.2
- if ($result === false)
- {
- unset($sql_ary['session_forum_id']);
-
- $this->update_session($sql_ary);
- }
-
- if ($this->data['user_id'] != ANONYMOUS && !empty($config['new_member_post_limit']) && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts'])
- {
- $this->leave_newly_registered();
- }
- }
-
$this->data['is_registered'] = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false;
$this->data['is_bot'] = (!$this->data['is_registered'] && $this->data['user_id'] != ANONYMOUS) ? true : false;
$this->data['user_lang'] = basename($this->data['user_lang']);
@@ -734,18 +711,6 @@ class session
// Only update session DB a minute or so after last update or if page changes
if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page']))
{
- $this->data['session_time'] = $this->data['session_last_visit'] = $this->time_now;
-
- $sql_ary = array('session_time' => $this->time_now, 'session_last_visit' => $this->time_now, 'session_admin' => 0);
-
- if ($this->update_session_page)
- {
- $sql_ary['session_page'] = substr($this->page['page'], 0, 199);
- $sql_ary['session_forum_id'] = $this->page['forum'];
- }
-
- $this->update_session($sql_ary);
-
// Update the last visit time
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_lastvisit = ' . (int) $this->data['session_time'] . '
@@ -1599,4 +1564,41 @@ class session
$vars = array('session_data', 'session_id');
extract($phpbb_dispatcher->trigger_event('core.update_session_after', compact($vars)));
}
+
+ public function update_session_infos()
+ {
+ global $config, $db, $request;
+
+ // No need to update if it's a new session. Informations are already inserted by session_create()
+ if (isset($this->data['session_created']) && $this->data['session_created'])
+ {
+ return;
+ }
+
+ // Only update session DB a minute or so after last update or if page changes
+ if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page']))
+ {
+ $sql_ary = array('session_time' => $this->time_now);
+
+ // Do not update the session page for ajax requests, so the view online still works as intended
+ if ($this->update_session_page && !$request->is_ajax())
+ {
+ $sql_ary['session_page'] = substr($this->page['page'], 0, 199);
+ $sql_ary['session_forum_id'] = $this->page['forum'];
+ }
+
+ $db->sql_return_on_error(true);
+
+ $this->update_session($sql_ary);
+
+ $db->sql_return_on_error(false);
+
+ $this->data = array_merge($this->data, $sql_ary);
+
+ if ($this->data['user_id'] != ANONYMOUS && isset($config['new_member_post_limit']) && $this->data['user_new'] && $config['new_member_post_limit'] <= $this->data['user_posts'])
+ {
+ $this->leave_newly_registered();
+ }
+ }
+ }
}
diff --git a/phpBB/phpbb/template/asset.php b/phpBB/phpbb/template/asset.php
index 67dbd7b357..ff9366af4a 100644
--- a/phpBB/phpbb/template/asset.php
+++ b/phpBB/phpbb/template/asset.php
@@ -152,6 +152,24 @@ 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($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 (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 = 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)
{
$paths = explode('/', $path);
@@ -161,6 +179,7 @@ class asset
}
$path = implode('/', $paths);
}
+
$this->components['path'] = $path;
}
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index bd754d9bbd..d1bbb2b55a 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -350,7 +350,7 @@ class twig extends \phpbb\template\base
return $this->twig->render($this->get_filename_from_handle($handle), $this->get_template_vars());
}
- $this->assign_var($template_var, $this->twig->render($this->get_filename_from_handle($handle, $this->get_template_vars())));
+ $this->assign_var($template_var, $this->twig->render($this->get_filename_from_handle($handle), $this->get_template_vars()));
return $this;
}
diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php
index f5ad5096bb..faedd79703 100644
--- a/phpBB/phpbb/user.php
+++ b/phpBB/phpbb/user.php
@@ -725,7 +725,7 @@ class user extends \phpbb\session
$utc = new \DateTimeZone('UTC');
}
- $time = new $this->datetime($this, "@$gmepoch", $utc);
+ $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc);
$time->setTimezone($this->timezone);
return $time->format($format, $forcedate);
diff --git a/phpBB/phpbb/user_loader.php b/phpBB/phpbb/user_loader.php
index 5ce8ca2d4d..967d96d73a 100644
--- a/phpBB/phpbb/user_loader.php
+++ b/phpBB/phpbb/user_loader.php
@@ -189,12 +189,7 @@ class user_loader
return '';
}
- if (!function_exists('get_user_avatar'))
- {
- include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
- }
-
- return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height'], 'USER_AVATAR', false, $lazy);
+ return phpbb_get_avatar(\phpbb\avatar\manager::clean_row($user, 'user'), 'USER_AVATAR', false, $lazy);
}
/**
diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php
index e4f68f5aab..a1e66ba8fe 100644
--- a/phpBB/phpbb/version_helper.php
+++ b/phpBB/phpbb/version_helper.php
@@ -34,6 +34,11 @@ class version_helper
protected $file = 'versions.json';
/**
+ * @var bool Use SSL or not
+ */
+ protected $use_ssl = false;
+
+ /**
* @var string Current version installed
*/
protected $current_version;
@@ -85,13 +90,15 @@ class version_helper
* @param string $host Host (e.g. version.phpbb.com)
* @param string $path Path to file (e.g. /phpbb)
* @param string $file File name (Default: versions.json)
+ * @param bool $use_ssl Use SSL or not (Default: false)
* @return version_helper
*/
- public function set_file_location($host, $path, $file = 'versions.json')
+ public function set_file_location($host, $path, $file = 'versions.json', $use_ssl = false)
{
$this->host = $host;
$this->path = $path;
$this->file = $file;
+ $this->use_ssl = $use_ssl;
return $this;
}
@@ -244,7 +251,7 @@ class version_helper
*/
public function get_versions($force_update = false, $force_cache = false)
{
- $cache_file = '_versioncheck_' . $this->host . $this->path . $this->file;
+ $cache_file = '_versioncheck_' . $this->host . $this->path . $this->file . $this->use_ssl;
$info = $this->cache->get($cache_file);
@@ -255,7 +262,7 @@ class version_helper
else if ($info === false || $force_update)
{
try {
- $info = $this->file_downloader->get($this->host, $this->path, $this->file);
+ $info = $this->file_downloader->get($this->host, $this->path, $this->file, $this->use_ssl ? 443 : 80);
}
catch (\phpbb\exception\runtime_exception $exception)
{