aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/attachment/delete.php56
-rw-r--r--phpBB/phpbb/attachment/resync.php4
-rw-r--r--phpBB/phpbb/attachment/upload.php2
-rw-r--r--phpBB/phpbb/auth/auth.php10
-rw-r--r--phpBB/phpbb/auth/provider/ldap.php4
-rw-r--r--phpBB/phpbb/auth/provider/oauth/oauth.php83
-rw-r--r--phpBB/phpbb/auth/provider/provider_interface.php7
-rw-r--r--phpBB/phpbb/avatar/driver/local.php6
-rw-r--r--phpBB/phpbb/avatar/driver/upload.php14
-rw-r--r--phpBB/phpbb/avatar/manager.php25
-rw-r--r--phpBB/phpbb/cache/driver/apcu.php6
-rw-r--r--phpBB/phpbb/cache/driver/base.php6
-rw-r--r--phpBB/phpbb/cache/driver/file.php4
-rw-r--r--phpBB/phpbb/cache/driver/memory.php7
-rw-r--r--phpBB/phpbb/cache/service.php2
-rw-r--r--phpBB/phpbb/captcha/char_cube3d.php2
-rw-r--r--phpBB/phpbb/captcha/colour_manager.php2
-rw-r--r--phpBB/phpbb/captcha/gd.php54
-rw-r--r--phpBB/phpbb/captcha/plugins/captcha_abstract.php2
-rw-r--r--phpBB/phpbb/captcha/plugins/gd.php2
-rw-r--r--phpBB/phpbb/captcha/plugins/gd_wave.php2
-rw-r--r--phpBB/phpbb/captcha/plugins/nogd.php2
-rw-r--r--phpBB/phpbb/captcha/plugins/qa.php25
-rw-r--r--phpBB/phpbb/captcha/plugins/recaptcha.php2
-rw-r--r--phpBB/phpbb/console/command/extension/enable.php7
-rw-r--r--phpBB/phpbb/console/command/thumbnail/delete.php13
-rw-r--r--phpBB/phpbb/console/command/thumbnail/generate.php13
-rw-r--r--phpBB/phpbb/console/exception_subscriber.php13
-rw-r--r--phpBB/phpbb/content_visibility.php130
-rw-r--r--phpBB/phpbb/cron/task/core/prune_all_forums.php23
-rw-r--r--phpBB/phpbb/datetime.php6
-rw-r--r--phpBB/phpbb/db/driver/driver.php26
-rw-r--r--phpBB/phpbb/db/driver/mssql_base.php8
-rw-r--r--phpBB/phpbb/db/driver/mssqlnative.php5
-rw-r--r--phpBB/phpbb/db/driver/oracle.php6
-rw-r--r--phpBB/phpbb/db/extractor/mssql_extractor.php4
-rw-r--r--phpBB/phpbb/db/extractor/oracle_extractor.php4
-rw-r--r--phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php44
-rw-r--r--phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php14
-rw-r--r--phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php11
-rw-r--r--phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php4
-rw-r--r--phpBB/phpbb/db/migration/data/v310/dev.php25
-rw-r--r--phpBB/phpbb/db/migration/data/v310/extensions.php4
-rw-r--r--phpBB/phpbb/db/migration/data/v310/notifications.php7
-rw-r--r--phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php8
-rw-r--r--phpBB/phpbb/db/migration/data/v310/style_update_p1.php12
-rw-r--r--phpBB/phpbb/db/migration/data/v310/teampage.php4
-rw-r--r--phpBB/phpbb/db/migration/data/v31x/v3112.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php9
-rw-r--r--phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php19
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/disable_remote_avatar.php34
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/email_force_sender.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/f_list_topics_permission_add.php31
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php54
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/jquery_update.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php84
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/remove_imagick.php31
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/smtp_dynamic_data.php42
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/timezone_p3.php29
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/update_prosilver_bitfield.php39
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v321.php1
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v322.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v322rc1.php41
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v323.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v323rc1.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v323rc2.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v324.php38
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v324rc1.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v325.php38
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v325rc1.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v326.php39
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v326rc1.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v327.php37
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v327rc1.php36
-rw-r--r--phpBB/phpbb/db/migration/data/v32x/v328rc1.php37
-rw-r--r--phpBB/phpbb/db/migration/tool/config.php2
-rw-r--r--phpBB/phpbb/db/migration/tool/config_text.php2
-rw-r--r--phpBB/phpbb/db/migration/tool/module.php274
-rw-r--r--phpBB/phpbb/db/migration/tool/permission.php2
-rw-r--r--phpBB/phpbb/db/migrator.php6
-rw-r--r--phpBB/phpbb/db/sql_insert_buffer.php4
-rw-r--r--phpBB/phpbb/db/tools/mssql.php86
-rw-r--r--phpBB/phpbb/db/tools/tools.php17
-rw-r--r--phpBB/phpbb/debug/error_handler.php4
-rw-r--r--phpBB/phpbb/di/container_builder.php7
-rw-r--r--phpBB/phpbb/event/dispatcher.php7
-rw-r--r--phpBB/phpbb/event/md_exporter.php38
-rw-r--r--phpBB/phpbb/event/php_exporter.php73
-rw-r--r--phpBB/phpbb/feed/helper.php55
-rw-r--r--phpBB/phpbb/feed/quote_helper.php36
-rw-r--r--phpBB/phpbb/file_downloader.php2
-rw-r--r--phpBB/phpbb/files/filespec.php6
-rw-r--r--phpBB/phpbb/files/types/form.php2
-rw-r--r--phpBB/phpbb/files/types/local.php2
-rw-r--r--phpBB/phpbb/files/upload.php8
-rw-r--r--phpBB/phpbb/filesystem/filesystem.php10
-rw-r--r--phpBB/phpbb/group/helper.php260
-rw-r--r--phpBB/phpbb/install/helper/config.php2
-rw-r--r--phpBB/phpbb/install/helper/database.php6
-rw-r--r--phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php12
-rw-r--r--phpBB/phpbb/install/module/install_data/task/add_bots.php2
-rw-r--r--phpBB/phpbb/install/module/install_data/task/add_modules.php2
-rw-r--r--phpBB/phpbb/install/module/install_database/task/add_config_settings.php6
-rw-r--r--phpBB/phpbb/install/module/install_database/task/add_default_data.php2
-rw-r--r--phpBB/phpbb/install/module/install_database/task/add_tables.php2
-rw-r--r--phpBB/phpbb/install/module/install_finish/task/install_extensions.php2
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php8
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php6
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php89
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php4
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php8
-rw-r--r--phpBB/phpbb/install/module/requirements/task/check_update.php7
-rw-r--r--phpBB/phpbb/install/module/update_database/task/update_extensions.php2
-rw-r--r--phpBB/phpbb/install/module/update_filesystem/task/diff_files.php45
-rw-r--r--phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php10
-rw-r--r--phpBB/phpbb/language/language.php4
-rw-r--r--phpBB/phpbb/language/language_file_loader.php2
-rw-r--r--phpBB/phpbb/log/log.php26
-rw-r--r--phpBB/phpbb/message/admin_form.php30
-rw-r--r--phpBB/phpbb/message/form.php4
-rw-r--r--phpBB/phpbb/message/message.php6
-rw-r--r--phpBB/phpbb/module/module_manager.php10
-rw-r--r--phpBB/phpbb/notification/manager.php33
-rw-r--r--phpBB/phpbb/notification/method/board.php2
-rw-r--r--phpBB/phpbb/notification/method/email.php2
-rw-r--r--phpBB/phpbb/notification/method/messenger_base.php4
-rw-r--r--phpBB/phpbb/notification/type/admin_activate_user.php2
-rw-r--r--phpBB/phpbb/notification/type/pm.php2
-rw-r--r--phpBB/phpbb/notification/type/post.php10
-rw-r--r--phpBB/phpbb/notification/type/report_pm.php13
-rw-r--r--phpBB/phpbb/notification/type/topic.php2
-rw-r--r--phpBB/phpbb/pagination.php13
-rw-r--r--phpBB/phpbb/permissions.php1
-rw-r--r--phpBB/phpbb/profilefields/manager.php10
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php2
-rw-r--r--phpBB/phpbb/profilefields/type/type_dropdown.php6
-rw-r--r--phpBB/phpbb/profilefields/type/type_url.php15
-rw-r--r--phpBB/phpbb/report/controller/report.php6
-rw-r--r--phpBB/phpbb/report/report_handler_pm.php4
-rw-r--r--phpBB/phpbb/report/report_handler_post.php4
-rw-r--r--phpBB/phpbb/request/request.php2
-rw-r--r--phpBB/phpbb/request/type_cast_helper.php65
-rw-r--r--phpBB/phpbb/request/type_cast_helper_interface.php14
-rw-r--r--phpBB/phpbb/search/base.php10
-rw-r--r--phpBB/phpbb/search/fulltext_mysql.php136
-rw-r--r--phpBB/phpbb/search/fulltext_native.php153
-rw-r--r--phpBB/phpbb/search/fulltext_postgres.php98
-rw-r--r--phpBB/phpbb/search/fulltext_sphinx.php41
-rw-r--r--phpBB/phpbb/search/sphinx/config.php4
-rw-r--r--phpBB/phpbb/search/sphinx/config_section.php6
-rw-r--r--phpBB/phpbb/session.php35
-rw-r--r--phpBB/phpbb/template/assets_bag.php4
-rw-r--r--phpBB/phpbb/template/context.php178
-rw-r--r--phpBB/phpbb/template/twig/extension.php4
-rw-r--r--phpBB/phpbb/template/twig/node/includeasset.php7
-rw-r--r--phpBB/phpbb/textformatter/s9e/bbcode_merger.php183
-rw-r--r--phpBB/phpbb/textformatter/s9e/factory.php58
-rw-r--r--phpBB/phpbb/textformatter/s9e/link_helper.php31
-rw-r--r--phpBB/phpbb/textformatter/s9e/parser.php6
-rw-r--r--phpBB/phpbb/textreparser/base.php4
-rw-r--r--phpBB/phpbb/textreparser/plugins/poll_title.php2
-rw-r--r--phpBB/phpbb/tree/nestedset.php6
-rw-r--r--phpBB/phpbb/user.php23
-rw-r--r--phpBB/phpbb/user_loader.php8
166 files changed, 3152 insertions, 1056 deletions
diff --git a/phpBB/phpbb/attachment/delete.php b/phpBB/phpbb/attachment/delete.php
index 922f24b5dc..3c98e21587 100644
--- a/phpBB/phpbb/attachment/delete.php
+++ b/phpBB/phpbb/attachment/delete.php
@@ -104,6 +104,8 @@ class delete
$this->set_sql_constraints($mode);
+ $sql_id = $this->sql_id;
+
/**
* Perform additional actions before collecting data for attachment(s) deletion
*
@@ -122,11 +124,21 @@ class delete
);
extract($this->dispatcher->trigger_event('core.delete_attachments_collect_data_before', compact($vars)));
+ $this->sql_id = $sql_id;
+ unset($sql_id);
+
// Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled)
$this->collect_attachment_info($resync);
// Delete attachments from database
- $this->delete_attachments_from_db();
+ $this->delete_attachments_from_db($mode, $ids, $resync);
+
+ $sql_id = $this->sql_id;
+ $post_ids = $this->post_ids;
+ $topic_ids = $this->topic_ids;
+ $message_ids = $this->message_ids;
+ $physical = $this->physical;
+ $num_deleted = $this->num_deleted;
/**
* Perform additional actions after attachment(s) deletion from the database
@@ -156,13 +168,21 @@ class delete
);
extract($this->dispatcher->trigger_event('core.delete_attachments_from_database_after', compact($vars)));
+ $this->sql_id = $sql_id;
+ $this->post_ids = $post_ids;
+ $this->topic_ids = $topic_ids;
+ $this->message_ids = $message_ids;
+ $this->physical = $physical;
+ $this->num_deleted = $num_deleted;
+ unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical, $num_deleted);
+
if (!$this->num_deleted)
{
return 0;
}
// Delete attachments from filesystem
- $this->remove_from_filesystem();
+ $this->remove_from_filesystem($mode, $ids, $resync);
// If we do not resync, we do not need to adjust any message, post, topic or user entries
if (!$resync)
@@ -288,8 +308,14 @@ class delete
/**
* Delete attachments from database table
*/
- protected function delete_attachments_from_db()
+ protected function delete_attachments_from_db($mode, $ids, $resync)
{
+ $sql_id = $this->sql_id;
+ $post_ids = $this->post_ids;
+ $topic_ids = $this->topic_ids;
+ $message_ids = $this->message_ids;
+ $physical = $this->physical;
+
/**
* Perform additional actions before attachment(s) deletion
*
@@ -316,6 +342,13 @@ class delete
);
extract($this->dispatcher->trigger_event('core.delete_attachments_before', compact($vars)));
+ $this->sql_id = $sql_id;
+ $this->post_ids = $post_ids;
+ $this->topic_ids = $topic_ids;
+ $this->message_ids = $message_ids;
+ $this->physical = $physical;
+ unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical);
+
// Delete attachments
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $this->db->sql_in_set($this->sql_id, $this->ids);
@@ -329,7 +362,7 @@ class delete
/**
* Delete attachments from filesystem
*/
- protected function remove_from_filesystem()
+ protected function remove_from_filesystem($mode, $ids, $resync)
{
$space_removed = $files_removed = 0;
@@ -348,6 +381,13 @@ class delete
}
}
+ $sql_id = $this->sql_id;
+ $post_ids = $this->post_ids;
+ $topic_ids = $this->topic_ids;
+ $message_ids = $this->message_ids;
+ $physical = $this->physical;
+ $num_deleted = $this->num_deleted;
+
/**
* Perform additional actions after attachment(s) deletion from the filesystem
*
@@ -380,6 +420,14 @@ class delete
);
extract($this->dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars)));
+ $this->sql_id = $sql_id;
+ $this->post_ids = $post_ids;
+ $this->topic_ids = $topic_ids;
+ $this->message_ids = $message_ids;
+ $this->physical = $physical;
+ $this->num_deleted = $num_deleted;
+ unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical, $num_deleted);
+
if ($space_removed || $files_removed)
{
$this->config->increment('upload_dir_size', $space_removed * (-1), false);
diff --git a/phpBB/phpbb/attachment/resync.php b/phpBB/phpbb/attachment/resync.php
index 6c2e0a8b0d..aeacf82511 100644
--- a/phpBB/phpbb/attachment/resync.php
+++ b/phpBB/phpbb/attachment/resync.php
@@ -87,7 +87,7 @@ class resync
*/
public function resync($type, $ids)
{
- if (empty($type) || !is_array($ids) || !sizeof($ids) || !in_array($type, array('post', 'topic', 'message')))
+ if (empty($type) || !is_array($ids) || !count($ids) || !in_array($type, array('post', 'topic', 'message')))
{
return;
}
@@ -112,7 +112,7 @@ class resync
// Now only unset those ids remaining
$ids = array_diff($ids, $remaining_ids);
- if (sizeof($ids))
+ if (count($ids))
{
$sql = 'UPDATE ' . $this->resync_table . '
SET ' . $type . '_attachment = 0
diff --git a/phpBB/phpbb/attachment/upload.php b/phpBB/phpbb/attachment/upload.php
index f9863b372c..b9d32058db 100644
--- a/phpBB/phpbb/attachment/upload.php
+++ b/phpBB/phpbb/attachment/upload.php
@@ -162,7 +162,7 @@ class upload
// Make sure the image category only holds valid images...
$this->check_image($is_image);
- if (sizeof($this->file->error))
+ if (count($this->file->error))
{
$this->file->remove();
$this->file_data['error'] = array_merge($this->file_data['error'], $this->file->error);
diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php
index dbd83f1eb0..f46a21a8ae 100644
--- a/phpBB/phpbb/auth/auth.php
+++ b/phpBB/phpbb/auth/auth.php
@@ -72,8 +72,8 @@ class auth
// Verify bitstring length with options provided...
$renew = false;
- $global_length = sizeof($this->acl_options['global']);
- $local_length = sizeof($this->acl_options['local']);
+ $global_length = count($this->acl_options['global']);
+ $local_length = count($this->acl_options['local']);
// Specify comparing length (bitstring is padded to 31 bits)
$global_length = ($global_length % 31) ? ($global_length - ($global_length % 31) + 31) : $global_length;
@@ -236,7 +236,7 @@ class auth
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
- if (sizeof($this->acl))
+ if (count($this->acl))
{
$sql .= ' WHERE ' . $db->sql_in_set('forum_id', array_keys($this->acl), true);
}
@@ -278,7 +278,7 @@ class auth
}
// If we get forum_ids not having this permission, we need to fill the remaining parts
- if ($negate && sizeof($this->acl_forum_ids))
+ if ($negate && count($this->acl_forum_ids))
{
foreach ($this->acl_forum_ids as $f)
{
@@ -455,7 +455,7 @@ class auth
{
$hold_str = '';
- if (sizeof($hold_ary))
+ if (count($hold_ary))
{
ksort($hold_ary);
diff --git a/phpBB/phpbb/auth/provider/ldap.php b/phpBB/phpbb/auth/provider/ldap.php
index c48b771ab0..0789a6234d 100644
--- a/phpBB/phpbb/auth/provider/ldap.php
+++ b/phpBB/phpbb/auth/provider/ldap.php
@@ -99,7 +99,7 @@ class ldap extends \phpbb\auth\provider\base
@ldap_close($ldap);
- if (!is_array($result) || sizeof($result) < 2)
+ if (!is_array($result) || count($result) < 2)
{
return sprintf($this->user->lang['LDAP_NO_IDENTITY'], $this->user->data['username']);
}
@@ -192,7 +192,7 @@ class ldap extends \phpbb\auth\provider\base
$ldap_result = @ldap_get_entries($ldap, $search);
- if (is_array($ldap_result) && sizeof($ldap_result) > 1)
+ if (is_array($ldap_result) && count($ldap_result) > 1)
{
if (@ldap_bind($ldap, $ldap_result[0]['dn'], htmlspecialchars_decode($password)))
{
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php
index fdc5f57df0..0d94acfbca 100644
--- a/phpBB/phpbb/auth/provider/oauth/oauth.php
+++ b/phpBB/phpbb/auth/provider/oauth/oauth.php
@@ -191,7 +191,7 @@ class oauth extends \phpbb\auth\provider\base
return $provider->login($username, $password);
}
- // Requst the name of the OAuth service
+ // Request the name of the OAuth service
$service_name_original = $this->request->variable('oauth_service', '', false);
$service_name = 'auth.provider.oauth.service.' . strtolower($service_name_original);
if ($service_name_original === '' || !array_key_exists($service_name, $this->service_providers))
@@ -221,12 +221,37 @@ class oauth extends \phpbb\auth\provider\base
'provider' => $service_name_original,
'oauth_provider_id' => $unique_id
);
+
$sql = 'SELECT user_id FROM ' . $this->auth_provider_oauth_token_account_assoc . '
WHERE ' . $this->db->sql_build_array('SELECT', $data);
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
+ $redirect_data = array(
+ 'auth_provider' => 'oauth',
+ 'login_link_oauth_service' => $service_name_original,
+ );
+
+ /**
+ * Event is triggered before check if provider is already associated with an account
+ *
+ * @event core.oauth_login_after_check_if_provider_id_has_match
+ * @var array row User row
+ * @var array data Provider data
+ * @var array redirect_data Data to be appended to the redirect url
+ * @var \OAuth\Common\Service\ServiceInterface service OAuth service
+ * @since 3.2.3-RC1
+ * @changed 3.2.6-RC1 Added redirect_data
+ */
+ $vars = array(
+ 'row',
+ 'data',
+ 'redirect_data',
+ 'service',
+ );
+ extract($this->dispatcher->trigger_event('core.oauth_login_after_check_if_provider_id_has_match', compact($vars)));
+
if (!$row)
{
// The user does not yet exist, ask to link or create profile
@@ -234,15 +259,12 @@ class oauth extends \phpbb\auth\provider\base
'status' => LOGIN_SUCCESS_LINK_PROFILE,
'error_msg' => 'LOGIN_OAUTH_ACCOUNT_NOT_LINKED',
'user_row' => array(),
- 'redirect_data' => array(
- 'auth_provider' => 'oauth',
- 'login_link_oauth_service' => $service_name_original,
- ),
+ 'redirect_data' => $redirect_data,
);
}
// Retrieve the user's account
- $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type, user_login_attempts
+ $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_ip, user_type, user_login_attempts
FROM ' . $this->users_table . '
WHERE user_id = ' . (int) $row['user_id'];
$result = $this->db->sql_query($sql);
@@ -254,11 +276,36 @@ class oauth extends \phpbb\auth\provider\base
throw new \Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY');
}
+ /**
+ * Check if the user is banned.
+ * The fourth parameter, return, has to be true,
+ * otherwise the OAuth login is still called and
+ * an uncaught exception is thrown as there is no
+ * token stored in the database.
+ */
+ $ban = $this->user->check_ban($row['user_id'], $row['user_ip'], $row['user_email'], true);
+ if (!empty($ban))
+ {
+ $till_date = !empty($ban['ban_end']) ? $this->user->format_date($ban['ban_end']) : '';
+ $message = !empty($ban['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM';
+
+ $contact_link = phpbb_get_board_contact_link($this->config, $this->phpbb_root_path, $this->php_ext);
+ $message = $this->user->lang($message, $till_date, '<a href="' . $contact_link . '">', '</a>');
+ $message .= !empty($ban['ban_give_reason']) ? '<br /><br />' . $this->user->lang('BOARD_BAN_REASON', $ban['ban_give_reason']) : '';
+ $message .= !empty($ban['ban_triggered_by']) ? '<br /><br /><em>' . $this->user->lang('BAN_TRIGGERED_BY_' . strtoupper($ban['ban_triggered_by'])) . '</em>' : '';
+
+ return array(
+ 'status' => LOGIN_BREAK,
+ 'error_msg' => $message,
+ 'user_row' => $row,
+ );
+ }
+
// 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 is triggered after user is successfully logged in via OAuth.
*
* @event core.auth_oauth_login_after
* @var array row User row
@@ -376,7 +423,7 @@ class oauth extends \phpbb\auth\provider\base
if ($credentials['key'] && $credentials['secret'])
{
$actual_name = str_replace('auth.provider.oauth.service.', '', $service_name);
- $redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name;
+ $redirect_url = generate_board_url() . '/ucp.' . $this->php_ext . '?mode=login&login=external&oauth_service=' . $actual_name;
$login_data['BLOCK_VARS'][$service_name] = array(
'REDIRECT_URL' => redirect($redirect_url, true),
'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)],
@@ -587,6 +634,21 @@ class oauth extends \phpbb\auth\provider\base
*/
protected function link_account_perform_link(array $data)
{
+ // Check if the external account is already associated with other user
+ $sql = 'SELECT user_id
+ FROM ' . $this->auth_provider_oauth_token_account_assoc . "
+ WHERE provider = '" . $this->db->sql_escape($data['provider']) . "'
+ AND oauth_provider_id = '" . $this->db->sql_escape($data['oauth_provider_id']) . "'";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ if ($row)
+ {
+ trigger_error('AUTH_PROVIDER_OAUTH_ERROR_ALREADY_LINKED');
+ }
+
+ // Link account
$sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . '
' . $this->db->sql_build_array('INSERT', $data);
$this->db->sql_query($sql);
@@ -635,7 +697,7 @@ class oauth extends \phpbb\auth\provider\base
$oauth_user_ids = array();
- if ($rows !== false && sizeof($rows))
+ if ($rows !== false && count($rows))
{
foreach ($rows as $row)
{
@@ -658,6 +720,7 @@ class oauth extends \phpbb\auth\provider\base
'oauth_service' => $actual_name,
),
+ 'SERVICE_ID' => $actual_name,
'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)],
'UNIQUE_ID' => (isset($oauth_user_ids[$actual_name])) ? $oauth_user_ids[$actual_name] : null,
);
@@ -691,7 +754,7 @@ class oauth extends \phpbb\auth\provider\base
AND user_id = " . (int) $user_id;
$this->db->sql_query($sql);
- // Clear all tokens belonging to the user on this servce
+ // Clear all tokens belonging to the user on this service
$service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']);
$storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table);
$storage->clearToken($service_name);
diff --git a/phpBB/phpbb/auth/provider/provider_interface.php b/phpBB/phpbb/auth/provider/provider_interface.php
index 35e0f559a1..463324ff46 100644
--- a/phpBB/phpbb/auth/provider/provider_interface.php
+++ b/phpBB/phpbb/auth/provider/provider_interface.php
@@ -71,9 +71,10 @@ interface provider_interface
* options with whatever configuraton values are passed to it as an array.
* It then returns the name of the acp file related to this authentication
* provider.
- * @param array $new_config Contains the new configuration values that
- * have been set in acp_board.
- * @return array|null Returns null if not implemented or an array with
+ *
+ * @param \phpbb\config\config $new_config Contains the new configuration values
+ * that have been set in acp_board.
+ * @return array|null Returns null if not implemented or an array with
* the template file name and an array of the vars
* that the template needs that must conform to the
* following example:
diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php
index f5547c4bc6..4b84e4201c 100644
--- a/phpBB/phpbb/avatar/driver/local.php
+++ b/phpBB/phpbb/avatar/driver/local.php
@@ -64,7 +64,7 @@ class local extends \phpbb\avatar\driver\driver
$table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4;
$row_count = $col_count = $avatar_pos = 0;
- $avatar_count = sizeof($avatar_list[$category]);
+ $avatar_count = count($avatar_list[$category]);
reset($avatar_list[$category]);
@@ -158,7 +158,7 @@ class local extends \phpbb\avatar\driver\driver
*/
protected function get_avatar_list($user)
{
- $avatar_list = ($this->cache == null) ? false : $this->cache->get('_avatar_local_list');
+ $avatar_list = ($this->cache == null) ? false : $this->cache->get('_avatar_local_list_' . $user->data['user_lang']);
if ($avatar_list === false)
{
@@ -198,7 +198,7 @@ class local extends \phpbb\avatar\driver\driver
if ($this->cache != null)
{
- $this->cache->put('_avatar_local_list', $avatar_list, 86400);
+ $this->cache->put('_avatar_local_list_' . $user->data['user_lang'], $avatar_list, 86400);
}
}
diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php
index 887a0ff258..a012bb15b6 100644
--- a/phpBB/phpbb/avatar/driver/upload.php
+++ b/phpBB/phpbb/avatar/driver/upload.php
@@ -148,7 +148,8 @@ class upload extends \phpbb\avatar\driver\driver
// Do not allow specifying the port (see RFC 3986) or IP addresses
// remote_upload() will do its own check for allowed filetypes
- if (preg_match('@^(http|https|ftp)://[^/:?#]+:[0-9]+[/:?#]@i', $url) ||
+ if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url) ||
+ preg_match('@^(http|https|ftp)://[^/:?#]+:[0-9]+[/:?#]@i', $url) ||
preg_match('#^(http|https|ftp)://(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])#i', $url) ||
preg_match('#^(http|https|ftp)://(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){0,5}(?:[\dA-F]{1,4}(?::[\dA-F]{1,4})?|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:)|(?:::))#i', $url))
{
@@ -167,7 +168,7 @@ class upload extends \phpbb\avatar\driver\driver
$file->clean_filename('avatar', $prefix, $row['id']);
// If there was an error during upload, then abort operation
- if (sizeof($file->error))
+ if (count($file->error))
{
$file->remove();
$error = $file->error;
@@ -203,15 +204,18 @@ class upload extends \phpbb\avatar\driver\driver
*
* @event core.avatar_driver_upload_move_file_before
* @var array filedata Array containing uploaded file data
+ * @var \phpbb\files\filespec file Instance of filespec class
* @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
+ * @changed 3.2.3-RC1 Added file
*/
$vars = array(
'filedata',
+ 'file',
'destination',
'prefix',
'row',
@@ -221,7 +225,7 @@ class upload extends \phpbb\avatar\driver\driver
unset($filedata);
- if (!sizeof($error))
+ if (!count($error))
{
// Move file and overwrite any existing image
$file->move_file($destination, true);
@@ -229,7 +233,7 @@ class upload extends \phpbb\avatar\driver\driver
// If there was an error during move, then clean up leftovers
$error = array_merge($error, $file->error);
- if (sizeof($error))
+ if (count($error))
{
$file->remove();
return false;
@@ -291,7 +295,7 @@ class upload extends \phpbb\avatar\driver\driver
);
extract($this->dispatcher->trigger_event('core.avatar_driver_upload_delete_before', compact($vars)));
- if (!sizeof($error) && $this->filesystem->exists($filename))
+ if (!count($error) && $this->filesystem->exists($filename))
{
try
{
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php
index 26eb17c265..a909a91042 100644
--- a/phpBB/phpbb/avatar/manager.php
+++ b/phpBB/phpbb/avatar/manager.php
@@ -22,6 +22,12 @@ class manager
protected $config;
/**
+ * phpBB event dispatcher
+ * @var \phpbb\event\dispatcher_interface
+ */
+ protected $phpbb_dispatcher;
+
+ /**
* Array that contains a list of enabled drivers
* @var array
*/
@@ -49,11 +55,13 @@ class manager
* Construct an avatar manager object
*
* @param \phpbb\config\config $config phpBB configuration
+ * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher phpBB event dispatcher
* @param array $avatar_drivers Avatar drivers passed via the service container
*/
- public function __construct(\phpbb\config\config $config, $avatar_drivers)
+ public function __construct(\phpbb\config\config $config, \phpbb\event\dispatcher_interface $phpbb_dispatcher, $avatar_drivers)
{
$this->config = $config;
+ $this->phpbb_dispatcher = $phpbb_dispatcher;
$this->register_avatar_drivers($avatar_drivers);
}
@@ -263,7 +271,7 @@ class manager
$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),
+ 'allow_avatar_' . $config_name => array('lang' => 'ALLOW_' . strtoupper(str_replace('\\', '_', $config_name)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
);
}
@@ -331,6 +339,19 @@ class manager
WHERE user_avatar = '" . $db->sql_escape($avatar_data['avatar']) . "'";
$db->sql_query($sql);
}
+
+ /**
+ * Event is triggered after user avatar has been deleted
+ *
+ * @event core.avatar_manager_avatar_delete_after
+ * @var \phpbb\user user phpBB user object
+ * @var array avatar_data Normalised avatar-related user data
+ * @var string table Table to delete avatar from
+ * @var string prefix Column prefix to delete avatar from
+ * @since 3.2.4-RC1
+ */
+ $vars = array('user', 'avatar_data', 'table', 'prefix');
+ extract($this->phpbb_dispatcher->trigger_event('core.avatar_manager_avatar_delete_after', compact($vars)));
}
/**
diff --git a/phpBB/phpbb/cache/driver/apcu.php b/phpBB/phpbb/cache/driver/apcu.php
index 40192e4026..c96cf0de57 100644
--- a/phpBB/phpbb/cache/driver/apcu.php
+++ b/phpBB/phpbb/cache/driver/apcu.php
@@ -25,7 +25,11 @@ class apcu extends \phpbb\cache\driver\memory
*/
function purge()
{
- apcu_clear_cache();
+ /*
+ * Use an iterator to selectively delete our cache entries without disturbing
+ * any other cache users (e.g. other phpBB boards hosted on this server)
+ */
+ apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#'));
parent::purge();
}
diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php
index f4b3dc278d..3eca521148 100644
--- a/phpBB/phpbb/cache/driver/base.php
+++ b/phpBB/phpbb/cache/driver/base.php
@@ -123,7 +123,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface
*/
function sql_fetchrow($query_id)
{
- if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
+ if ($this->sql_row_pointer[$query_id] < count($this->sql_rowset[$query_id]))
{
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
}
@@ -136,7 +136,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface
*/
function sql_fetchfield($query_id, $field)
{
- if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
+ if ($this->sql_row_pointer[$query_id] < count($this->sql_rowset[$query_id]))
{
return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++][$field] : false;
}
@@ -149,7 +149,7 @@ abstract class base implements \phpbb\cache\driver\driver_interface
*/
function sql_rowseek($rownum, $query_id)
{
- if ($rownum >= sizeof($this->sql_rowset[$query_id]))
+ if ($rownum >= count($this->sql_rowset[$query_id]))
{
return false;
}
diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php
index e9d2ba8e04..de6f444251 100644
--- a/phpBB/phpbb/cache/driver/file.php
+++ b/phpBB/phpbb/cache/driver/file.php
@@ -135,7 +135,7 @@ class file extends \phpbb\cache\driver\base
if (file_exists($this->cache_dir . 'data_global.' . $phpEx))
{
- if (!sizeof($this->vars))
+ if (!count($this->vars))
{
$this->load();
}
@@ -290,7 +290,7 @@ class file extends \phpbb\cache\driver\base
}
else
{
- if (!sizeof($this->vars))
+ if (!count($this->vars))
{
$this->load();
}
diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php
index cc03804705..eba9549877 100644
--- a/phpBB/phpbb/cache/driver/memory.php
+++ b/phpBB/phpbb/cache/driver/memory.php
@@ -51,10 +51,11 @@ abstract class memory extends \phpbb\cache\driver\base
function load()
{
// grab the global cache
- $this->vars = $this->_read('global');
+ $data = $this->_read('global');
- if ($this->vars !== false)
+ if ($data !== false)
{
+ $this->vars = $data;
return true;
}
@@ -188,7 +189,7 @@ abstract class memory extends \phpbb\cache\driver\base
}
else
{
- if (!sizeof($this->vars))
+ if (!count($this->vars))
{
$this->load();
}
diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php
index 8a4366fed1..502ae27625 100644
--- a/phpBB/phpbb/cache/service.php
+++ b/phpBB/phpbb/cache/service.php
@@ -227,7 +227,7 @@ class service
// Store allowed extensions forum wise
if ($row['allow_group'])
{
- $extensions['_allowed_post'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;
+ $extensions['_allowed_post'][$extension] = (!count($allowed_forums)) ? 0 : $allowed_forums;
}
if ($row['allow_in_pm'])
diff --git a/phpBB/phpbb/captcha/char_cube3d.php b/phpBB/phpbb/captcha/char_cube3d.php
index a712b16dce..0255259ac4 100644
--- a/phpBB/phpbb/captcha/char_cube3d.php
+++ b/phpBB/phpbb/captcha/char_cube3d.php
@@ -220,7 +220,7 @@ class char_cube3d
*/
function scale($vector, $length)
{
- if (sizeof($vector) == 2)
+ if (count($vector) == 2)
{
return array($vector[0] * $length, $vector[1] * $length);
}
diff --git a/phpBB/phpbb/captcha/colour_manager.php b/phpBB/phpbb/captcha/colour_manager.php
index 6ca3c3fd2c..82332da810 100644
--- a/phpBB/phpbb/captcha/colour_manager.php
+++ b/phpBB/phpbb/captcha/colour_manager.php
@@ -256,7 +256,7 @@ class colour_manager
if (is_array($resource))
{
$results = array();
- for ($i = 0, $size = sizeof($resource); $i < $size; ++$i)
+ for ($i = 0, $size = count($resource); $i < $size; ++$i)
{
$results = array_merge($results, $this->mono_range($resource[$i], $count, $include_original));
}
diff --git a/phpBB/phpbb/captcha/gd.php b/phpBB/phpbb/captcha/gd.php
index e9538439c6..91b2f89d81 100644
--- a/phpBB/phpbb/captcha/gd.php
+++ b/phpBB/phpbb/captcha/gd.php
@@ -100,7 +100,7 @@ class gd
$noise_bitmaps = $this->captcha_noise_bg_bitmaps();
for ($i = 0; $i < $code_len; ++$i)
{
- $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, sizeof($noise_bitmaps['data'])));
+ $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, count($noise_bitmaps['data'])));
$noise[$i]->range();
//$box = $noise[$i]->dimensions($sizes[$i]);
@@ -1658,32 +1658,32 @@ class gd
'height' => 15,
'data' => array(
- 'A' => $chars['A'][mt_rand(0, min(sizeof($chars['A']), $config['captcha_gd_fonts']) -1)],
- 'B' => $chars['B'][mt_rand(0, min(sizeof($chars['B']), $config['captcha_gd_fonts']) -1)],
- 'C' => $chars['C'][mt_rand(0, min(sizeof($chars['C']), $config['captcha_gd_fonts']) -1)],
- 'D' => $chars['D'][mt_rand(0, min(sizeof($chars['D']), $config['captcha_gd_fonts']) -1)],
- 'E' => $chars['E'][mt_rand(0, min(sizeof($chars['E']), $config['captcha_gd_fonts']) -1)],
- 'F' => $chars['F'][mt_rand(0, min(sizeof($chars['F']), $config['captcha_gd_fonts']) -1)],
- 'G' => $chars['G'][mt_rand(0, min(sizeof($chars['G']), $config['captcha_gd_fonts']) -1)],
- 'H' => $chars['H'][mt_rand(0, min(sizeof($chars['H']), $config['captcha_gd_fonts']) -1)],
- 'I' => $chars['I'][mt_rand(0, min(sizeof($chars['I']), $config['captcha_gd_fonts']) -1)],
- 'J' => $chars['J'][mt_rand(0, min(sizeof($chars['J']), $config['captcha_gd_fonts']) -1)],
- 'K' => $chars['K'][mt_rand(0, min(sizeof($chars['K']), $config['captcha_gd_fonts']) -1)],
- 'L' => $chars['L'][mt_rand(0, min(sizeof($chars['L']), $config['captcha_gd_fonts']) -1)],
- 'M' => $chars['M'][mt_rand(0, min(sizeof($chars['M']), $config['captcha_gd_fonts']) -1)],
- 'N' => $chars['N'][mt_rand(0, min(sizeof($chars['N']), $config['captcha_gd_fonts']) -1)],
- 'O' => $chars['O'][mt_rand(0, min(sizeof($chars['O']), $config['captcha_gd_fonts']) -1)],
- 'P' => $chars['P'][mt_rand(0, min(sizeof($chars['P']), $config['captcha_gd_fonts']) -1)],
- 'Q' => $chars['Q'][mt_rand(0, min(sizeof($chars['Q']), $config['captcha_gd_fonts']) -1)],
- 'R' => $chars['R'][mt_rand(0, min(sizeof($chars['R']), $config['captcha_gd_fonts']) -1)],
- 'S' => $chars['S'][mt_rand(0, min(sizeof($chars['S']), $config['captcha_gd_fonts']) -1)],
- 'T' => $chars['T'][mt_rand(0, min(sizeof($chars['T']), $config['captcha_gd_fonts']) -1)],
- 'U' => $chars['U'][mt_rand(0, min(sizeof($chars['U']), $config['captcha_gd_fonts']) -1)],
- 'V' => $chars['V'][mt_rand(0, min(sizeof($chars['V']), $config['captcha_gd_fonts']) -1)],
- 'W' => $chars['W'][mt_rand(0, min(sizeof($chars['W']), $config['captcha_gd_fonts']) -1)],
- 'X' => $chars['X'][mt_rand(0, min(sizeof($chars['X']), $config['captcha_gd_fonts']) -1)],
- 'Y' => $chars['Y'][mt_rand(0, min(sizeof($chars['Y']), $config['captcha_gd_fonts']) -1)],
- 'Z' => $chars['Z'][mt_rand(0, min(sizeof($chars['Z']), $config['captcha_gd_fonts']) -1)],
+ 'A' => $chars['A'][mt_rand(0, min(count($chars['A']), $config['captcha_gd_fonts']) -1)],
+ 'B' => $chars['B'][mt_rand(0, min(count($chars['B']), $config['captcha_gd_fonts']) -1)],
+ 'C' => $chars['C'][mt_rand(0, min(count($chars['C']), $config['captcha_gd_fonts']) -1)],
+ 'D' => $chars['D'][mt_rand(0, min(count($chars['D']), $config['captcha_gd_fonts']) -1)],
+ 'E' => $chars['E'][mt_rand(0, min(count($chars['E']), $config['captcha_gd_fonts']) -1)],
+ 'F' => $chars['F'][mt_rand(0, min(count($chars['F']), $config['captcha_gd_fonts']) -1)],
+ 'G' => $chars['G'][mt_rand(0, min(count($chars['G']), $config['captcha_gd_fonts']) -1)],
+ 'H' => $chars['H'][mt_rand(0, min(count($chars['H']), $config['captcha_gd_fonts']) -1)],
+ 'I' => $chars['I'][mt_rand(0, min(count($chars['I']), $config['captcha_gd_fonts']) -1)],
+ 'J' => $chars['J'][mt_rand(0, min(count($chars['J']), $config['captcha_gd_fonts']) -1)],
+ 'K' => $chars['K'][mt_rand(0, min(count($chars['K']), $config['captcha_gd_fonts']) -1)],
+ 'L' => $chars['L'][mt_rand(0, min(count($chars['L']), $config['captcha_gd_fonts']) -1)],
+ 'M' => $chars['M'][mt_rand(0, min(count($chars['M']), $config['captcha_gd_fonts']) -1)],
+ 'N' => $chars['N'][mt_rand(0, min(count($chars['N']), $config['captcha_gd_fonts']) -1)],
+ 'O' => $chars['O'][mt_rand(0, min(count($chars['O']), $config['captcha_gd_fonts']) -1)],
+ 'P' => $chars['P'][mt_rand(0, min(count($chars['P']), $config['captcha_gd_fonts']) -1)],
+ 'Q' => $chars['Q'][mt_rand(0, min(count($chars['Q']), $config['captcha_gd_fonts']) -1)],
+ 'R' => $chars['R'][mt_rand(0, min(count($chars['R']), $config['captcha_gd_fonts']) -1)],
+ 'S' => $chars['S'][mt_rand(0, min(count($chars['S']), $config['captcha_gd_fonts']) -1)],
+ 'T' => $chars['T'][mt_rand(0, min(count($chars['T']), $config['captcha_gd_fonts']) -1)],
+ 'U' => $chars['U'][mt_rand(0, min(count($chars['U']), $config['captcha_gd_fonts']) -1)],
+ 'V' => $chars['V'][mt_rand(0, min(count($chars['V']), $config['captcha_gd_fonts']) -1)],
+ 'W' => $chars['W'][mt_rand(0, min(count($chars['W']), $config['captcha_gd_fonts']) -1)],
+ 'X' => $chars['X'][mt_rand(0, min(count($chars['X']), $config['captcha_gd_fonts']) -1)],
+ 'Y' => $chars['Y'][mt_rand(0, min(count($chars['Y']), $config['captcha_gd_fonts']) -1)],
+ 'Z' => $chars['Z'][mt_rand(0, min(count($chars['Z']), $config['captcha_gd_fonts']) -1)],
'1' => array(
array(0,0,0,1,1,0,0,0,0),
diff --git a/phpBB/phpbb/captcha/plugins/captcha_abstract.php b/phpBB/phpbb/captcha/plugins/captcha_abstract.php
index 82b08704ff..b508767d17 100644
--- a/phpBB/phpbb/captcha/plugins/captcha_abstract.php
+++ b/phpBB/phpbb/captcha/plugins/captcha_abstract.php
@@ -169,7 +169,7 @@ abstract class captcha_abstract
}
while ($row = $db->sql_fetchrow($result));
- if (sizeof($sql_in))
+ if (count($sql_in))
{
$sql = 'DELETE FROM ' . CONFIRM_TABLE . '
WHERE ' . $db->sql_in_set('session_id', $sql_in);
diff --git a/phpBB/phpbb/captcha/plugins/gd.php b/phpBB/phpbb/captcha/plugins/gd.php
index 831e5bcfdf..6d3c9bb3d2 100644
--- a/phpBB/phpbb/captcha/plugins/gd.php
+++ b/phpBB/phpbb/captcha/plugins/gd.php
@@ -51,7 +51,7 @@ class gd extends captcha_abstract
return 'CAPTCHA_GD';
}
- function acp_page($id, &$module)
+ function acp_page($id, $module)
{
global $user, $template, $phpbb_log, $request;
global $config;
diff --git a/phpBB/phpbb/captcha/plugins/gd_wave.php b/phpBB/phpbb/captcha/plugins/gd_wave.php
index bde46f8815..4ac26ed2b7 100644
--- a/phpBB/phpbb/captcha/plugins/gd_wave.php
+++ b/phpBB/phpbb/captcha/plugins/gd_wave.php
@@ -33,7 +33,7 @@ class gd_wave extends captcha_abstract
return '\\phpbb\\captcha\\gd_wave';
}
- function acp_page($id, &$module)
+ function acp_page($id, $module)
{
global $user;
diff --git a/phpBB/phpbb/captcha/plugins/nogd.php b/phpBB/phpbb/captcha/plugins/nogd.php
index 6845e5935c..da67cd2bf4 100644
--- a/phpBB/phpbb/captcha/plugins/nogd.php
+++ b/phpBB/phpbb/captcha/plugins/nogd.php
@@ -33,7 +33,7 @@ class nogd extends captcha_abstract
return '\\phpbb\\captcha\\non_gd';
}
- function acp_page($id, &$module)
+ function acp_page($id, $module)
{
global $user;
diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php
index 9d481acc5d..966b8d32f2 100644
--- a/phpBB/phpbb/captcha/plugins/qa.php
+++ b/phpBB/phpbb/captcha/plugins/qa.php
@@ -21,7 +21,7 @@ class qa
{
var $confirm_id;
var $answer;
- var $question_ids;
+ var $question_ids = [];
var $question_text;
var $question_lang;
var $question_strict;
@@ -84,7 +84,7 @@ class qa
$db->sql_freeresult($result);
// fallback to the board default lang
- if (!sizeof($this->question_ids))
+ if (!count($this->question_ids))
{
$this->question_lang = $config['default_lang'];
@@ -101,14 +101,13 @@ class qa
}
// final fallback to any language
- if (!sizeof($this->question_ids))
+ if (!count($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';
+ WHERE q.question_id = a.question_id';
$result = $db->sql_query($sql, 7200);
while ($row = $db->sql_fetchrow($result))
@@ -311,7 +310,7 @@ class qa
}
while ($row = $db->sql_fetchrow($result));
- if (sizeof($sql_in))
+ if (count($sql_in))
{
$sql = 'DELETE FROM ' . $this->table_qa_confirm . '
WHERE ' . $db->sql_in_set('confirm_id', $sql_in);
@@ -395,7 +394,7 @@ class qa
$error = '';
- if (!sizeof($this->question_ids))
+ if (!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')));
@@ -439,7 +438,7 @@ class qa
{
global $db, $user;
- if (!sizeof($this->question_ids))
+ if (!count($this->question_ids))
{
return;
}
@@ -465,7 +464,7 @@ class qa
{
global $db, $user;
- if (!sizeof($this->question_ids))
+ if (!count($this->question_ids))
{
return;
}
@@ -536,7 +535,7 @@ class qa
{
global $db, $user;
- if (!strlen($this->confirm_id) || !sizeof($this->question_ids))
+ if (!strlen($this->confirm_id) || !count($this->question_ids))
{
return false;
}
@@ -638,7 +637,7 @@ class qa
/**
* API function - The ACP backend, this marks the end of the easy methods
*/
- function acp_page($id, &$module)
+ function acp_page($id, $module)
{
global $config, $request, $phpbb_log, $template, $user;
@@ -776,7 +775,7 @@ class qa
/**
* This handles the list overview
*/
- function acp_question_list(&$module)
+ function acp_question_list($module)
{
global $db, $template;
@@ -979,7 +978,7 @@ class qa
if (!isset($langs[$question_data['lang_iso']]) ||
!strlen($question_data['question_text']) ||
- !sizeof($question_data['answers']) ||
+ !count($question_data['answers']) ||
!is_array($question_data['answers']))
{
return false;
diff --git a/phpBB/phpbb/captcha/plugins/recaptcha.php b/phpBB/phpbb/captcha/plugins/recaptcha.php
index 152709a9ea..b7c0b5f5e2 100644
--- a/phpBB/phpbb/captcha/plugins/recaptcha.php
+++ b/phpBB/phpbb/captcha/plugins/recaptcha.php
@@ -66,7 +66,7 @@ class recaptcha extends captcha_abstract
throw new \Exception('No generator class given.');
}
- function acp_page($id, &$module)
+ function acp_page($id, $module)
{
global $config, $template, $user, $phpbb_log, $request;
diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php
index f92de0069c..a6f5b10e86 100644
--- a/phpBB/phpbb/console/command/extension/enable.php
+++ b/phpBB/phpbb/console/command/extension/enable.php
@@ -37,6 +37,13 @@ class enable extends command
$io = new SymfonyStyle($input, $output);
$name = $input->getArgument('extension-name');
+
+ if (!$this->manager->is_available($name))
+ {
+ $io->error($this->user->lang('CLI_EXTENSION_NOT_EXIST', $name));
+ return 1;
+ }
+
$extension = $this->manager->get_extension($name);
if (!$extension->is_enableable())
diff --git a/phpBB/phpbb/console/command/thumbnail/delete.php b/phpBB/phpbb/console/command/thumbnail/delete.php
index cfa9891fbc..7b95c20cf2 100644
--- a/phpBB/phpbb/console/command/thumbnail/delete.php
+++ b/phpBB/phpbb/console/command/thumbnail/delete.php
@@ -19,6 +19,11 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class delete extends \phpbb\console\command\command
{
/**
+ * @var \phpbb\config\config
+ */
+ protected $config;
+
+ /**
* @var \phpbb\db\driver\driver_interface
*/
protected $db;
@@ -32,12 +37,14 @@ class delete extends \phpbb\console\command\command
/**
* Constructor
*
+ * @param \config\config $config The config
* @param \phpbb\user $user The user object (used to get language information)
* @param \phpbb\db\driver\driver_interface $db Database connection
* @param string $phpbb_root_path Root path
*/
- public function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db, $phpbb_root_path)
+ public function __construct(\phpbb\config\config $config, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, $phpbb_root_path)
{
+ $this->config = $config;
$this->db = $db;
$this->phpbb_root_path = $phpbb_root_path;
@@ -101,13 +108,13 @@ class delete extends \phpbb\console\command\command
$return = 0;
while ($row = $this->db->sql_fetchrow($result))
{
- $thumbnail_path = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
+ $thumbnail_path = $this->phpbb_root_path . $this->config['upload_path'] . '/thumb_' . $row['physical_filename'];
if (@unlink($thumbnail_path))
{
$thumbnail_deleted[] = $row['attach_id'];
- if (sizeof($thumbnail_deleted) === 250)
+ if (count($thumbnail_deleted) === 250)
{
$this->commit_changes($thumbnail_deleted);
$thumbnail_deleted = array();
diff --git a/phpBB/phpbb/console/command/thumbnail/generate.php b/phpBB/phpbb/console/command/thumbnail/generate.php
index 64f7555336..1f6582b17b 100644
--- a/phpBB/phpbb/console/command/thumbnail/generate.php
+++ b/phpBB/phpbb/console/command/thumbnail/generate.php
@@ -20,6 +20,11 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class generate extends \phpbb\console\command\command
{
/**
+ * @var \phpbb\config\config
+ */
+ protected $config;
+
+ /**
* @var \phpbb\db\driver\driver_interface
*/
protected $db;
@@ -45,14 +50,16 @@ class generate extends \phpbb\console\command\command
/**
* Constructor
*
+ * @param \config\config $config The config
* @param \phpbb\user $user The user object (used to get language information)
* @param \phpbb\db\driver\driver_interface $db Database connection
* @param \phpbb\cache\service $cache The cache service
* @param string $phpbb_root_path Root path
* @param string $php_ext PHP extension
*/
- public function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $phpbb_root_path, $php_ext)
+ public function __construct(\phpbb\config\config $config, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $phpbb_root_path, $php_ext)
{
+ $this->config = $config;
$this->db = $db;
$this->cache = $cache;
$this->phpbb_root_path = $phpbb_root_path;
@@ -126,8 +133,8 @@ class generate extends \phpbb\console\command\command
{
if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE)
{
- $source = $this->phpbb_root_path . 'files/' . $row['physical_filename'];
- $destination = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
+ $source = $this->phpbb_root_path . $this->config['upload_path'] . '/' . $row['physical_filename'];
+ $destination = $this->phpbb_root_path . $this->config['upload_path'] . '/thumb_' . $row['physical_filename'];
if (create_thumbnail($source, $destination, $row['mimetype']))
{
diff --git a/phpBB/phpbb/console/exception_subscriber.php b/phpBB/phpbb/console/exception_subscriber.php
index b920d4abae..b240993203 100644
--- a/phpBB/phpbb/console/exception_subscriber.php
+++ b/phpBB/phpbb/console/exception_subscriber.php
@@ -29,12 +29,10 @@ class exception_subscriber implements EventSubscriberInterface
* Construct method
*
* @param \phpbb\language\language $language Language object
- * @param bool $debug Debug mode
*/
- public function __construct(\phpbb\language\language $language, $debug = false)
+ public function __construct(\phpbb\language\language $language)
{
$this->language = $language;
- $this->debug = $debug;
}
/**
@@ -52,14 +50,7 @@ class exception_subscriber implements EventSubscriberInterface
$parameters = array_merge(array($original_exception->getMessage()), $original_exception->get_parameters());
$message = call_user_func_array(array($this->language, 'lang'), $parameters);
- if ($this->debug)
- {
- $exception = new \RuntimeException($message , $original_exception->getCode(), $original_exception);
- }
- else
- {
- $exception = new \RuntimeException($message , $original_exception->getCode());
- }
+ $exception = new \RuntimeException($message , $original_exception->getCode(), $original_exception);
$event->setException($exception);
}
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index bf7dc2c703..f023e0742c 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -131,6 +131,42 @@ class content_visibility
return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted'];
}
+
+ /**
+ * Check topic/post visibility for a given forum ID
+ *
+ * Note: Read permissions are not checked.
+ *
+ * @param $mode string Either "topic" or "post"
+ * @param $forum_id int The forum id is used for permission checks
+ * @param $data array Array with item information to check visibility
+ * @return bool True if the item is visible, false if not
+ */
+ public function is_visible($mode, $forum_id, $data)
+ {
+ $is_visible = $this->auth->acl_get('m_approve', $forum_id) || $data[$mode . '_visibility'] == ITEM_APPROVED;
+
+ /**
+ * Allow changing the result of calling is_visible
+ *
+ * @event core.phpbb_content_visibility_is_visible
+ * @var bool is_visible Default visibility condition, to be modified by extensions if needed.
+ * @var string mode Either "topic" or "post"
+ * @var int forum_id Forum id of the current item
+ * @var array data Array of item information
+ * @since 3.2.2-RC1
+ */
+ $vars = array(
+ 'is_visible',
+ 'mode',
+ 'forum_id',
+ 'data',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_is_visible', compact($vars)));
+
+ return $is_visible;
+ }
+
/**
* Create topic/post visibility SQL for a given forum ID
*
@@ -176,10 +212,14 @@ class content_visibility
if ($this->auth->acl_get('m_approve', $forum_id))
{
- return $where_sql . '1 = 1';
+ $where_sql .= '1 = 1';
+ }
+ else
+ {
+ $where_sql .= $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
}
- return $where_sql . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
+ return '(' . $where_sql . ')';
}
/**
@@ -195,16 +235,21 @@ class content_visibility
*/
public function get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '')
{
- $where_sql = '(';
+ $where_sql = '';
- $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true)));
+ $approve_forums = array_keys($this->auth->acl_getf('m_approve', true));
+ if (!empty($forum_ids) && !empty($approve_forums))
+ {
+ $approve_forums = array_intersect($forum_ids, $approve_forums);
+ $forum_ids = array_diff($forum_ids, $approve_forums);
+ }
$get_forums_visibility_sql_overwrite = false;
/**
* Allow changing the result of calling get_forums_visibility_sql
*
* @event core.phpbb_content_visibility_get_forums_visibility_before
- * @var string where_sql The action the user tried to execute
+ * @var string where_sql Extra visibility conditions. It must end with either an SQL "AND" or an "OR"
* @var string mode Either "topic" or "post" depending on the query this is being used in
* @var array forum_ids Array of forum ids which the posts/topics are limited to
* @var string table_alias Table alias to prefix in SQL queries
@@ -229,33 +274,13 @@ class content_visibility
return $get_forums_visibility_sql_overwrite;
}
- if (sizeof($approve_forums))
- {
- // Remove moderator forums from the rest
- $forum_ids = array_diff($forum_ids, $approve_forums);
-
- if (!sizeof($forum_ids))
- {
- // The user can see all posts/topics in all specified forums
- return $where_sql . $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums) . ')';
- }
- else
- {
- // Moderator can view all posts/topics in some forums
- $where_sql .= $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums) . ' OR ';
- }
- }
- else
- {
- // The user is just a normal user
- return $where_sql . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . '
- AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true) . ')';
- }
-
+ // Moderator can view all posts/topics in the moderated forums
+ $where_sql .= '(' . $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums, false, true) . ' OR ';
+ // Normal user can view approved items only
$where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . '
- AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids) . '))';
+ AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true) . '))';
- return $where_sql;
+ return '(' . $where_sql . ')';
}
/**
@@ -281,12 +306,12 @@ class content_visibility
* Allow changing the result of calling get_global_visibility_sql
*
* @event core.phpbb_content_visibility_get_global_visibility_before
- * @var array where_sqls The action the user tried to execute
+ * @var array where_sqls Array of extra visibility conditions. Will be joined by imploding with "OR".
* @var string mode Either "topic" or "post" depending on the query this is being used in
* @var array exclude_forum_ids Array of forum ids the current user doesn't have access to
* @var string table_alias Table alias to prefix in SQL queries
* @var array approve_forums Array of forums where the user has m_approve permissions
- * @var string visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR")
+ * @var string visibility_sql_overwrite If not empty, forces the function to return visibility_sql_overwrite after executing the event
* @since 3.1.3-RC1
*/
$vars = array(
@@ -304,24 +329,17 @@ class content_visibility
return $visibility_sql_overwrite;
}
- if (sizeof($exclude_forum_ids))
- {
- $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . '
- AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')';
- }
- else
- {
- $where_sqls[] = $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
- }
+ // Include approved items in all forums but the excluded
+ $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true, true) . '
+ AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')';
- if (sizeof($approve_forums))
+ // If user has moderator permissions, add everything in the moderated forums
+ if (count($approve_forums))
{
$where_sqls[] = $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums);
- return '(' . implode(' OR ', $where_sqls) . ')';
}
- // There is only one element, so we just return that one
- return $where_sqls[0];
+ return '(' . implode(' OR ', $where_sqls) . ')';
}
/**
@@ -437,12 +455,13 @@ class content_visibility
* @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 int time 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
+ * @changed 3.2.2-RC1 Use time instead of non-existent timestamp
*/
$vars = array(
'visibility',
@@ -450,7 +469,7 @@ class content_visibility
'topic_id',
'forum_id',
'user_id',
- 'timestamp',
+ 'time',
'reason',
'is_starter',
'is_latest',
@@ -565,7 +584,7 @@ class content_visibility
$sql_ary[$recipient_field] = " + $count_increase";
}
- if (sizeof($sql_ary))
+ if (count($sql_ary))
{
$forum_sql = array();
@@ -622,12 +641,13 @@ class content_visibility
* @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 int time 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
+ * @changed 3.2.2-RC1 Use time instead of non-existent timestamp
*/
$vars = array(
'visibility',
@@ -635,7 +655,7 @@ class content_visibility
'topic_id',
'forum_id',
'user_id',
- 'timestamp',
+ 'time',
'reason',
'is_starter',
'is_latest',
@@ -709,18 +729,19 @@ class content_visibility
* @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 int time 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
+ * @changed 3.2.2-RC1 Use time instead of non-existent timestamp
*/
$vars = array(
'visibility',
'topic_id',
'forum_id',
'user_id',
- 'timestamp',
+ 'time',
'reason',
'force_update_all',
'data',
@@ -758,18 +779,19 @@ class content_visibility
* @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 int time 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
+ * @changed 3.2.2-RC1 Use time instead of non-existent timestamp
*/
$vars = array(
'visibility',
'topic_id',
'forum_id',
'user_id',
- 'timestamp',
+ 'time',
'reason',
'force_update_all',
'data',
diff --git a/phpBB/phpbb/cron/task/core/prune_all_forums.php b/phpBB/phpbb/cron/task/core/prune_all_forums.php
index b47939ccbe..5005f5b894 100644
--- a/phpBB/phpbb/cron/task/core/prune_all_forums.php
+++ b/phpBB/phpbb/cron/task/core/prune_all_forums.php
@@ -55,21 +55,26 @@ class prune_all_forums extends \phpbb\cron\task\base
include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
- $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
- FROM ' . FORUMS_TABLE . "
- WHERE enable_prune = 1
- AND prune_next < " . time();
+ $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, enable_shadow_prune, prune_shadow_days, prune_shadow_freq, prune_shadow_next, forum_flags, prune_freq
+ FROM ' . FORUMS_TABLE;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if ($row['prune_days'])
+ if ($row['enable_prune'] && $row['prune_next'] < time())
{
- auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
- }
+ if ($row['prune_days'])
+ {
+ auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
+ }
- if ($row['prune_viewed'])
+ if ($row['prune_viewed'])
+ {
+ auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
+ }
+ }
+ if ($row['enable_shadow_prune'] && $row['prune_shadow_next'] < time() && $row['prune_shadow_days'])
{
- auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
+ auto_prune($row['forum_id'], 'shadow', $row['forum_flags'], $row['prune_shadow_days'], $row['prune_shadow_freq']);
}
}
$this->db->sql_freeresult($result);
diff --git a/phpBB/phpbb/datetime.php b/phpBB/phpbb/datetime.php
index 63cdba90fd..4b799b6219 100644
--- a/phpBB/phpbb/datetime.php
+++ b/phpBB/phpbb/datetime.php
@@ -60,6 +60,12 @@ class datetime extends \DateTime
public function format($format = '', $force_absolute = false)
{
$format = $format ? $format : $this->user->date_format;
+
+ if (substr($this->user->lang_name, 0,2) != 'en')
+ {
+ $format = preg_replace('/([^\\\])S/','$1', $format);
+ }
+
$format = self::format_cache($format, $this->user);
$relative = ($format['is_short'] && !$force_absolute);
$now = new self($this->user, 'now', $this->user->timezone);
diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php
index 214c5590e7..a36ce8c0d7 100644
--- a/phpBB/phpbb/db/driver/driver.php
+++ b/phpBB/phpbb/db/driver/driver.php
@@ -537,7 +537,9 @@ abstract class driver implements driver_interface
*/
function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
{
- if (!sizeof($array))
+ $array = (array) $array;
+
+ if (!count($array))
{
if (!$allow_empty_set)
{
@@ -559,12 +561,7 @@ abstract class driver implements driver_interface
}
}
- if (!is_array($array))
- {
- $array = array($array);
- }
-
- if (sizeof($array) == 1)
+ if (count($array) == 1)
{
@reset($array);
$var = current($array);
@@ -632,7 +629,7 @@ abstract class driver implements driver_interface
*/
function sql_multi_insert($table, $sql_ary)
{
- if (!sizeof($sql_ary))
+ if (!count($sql_ary))
{
return false;
}
@@ -738,7 +735,7 @@ abstract class driver implements driver_interface
// We run the following code to determine if we need to re-order the table array. ;)
// The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison.
// DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is.
- if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false)
+ if (!empty($array['LEFT_JOIN']) && count($array['FROM']) > 1 && $used_multi_alias !== false)
{
// Take first LEFT JOIN
$join = current($array['LEFT_JOIN']);
@@ -848,7 +845,7 @@ abstract class driver implements driver_interface
default:
- switch (sizeof($condition))
+ switch (count($condition))
{
case 3:
@@ -906,9 +903,10 @@ abstract class driver implements driver_interface
// Subquery with {left hand} {operator} {compare kind} {SELECT Kind } {Sub Query}
- $condition = $condition[self::LEFT_STMT] . ' ' . $condition[self::COMPARE_OP] . ' ' . $condition[self::SUBQUERY_OP] . ' ( ';
- $condition .= $this->sql_build_query($condition[self::SUBQUERY_SELECT_TYPE], $condition[self::SUBQUERY_BUILD]);
- $condition .= ' )';
+ $result = $condition[self::LEFT_STMT] . ' ' . $condition[self::COMPARE_OP] . ' ' . $condition[self::SUBQUERY_OP] . ' ( ';
+ $result .= $this->sql_build_query($condition[self::SUBQUERY_SELECT_TYPE], $condition[self::SUBQUERY_BUILD]);
+ $result .= ' )';
+ $condition = $result;
break;
@@ -1138,7 +1136,7 @@ abstract class driver implements driver_interface
$html_table = func_get_arg(2);
$row = func_get_arg(3);
- if (!$html_table && sizeof($row))
+ if (!$html_table && count($row))
{
$html_table = true;
$this->html_hold .= '<table cellspacing="1"><tr>';
diff --git a/phpBB/phpbb/db/driver/mssql_base.php b/phpBB/phpbb/db/driver/mssql_base.php
index 514df9eaca..98d16ca7fc 100644
--- a/phpBB/phpbb/db/driver/mssql_base.php
+++ b/phpBB/phpbb/db/driver/mssql_base.php
@@ -61,6 +61,14 @@ abstract class mssql_base extends \phpbb\db\driver\driver
}
/**
+ * {@inheritDoc}
+ */
+ function cast_expr_to_bigint($expression)
+ {
+ return 'CONVERT(BIGINT, ' . $expression . ')';
+ }
+
+ /**
* Build db-specific query data
* @access private
*/
diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php
index 50dce35baa..a4dcac5966 100644
--- a/phpBB/phpbb/db/driver/mssqlnative.php
+++ b/phpBB/phpbb/db/driver/mssqlnative.php
@@ -50,7 +50,8 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
$this->db_connect_id = sqlsrv_connect($this->server, array(
'Database' => $this->dbname,
'UID' => $this->user,
- 'PWD' => $sqlpassword
+ 'PWD' => $sqlpassword,
+ 'CharacterSet' => 'UTF-8'
));
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
@@ -267,7 +268,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
unset($row['line2'], $row['line3']);
}
}
- return (sizeof($row)) ? $row : false;
+ return ($row !== null) ? $row : false;
}
/**
diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php
index 54238a15ef..5fd14709f8 100644
--- a/phpBB/phpbb/db/driver/oracle.php
+++ b/phpBB/phpbb/db/driver/oracle.php
@@ -136,7 +136,7 @@ class oracle extends \phpbb\db\driver\driver
*/
function _rewrite_col_compare($args)
{
- if (sizeof($args) == 4)
+ if (count($args) == 4)
{
if ($args[2] == '=')
{
@@ -290,7 +290,7 @@ class oracle extends \phpbb\db\driver\driver
and/or need the db restore script, uncomment this.
- if (sizeof($cols) !== sizeof($vals))
+ if (count($cols) !== count($vals))
{
// Try to replace some common data we know is from our restore script or from other sources
$regs[3] = str_replace("'||chr(47)||'", '/', $regs[3]);
@@ -332,7 +332,7 @@ class oracle extends \phpbb\db\driver\driver
if ($string)
{
// New value if cols != value
- $vals[(sizeof($cols) !== sizeof($vals)) ? $i : $i - 1] .= $string;
+ $vals[(count($cols) !== count($vals)) ? $i : $i - 1] .= $string;
}
$vals = array(0 => $vals);
diff --git a/phpBB/phpbb/db/extractor/mssql_extractor.php b/phpBB/phpbb/db/extractor/mssql_extractor.php
index 2817d3ebcc..4eeab4780e 100644
--- a/phpBB/phpbb/db/extractor/mssql_extractor.php
+++ b/phpBB/phpbb/db/extractor/mssql_extractor.php
@@ -132,14 +132,14 @@ class mssql_extractor extends base_extractor
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if (!sizeof($rows))
+ if (!count($rows))
{
$sql_data .= "ALTER TABLE [$table_name] WITH NOCHECK ADD\n";
$sql_data .= "\tCONSTRAINT [{$row['CONSTRAINT_NAME']}] PRIMARY KEY CLUSTERED \n\t(\n";
}
$rows[] = "\t\t[{$row['COLUMN_NAME']}]";
}
- if (sizeof($rows))
+ if (count($rows))
{
$sql_data .= implode(",\n", $rows);
$sql_data .= "\n\t) ON [PRIMARY] \nGO\n";
diff --git a/phpBB/phpbb/db/extractor/oracle_extractor.php b/phpBB/phpbb/db/extractor/oracle_extractor.php
index 79a991889b..bc43a37b10 100644
--- a/phpBB/phpbb/db/extractor/oracle_extractor.php
+++ b/phpBB/phpbb/db/extractor/oracle_extractor.php
@@ -82,7 +82,7 @@ class oracle_extractor extends base_extractor
}
$this->db->sql_freeresult($result);
- if (sizeof($primary_key))
+ if (count($primary_key))
{
$rows[] = " CONSTRAINT {$constraint_name} PRIMARY KEY (" . implode(', ', $primary_key) . ')';
}
@@ -103,7 +103,7 @@ class oracle_extractor extends base_extractor
}
$this->db->sql_freeresult($result);
- if (sizeof($unique))
+ if (count($unique))
{
$rows[] = " CONSTRAINT {$constraint_name} UNIQUE (" . implode(', ', $unique) . ')';
}
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php
index faef68121d..40bb58c10d 100644
--- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php
+++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_6_rc1.php
@@ -153,7 +153,10 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration
'ACP_BOARD_CONFIGURATION',
array(
'module_basename' => 'acp_board',
- 'modes' => array('feed'),
+ 'module_langname' => 'ACP_FEED_SETTINGS',
+ 'module_mode' => 'feed',
+ 'module_auth' => 'acl_a_board',
+ 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS'),
),
)),
array('module.add', array(
@@ -161,7 +164,11 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration
'ACP_CAT_USERS',
array(
'module_basename' => 'acp_users',
- 'modes' => array('warnings'),
+ 'module_langname' => 'ACP_USER_WARNINGS',
+ 'module_mode' => 'warnings',
+ 'module_auth' => 'acl_a_user',
+ 'module_display' => false,
+ 'after' => array('feedback', 'ACP_USER_FEEDBACK'),
),
)),
array('module.add', array(
@@ -169,7 +176,9 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration
'ACP_SERVER_CONFIGURATION',
array(
'module_basename' => 'acp_send_statistics',
- 'modes' => array('send_statistics'),
+ 'module_langname' => 'ACP_SEND_STATISTICS',
+ 'module_mode' => 'send_statistics',
+ 'module_auth' => 'acl_a_server',
),
)),
array('module.add', array(
@@ -177,7 +186,10 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration
'ACP_FORUM_BASED_PERMISSIONS',
array(
'module_basename' => 'acp_permissions',
- 'modes' => array('setting_forum_copy'),
+ 'module_langname' => 'ACP_FORUM_PERMISSIONS_COPY',
+ 'module_mode' => 'setting_forum_copy',
+ 'module_auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth',
+ 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS'),
),
)),
array('module.add', array(
@@ -185,7 +197,29 @@ class release_3_0_6_rc1 extends \phpbb\db\migration\migration
'MCP_REPORTS',
array(
'module_basename' => 'mcp_pm_reports',
- 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'),
+ 'module_langname' => 'MCP_PM_REPORTS_OPEN',
+ 'module_mode' => 'pm_reports',
+ 'module_auth' => 'acl_m_pm_report',
+ ),
+ )),
+ array('module.add', array(
+ 'mcp',
+ 'MCP_REPORTS',
+ array(
+ 'module_basename' => 'mcp_pm_reports',
+ 'module_langname' => 'MCP_PM_REPORTS_CLOSED',
+ 'module_mode' => 'pm_reports_closed',
+ 'module_auth' => 'acl_m_pm_report',
+ ),
+ )),
+ array('module.add', array(
+ 'mcp',
+ 'MCP_REPORTS',
+ array(
+ 'module_basename' => 'mcp_pm_reports',
+ 'module_langname' => 'MCP_PM_REPORT_DETAILS',
+ 'module_mode' => 'pm_report_details',
+ 'module_auth' => 'acl_m_pm_report',
),
)),
array('custom', array(array(&$this, 'add_newly_registered_group'))),
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php
index 22fd51543b..836cb4577a 100644
--- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php
+++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php
@@ -36,7 +36,10 @@ class release_3_0_8_rc1 extends \phpbb\db\migration\migration
'ACP_MESSAGES',
array(
'module_basename' => 'acp_board',
- 'modes' => array('post'),
+ 'module_langname' => 'ACP_POST_SETTINGS',
+ 'module_mode' => 'post',
+ 'module_auth' => 'acl_a_board',
+ 'after' => array('message', 'ACP_MESSAGE_SETTINGS'),
),
)),
array('config.add', array('load_unreads_search', 1)),
@@ -55,9 +58,14 @@ class release_3_0_8_rc1 extends \phpbb\db\migration\migration
$result = $this->db->sql_query($sql);
$extension_groups_updated = array();
- while ($lang_dir = $this->db->sql_fetchfield('lang_dir'))
+ while ($row = $this->db->sql_fetchrow($result))
{
- $lang_dir = basename($lang_dir);
+ if (empty($row['lang_dir']))
+ {
+ continue;
+ }
+
+ $lang_dir = basename($row['lang_dir']);
// The language strings we need are either in language/.../acp/attachments.php
// in the update package if we're updating to 3.0.8-RC1 or later,
diff --git a/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php
index 2d51bd53e4..1e2024a071 100644
--- a/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php
+++ b/phpBB/phpbb/db/migration/data/v310/auth_provider_oauth.php
@@ -17,7 +17,12 @@ class auth_provider_oauth extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
- return $this->db_tools->sql_table_exists($this->table_prefix . 'auth_provider_oauth');
+ return $this->db_tools->sql_table_exists($this->table_prefix . 'oauth_tokens');
+ }
+
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v30x\release_3_0_0');
}
public function update_schema()
@@ -69,7 +74,9 @@ class auth_provider_oauth extends \phpbb\db\migration\migration
'UCP_PROFILE',
array(
'module_basename' => 'ucp_auth_link',
- 'modes' => array('auth_link'),
+ 'module_langname' => 'UCP_AUTH_LINK_MANAGE',
+ 'module_mode' => 'auth_link',
+ 'module_auth' => 'authmethod_oauth',
),
)),
);
diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php
index 20bd547ac3..e48a9a1d3d 100644
--- a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php
+++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php
@@ -23,7 +23,9 @@ class contact_admin_acp_module extends \phpbb\db\migration\migration
'ACP_BOARD_CONFIGURATION',
array(
'module_basename' => 'acp_contact',
- 'modes' => array('contact'),
+ 'module_langname' => 'ACP_CONTACT_SETTINGS',
+ 'module_mode' => 'contact',
+ 'module_auth' => 'acl_a_board',
),
)),
);
diff --git a/phpBB/phpbb/db/migration/data/v310/dev.php b/phpBB/phpbb/db/migration/data/v310/dev.php
index 250258eea7..9cc953ad8d 100644
--- a/phpBB/phpbb/db/migration/data/v310/dev.php
+++ b/phpBB/phpbb/db/migration/data/v310/dev.php
@@ -125,7 +125,9 @@ class dev extends \phpbb\db\migration\container_aware_migration
'ACP_GROUPS',
array(
'module_basename' => 'acp_groups',
- 'modes' => array('position'),
+ 'module_langname' => 'ACP_GROUPS_POSITION',
+ 'module_mode' => 'position',
+ 'module_auth' => 'acl_a_group',
),
)),
array('module.add', array(
@@ -133,7 +135,9 @@ class dev extends \phpbb\db\migration\container_aware_migration
'ACP_ATTACHMENTS',
array(
'module_basename' => 'acp_attachments',
- 'modes' => array('manage'),
+ 'module_langname' => 'ACP_MANAGE_ATTACHMENTS',
+ 'module_mode' => 'manage',
+ 'module_auth' => 'acl_a_attach',
),
)),
array('module.add', array(
@@ -141,7 +145,19 @@ class dev extends \phpbb\db\migration\container_aware_migration
'ACP_STYLE_MANAGEMENT',
array(
'module_basename' => 'acp_styles',
- 'modes' => array('install', 'cache'),
+ 'module_langname' => 'ACP_STYLES_INSTALL',
+ 'module_mode' => 'install',
+ 'module_auth' => 'acl_a_styles',
+ ),
+ )),
+ array('module.add', array(
+ 'acp',
+ 'ACP_STYLE_MANAGEMENT',
+ array(
+ 'module_basename' => 'acp_styles',
+ 'module_langname' => 'ACP_STYLES_CACHE',
+ 'module_mode' => 'cache',
+ 'module_auth' => 'acl_a_styles',
),
)),
array('module.add', array(
@@ -149,7 +165,8 @@ class dev extends \phpbb\db\migration\container_aware_migration
'UCP_PROFILE',
array(
'module_basename' => 'ucp_profile',
- 'modes' => array('autologin_keys'),
+ 'module_langname' => 'UCP_PROFILE_AUTOLOGIN_KEYS',
+ 'module_mode' => 'autologin_keys',
),
)),
// Module will be renamed later
diff --git a/phpBB/phpbb/db/migration/data/v310/extensions.php b/phpBB/phpbb/db/migration/data/v310/extensions.php
index 3171435482..2e7c5c5316 100644
--- a/phpBB/phpbb/db/migration/data/v310/extensions.php
+++ b/phpBB/phpbb/db/migration/data/v310/extensions.php
@@ -66,7 +66,9 @@ class extensions extends \phpbb\db\migration\migration
'ACP_EXTENSION_MANAGEMENT',
array(
'module_basename' => 'acp_extensions',
- 'modes' => array('main'),
+ 'module_langname' => 'ACP_EXTENSIONS',
+ 'module_mode' => 'main',
+ 'module_auth' => 'acl_a_extensions',
),
)),
array('permission.add', array('a_extensions', true, 'a_styles')),
diff --git a/phpBB/phpbb/db/migration/data/v310/notifications.php b/phpBB/phpbb/db/migration/data/v310/notifications.php
index f4d012b5ac..789aaa3ba9 100644
--- a/phpBB/phpbb/db/migration/data/v310/notifications.php
+++ b/phpBB/phpbb/db/migration/data/v310/notifications.php
@@ -85,7 +85,9 @@ class notifications extends \phpbb\db\migration\migration
'UCP_MAIN',
array(
'module_basename' => 'ucp_notifications',
- 'modes' => array('notification_list'),
+ 'module_langname' => 'UCP_NOTIFICATION_LIST',
+ 'module_mode' => 'notification_list',
+ 'module_auth' => 'cfg_allow_board_notifications',
),
)),
array('module.add', array(
@@ -93,7 +95,8 @@ class notifications extends \phpbb\db\migration\migration
'UCP_PREFS',
array(
'module_basename' => 'ucp_notifications',
- 'modes' => array('notification_options'),
+ 'module_langname' => 'UCP_NOTIFICATION_OPTIONS',
+ 'module_mode' => 'notification_options',
),
)),
array('config.add', array('load_notifications', 1)),
diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
index 5e68db5889..90dab991e1 100644
--- a/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
+++ b/phpBB/phpbb/db/migration/data/v310/softdelete_mcp_modules.php
@@ -45,7 +45,9 @@ class softdelete_mcp_modules extends \phpbb\db\migration\migration
'MCP_QUEUE',
array(
'module_basename' => 'mcp_queue',
- 'modes' => array('deleted_topics'),
+ 'module_langname' => 'MCP_QUEUE_DELETED_TOPICS',
+ 'module_mode' => 'deleted_topics',
+ 'module_auth' => 'aclf_m_approve',
),
)),
array('module.add', array(
@@ -53,7 +55,9 @@ class softdelete_mcp_modules extends \phpbb\db\migration\migration
'MCP_QUEUE',
array(
'module_basename' => 'mcp_queue',
- 'modes' => array('deleted_posts'),
+ 'module_langname' => 'MCP_QUEUE_DELETED_POSTS',
+ 'module_mode' => 'deleted_posts',
+ 'module_auth' => 'aclf_m_approve',
),
)),
);
diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php
index 2c7b7edf2e..a7e30a9cb7 100644
--- a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php
+++ b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php
@@ -133,7 +133,7 @@ class style_update_p1 extends \phpbb\db\migration\migration
}
// Remove old entries from styles table
- if (!sizeof($valid_styles))
+ if (!count($valid_styles))
{
// No valid styles: remove everything and add prosilver
$this->sql_query('DELETE FROM ' . STYLES_TABLE);
@@ -160,12 +160,12 @@ class style_update_p1 extends \phpbb\db\migration\migration
FROM ' . STYLES_TABLE . "
WHERE style_name = 'prosilver'";
$result = $this->sql_query($sql);
- $default_style = $this->db->sql_fetchfield('style_id');
+ $default_style = (int) $this->db->sql_fetchfield('style_id');
$this->db->sql_freeresult($result);
$this->config->set('default_style', $default_style);
- $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0';
+ $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = ' . (int) $default_style;
$this->sql_query($sql);
}
else
@@ -183,9 +183,9 @@ class style_update_p1 extends \phpbb\db\migration\migration
}
// Reset styles for users
- $this->sql_query('UPDATE ' . USERS_TABLE . '
- SET user_style = 0
- WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true));
+ $this->sql_query('UPDATE ' . USERS_TABLE . "
+ SET user_style = '" . (int) $valid_styles[0] . "'
+ WHERE " . $this->db->sql_in_set('user_style', $valid_styles, true));
}
}
}
diff --git a/phpBB/phpbb/db/migration/data/v310/teampage.php b/phpBB/phpbb/db/migration/data/v310/teampage.php
index f8edbc3492..3a37b17e97 100644
--- a/phpBB/phpbb/db/migration/data/v310/teampage.php
+++ b/phpBB/phpbb/db/migration/data/v310/teampage.php
@@ -93,13 +93,13 @@ class teampage extends \phpbb\db\migration\migration
$teampage_entries[] = array(
'group_id' => (int) $row['group_id'],
'teampage_name' => '',
- 'teampage_position' => sizeof($teampage_entries) + 1,
+ 'teampage_position' => count($teampage_entries) + 1,
'teampage_parent' => 0,
);
}
$this->db->sql_freeresult($result);
- if (sizeof($teampage_entries))
+ if (count($teampage_entries))
{
$this->db->sql_multi_insert(TEAMPAGE_TABLE, $teampage_entries);
}
diff --git a/phpBB/phpbb/db/migration/data/v31x/v3112.php b/phpBB/phpbb/db/migration/data/v31x/v3112.php
new file mode 100644
index 0000000000..0d75d35184
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v31x/v3112.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 v3112 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.1.12', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v3111',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.1.12')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php
index 8fadb4bde4..804adc4490 100644
--- a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php
+++ b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php
@@ -32,16 +32,15 @@ class add_help_phpbb extends \phpbb\db\migration\migration
return array(
array('config.add', array('help_send_statistics', true)),
array('config.add', array('help_send_statistics_time', 0)),
- array('if', array(
- array('module.exists', array('acp', false, 'ACP_SEND_STATISTICS')),
- array('module.remove', array('acp', false, 'ACP_SEND_STATISTICS')),
- )),
+ array('module.remove', array('acp', false, 'ACP_SEND_STATISTICS')),
array('module.add', array(
'acp',
'ACP_SERVER_CONFIGURATION',
array(
'module_basename' => 'acp_help_phpbb',
- 'modes' => array('help_phpbb'),
+ 'module_langname' => 'ACP_HELP_PHPBB',
+ 'module_mode' => 'help_phpbb',
+ 'module_auth' => 'acl_a_server',
),
)),
);
diff --git a/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php
index c14d31f1c0..88fe59ccc9 100644
--- a/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php
+++ b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php
@@ -15,10 +15,17 @@ namespace phpbb\db\migration\data\v320;
class remove_outdated_media extends \phpbb\db\migration\migration
{
+ // Following constants were deprecated in 3.2
+ // and moved from constants.php to compatibility_globals.php,
+ // thus define them as class constants
+ const ATTACHMENT_CATEGORY_WM = 2;
+ const ATTACHMENT_CATEGORY_RM = 3;
+ const ATTACHMENT_CATEGORY_QUICKTIME = 6;
+
protected $cat_id = array(
- ATTACHMENT_CATEGORY_WM,
- ATTACHMENT_CATEGORY_RM,
- ATTACHMENT_CATEGORY_QUICKTIME,
+ self::ATTACHMENT_CATEGORY_WM,
+ self::ATTACHMENT_CATEGORY_RM,
+ self::ATTACHMENT_CATEGORY_QUICKTIME,
);
static public function depends_on()
@@ -78,13 +85,11 @@ class remove_outdated_media extends \phpbb\db\migration\migration
WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
}
- $result = $this->db->sql_query($sql);
- $this->db->sql_freeresult($result);
+ $this->db->sql_query($sql);
// delete the now empty, outdated media extension groups
$sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . '
WHERE ' . $this->db->sql_in_set('group_id', $group_ids);
- $result = $this->db->sql_query($sql);
- $this->db->sql_freeresult($result);
+ $this->db->sql_query($sql);
}
}
diff --git a/phpBB/phpbb/db/migration/data/v32x/disable_remote_avatar.php b/phpBB/phpbb/db/migration/data/v32x/disable_remote_avatar.php
new file mode 100644
index 0000000000..b08833fad4
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/disable_remote_avatar.php
@@ -0,0 +1,34 @@
+<?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\v32x;
+
+use phpbb\db\migration\migration;
+
+class disable_remote_avatar extends migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v325',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('allow_avatar_remote', '0')),
+ array('config.update', array('allow_avatar_remote_upload', '0')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/email_force_sender.php b/phpBB/phpbb/db/migration/data/v32x/email_force_sender.php
new file mode 100644
index 0000000000..5319b7f76e
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/email_force_sender.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\v32x;
+
+class email_force_sender extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v321',
+ );
+ }
+
+ public function effectively_installed()
+ {
+ return isset($this->config['email_force_sender']);
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.add', array('email_force_sender', '0')),
+ array('config.remove', array('email_function_name')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php b/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php
new file mode 100644
index 0000000000..a7b99606f7
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.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\v32x;
+
+class enable_accurate_pm_button extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v322',
+ );
+ }
+
+ public function effectively_installed()
+ {
+ return isset($this->config['enable_accurate_pm_button']);
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.add', array('enable_accurate_pm_button', '1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/f_list_topics_permission_add.php b/phpBB/phpbb/db/migration/data/v32x/f_list_topics_permission_add.php
new file mode 100644
index 0000000000..49727e5a62
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/f_list_topics_permission_add.php
@@ -0,0 +1,31 @@
+<?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\v32x;
+
+class f_list_topics_permission_add extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v321',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('permission.add', array('f_list_topics', false, 'f_read')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php
new file mode 100644
index 0000000000..16fbdbc77b
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php
@@ -0,0 +1,54 @@
+<?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\v32x;
+
+class fix_user_styles extends \phpbb\db\migration\migration
+{
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v320\v320',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'styles_fix'))),
+ );
+ }
+
+ public function styles_fix()
+ {
+ $default_style = (int) $this->config['default_style'];
+ $enabled_styles = array();
+
+ // Get enabled styles
+ $sql = 'SELECT style_id
+ FROM ' . STYLES_TABLE . '
+ WHERE style_active = 1';
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $enabled_styles[] = (int) $row['style_id'];
+ }
+ $this->db->sql_freeresult($result);
+
+ // Set the default style to users who have an invalid style
+ $this->sql_query('UPDATE ' . USERS_TABLE . '
+ SET user_style = ' . (int) $default_style . '
+ WHERE ' . $this->db->sql_in_set('user_style', $enabled_styles, true));
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php b/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.php
new file mode 100644
index 0000000000..afcecf2ef0
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/forum_topics_per_page_type.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\v32x;
+
+class forum_topics_per_page_type extends \phpbb\db\migration\migration
+{
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v323',
+ );
+ }
+
+ public function update_schema()
+ {
+ return array(
+ 'change_columns' => array(
+ $this->table_prefix . 'forums' => array(
+ 'forum_topics_per_page' => array('USINT', 0),
+ ),
+ ),
+ );
+ }
+
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/jquery_update.php b/phpBB/phpbb/db/migration/data/v32x/jquery_update.php
new file mode 100644
index 0000000000..6dc58ec638
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/jquery_update.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\v32x;
+
+class jquery_update extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return $this->config['load_jquery_url'] === '//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js';
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v325rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js')),
+ );
+ }
+
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php
new file mode 100644
index 0000000000..71ee19e3dd
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php
@@ -0,0 +1,84 @@
+<?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\v32x;
+
+class merge_duplicate_bbcodes extends \phpbb\db\migration\container_aware_migration
+{
+ public function update_data()
+ {
+ return [
+ ['custom', [[$this, 'update_bbcodes_table']]],
+ ];
+ }
+
+ public function update_bbcodes_table()
+ {
+ $sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline, bbcode_match, bbcode_tpl FROM ' . BBCODES_TABLE;
+ $result = $this->sql_query($sql);
+ $bbcodes = [];
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $variant = (substr($row['bbcode_tag'], -1) === '=') ? 'with': 'without';
+ $bbcode_name = strtolower(rtrim($row['bbcode_tag'], '='));
+ $bbcodes[$bbcode_name][$variant] = $row;
+ }
+ $this->db->sql_freeresult($result);
+
+ foreach ($bbcodes as $bbcode_name => $variants)
+ {
+ if (count($variants) === 2)
+ {
+ $this->merge_bbcodes($variants['without'], $variants['with']);
+ }
+ }
+ }
+
+ protected function merge_bbcodes(array $without, array $with)
+ {
+ try
+ {
+ $merged = $this->container->get('text_formatter.s9e.bbcode_merger')->merge_bbcodes(
+ [
+ 'usage' => $without['bbcode_match'],
+ 'template' => $without['bbcode_tpl']
+ ],
+ [
+ 'usage' => $with['bbcode_match'],
+ 'template' => $with['bbcode_tpl']
+ ]
+ );
+ }
+ catch (\Exception $e)
+ {
+ // Ignore the pair and move on. The BBCodes would have to be fixed manually
+ return;
+ }
+
+ $bbcode_data = [
+ 'bbcode_tag' => $without['bbcode_tag'],
+ 'bbcode_helpline' => $without['bbcode_helpline'] . ' | ' . $with['bbcode_helpline'],
+ 'bbcode_match' => $merged['usage'],
+ 'bbcode_tpl' => $merged['template']
+ ];
+
+ $sql = 'UPDATE ' . BBCODES_TABLE . '
+ SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . '
+ WHERE bbcode_id = ' . (int) $without['bbcode_id'];
+ $this->sql_query($sql);
+
+ $sql = 'DELETE FROM ' . BBCODES_TABLE . '
+ WHERE bbcode_id = ' . (int) $with['bbcode_id'];
+ $this->sql_query($sql);
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/remove_imagick.php b/phpBB/phpbb/db/migration/data/v32x/remove_imagick.php
new file mode 100644
index 0000000000..7ad396f8e8
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/remove_imagick.php
@@ -0,0 +1,31 @@
+<?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\v32x;
+
+class remove_imagick extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v324rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.remove', array('img_imagick')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/smtp_dynamic_data.php b/phpBB/phpbb/db/migration/data/v32x/smtp_dynamic_data.php
new file mode 100644
index 0000000000..aeaa3e8979
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/smtp_dynamic_data.php
@@ -0,0 +1,42 @@
+<?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\v32x;
+
+class smtp_dynamic_data extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v326rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'set_smtp_dynamic'))),
+ );
+ }
+
+ public function set_smtp_dynamic()
+ {
+ $smtp_auth_entries = [
+ 'smtp_password',
+ 'smtp_username',
+ ];
+ $this->sql_query('UPDATE ' . CONFIG_TABLE . '
+ SET is_dynamic = 1
+ WHERE ' . $this->db->sql_in_set('config_name', $smtp_auth_entries));
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/timezone_p3.php b/phpBB/phpbb/db/migration/data/v32x/timezone_p3.php
new file mode 100644
index 0000000000..433f62ace9
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/timezone_p3.php
@@ -0,0 +1,29 @@
+<?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\v32x;
+
+class timezone_p3 extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array('\phpbb\db\migration\data\v310\timezone');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.remove', array('board_dst')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/update_prosilver_bitfield.php b/phpBB/phpbb/db/migration/data/v32x/update_prosilver_bitfield.php
new file mode 100644
index 0000000000..6e51a01834
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/update_prosilver_bitfield.php
@@ -0,0 +1,39 @@
+<?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\v32x;
+
+class update_prosilver_bitfield extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v321',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'update_bbcode_bitfield'))),
+ );
+ }
+
+ public function update_bbcode_bitfield()
+ {
+ $sql = 'UPDATE ' . STYLES_TABLE . "
+ SET bbcode_bitfield = '//g='
+ WHERE style_path = 'prosilver'";
+ $this->sql_query($sql);
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v321.php b/phpBB/phpbb/db/migration/data/v32x/v321.php
index 268f978b4b..fdbb5cff19 100644
--- a/phpBB/phpbb/db/migration/data/v32x/v321.php
+++ b/phpBB/phpbb/db/migration/data/v32x/v321.php
@@ -23,6 +23,7 @@ class v321 extends \phpbb\db\migration\migration
static public function depends_on()
{
return array(
+ '\phpbb\db\migration\data\v31x\v3111',
'\phpbb\db\migration\data\v32x\v321rc1',
);
diff --git a/phpBB/phpbb/db/migration/data/v32x/v322.php b/phpBB/phpbb/db/migration/data/v32x/v322.php
new file mode 100644
index 0000000000..7ecbbb3e79
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v322.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\v32x;
+
+class v322 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.2', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v31x\v3112',
+ '\phpbb\db\migration\data\v32x\v322rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.2')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v322rc1.php b/phpBB/phpbb/db/migration/data/v32x/v322rc1.php
new file mode 100644
index 0000000000..4fd6270132
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v322rc1.php
@@ -0,0 +1,41 @@
+<?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\v32x;
+
+class v322rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.2-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v321',
+ '\phpbb\db\migration\data\v32x\fix_user_styles',
+ '\phpbb\db\migration\data\v32x\update_prosilver_bitfield',
+ '\phpbb\db\migration\data\v32x\email_force_sender',
+ '\phpbb\db\migration\data\v32x\f_list_topics_permission_add',
+ '\phpbb\db\migration\data\v32x\merge_duplicate_bbcodes',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.2-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v323.php b/phpBB/phpbb/db/migration/data/v32x/v323.php
new file mode 100644
index 0000000000..1ec28ceb37
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v323.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\v32x;
+
+class v323 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.3', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v323rc2',
+ );
+
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.3')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v323rc1.php b/phpBB/phpbb/db/migration/data/v32x/v323rc1.php
new file mode 100644
index 0000000000..c3fcd1ab0b
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v323rc1.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\v32x;
+
+class v323rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.3-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v322',
+ '\phpbb\db\migration\data\v32x\enable_accurate_pm_button',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.3-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v323rc2.php b/phpBB/phpbb/db/migration/data/v32x/v323rc2.php
new file mode 100644
index 0000000000..32235ee067
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v323rc2.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\v32x;
+
+class v323rc2 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.3-RC2', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v323rc1',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.3-RC2')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v324.php b/phpBB/phpbb/db/migration/data/v32x/v324.php
new file mode 100644
index 0000000000..cd7783fdee
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v324.php
@@ -0,0 +1,38 @@
+<?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\v32x;
+
+class v324 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.4', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v324rc1',
+ '\phpbb\db\migration\data\v32x\remove_imagick',
+ );
+
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.4')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v324rc1.php b/phpBB/phpbb/db/migration/data/v32x/v324rc1.php
new file mode 100644
index 0000000000..0221e2621a
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v324rc1.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\v32x;
+
+class v324rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.4-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v323',
+ '\phpbb\db\migration\data\v32x\forum_topics_per_page_type',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.4-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v325.php b/phpBB/phpbb/db/migration/data/v32x/v325.php
new file mode 100644
index 0000000000..59de4916df
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v325.php
@@ -0,0 +1,38 @@
+<?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\v32x;
+
+class v325 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.5', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v325rc1',
+ '\phpbb\db\migration\data\v32x\jquery_update',
+ );
+
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.5')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v325rc1.php b/phpBB/phpbb/db/migration/data/v32x/v325rc1.php
new file mode 100644
index 0000000000..2d0de0a432
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v325rc1.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\v32x;
+
+class v325rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.5-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v324',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.5-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v326.php b/phpBB/phpbb/db/migration/data/v32x/v326.php
new file mode 100644
index 0000000000..2d511b9ed8
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v326.php
@@ -0,0 +1,39 @@
+<?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\v32x;
+
+class v326 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.6', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v326rc1',
+ '\phpbb\db\migration\data\v32x\disable_remote_avatar',
+ '\phpbb\db\migration\data\v32x\smtp_dynamic_data',
+ );
+
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.6')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v326rc1.php b/phpBB/phpbb/db/migration/data/v32x/v326rc1.php
new file mode 100644
index 0000000000..092700d3db
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v326rc1.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\v32x;
+
+class v326rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.6-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v325',
+ );
+
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.6-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v327.php b/phpBB/phpbb/db/migration/data/v32x/v327.php
new file mode 100644
index 0000000000..f9ea11f4b9
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v327.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\v32x;
+
+class v327 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.7', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v327rc1',
+ );
+
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.7')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v327rc1.php b/phpBB/phpbb/db/migration/data/v32x/v327rc1.php
new file mode 100644
index 0000000000..c8169105af
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v327rc1.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\v32x;
+
+class v327rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.7-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\v326',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.7-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/data/v32x/v328rc1.php b/phpBB/phpbb/db/migration/data/v32x/v328rc1.php
new file mode 100644
index 0000000000..fa43cf33a7
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v32x/v328rc1.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\v32x;
+
+class v328rc1 extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return phpbb_version_compare($this->config['version'], '3.2.8-RC1', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v32x\timezone_p3',
+ '\phpbb\db\migration\data\v32x\v327',
+ );
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('version', '3.2.8-RC1')),
+ );
+ }
+}
diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php
index 33aa8ff026..a351c4858e 100644
--- a/phpBB/phpbb/db/migration/tool/config.php
+++ b/phpBB/phpbb/db/migration/tool/config.php
@@ -134,7 +134,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
case 'remove':
$call = 'add';
- if (sizeof($arguments) == 1)
+ if (count($arguments) == 1)
{
$arguments[] = '';
}
diff --git a/phpBB/phpbb/db/migration/tool/config_text.php b/phpBB/phpbb/db/migration/tool/config_text.php
index 54b45f6f6d..5fe9a25b70 100644
--- a/phpBB/phpbb/db/migration/tool/config_text.php
+++ b/phpBB/phpbb/db/migration/tool/config_text.php
@@ -110,7 +110,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
case 'remove':
$call = 'add';
- if (sizeof($arguments) == 1)
+ if (count($arguments) == 1)
{
$arguments[] = '';
}
diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php
index b47c426110..e5133c8152 100644
--- a/phpBB/phpbb/db/migration/tool/module.php
+++ b/phpBB/phpbb/db/migration/tool/module.php
@@ -84,9 +84,12 @@ class module implements \phpbb\db\migration\tool\tool_interface
* Use false to ignore the parent check and check class wide.
* @param int|string $module The module_id|module_langname you would like to
* check for to see if it exists
- * @return bool true/false if module exists
+ * @param bool $lazy Checks lazily if the module exists. Returns true if it exists in at
+ * least one given parent.
+ * @return bool true if module exists in *all* given parents, false if not in any given parent;
+ * true if ignoring parent check and module exists class wide, false if not found at all.
*/
- public function exists($class, $parent, $module)
+ public function exists($class, $parent, $module, $lazy = false)
{
// the main root directory should return true
if (!$module)
@@ -94,33 +97,48 @@ class module implements \phpbb\db\migration\tool\tool_interface
return true;
}
- $parent_sql = '';
+ $parent_sqls = [];
if ($parent !== false)
{
- $parent = $this->get_parent_module_id($parent, $module, false);
- if ($parent === false)
+ $parents = $this->get_parent_module_id($parent, $module, false);
+ if ($parents === false)
{
return false;
}
- $parent_sql = 'AND parent_id = ' . (int) $parent;
+ foreach ((array) $parents as $parent_id)
+ {
+ $parent_sqls[] = 'AND parent_id = ' . (int) $parent_id;
+ }
+ }
+ else
+ {
+ $parent_sqls[] = '';
}
- $sql = 'SELECT module_id
- FROM ' . $this->modules_table . "
- WHERE module_class = '" . $this->db->sql_escape($class) . "'
- $parent_sql
- AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'");
- $result = $this->db->sql_query($sql);
- $module_id = $this->db->sql_fetchfield('module_id');
- $this->db->sql_freeresult($result);
-
- if ($module_id)
+ foreach ($parent_sqls as $parent_sql)
{
- return true;
+ $sql = 'SELECT module_id
+ FROM ' . $this->modules_table . "
+ WHERE module_class = '" . $this->db->sql_escape($class) . "'
+ $parent_sql
+ AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'");
+ $result = $this->db->sql_query($sql);
+ $module_id = $this->db->sql_fetchfield('module_id');
+ $this->db->sql_freeresult($result);
+
+ if (!$lazy && !$module_id)
+ {
+ return false;
+ }
+ if ($lazy && $module_id)
+ {
+ return true;
+ }
}
- return false;
+ // Returns true, if modules exist in all parents and false otherwise
+ return !$lazy;
}
/**
@@ -172,7 +190,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
$data = array('module_langname' => $data);
}
- $parent = $data['parent_id'] = $this->get_parent_module_id($parent, $data);
+ $parents = (array) $this->get_parent_module_id($parent, $data);
if (!isset($data['module_langname']))
{
@@ -195,99 +213,135 @@ class module implements \phpbb\db\migration\tool\tool_interface
);
// Run the "manual" way with the data we've collected.
- $this->add($class, $parent, $new_module);
+ foreach ($parents as $parent)
+ {
+ $this->add($class, $parent, $new_module);
+ }
}
}
return;
}
- // The "manual" way
- if (!$this->exists($class, false, $parent))
- {
- throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent);
- }
-
- if ($this->exists($class, $parent, $data['module_langname']))
+ foreach ($parents as $parent)
{
- throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']);
- }
+ $data['parent_id'] = $parent;
- $module_data = array(
- 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1,
- 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1,
- 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '',
- 'module_class' => $class,
- 'parent_id' => (int) $parent,
- 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '',
- 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '',
- 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '',
- );
-
- try
- {
- $this->module_manager->update_module_data($module_data);
+ // The "manual" way
+ if (!$this->exists($class, false, $parent))
+ {
+ throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent);
+ }
- // Success
- $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
- $phpbb_log->add('admin', (isset($user->data['user_id'])) ? $user->data['user_id'] : ANONYMOUS, $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name));
+ if ($this->exists($class, $parent, $data['module_langname']))
+ {
+ throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']);
+ }
- // Move the module if requested above/below an existing one
- if (isset($data['before']) && $data['before'])
+ $module_data = array(
+ 'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1,
+ 'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1,
+ 'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '',
+ 'module_class' => $class,
+ 'parent_id' => (int) $parent,
+ 'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '',
+ 'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '',
+ 'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '',
+ );
+
+ try
{
- $sql = 'SELECT left_id
+ $this->module_manager->update_module_data($module_data);
+
+ // Success
+ $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
+ $phpbb_log->add('admin', (isset($user->data['user_id'])) ? $user->data['user_id'] : ANONYMOUS, $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name));
+
+ // Move the module if requested above/below an existing one
+ if (isset($data['before']) && $data['before'])
+ {
+ $before_mode = $before_langname = '';
+ if (is_array($data['before']))
+ {
+ // Restore legacy-legacy behaviour from phpBB 3.0
+ list($before_mode, $before_langname) = $data['before'];
+ }
+ else
+ {
+ // Legacy behaviour from phpBB 3.1+
+ $before_langname = $data['before'];
+ }
+
+ $sql = 'SELECT left_id
FROM ' . $this->modules_table . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND parent_id = " . (int) $parent . "
- AND module_langname = '" . $this->db->sql_escape($data['before']) . "'";
- $this->db->sql_query($sql);
- $to_left = (int) $this->db->sql_fetchfield('left_id');
+ AND module_langname = '" . $this->db->sql_escape($before_langname) . "'"
+ . (($before_mode) ? " AND module_mode = '" . $this->db->sql_escape($before_mode) . "'" : '');
+ $result = $this->db->sql_query($sql);
+ $to_left = (int) $this->db->sql_fetchfield('left_id');
+ $this->db->sql_freeresult($result);
- $sql = 'UPDATE ' . $this->modules_table . "
+ $sql = 'UPDATE ' . $this->modules_table . "
SET left_id = left_id + 2, right_id = right_id + 2
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND left_id >= $to_left
AND left_id < {$module_data['left_id']}";
- $this->db->sql_query($sql);
+ $this->db->sql_query($sql);
- $sql = 'UPDATE ' . $this->modules_table . "
+ $sql = 'UPDATE ' . $this->modules_table . "
SET left_id = $to_left, right_id = " . ($to_left + 1) . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND module_id = {$module_data['module_id']}";
- $this->db->sql_query($sql);
- }
- else if (isset($data['after']) && $data['after'])
- {
- $sql = 'SELECT right_id
+ $this->db->sql_query($sql);
+ }
+ else if (isset($data['after']) && $data['after'])
+ {
+ $after_mode = $after_langname = '';
+ if (is_array($data['after']))
+ {
+ // Restore legacy-legacy behaviour from phpBB 3.0
+ list($after_mode, $after_langname) = $data['after'];
+ }
+ else
+ {
+ // Legacy behaviour from phpBB 3.1+
+ $after_langname = $data['after'];
+ }
+
+ $sql = 'SELECT right_id
FROM ' . $this->modules_table . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND parent_id = " . (int) $parent . "
- AND module_langname = '" . $this->db->sql_escape($data['after']) . "'";
- $this->db->sql_query($sql);
- $to_right = (int) $this->db->sql_fetchfield('right_id');
+ AND module_langname = '" . $this->db->sql_escape($after_langname) . "'"
+ . (($after_mode) ? " AND module_mode = '" . $this->db->sql_escape($after_mode) . "'" : '');
+ $result = $this->db->sql_query($sql);
+ $to_right = (int) $this->db->sql_fetchfield('right_id');
+ $this->db->sql_freeresult($result);
- $sql = 'UPDATE ' . $this->modules_table . "
+ $sql = 'UPDATE ' . $this->modules_table . "
SET left_id = left_id + 2, right_id = right_id + 2
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND left_id >= $to_right
AND left_id < {$module_data['left_id']}";
- $this->db->sql_query($sql);
+ $this->db->sql_query($sql);
- $sql = 'UPDATE ' . $this->modules_table . '
+ $sql = 'UPDATE ' . $this->modules_table . '
SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND module_id = {$module_data['module_id']}";
- $this->db->sql_query($sql);
+ $this->db->sql_query($sql);
+ }
+ }
+ catch (module_exception $e)
+ {
+ // Error
+ throw new \phpbb\db\migration\exception('MODULE_ERROR', $e->getMessage());
}
- }
- catch (module_exception $e)
- {
- // Error
- throw new \phpbb\db\migration\exception('MODULE_ERROR', $e->getMessage());
}
// Clear the Modules Cache
- $this->cache->destroy("_modules_$class");
+ $this->module_manager->remove_cache_file($class);
}
/**
@@ -334,7 +388,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
}
else
{
- if (!$this->exists($class, $parent, $module))
+ if (!$this->exists($class, $parent, $module, true))
{
return;
}
@@ -342,8 +396,8 @@ class module implements \phpbb\db\migration\tool\tool_interface
$parent_sql = '';
if ($parent !== false)
{
- $parent = $this->get_parent_module_id($parent, $module);
- $parent_sql = 'AND parent_id = ' . (int) $parent;
+ $parents = (array) $this->get_parent_module_id($parent, $module);
+ $parent_sql = 'AND ' . $this->db->sql_in_set('parent_id', $parents);
}
$module_ids = array();
@@ -371,7 +425,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
$this->module_manager->delete_module($module_id, $class);
}
- $this->cache->destroy("_modules_$class");
+ $this->module_manager->remove_cache_file($class);
}
}
@@ -457,23 +511,14 @@ class module implements \phpbb\db\migration\tool\tool_interface
* @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
+ * @return mixed The int parent module_id, an array of int parent module_id values 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
@@ -482,65 +527,30 @@ class module implements \phpbb\db\migration\tool\tool_interface
// Search for the parent module_langname
$ids = array_keys($this->module_categories, $parent_id);
- switch (sizeof($ids))
+ switch (count($ids))
{
// No parent with the given module_langname exist
case 0:
- $exception = new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id);
+ if ($throw_exception)
+ {
+ throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id);
+ }
+
+ return false;
break;
// Return the module id
case 1:
- $parent_id = (int) $ids[0];
+ return (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);
- }
+ // This represents the old behaviour of phpBB 3.0
+ return $ids;
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 9688420025..4b53aa32a7 100644
--- a/phpBB/phpbb/db/migration/tool/permission.php
+++ b/phpBB/phpbb/db/migration/tool/permission.php
@@ -442,7 +442,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
}
);
- if (sizeof($auth_option))
+ if (count($auth_option))
{
return $this->permission_set($role_name, $auth_option, 'role', $has_permission);
}
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index 6c026c3ae1..2b0c66fc58 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -632,7 +632,7 @@ class migrator
*/
protected function process_data_step($steps, $state, $revert = false)
{
- if (sizeof($steps) === 0)
+ if (count($steps) === 0)
{
return true;
}
@@ -659,7 +659,7 @@ class migrator
// 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))
+ if (($result !== null && $result !== true) || $step + 1 < count($steps))
{
return array(
'result' => $result,
@@ -760,7 +760,7 @@ class migrator
$condition = $parameters[0];
- if (!$condition)
+ if (!$condition || (is_array($condition) && !$this->run_step($condition, $last_result, $reverse)))
{
return false;
}
diff --git a/phpBB/phpbb/db/sql_insert_buffer.php b/phpBB/phpbb/db/sql_insert_buffer.php
index 18e4814a77..30e807b154 100644
--- a/phpBB/phpbb/db/sql_insert_buffer.php
+++ b/phpBB/phpbb/db/sql_insert_buffer.php
@@ -92,7 +92,7 @@ class sql_insert_buffer
// Flush buffer if it is full or when DB does not support multi inserts.
// In the later case, the buffer will always only contain one row.
- if (!$this->db->get_multi_insert() || sizeof($this->buffer) >= $this->max_buffered_rows)
+ if (!$this->db->get_multi_insert() || count($this->buffer) >= $this->max_buffered_rows)
{
return $this->flush();
}
@@ -104,7 +104,7 @@ class sql_insert_buffer
* Inserts a row set, i.e. an array of rows, by calling insert().
*
* Please note that it is in most cases better to use insert() instead of
- * first building a huge rowset. Or at least sizeof($rows) should be kept
+ * first building a huge rowset. Or at least count($rows) should be kept
* small.
*
* @param array $rows
diff --git a/phpBB/phpbb/db/tools/mssql.php b/phpBB/phpbb/db/tools/mssql.php
index 23b49aab44..cbedf9a5c4 100644
--- a/phpBB/phpbb/db/tools/mssql.php
+++ b/phpBB/phpbb/db/tools/mssql.php
@@ -49,18 +49,18 @@ class mssql extends tools
'STEXT' => '[varchar] (3000)',
'TEXT' => '[varchar] (8000)',
'MTEXT' => '[text]',
- 'XSTEXT_UNI'=> '[varchar] (100)',
- 'STEXT_UNI' => '[varchar] (255)',
- 'TEXT_UNI' => '[varchar] (4000)',
- 'MTEXT_UNI' => '[text]',
+ 'XSTEXT_UNI'=> '[nvarchar] (100)',
+ 'STEXT_UNI' => '[nvarchar] (255)',
+ 'TEXT_UNI' => '[nvarchar] (4000)',
+ 'MTEXT_UNI' => '[ntext]',
'TIMESTAMP' => '[int]',
'DECIMAL' => '[float]',
'DECIMAL:' => '[float]',
'PDECIMAL' => '[float]',
'PDECIMAL:' => '[float]',
- 'VCHAR_UNI' => '[varchar] (255)',
- 'VCHAR_UNI:'=> '[varchar] (%d)',
- 'VCHAR_CI' => '[varchar] (255)',
+ 'VCHAR_UNI' => '[nvarchar] (255)',
+ 'VCHAR_UNI:'=> '[nvarchar] (%d)',
+ 'VCHAR_CI' => '[nvarchar] (255)',
'VARBINARY' => '[varchar] (255)',
),
@@ -80,18 +80,18 @@ class mssql extends tools
'STEXT' => '[varchar] (3000)',
'TEXT' => '[varchar] (8000)',
'MTEXT' => '[text]',
- 'XSTEXT_UNI'=> '[varchar] (100)',
- 'STEXT_UNI' => '[varchar] (255)',
- 'TEXT_UNI' => '[varchar] (4000)',
- 'MTEXT_UNI' => '[text]',
+ 'XSTEXT_UNI'=> '[nvarchar] (100)',
+ 'STEXT_UNI' => '[nvarchar] (255)',
+ 'TEXT_UNI' => '[nvarchar] (4000)',
+ 'MTEXT_UNI' => '[ntext]',
'TIMESTAMP' => '[int]',
'DECIMAL' => '[float]',
'DECIMAL:' => '[float]',
'PDECIMAL' => '[float]',
'PDECIMAL:' => '[float]',
- 'VCHAR_UNI' => '[varchar] (255)',
- 'VCHAR_UNI:'=> '[varchar] (%d)',
- 'VCHAR_CI' => '[varchar] (255)',
+ 'VCHAR_UNI' => '[nvarchar] (255)',
+ 'VCHAR_UNI:'=> '[nvarchar] (%d)',
+ 'VCHAR_CI' => '[nvarchar] (255)',
'VARBINARY' => '[varchar] (255)',
),
);
@@ -440,7 +440,7 @@ class mssql extends tools
{
$result = $this->sql_index_drop($table_name, $index_name);
$statements = array_merge($statements, $result);
- if (sizeof($index_data) > 1)
+ if (count($index_data) > 1)
{
// Remove this column from the index and recreate it
$recreate_indexes[$index_name] = array_diff($index_data, array($column_name));
@@ -448,6 +448,10 @@ class mssql extends tools
}
}
+ // Drop primary keys depending on this column
+ $result = $this->mssql_get_drop_default_primary_key_queries($table_name, $column_name);
+ $statements = array_merge($statements, $result);
+
// Drop default value constraint
$result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name);
$statements = array_merge($statements, $result);
@@ -541,10 +545,7 @@ class mssql extends tools
{
$statements = array();
- if ($this->mssql_is_sql_server_2000())
- {
- $this->check_index_name_length($table_name, $index_name);
- }
+ $this->check_index_name_length($table_name, $index_name);
// remove index length
$column = preg_replace('#:.*$#', '', $column);
@@ -555,6 +556,21 @@ class mssql extends tools
}
/**
+ * {@inheritdoc}
+ */
+ protected function get_max_index_name_length()
+ {
+ if ($this->mssql_is_sql_server_2000())
+ {
+ return parent::get_max_index_name_length();
+ }
+ else
+ {
+ return 128;
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
function sql_list_index($table_name)
@@ -685,6 +701,38 @@ class mssql extends tools
}
/**
+ * Get queries to drop the primary keys depending on the specified column
+ *
+ * We need to drop primary keys depending on this column before being able
+ * to delete them.
+ *
+ * @param string $table_name
+ * @param string $column_name
+ * @return array Array with SQL statements
+ */
+ protected function mssql_get_drop_default_primary_key_queries($table_name, $column_name)
+ {
+ $statements = array();
+
+ $sql = "SELECT ccu.CONSTRAINT_NAME, ccu.COLUMN_NAME
+ FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
+ JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name
+ WHERE tc.TABLE_NAME = '{$table_name}'
+ AND tc.CONSTRAINT_TYPE = 'Primary Key'
+ AND ccu.COLUMN_NAME = '{$column_name}'";
+
+ $result = $this->db->sql_query($sql);
+
+ while ($primary_key = $this->db->sql_fetchrow($result))
+ {
+ $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $primary_key['CONSTRAINT_NAME'] . ']';
+ }
+ $this->db->sql_freeresult($result);
+
+ return $statements;
+ }
+
+ /**
* Checks to see if column is an identity column
*
* Identity columns cannot have defaults set for them.
diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php
index 2f891e43d5..c3352a1f66 100644
--- a/phpBB/phpbb/db/tools/tools.php
+++ b/phpBB/phpbb/db/tools/tools.php
@@ -576,7 +576,7 @@ class tools implements tools_interface
{
foreach ($indexes as $index_name)
{
- if (!$this->sql_index_exists($table, $index_name))
+ if (!$this->sql_index_exists($table, $index_name) && !$this->sql_unique_index_exists($table, $index_name))
{
continue;
}
@@ -1561,7 +1561,8 @@ class tools implements tools_interface
*/
protected function check_index_name_length($table_name, $index_name, $throw_error = true)
{
- if (strlen($index_name) > 30)
+ $max_index_name_length = $this->get_max_index_name_length();
+ if (strlen($index_name) > $max_index_name_length)
{
// Try removing the table prefix if it's at the beginning
$table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config)
@@ -1582,7 +1583,7 @@ class tools implements tools_interface
if ($throw_error)
{
- trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
+ trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters.", E_USER_ERROR);
}
}
@@ -1590,6 +1591,16 @@ class tools implements tools_interface
}
/**
+ * Get maximum index name length. Might vary depending on db type
+ *
+ * @return int Maximum index name length
+ */
+ protected function get_max_index_name_length()
+ {
+ return 30;
+ }
+
+ /**
* {@inheritDoc}
*/
function sql_list_index($table_name)
diff --git a/phpBB/phpbb/debug/error_handler.php b/phpBB/phpbb/debug/error_handler.php
index 246e724f56..ebd828b97f 100644
--- a/phpBB/phpbb/debug/error_handler.php
+++ b/phpBB/phpbb/debug/error_handler.php
@@ -17,7 +17,7 @@ use Symfony\Component\Debug\ErrorHandler;
class error_handler extends ErrorHandler
{
- public function handleError($type, $message, $file, $line, array $context, array $backtrace = null)
+ public function handleError($type, $message, $file, $line)
{
if ($type === E_USER_WARNING || $type === E_USER_NOTICE)
{
@@ -26,6 +26,6 @@ class error_handler extends ErrorHandler
$handler($type, $message, $file, $line);
}
- return parent::handleError($type, $message, $file, $line, $context, $backtrace);
+ return parent::handleError($type, $message, $file, $line);
}
}
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index ac1a1a1733..8c1ce8bde2 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -143,6 +143,13 @@ class container_builder
{
if ($this->use_extensions)
{
+ $autoload_cache = new ConfigCache($this->get_autoload_filename(), defined('DEBUG'));
+ if (!$autoload_cache->isFresh())
+ {
+ // autoload cache should be refreshed
+ $this->load_extensions();
+ }
+
require($this->get_autoload_filename());
}
diff --git a/phpBB/phpbb/event/dispatcher.php b/phpBB/phpbb/event/dispatcher.php
index 1c4abeb108..1ba2ab8987 100644
--- a/phpBB/phpbb/event/dispatcher.php
+++ b/phpBB/phpbb/event/dispatcher.php
@@ -57,7 +57,12 @@ class dispatcher extends ContainerAwareEventDispatcher implements dispatcher_int
return $event;
}
- return parent::dispatch($eventName, $event);
+ foreach ((array) $eventName as $name)
+ {
+ $event = parent::dispatch($name, $event);
+ }
+
+ return $event;
}
/**
diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php
index e042d0a5d1..1a2d7c989e 100644
--- a/phpBB/phpbb/event/md_exporter.php
+++ b/phpBB/phpbb/event/md_exporter.php
@@ -87,7 +87,7 @@ class md_exporter
$this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name));
}
- return sizeof($this->events);
+ return count($this->events);
}
/**
@@ -113,7 +113,7 @@ class md_exporter
}
}
- return sizeof($this->events);
+ return count($this->events);
}
/**
@@ -143,6 +143,8 @@ class md_exporter
list($event_name, $details) = explode("\n===\n", $event, 2);
$this->validate_event_name($event_name);
+ $sorted_events = [$this->current_event, $event_name];
+ natsort($sorted_events);
$this->current_event = $event_name;
if (isset($this->events[$this->current_event]))
@@ -150,6 +152,12 @@ class md_exporter
throw new \LogicException("The event '{$this->current_event}' is defined multiple times");
}
+ // Use array_values() to get actual first element and check against natural order
+ if (array_values($sorted_events)[0] === $event_name)
+ {
+ throw new \LogicException("The event '{$sorted_events[1]}' should be defined before '{$sorted_events[0]}'");
+ }
+
if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0)
|| ($this->filter == 'styles' && strpos($this->current_event, 'acp_') === 0))
{
@@ -219,7 +227,7 @@ class md_exporter
);
}
- return sizeof($this->events);
+ return count($this->events);
}
/**
@@ -381,9 +389,16 @@ class md_exporter
$files = explode("\n + ", $file_details);
foreach ($files as $file)
{
+ if (!preg_match('#^([^ ]+)( \([0-9]+\))?$#', $file))
+ {
+ throw new \LogicException("Invalid event instances for file '{$file}' found for event '{$this->current_event}'", 1);
+ }
+
+ list($file) = explode(" ", $file);
+
if (!file_exists($this->path . $file) || substr($file, -5) !== '.html')
{
- throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1);
+ throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);
}
if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0)
@@ -396,7 +411,7 @@ class md_exporter
}
else
{
- throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);
+ throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 3);
}
$this->events_by_file[$file][] = $this->current_event;
@@ -416,7 +431,7 @@ class md_exporter
}
else
{
- throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 2);
+ throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 1);
}
return $files_list;
@@ -439,16 +454,9 @@ class md_exporter
$event_list = array();
$file_content = file_get_contents($this->path . $file);
- $events = explode('<!-- EVENT ', $file_content);
- // Remove the code before the first event
- array_shift($events);
- foreach ($events as $event)
- {
- $event = explode(' -->', $event, 2);
- $event_list[] = array_shift($event);
- }
+ preg_match_all('/(?:{%|<!--) EVENT (.*) (?:%}|-->)/U', $file_content, $event_list);
- return $event_list;
+ return $event_list[1];
}
/**
diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php
index 26d7e2b426..71c94a681d 100644
--- a/phpBB/phpbb/event/php_exporter.php
+++ b/phpBB/phpbb/event/php_exporter.php
@@ -117,7 +117,7 @@ class php_exporter
}
ksort($this->events);
- return sizeof($this->events);
+ return count($this->events);
}
/**
@@ -196,13 +196,13 @@ class php_exporter
$content = file_get_contents($this->path . $this->current_file);
$num_events_found = 0;
- if (strpos($content, "dispatcher->trigger_event('") || strpos($content, "dispatcher->dispatch('"))
+ if (strpos($content, 'dispatcher->trigger_event(') || strpos($content, 'dispatcher->dispatch('))
{
$this->set_content(explode("\n", $content));
- for ($i = 0, $num_lines = sizeof($this->file_lines); $i < $num_lines; $i++)
+ for ($i = 0, $num_lines = count($this->file_lines); $i < $num_lines; $i++)
{
$event_line = false;
- $found_trigger_event = strpos($this->file_lines[$i], "dispatcher->trigger_event('");
+ $found_trigger_event = strpos($this->file_lines[$i], 'dispatcher->trigger_event(');
$arguments = array();
if ($found_trigger_event !== false)
{
@@ -216,7 +216,7 @@ class php_exporter
}
else
{
- $found_dispatch = strpos($this->file_lines[$i], "dispatcher->dispatch('");
+ $found_dispatch = strpos($this->file_lines[$i], 'dispatcher->dispatch(');
if ($found_dispatch !== false)
{
$event_line = $i;
@@ -264,7 +264,30 @@ class php_exporter
// Find event description line
$description_line_num = $this->find_description();
- $description = substr(trim($this->file_lines[$description_line_num]), strlen('* '));
+ $description_lines = array();
+
+ while (true)
+ {
+ $description_line = substr(trim($this->file_lines[$description_line_num]), strlen('*'));
+ $description_line = trim(str_replace("\t", " ", $description_line));
+
+ // Reached end of description if line is a tag
+ if (strlen($description_line) && $description_line[0] == '@')
+ {
+ break;
+ }
+
+ $description_lines[] = $description_line;
+ $description_line_num++;
+ }
+
+ // If there is an empty line between description and first tag, remove it
+ if (!strlen(end($description_lines)))
+ {
+ array_pop($description_lines);
+ }
+
+ $description = trim(implode('<br/>', $description_lines));
if (isset($this->events[$this->current_event]))
{
@@ -316,17 +339,17 @@ class php_exporter
if ($is_dispatch)
{
- $regex = '#\$([a-z](?:[a-z0-9_]|->)*)';
- $regex .= '->dispatch\(';
- $regex .= '\'' . $this->preg_match_event_name() . '\'';
- $regex .= '\);#';
+ $regex = '#\$[a-z](?:[a-z0-9_]|->)*';
+ $regex .= '->dispatch\((\[)?';
+ $regex .= '\'' . $this->preg_match_event_name() . '(?(1)\', \'(?2))+\'';
+ $regex .= '(?(1)\])\);#';
}
else
{
- $regex = '#extract\(\$([a-z](?:[a-z0-9_]|->)*)';
- $regex .= '->trigger_event\(';
- $regex .= '\'' . $this->preg_match_event_name() . '\'';
- $regex .= ', compact\(\$vars\)\)\);#';
+ $regex = '#extract\(\$[a-z](?:[a-z0-9_]|->)*';
+ $regex .= '->trigger_event\((\[)?';
+ $regex .= '\'' . $this->preg_match_event_name() . '(?(1)\', \'(?2))+\'';
+ $regex .= '(?(1)\]), compact\(\$vars\)\)\);#';
}
$match = array();
@@ -359,7 +382,7 @@ class php_exporter
public function get_vars_from_array()
{
$line = ltrim($this->file_lines[$this->current_event_line - 1], "\t");
- if ($line === ');')
+ if ($line === ');' || $line === '];')
{
$vars_array = $this->get_vars_from_multi_line_array();
}
@@ -370,7 +393,7 @@ class php_exporter
foreach ($vars_array as $var)
{
- if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var))
+ if (!preg_match('#^[a-z_][a-z0-9_]*$#i', $var))
{
throw new \LogicException("Found invalid var '{$var}' in array for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 3);
}
@@ -392,12 +415,12 @@ class php_exporter
public function get_vars_from_single_line_array($line, $throw_multiline = true)
{
$match = array();
- preg_match('#^\$vars = (?:\[|array\()\'([a-zA-Z0-9_\' ,]+)\'[\)\]];$#', $line, $match);
+ preg_match('#^\$vars = (?:(\[)|array\()\'([a-z0-9_\' ,]+)\'(?(1)\]|\));$#i', $line, $match);
- if (isset($match[1]))
+ if (isset($match[2]))
{
- $vars_array = explode("', '", $match[1]);
- if ($throw_multiline && sizeof($vars_array) > 6)
+ $vars_array = explode("', '", $match[2]);
+ if ($throw_multiline && count($vars_array) > 6)
{
throw new \LogicException('Should use multiple lines for $vars definition '
. "for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 2);
@@ -420,7 +443,7 @@ class php_exporter
{
$current_vars_line = 2;
$var_lines = array();
- while (ltrim($this->file_lines[$this->current_event_line - $current_vars_line], "\t") !== '$vars = array(')
+ while (!in_array(ltrim($this->file_lines[$this->current_event_line - $current_vars_line], "\t"), ['$vars = array(', '$vars = [']))
{
$var_lines[] = substr(trim($this->file_lines[$this->current_event_line - $current_vars_line]), 0, -1);
@@ -460,7 +483,7 @@ class php_exporter
if (strpos($var_line, '* @var ') === 0)
{
$doc_line = explode(' ', $var_line, 5);
- if (sizeof($doc_line) !== 5)
+ if (count($doc_line) !== 5)
{
throw new \LogicException("Found invalid line '{$this->file_lines[$this->current_event_line - $current_doc_line]}' "
. "for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 1);
@@ -485,7 +508,7 @@ class php_exporter
foreach ($doc_vars as $var)
{
- if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var))
+ if (!preg_match('#^[a-z_][a-z0-9_]*$#i', $var))
{
throw new \LogicException("Found invalid @var '{$var}' in docblock for event "
. "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 4);
@@ -707,9 +730,9 @@ class php_exporter
{
$vars_array = array_unique($vars_array);
$vars_docblock = array_unique($vars_docblock);
- $sizeof_vars_array = sizeof($vars_array);
+ $sizeof_vars_array = count($vars_array);
- if ($sizeof_vars_array !== sizeof($vars_docblock) || $sizeof_vars_array !== sizeof(array_intersect($vars_array, $vars_docblock)))
+ if ($sizeof_vars_array !== count($vars_docblock) || $sizeof_vars_array !== count(array_intersect($vars_array, $vars_docblock)))
{
throw new \LogicException("\$vars array does not match the list of '@var' tags for event "
. "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'");
diff --git a/phpBB/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php
index e15d1e131e..7d50b7ce7d 100644
--- a/phpBB/phpbb/feed/helper.php
+++ b/phpBB/phpbb/feed/helper.php
@@ -13,41 +13,52 @@
namespace phpbb\feed;
+use phpbb\config\config;
+use phpbb\path_helper;
+use phpbb\textformatter\s9e\renderer;
+use phpbb\user;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
/**
* Class with some helpful functions used in feeds
*/
class helper
{
- /** @var \phpbb\config\config */
+ /** @var config */
protected $config;
- /** @var \phpbb\user */
- protected $user;
+ /** @var ContainerInterface */
+ protected $container;
- /** @var string */
- protected $phpbb_root_path;
+ /** @var path_helper */
+ protected $path_helper;
- /** @var string */
- protected $phpEx;
+ /** @var renderer */
+ protected $renderer;
+
+ /** @var user */
+ protected $user;
/**
* Constructor
*
- * @param \phpbb\config\config $config Config object
- * @param \phpbb\user $user User object
- * @param string $phpbb_root_path Root path
- * @param string $phpEx PHP file extension
+ * @param config $config Config object
+ * @param ContainerInterface $container Service container object
+ * @param path_helper $path_helper Path helper object
+ * @param renderer $renderer TextFormatter renderer object
+ * @param user $user User object
*/
- public function __construct(\phpbb\config\config $config, \phpbb\user $user, $phpbb_root_path, $phpEx)
+ public function __construct(config $config, ContainerInterface $container, path_helper $path_helper, renderer $renderer, user $user)
{
$this->config = $config;
+ $this->container = $container;
+ $this->path_helper = $path_helper;
+ $this->renderer = $renderer;
$this->user = $user;
- $this->phpbb_root_path = $phpbb_root_path;
- $this->phpEx = $phpEx;
}
/**
- * Run links through append_sid(), prepend generate_board_url() and remove session id
+ * Returns the board url (and caches it in the function)
*/
public function get_board_url()
{
@@ -104,16 +115,12 @@ class helper
return '';
}
- // Prepare some bbcodes for better parsing
- $content = preg_replace("#\[quote(=&quot;.*?&quot;)?:$uid\]\s*(.*?)\s*\[/quote:$uid\]#si", "[quote$1:$uid]<br />$2<br />[/quote:$uid]", $content);
-
- $content = generate_text_for_display($content, $uid, $bitfield, $options);
+ // Setup our own quote_helper to remove all attributes from quotes
+ $this->renderer->configure_quote_helper($this->container->get('feed.quote_helper'));
- // Add newlines
- $content = str_replace('<br />', '<br />' . "\n", $content);
+ $this->renderer->set_smilies_path($this->get_board_url() . '/' . $this->config['smilies_path']);
- // Convert smiley Relative paths to Absolute path, Windows style
- $content = str_replace($this->phpbb_root_path . $this->config['smilies_path'], $this->get_board_url() . '/' . $this->config['smilies_path'], $content);
+ $content = generate_text_for_display($content, $uid, $bitfield, $options);
// Remove "Select all" link and mouse events
$content = str_replace('<a href="#" onclick="selectCode(this); return false;">' . $this->user->lang['SELECT_ALL_CODE'] . '</a>', '', $content);
@@ -152,7 +159,7 @@ class helper
$content .= implode('<br />', $post_attachments);
// Convert attachments' relative path to absolute path
- $content = str_replace($this->phpbb_root_path . 'download/file.' . $this->phpEx, $this->get_board_url() . '/download/file.' . $this->phpEx, $content);
+ $content = str_replace($this->path_helper->get_web_root_path() . 'download/file.' . $this->path_helper->get_php_ext(), $this->get_board_url() . '/download/file.' . $this->path_helper->get_php_ext(), $content);
}
// Remove Comments from inline attachments [ia]
diff --git a/phpBB/phpbb/feed/quote_helper.php b/phpBB/phpbb/feed/quote_helper.php
new file mode 100644
index 0000000000..843d075028
--- /dev/null
+++ b/phpBB/phpbb/feed/quote_helper.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\feed;
+
+/**
+ * Modified quote_helper for feeds (basically just removing all attributes)
+ */
+class quote_helper extends \phpbb\textformatter\s9e\quote_helper
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function inject_metadata($xml)
+ {
+ // In feeds we don't want any attributes, so delete all of them
+ return \s9e\TextFormatter\Utils::replaceAttributes(
+ $xml,
+ 'QUOTE',
+ function ()
+ {
+ return [];
+ }
+ );
+ }
+}
diff --git a/phpBB/phpbb/file_downloader.php b/phpBB/phpbb/file_downloader.php
index ab9505a14c..403ca5bc83 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(($port == 443 ? 'tls://' : '') . $host, $port, $this->error_number, $this->error_string, $timeout))
+ if ($socket = @fsockopen(($port == 443 ? 'ssl://' : '') . $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/files/filespec.php b/phpBB/phpbb/files/filespec.php
index f1a32ef4a8..6847bca4cb 100644
--- a/phpBB/phpbb/files/filespec.php
+++ b/phpBB/phpbb/files/filespec.php
@@ -121,7 +121,7 @@ class filespec
*/
public function set_upload_ary($upload_ary)
{
- if (!isset($upload_ary) || !sizeof($upload_ary))
+ if (!isset($upload_ary) || !count($upload_ary))
{
return $this;
}
@@ -403,7 +403,7 @@ class filespec
*/
public function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false)
{
- if (sizeof($this->error))
+ if (count($this->error))
{
return false;
}
@@ -478,7 +478,7 @@ class filespec
// Remove temporary filename
@unlink($this->filename);
- if (sizeof($this->error))
+ if (count($this->error))
{
return false;
}
diff --git a/phpBB/phpbb/files/types/form.php b/phpBB/phpbb/files/types/form.php
index 832f090c47..2c3beb6e02 100644
--- a/phpBB/phpbb/files/types/form.php
+++ b/phpBB/phpbb/files/types/form.php
@@ -119,7 +119,7 @@ class form extends base
// PHP Upload file size check
$file = $this->check_upload_size($file);
- if (sizeof($file->error))
+ if (count($file->error))
{
return $file;
}
diff --git a/phpBB/phpbb/files/types/local.php b/phpBB/phpbb/files/types/local.php
index 7e9210b196..4dfe4f7506 100644
--- a/phpBB/phpbb/files/types/local.php
+++ b/phpBB/phpbb/files/types/local.php
@@ -86,7 +86,7 @@ class local extends base
// PHP Upload file size check
$file = $this->check_upload_size($file);
- if (sizeof($file->error))
+ if (count($file->error))
{
return $file;
}
diff --git a/phpBB/phpbb/files/upload.php b/phpBB/phpbb/files/upload.php
index a9bf74094d..50e15c9844 100644
--- a/phpBB/phpbb/files/upload.php
+++ b/phpBB/phpbb/files/upload.php
@@ -261,7 +261,7 @@ class upload
*
* @param filespec $file Instance of filespec class
*/
- public function common_checks(&$file)
+ public function common_checks($file)
{
// Filesize is too big or it's 0 if it was larger than the maxsize in the upload form
if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0))
@@ -297,7 +297,7 @@ class upload
*
* @return bool True if extension is allowed, false if not
*/
- public function valid_extension(&$file)
+ public function valid_extension($file)
{
return (in_array($file->get('extension'), $this->allowed_extensions)) ? true : false;
}
@@ -310,7 +310,7 @@ class upload
* @return bool True if dimensions are valid or no constraints set, false
* if not
*/
- public function valid_dimensions(&$file)
+ public function valid_dimensions($file)
{
if (!$this->max_width && !$this->max_height && !$this->min_width && !$this->min_height)
{
@@ -350,7 +350,7 @@ class upload
*
* @return bool True if content is valid, false if not
*/
- public function valid_content(&$file)
+ public function valid_content($file)
{
return ($file->check_content($this->disallowed_content));
}
diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php
index 2112882d1d..bfafdf5ddd 100644
--- a/phpBB/phpbb/filesystem/filesystem.php
+++ b/phpBB/phpbb/filesystem/filesystem.php
@@ -171,7 +171,7 @@ class filesystem implements filesystem_interface
continue;
}
- if ($part === '..' && !empty($filtered) && $filtered[sizeof($filtered) - 1] !== '.' && $filtered[sizeof($filtered) - 1] !== '..')
+ if ($part === '..' && !empty($filtered) && $filtered[count($filtered) - 1] !== '.' && $filtered[count($filtered) - 1] !== '..')
{
array_pop($filtered);
}
@@ -367,7 +367,7 @@ class filesystem implements filesystem_interface
$common_php_group = @filegroup(__FILE__);
// And the owner and the groups PHP is running under.
- $php_uid = (function_exists('posic_getuid')) ? @posix_getuid() : false;
+ $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false;
$php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false;
// If we are unable to get owner/group, then do not try to set them by guessing
@@ -671,7 +671,7 @@ class filesystem implements filesystem_interface
else if (function_exists('debug_backtrace'))
{
$call_stack = debug_backtrace(0);
- $this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[sizeof($call_stack) - 1]['file']));
+ $this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[count($call_stack) - 1]['file']));
}
else
{
@@ -683,7 +683,7 @@ class filesystem implements filesystem_interface
//$dir_parts = explode(DIRECTORY_SEPARATOR, __DIR__);
//$namespace_parts = explode('\\', trim(__NAMESPACE__, '\\'));
- //$namespace_part_count = sizeof($namespace_parts);
+ //$namespace_part_count = count($namespace_parts);
// Check if we still loading from root
//if (array_slice($dir_parts, -$namespace_part_count) === $namespace_parts)
@@ -807,7 +807,7 @@ class filesystem implements filesystem_interface
array_pop($resolved);
$resolved_path = false;
}
- else if ($path_part === '..' && !empty($resolved) && !in_array($resolved[sizeof($resolved) - 1], array('.', '..')))
+ else if ($path_part === '..' && !empty($resolved) && !in_array($resolved[count($resolved) - 1], array('.', '..')))
{
array_pop($resolved);
$resolved_path = false;
diff --git a/phpBB/phpbb/group/helper.php b/phpBB/phpbb/group/helper.php
index 5befddfc53..aa3876b325 100644
--- a/phpBB/phpbb/group/helper.php
+++ b/phpBB/phpbb/group/helper.php
@@ -13,19 +13,74 @@
namespace phpbb\group;
+use phpbb\auth\auth;
+use phpbb\cache\service as cache;
+use phpbb\config\config;
+use phpbb\language\language;
+use phpbb\event\dispatcher_interface;
+use phpbb\path_helper;
+use phpbb\user;
+
class helper
{
- /** @var \phpbb\language\language */
+ /** @var auth */
+ protected $auth;
+
+ /** @var cache */
+ protected $cache;
+
+ /** @var config */
+ protected $config;
+
+ /** @var language */
protected $language;
+ /** @var dispatcher_interface */
+ protected $dispatcher;
+
+ /** @var path_helper */
+ protected $path_helper;
+
+ /** @var user */
+ protected $user;
+
+ /** @var string phpBB root path */
+ protected $phpbb_root_path;
+
+ /** @var array Return templates for a group name string */
+ protected $name_strings;
+
/**
* Constructor
*
- * @param \phpbb\language\language $language Language object
+ * @param auth $auth Authentication object
+ * @param cache $cache Cache service object
+ * @param config $config Configuration object
+ * @param language $language Language object
+ * @param dispatcher_interface $dispatcher Event dispatcher object
+ * @param path_helper $path_helper Path helper object
+ * @param user $user User object
*/
- public function __construct(\phpbb\language\language $language)
+ public function __construct(auth $auth, cache $cache, config $config, language $language, dispatcher_interface $dispatcher, path_helper $path_helper, user $user)
{
+ $this->auth = $auth;
+ $this->cache = $cache;
+ $this->config = $config;
$this->language = $language;
+ $this->dispatcher = $dispatcher;
+ $this->path_helper = $path_helper;
+ $this->user = $user;
+
+ $this->phpbb_root_path = $path_helper->get_phpbb_root_path();
+
+ /** @html Group name spans and links for usage in the template */
+ $this->name_strings = array(
+ 'base_url' => "{$path_helper->get_phpbb_root_path()}memberlist.{$path_helper->get_php_ext()}?mode=group&amp;g={GROUP_ID}",
+ 'tpl_noprofile' => '<span class="username">{GROUP_NAME}</span>',
+ 'tpl_noprofile_colour' => '<span class="username-coloured" style="color: {GROUP_COLOUR};">{GROUP_NAME}</span>',
+ 'tpl_profile' => '<a class="username" href="{PROFILE_URL}">{GROUP_NAME}</a>',
+ 'tpl_profile_colour' => '<a class="username-coloured" href="{PROFILE_URL}" style="color: {GROUP_COLOUR};">{GROUP_NAME}</a>',
+ );
}
/**
@@ -37,4 +92,203 @@ class helper
{
return $this->language->is_set('G_' . utf8_strtoupper($group_name)) ? $this->language->lang('G_' . utf8_strtoupper($group_name)) : $group_name;
}
+
+ /**
+ * Get group name details for placing into templates.
+ *
+ * @html Group name spans and links
+ *
+ * @param string $mode Profile (for getting an url to the profile),
+ * group_name (for obtaining the group name),
+ * colour (for obtaining the group colour),
+ * full (for obtaining a coloured group name link to the group's profile),
+ * no_profile (the same as full but forcing no profile link)
+ * @param int $group_id The group id
+ * @param string $group_name The group name
+ * @param string $group_colour The group colour
+ * @param mixed $custom_profile_url optional parameter to specify a profile url. The group id gets appended to this url as &amp;g={group_id}
+ *
+ * @return string A string consisting of what is wanted based on $mode.
+ */
+ public function get_name_string($mode, $group_id, $group_name, $group_colour = '', $custom_profile_url = false)
+ {
+ $s_is_bots = ($group_name === 'BOTS');
+
+ // This switch makes sure we only run code required for the mode
+ switch ($mode)
+ {
+ case 'full':
+ case 'no_profile':
+ case 'colour':
+
+ // Build correct group colour
+ $group_colour = $group_colour ? '#' . $group_colour : '';
+
+ // Return colour
+ if ($mode === 'colour')
+ {
+ $group_name_string = $group_colour;
+ break;
+ }
+
+ // no break;
+
+ case 'group_name':
+
+ // Build correct group name
+ $group_name = $this->get_name($group_name);
+
+ // Return group name
+ if ($mode === 'group_name')
+ {
+ $group_name_string = $group_name;
+ break;
+ }
+
+ // no break;
+
+ case 'profile':
+
+ // Build correct profile url - only show if not anonymous and permission to view profile if registered user
+ // For anonymous the link leads to a login page.
+ if ($group_id && !$s_is_bots && ($this->user->data['user_id'] == ANONYMOUS || $this->auth->acl_get('u_viewprofile')))
+ {
+ $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&amp;g=' . (int) $group_id : str_replace(array('={GROUP_ID}', '=%7BGROUP_ID%7D'), '=' . (int) $group_id, append_sid($this->name_strings['base_url']));
+ }
+ else
+ {
+ $profile_url = '';
+ }
+
+ // Return profile
+ if ($mode === 'profile')
+ {
+ $group_name_string = $profile_url;
+ break;
+ }
+
+ // no break;
+ }
+
+ if (!isset($group_name_string))
+ {
+ if (($mode === 'full' && empty($profile_url)) || $mode === 'no_profile' || $s_is_bots)
+ {
+ $group_name_string = str_replace(array('{GROUP_COLOUR}', '{GROUP_NAME}'), array($group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_noprofile'] : $this->name_strings['tpl_noprofile_colour']);
+ }
+ else
+ {
+ $group_name_string = str_replace(array('{PROFILE_URL}', '{GROUP_COLOUR}', '{GROUP_NAME}'), array($profile_url, $group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_profile'] : $this->name_strings['tpl_profile_colour']);
+ }
+ }
+
+ $name_strings = $this->name_strings;
+
+ /**
+ * Use this event to change the output of the group name
+ *
+ * @event core.modify_group_name_string
+ * @var string mode profile|group_name|colour|full|no_profile
+ * @var int group_id The group identifier
+ * @var string group_name The group name
+ * @var string group_colour The group colour
+ * @var string custom_profile_url Optional parameter to specify a profile url.
+ * @var string group_name_string The string that has been generated
+ * @var array name_strings Array of original return templates
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'mode',
+ 'group_id',
+ 'group_name',
+ 'group_colour',
+ 'custom_profile_url',
+ 'group_name_string',
+ 'name_strings',
+ );
+ extract($this->dispatcher->trigger_event('core.modify_group_name_string', compact($vars)));
+
+ return $group_name_string;
+ }
+
+ /**
+ * Get group rank title and image
+ *
+ * @html Group rank image element
+ *
+ * @param array $group_data The current stored group data
+ *
+ * @return array An associative array containing the rank title (title),
+ * the rank image as full img tag (img) and the rank image source (img_src)
+ */
+ public function get_rank($group_data)
+ {
+ $group_rank_data = array(
+ 'title' => null,
+ 'img' => null,
+ 'img_src' => null,
+ );
+
+ /**
+ * Preparing a group's rank before displaying
+ *
+ * @event core.get_group_rank_before
+ * @var array group_data Array with group's data
+ * @since 3.2.8-RC1
+ */
+
+ $vars = array('group_data');
+ extract($this->dispatcher->trigger_event('core.get_group_rank_before', compact($vars)));
+
+ if (!empty($group_data['group_rank']))
+ {
+ // Only obtain ranks if group rank is set
+ $ranks = $this->cache->obtain_ranks();
+
+ if (isset($ranks['special'][$group_data['group_rank']]))
+ {
+ $rank = $ranks['special'][$group_data['group_rank']];
+
+ $group_rank_data['title'] = $rank['rank_title'];
+
+ $group_rank_data['img_src'] = (!empty($rank['rank_image'])) ? $this->path_helper->update_web_root_path($this->phpbb_root_path . $this->config['ranks_path'] . '/' . $rank['rank_image']) : '';
+
+ /** @html Group rank image element for usage in the template */
+ $group_rank_data['img'] = (!empty($rank['rank_image'])) ? '<img src="' . $group_rank_data['img_src'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
+ }
+ }
+
+ /**
+ * Modify a group's rank before displaying
+ *
+ * @event core.get_group_rank_after
+ * @var array group_data Array with group's data
+ * @var array group_rank_data Group rank data
+ * @since 3.2.8-RC1
+ */
+
+ $vars = array(
+ 'group_data',
+ 'group_rank_data',
+ );
+ extract($this->dispatcher->trigger_event('core.get_group_rank_after', compact($vars)));
+
+ return $group_rank_data;
+ }
+
+ /**
+ * Get group avatar.
+ * Wrapper function for phpbb_get_group_avatar()
+ *
+ * @param array $group_row Row from the groups table
+ * @param string $alt Optional language string for alt tag within image, can be a language key or text
+ * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
+ * @param bool $lazy If true, will be lazy loaded (requires JS)
+ *
+ * @return string Avatar html
+ */
+ function get_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
+ {
+ return phpbb_get_group_avatar($group_row, $alt, $ignore_config, $lazy);
+ }
}
diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php
index fad6749019..7eb0ae3b05 100644
--- a/phpBB/phpbb/install/helper/config.php
+++ b/phpBB/phpbb/install/helper/config.php
@@ -330,6 +330,8 @@ class config
fwrite($fp, $file_content);
fclose($fp);
+ // Enforce 0600 permission for install config
+ $this->filesystem->chmod([$this->install_config_file], 0600);
}
/**
diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php
index 59b86a8ca7..fa5a10c6fc 100644
--- a/phpBB/phpbb/install/helper/database.php
+++ b/phpBB/phpbb/install/helper/database.php
@@ -76,7 +76,7 @@ class database
'LABEL' => 'Oracle',
'SCHEMA' => 'oracle',
'MODULE' => 'oci8',
- 'DELIM' => '/',
+ 'DELIM' => ';',
'DRIVER' => 'phpbb\db\driver\oracle',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -338,7 +338,7 @@ class database
// Check if SQLite database is writable
if ($dbms_info['SCHEMA'] === 'sqlite'
- && (!$this->filesystem->is_writable($dbhost) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME))))
+ && (($this->filesystem->exists($dbhost) && !$this->filesystem->is_writable($dbhost)) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME))))
{
$errors[] = array(
'title' =>'INST_ERR_DB_NO_WRITABLE',
@@ -372,7 +372,7 @@ class database
$tables = array_map('strtolower', $tables);
$table_intersect = array_intersect($tables, $table_ary);
- if (sizeof($table_intersect))
+ if (count($table_intersect))
{
$errors[] = array(
'title' => 'INST_ERR_PREFIX',
diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
index bce0149890..2a608f504e 100644
--- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
+++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
@@ -187,6 +187,7 @@ class ajax_iohandler extends iohandler_base
$tpl_ary['KEY'] = $input_name;
$tpl_ary['S_EXPLAIN'] = false;
$tpl_ary['DISABLED'] = isset($input_options['disabled']) ? $input_options['disabled'] : false;
+ $tpl_ary['IS_SECONDARY'] = isset($input_options['is_secondary']) ? $input_options['is_secondary'] : false;
if (isset($input_options['default']))
{
@@ -203,7 +204,7 @@ class ajax_iohandler extends iohandler_base
if (in_array($input_options['type'], array('select', 'radio'), true))
{
- for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++)
+ for ($i = 0, $total = count($input_options['options']); $i < $total; $i++)
{
if (isset($input_options['options'][$i]['label']))
{
@@ -218,6 +219,11 @@ class ajax_iohandler extends iohandler_base
$this->template->assign_block_vars($block_name, $tpl_ary);
}
+ if (isset($form['database_update_submit']) && !$form['database_update_submit']['disabled'])
+ {
+ $this->template->assign_var('FORM_TITLE', $this->language->lang('UPDATE_CONTINUE_UPDATE_PROCESS'));
+ }
+
$this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form);
if (!$not_button_form)
@@ -375,7 +381,7 @@ class ajax_iohandler extends iohandler_base
*/
public function set_active_stage_menu($menu_path)
{
- $this->nav_data['active'] = $menu_path[sizeof($menu_path) - 1];
+ $this->nav_data['active'] = $menu_path[count($menu_path) - 1];
$this->send_response();
}
@@ -384,7 +390,7 @@ class ajax_iohandler extends iohandler_base
*/
public function set_finished_stage_menu($menu_path)
{
- $this->nav_data['finished'][] = $menu_path[sizeof($menu_path) - 1];
+ $this->nav_data['finished'][] = $menu_path[count($menu_path) - 1];
$this->send_response();
}
diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php
index 1f1cecceb2..07f8e025cf 100644
--- a/phpBB/phpbb/install/module/install_data/task/add_bots.php
+++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php
@@ -239,7 +239,7 @@ class add_bots extends \phpbb\install\task_base
$this->install_config->set('add_bot_index', $i);
- if ($i < sizeof($this->bot_list))
+ if ($i < count($this->bot_list))
{
throw new resource_limit_reached_exception();
}
diff --git a/phpBB/phpbb/install/module/install_data/task/add_modules.php b/phpBB/phpbb/install/module/install_data/task/add_modules.php
index d21a5be823..b64f4c31db 100644
--- a/phpBB/phpbb/install/module/install_data/task/add_modules.php
+++ b/phpBB/phpbb/install/module/install_data/task/add_modules.php
@@ -169,7 +169,7 @@ class add_modules extends \phpbb\install\task_base
$this->db->sql_return_on_error(true);
$module_classes = array('acp', 'mcp', 'ucp');
- $total = sizeof($module_classes);
+ $total = count($module_classes);
$i = $this->config->get('module_class_index', 0);
$module_classes = array_slice($module_classes, $i);
diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php
index 8002e3ed97..ba439609ff 100644
--- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php
+++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php
@@ -151,10 +151,6 @@ class add_config_settings extends \phpbb\install\task_base
VALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')",
'UPDATE ' . $this->config_table . "
- SET config_value = '" . $this->db->sql_escape($this->install_config->get('img_imagick')) . "'
- WHERE config_name = 'img_imagick'",
-
- 'UPDATE ' . $this->config_table . "
SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "'
WHERE config_name = 'server_name'",
@@ -327,7 +323,7 @@ class add_config_settings extends \phpbb\install\task_base
}
$i = $this->install_config->get('add_config_settings_index', 0);
- $total = sizeof($sql_ary);
+ $total = count($sql_ary);
$sql_ary = array_slice($sql_ary, $i);
foreach ($sql_ary as $sql)
diff --git a/phpBB/phpbb/install/module/install_database/task/add_default_data.php b/phpBB/phpbb/install/module/install_database/task/add_default_data.php
index e32101a3f7..c05e5321fb 100644
--- a/phpBB/phpbb/install/module/install_database/task/add_default_data.php
+++ b/phpBB/phpbb/install/module/install_database/task/add_default_data.php
@@ -99,7 +99,7 @@ class add_default_data extends \phpbb\install\task_base
$sql_query = $this->database_helper->split_sql_file($sql_query, $dbms_info[$dbms]['DELIM']);
$i = $this->config->get('add_default_data_index', 0);
- $total = sizeof($sql_query);
+ $total = count($sql_query);
$sql_query = array_slice($sql_query, $i);
foreach ($sql_query as $sql)
diff --git a/phpBB/phpbb/install/module/install_database/task/add_tables.php b/phpBB/phpbb/install/module/install_database/task/add_tables.php
index f344f91582..dc814f36ef 100644
--- a/phpBB/phpbb/install/module/install_database/task/add_tables.php
+++ b/phpBB/phpbb/install/module/install_database/task/add_tables.php
@@ -101,7 +101,7 @@ class add_tables extends \phpbb\install\task_base
$db_table_schema = @file_get_contents($this->schema_file_path);
$db_table_schema = json_decode($db_table_schema, true);
- $total = sizeof($db_table_schema);
+ $total = count($db_table_schema);
$i = $this->config->get('add_table_index', 0);
$db_table_schema = array_slice($db_table_schema, $i);
diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
index eee13a6581..47ea156c66 100644
--- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
+++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
@@ -157,7 +157,7 @@ class install_extensions extends \phpbb\install\task_base
$this->install_config->set('install_extensions_index', $i);
- if ($i < sizeof($all_available_extensions))
+ if ($i < count($all_available_extensions))
{
throw new resource_limit_reached_exception();
}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
index dc7b060746..6ec1e612b9 100644
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
@@ -78,10 +78,10 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in
$dbms = $this->io_handler->get_input('dbms', '');
$dbhost = $this->io_handler->get_input('dbhost', '', true);
$dbport = $this->io_handler->get_input('dbport', '');
- $dbuser = $this->io_handler->get_input('dbuser', '');
- $dbpasswd = $this->io_handler->get_raw_input('dbpasswd', '');
- $dbname = $this->io_handler->get_input('dbname', '');
- $table_prefix = $this->io_handler->get_input('table_prefix', '');
+ $dbuser = $this->io_handler->get_input('dbuser', '', true);
+ $dbpasswd = $this->io_handler->get_raw_input('dbpasswd', '', true);
+ $dbname = $this->io_handler->get_input('dbname', '', true);
+ $table_prefix = $this->io_handler->get_input('table_prefix', '', true);
// Check database data
$user_data_vaild = $this->check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpasswd, $dbname, $table_prefix);
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
index e8a9c971b7..7cd0d7bf23 100644
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
@@ -50,11 +50,11 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta
// E-mail data
$email_enable = $this->io_handler->get_input('email_enable', true);
$smtp_delivery = $this->io_handler->get_input('smtp_delivery', '');
- $smtp_host = $this->io_handler->get_input('smtp_host', '');
+ $smtp_host = $this->io_handler->get_input('smtp_host', '', true);
$smtp_port = $this->io_handler->get_input('smtp_port', '');
$smtp_auth = $this->io_handler->get_input('smtp_auth', '');
- $smtp_user = $this->io_handler->get_input('smtp_user', '');
- $smtp_passwd = $this->io_handler->get_input('smtp_pass', '');
+ $smtp_user = $this->io_handler->get_input('smtp_user', '', true);
+ $smtp_passwd = $this->io_handler->get_input('smtp_pass', '', true);
$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php
deleted file mode 100644
index 377d96ed1a..0000000000
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_imagick_path.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- *
- * This file is part of the phpBB Forum Software package.
- *
- * @copyright (c) phpBB Limited <https://www.phpbb.com>
- * @license GNU General Public License, version 2 (GPL-2.0)
- *
- * For full copyright and license information, please see
- * the docs/CREDITS.txt file.
- *
- */
-
-namespace phpbb\install\module\obtain_data\task;
-
-class obtain_imagick_path extends \phpbb\install\task_base implements \phpbb\install\task_interface
-{
- /**
- * @var \phpbb\install\helper\config
- */
- protected $config;
-
- /**
- * Constructor
- *
- * @param \phpbb\install\helper\config $config Installer's config
- */
- public function __construct(\phpbb\install\helper\config $config)
- {
- $this->config = $config;
-
- parent::__construct(true);
- }
-
- /**
- * {@inheritdoc}
- */
- public function run()
- {
- // Can we find ImageMagick anywhere on the system?
- $exe = (DIRECTORY_SEPARATOR == '\\') ? '.exe' : '';
-
- $magic_home = getenv('MAGICK_HOME');
- $img_imagick = '';
- if (empty($magic_home))
- {
- $locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
- $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
-
- $locations = array_merge($path_locations, $locations);
- foreach ($locations as $location)
- {
- // The path might not end properly, fudge it
- if (substr($location, -1, 1) !== '/')
- {
- $location .= '/';
- }
-
- if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)
- {
- $img_imagick = str_replace('\\', '/', $location);
- continue;
- }
- }
- }
- else
- {
- $img_imagick = str_replace('\\', '/', $magic_home);
- }
-
- $this->config->set('img_imagick', $img_imagick);
- }
-
- /**
- * {@inheritdoc}
- */
- static public function get_step_count()
- {
- return 0;
- }
-
- /**
- * {@inheritdoc}
- */
- public function get_task_lang_name()
- {
- return '';
- }
-}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php
index 1ef70eae08..5096ce284e 100644
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_server_data.php
@@ -79,9 +79,9 @@ class obtain_server_data extends \phpbb\install\task_base implements \phpbb\inst
$cookie_secure = $this->io_handler->get_input('cookie_secure', $cookie_secure);
$server_protocol = $this->io_handler->get_input('server_protocol', $server_protocol);
$force_server_vars = $this->io_handler->get_input('force_server_vars', 0);
- $server_name = $this->io_handler->get_input('server_name', $server_name);
+ $server_name = $this->io_handler->get_input('server_name', $server_name, true);
$server_port = $this->io_handler->get_input('server_port', $server_port);
- $script_path = $this->io_handler->get_input('script_path', $script_path);
+ $script_path = $this->io_handler->get_input('script_path', $script_path, true);
// Clean up script path
if ($script_path !== '/')
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php
index f31472fc58..3c17576c13 100644
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_ftp_data.php
@@ -85,10 +85,10 @@ class obtain_update_ftp_data extends task_base
$method = $methods[0];
}
- $ftp_host = $this->iohandler->get_input('ftp_host', '');
- $ftp_user = $this->iohandler->get_input('ftp_user', '');
- $ftp_pass = htmlspecialchars_decode($this->iohandler->get_input('ftp_pass', ''));
- $ftp_path = $this->iohandler->get_input('ftp_path', '');
+ $ftp_host = $this->iohandler->get_input('ftp_host', '', true);
+ $ftp_user = $this->iohandler->get_input('ftp_user', '', true);
+ $ftp_pass = htmlspecialchars_decode($this->iohandler->get_input('ftp_pass', '', true));
+ $ftp_path = $this->iohandler->get_input('ftp_path', '', true);
$ftp_port = $this->iohandler->get_input('ftp_port', 21);
$ftp_time = $this->iohandler->get_input('ftp_timeout', 10);
diff --git a/phpBB/phpbb/install/module/requirements/task/check_update.php b/phpBB/phpbb/install/module/requirements/task/check_update.php
index cd66ffc8f9..4eb2c6d75e 100644
--- a/phpBB/phpbb/install/module/requirements/task/check_update.php
+++ b/phpBB/phpbb/install/module/requirements/task/check_update.php
@@ -122,8 +122,11 @@ class check_update extends task_base
// Check for a valid update directory
if (!$this->filesystem->exists($update_files) || !$this->filesystem->is_readable($update_files))
{
- $this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND');
- $this->set_test_passed(false);
+ if ($this->iohandler->get_input('update_type', 'all') === 'all')
+ {
+ $this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND');
+ $this->set_test_passed(false);
+ }
// If there are no update files, we can't check the version etc
// However, we can let the users run migrations if they really want to...
diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php
index b66847b243..0195b9c661 100644
--- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php
+++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php
@@ -206,7 +206,7 @@ class update_extensions extends task_base
$this->install_config->set('update_extensions_index', $i);
- if ($i < sizeof($all_available_extensions))
+ if ($i < count($all_available_extensions))
{
throw new resource_limit_reached_exception();
}
diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
index 1792a3b723..2f6048b4fd 100644
--- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
+++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
@@ -103,8 +103,8 @@ class diff_files extends task_base
$old_path = $this->update_helper->get_path_to_old_update_files();
$new_path = $this->update_helper->get_path_to_new_update_files();
- $files_to_diff = $this->installer_config->get('update_files', array());
- $files_to_diff = $files_to_diff['update_with_diff'];
+ $update_files = $this->installer_config->get('update_files', array());
+ $files_to_diff = $update_files['update_with_diff'];
// Set progress bar
$this->iohandler->set_task_count(count($files_to_diff), true);
@@ -145,7 +145,7 @@ class diff_files extends task_base
{
$file_contents[] = file_get_contents($file_to_diff);
- if ($file_contents[sizeof($file_contents) - 1] === false)
+ if ($file_contents[count($file_contents) - 1] === false)
{
$this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
unset($file_contents);
@@ -154,7 +154,6 @@ class diff_files extends task_base
}
$diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]);
- unset($file_contents);
// Handle conflicts
if ($diff->get_num_conflicts() !== 0)
@@ -162,12 +161,20 @@ class diff_files extends task_base
$merge_conflicts[] = $filename;
}
- // Save merged output
- $this->cache->put(
- '_file_' . md5($filename),
- base64_encode(implode("\n", $diff->merged_output()))
- );
+ if ($diff->merged_output() !== $file_contents[1])
+ {
+ // Save merged output
+ $this->cache->put(
+ '_file_' . md5($filename),
+ base64_encode(implode("\n", $diff->merged_output()))
+ );
+ }
+ else
+ {
+ unset($update_files['update_with_diff'][$key]);
+ }
+ unset($file_contents);
unset($diff);
}
else
@@ -199,6 +206,16 @@ class diff_files extends task_base
$this->installer_config->set('merge_conflict_list', $merge_conflicts);
$this->installer_config->set('file_diff_update_count', $progress_count);
+ foreach ($update_files as $type => $files)
+ {
+ if (empty($files))
+ {
+ unset($update_files[$type]);
+ }
+ }
+
+ $this->installer_config->set('update_files', $update_files);
+
// Request refresh
throw new resource_limit_reached_exception();
}
@@ -206,6 +223,16 @@ class diff_files extends task_base
$this->iohandler->finish_progress('ALL_FILES_DIFFED');
$this->installer_config->set('merge_conflict_list', $merge_conflicts);
+
+ foreach ($update_files as $type => $files)
+ {
+ if (empty($files))
+ {
+ unset($update_files[$type]);
+ }
+ }
+
+ $this->installer_config->set('update_files', $update_files);
}
/**
diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php
index 21aa93b7ea..4d7f0e0cdf 100644
--- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php
+++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php
@@ -86,7 +86,8 @@ class download_updated_files extends task_base
{
$file_update_info = $this->installer_config->get('update_files', array());
- if (count($file_update_info) > 0)
+ // Display download box only if the archive won't be empty
+ if (!empty($file_update_info) && !(isset($file_update_info['delete']) && count($file_update_info) == 1))
{
// Render download box
$this->iohandler->add_download_link(
@@ -99,13 +100,14 @@ class download_updated_files extends task_base
// Add form to continue update
$this->iohandler->add_user_form_group('UPDATE_CONTINUE_UPDATE_PROCESS', array(
'update_recheck_files_submit' => array(
- 'label' => 'UPDATE_RECHECK_UPDATE_FILES',
- 'type' => 'submit',
+ 'label' => 'UPDATE_RECHECK_UPDATE_FILES',
+ 'type' => 'submit',
+ 'is_secondary' => empty($file_update_info),
),
'database_update_submit' => array(
'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS',
'type' => 'submit',
- 'disabled' => count($file_update_info) > 0,
+ 'disabled' => !empty($file_update_info),
),
));
diff --git a/phpBB/phpbb/language/language.php b/phpBB/phpbb/language/language.php
index 42429c2c07..51e6d0b185 100644
--- a/phpBB/phpbb/language/language.php
+++ b/phpBB/phpbb/language/language.php
@@ -312,7 +312,7 @@ class language
// Replace key with language entry and simply pass along...
return vsprintf($lang, $args);
}
- else if (sizeof($lang) == 0)
+ else if (count($lang) == 0)
{
// If the language entry is an empty array, we just return the language key
return $key;
@@ -322,7 +322,7 @@ class language
$key_found = false;
// We now get the first number passed and will select the key based upon this number
- for ($i = 0, $num_args = sizeof($args); $i < $num_args; $i++)
+ for ($i = 0, $num_args = count($args); $i < $num_args; $i++)
{
if (is_int($args[$i]) || is_float($args[$i]))
{
diff --git a/phpBB/phpbb/language/language_file_loader.php b/phpBB/phpbb/language/language_file_loader.php
index 359202fd63..b6816afd16 100644
--- a/phpBB/phpbb/language/language_file_loader.php
+++ b/phpBB/phpbb/language/language_file_loader.php
@@ -127,7 +127,7 @@ class language_file_loader
// the first directory from the path (that should be the language directory)
$path_diff_parts = explode('/', $path_diff);
- if (sizeof($path_diff_parts) > 1)
+ if (count($path_diff_parts) > 1)
{
array_shift($path_diff_parts);
$component = implode('/', $path_diff_parts) . '/';
diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php
index 5aad7ee326..5333fe2bdf 100644
--- a/phpBB/phpbb/log/log.php
+++ b/phpBB/phpbb/log/log.php
@@ -391,7 +391,7 @@ class log implements \phpbb\log\log_interface
{
$sql_where .= ' AND ';
- if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1]))
+ if (is_array($field_value) && count($field_value) == 2 && !is_array($field_value[1]))
{
$sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1];
}
@@ -689,9 +689,9 @@ class log implements \phpbb\log\log_interface
}
}
- if (($num_args - sizeof($log_data_ary)) > 0)
+ if (($num_args - count($log_data_ary)) > 0)
{
- $log_data_ary = array_merge($log_data_ary, array_fill(0, $num_args - sizeof($log_data_ary), ''));
+ $log_data_ary = array_merge($log_data_ary, array_fill(0, $num_args - count($log_data_ary), ''));
}
$lang_arguments = array_merge(array($log[$i]['action']), $log_data_ary);
@@ -740,7 +740,7 @@ class log implements \phpbb\log\log_interface
$vars = array('log', 'topic_id_list', 'reportee_id_list');
extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', compact($vars)));
- if (sizeof($topic_id_list))
+ if (count($topic_id_list))
{
$topic_auth = $this->get_topic_auth($topic_id_list);
@@ -752,7 +752,7 @@ class log implements \phpbb\log\log_interface
}
}
- if (sizeof($reportee_id_list))
+ if (count($reportee_id_list))
{
$reportee_data_list = $this->get_reportee_data($reportee_id_list);
@@ -838,7 +838,7 @@ class log implements \phpbb\log\log_interface
$keywords_pattern = array();
// Build pattern and keywords...
- for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++)
+ for ($i = 0, $num_keywords = count($keywords); $i < $num_keywords; $i++)
{
$keywords_pattern[] = preg_quote($keywords[$i], '#');
$keywords[$i] = $this->db->sql_like_expression($this->db->get_any_char() . $keywords[$i] . $this->db->get_any_char());
@@ -933,6 +933,20 @@ class log implements \phpbb\log\log_interface
$forum_auth['f_read'][$row['topic_id']] = $row['forum_id'];
}
+ /**
+ * Allow modifying SQL query after topic data is retrieved (inside loop).
+ *
+ * @event core.phpbb_log_get_topic_auth_sql_after
+ * @var array forum_auth Forum permissions
+ * @var array row One row of data from SQL query
+ * @since 3.2.2-RC1
+ */
+ $vars = array(
+ 'forum_auth',
+ 'row',
+ );
+ extract($this->dispatcher->trigger_event('core.phpbb_log_get_topic_auth_sql_after', compact($vars)));
+
if ($this->auth->acl_gets('a_', 'm_', $row['forum_id']))
{
$forum_auth['m_'][$row['topic_id']] = $row['forum_id'];
diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php
index 96b8d3499e..ae1c1d8614 100644
--- a/phpBB/phpbb/message/admin_form.php
+++ b/phpBB/phpbb/message/admin_form.php
@@ -22,6 +22,9 @@ class admin_form extends form
/** @var \phpbb\config\db_text */
protected $config_text;
+ /** @var \phpbb\event\dispatcher_interface */
+ protected $dispatcher;
+
/** @var string */
protected $subject;
/** @var string */
@@ -37,13 +40,15 @@ class admin_form extends form
* @param \phpbb\config\db_text $config_text
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\user $user
+ * @param \phpbb\event\dispatcher_interface $dispatcher
* @param string $phpbb_root_path
* @param string $phpEx
*/
- public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $phpEx)
{
parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx);
$this->config_text = $config_text;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -91,6 +96,29 @@ class admin_form extends form
$this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL'];
}
+ $subject = $this->subject;
+ $body = $this->body;
+ $errors = $this->errors;
+
+ /**
+ * You can use this event to modify subject and/or body and add new errors.
+ *
+ * @event core.message_admin_form_submit_before
+ * @var string subject Message subject
+ * @var string body Message body
+ * @var array errors Form errors
+ * @since 3.2.6-RC1
+ */
+ $vars = [
+ 'subject',
+ 'body',
+ 'errors',
+ ];
+ extract($this->dispatcher->trigger_event('core.message_admin_form_submit_before', compact($vars)));
+ $this->subject = $subject;
+ $this->body = $body;
+ $this->errors = $errors;
+
if ($this->user->data['is_registered'])
{
$this->message->set_sender_from_user($this->user);
diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php
index 21d4de0b4d..63bada91ff 100644
--- a/phpBB/phpbb/message/form.php
+++ b/phpBB/phpbb/message/form.php
@@ -139,7 +139,7 @@ abstract class form
$this->errors[] = 'FORM_INVALID';
}
- if (!sizeof($this->errors))
+ if (!count($this->errors))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_emailtime = ' . time() . '
@@ -169,7 +169,7 @@ abstract class form
add_form_key('memberlist_email');
$template->assign_vars(array(
- 'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('<br />', $this->errors) : '',
+ 'ERROR_MESSAGE' => (count($this->errors)) ? implode('<br />', $this->errors) : '',
));
}
}
diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php
index 5fd24b542e..fa701d1c77 100644
--- a/phpBB/phpbb/message/message.php
+++ b/phpBB/phpbb/message/message.php
@@ -209,7 +209,7 @@ class message
*/
public function cc_sender()
{
- if (!sizeof($this->recipients))
+ if (!count($this->recipients))
{
trigger_error('No email recipients specified');
}
@@ -238,7 +238,7 @@ class message
*/
public function send(\messenger $messenger, $contact)
{
- if (!sizeof($this->recipients))
+ if (!count($this->recipients))
{
return;
}
@@ -271,7 +271,7 @@ class message
'MESSAGE' => htmlspecialchars_decode($this->body))
);
- if (sizeof($this->template_vars))
+ if (count($this->template_vars))
{
$messenger->assign_vars($this->template_vars);
}
diff --git a/phpBB/phpbb/module/module_manager.php b/phpBB/phpbb/module/module_manager.php
index 67bac5b33e..00df33f62f 100644
--- a/phpBB/phpbb/module/module_manager.php
+++ b/phpBB/phpbb/module/module_manager.php
@@ -311,7 +311,7 @@ class module_manager
// we're turning a category into a module
$branch = $this->get_module_branch($module_data['module_id'], $module_data['module_class'], 'children', false);
- if (sizeof($branch))
+ if (count($branch))
{
throw new module_not_found_exception('NO_CATEGORY_TO_MODULE');
}
@@ -353,10 +353,10 @@ class module_manager
}
$from_data = $moved_modules[0];
- $diff = sizeof($moved_modules) * 2;
+ $diff = count($moved_modules) * 2;
$moved_ids = array();
- for ($i = 0, $size = sizeof($moved_modules); $i < $size; ++$i)
+ for ($i = 0, $size = count($moved_modules); $i < $size; ++$i)
{
$moved_ids[] = $moved_modules[$i]['module_id'];
}
@@ -443,7 +443,7 @@ class module_manager
$branch = $this->get_module_branch($module_id, $module_class, 'children', false);
- if (sizeof($branch))
+ if (count($branch))
{
throw new module_exception('CANNOT_REMOVE_MODULE');
}
@@ -506,7 +506,7 @@ class module_manager
}
$this->db->sql_freeresult($result);
- if (!sizeof($target))
+ if (!count($target))
{
// The module is already on top or bottom
throw new module_not_found_exception();
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index 1cd7e5bc9a..52c650df5d 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -339,7 +339,7 @@ class manager
}
}
- if (!sizeof($notify_users))
+ if (!count($notify_users))
{
return;
}
@@ -899,32 +899,19 @@ class manager
*/
public function get_notification_type_id($notification_type_name)
{
- $notification_type_ids = $this->cache->get('notification_type_ids');
-
- $this->db->sql_transaction('begin');
-
- if ($notification_type_ids === false)
+ $sql = 'SELECT notification_type_id, notification_type_name
+ FROM ' . $this->notification_types_table;
+ $result = $this->db->sql_query($sql, 604800); // cache for one week
+ while ($row = $this->db->sql_fetchrow($result))
{
- $notification_type_ids = array();
-
- $sql = 'SELECT notification_type_id, notification_type_name
- FROM ' . $this->notification_types_table;
- $result = $this->db->sql_query($sql);
- while ($row = $this->db->sql_fetchrow($result))
- {
- $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
- }
- $this->db->sql_freeresult($result);
-
- $this->cache->put('notification_type_ids', $notification_type_ids);
+ $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
}
+ $this->db->sql_freeresult($result);
if (!isset($notification_type_ids[$notification_type_name]))
{
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('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name));
}
@@ -934,13 +921,13 @@ class manager
));
$this->db->sql_query($sql);
+ // expose new notification type ID for this request
$notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid();
- $this->cache->put('notification_type_ids', $notification_type_ids);
+ // destroy cache, we have a new addition which we have to to load next time
+ $this->cache->destroy('sql', $this->notification_types_table);
}
- $this->db->sql_transaction('commit');
-
return $notification_type_ids[$notification_type_name];
}
diff --git a/phpBB/phpbb/notification/method/board.php b/phpBB/phpbb/notification/method/board.php
index 931b252daa..faa53576e0 100644
--- a/phpBB/phpbb/notification/method/board.php
+++ b/phpBB/phpbb/notification/method/board.php
@@ -394,6 +394,6 @@ class board extends \phpbb\notification\method\base
WHERE notification_type_id = ' . (int) $notification_type_id;
$this->db->sql_query($sql);
- $this->cache->destroy('notification_type_ids');
+ $this->cache->destroy('sql', $this->notification_types_table);
}
}
diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php
index 56dd1e9367..6376d13dc7 100644
--- a/phpBB/phpbb/notification/method/email.php
+++ b/phpBB/phpbb/notification/method/email.php
@@ -65,7 +65,7 @@ class email extends \phpbb\notification\method\messenger_base
*/
public function is_available(type_interface $notification_type = null)
{
- return parent::is_available($notification_type) && $this->config['email_enable'] && $this->user->data['user_email'];
+ return parent::is_available($notification_type) && $this->config['email_enable'] && !empty($this->user->data['user_email']);
}
/**
diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php
index 32e79aa936..f82017b70e 100644
--- a/phpBB/phpbb/notification/method/messenger_base.php
+++ b/phpBB/phpbb/notification/method/messenger_base.php
@@ -87,7 +87,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
$banned_users = phpbb_get_banned_user_ids($user_ids);
// Load all the users we need
- $this->user_loader->load_users($user_ids);
+ $this->user_loader->load_users(array_diff($user_ids, $banned_users), array(USER_IGNORE));
// Load the messenger
if (!class_exists('messenger'))
@@ -107,7 +107,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
$user = $this->user_loader->get_user($notification->user_id);
- if ($user['user_type'] == USER_IGNORE || ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL) || in_array($notification->user_id, $banned_users))
+ if ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL)
{
continue;
}
diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php
index 9f2ae857ef..78c10ac36a 100644
--- a/phpBB/phpbb/notification/type/admin_activate_user.php
+++ b/phpBB/phpbb/notification/type/admin_activate_user.php
@@ -175,7 +175,7 @@ class admin_activate_user extends \phpbb\notification\type\base
/**
* {@inheritdoc}
*/
- public function create_insert_array($user, $pre_create_data)
+ public function create_insert_array($user, $pre_create_data = array())
{
$this->set_data('user_actkey', $user['user_actkey']);
$this->notification_time = $user['user_regdate'];
diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php
index 8fb9172911..c51586afb9 100644
--- a/phpBB/phpbb/notification/type/pm.php
+++ b/phpBB/phpbb/notification/type/pm.php
@@ -99,7 +99,7 @@ class pm extends \phpbb\notification\type\base
'ignore_users' => array(),
), $options);
- if (!sizeof($pm['recipients']))
+ if (!count($pm['recipients']))
{
return array();
}
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php
index 03221e7c7a..254f4c07b3 100644
--- a/phpBB/phpbb/notification/type/post.php
+++ b/phpBB/phpbb/notification/type/post.php
@@ -202,9 +202,9 @@ class post extends \phpbb\notification\type\base
'username' => $this->get_data('post_username'),
)), $responders);
- $responders_cnt = sizeof($responders);
+ $responders_cnt = count($responders);
$responders = $this->trim_user_ary($responders);
- $trimmed_responders_cnt = $responders_cnt - sizeof($responders);
+ $trimmed_responders_cnt = $responders_cnt - count($responders);
foreach ($responders as $responder)
{
@@ -337,7 +337,7 @@ class post extends \phpbb\notification\type\base
*/
public function trim_user_ary($users)
{
- if (sizeof($users) > 4)
+ if (count($users) > 4)
{
array_splice($users, 3);
}
@@ -357,7 +357,7 @@ class post extends \phpbb\notification\type\base
*/
public function pre_create_insert_array($post, $notify_users)
{
- if (!sizeof($notify_users) || !$this->inherit_read_status)
+ if (!count($notify_users) || !$this->inherit_read_status)
{
return array();
}
@@ -426,7 +426,7 @@ class post extends \phpbb\notification\type\base
// Do not add more than 25 responders,
// we trim the username list to "a, b, c and x others" anyway
// so there is no use to add all of them anyway.
- if (sizeof($responders) > 25)
+ if (count($responders) > 25)
{
return array();
}
diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php
index 7e53ffb3ca..444f98270d 100644
--- a/phpBB/phpbb/notification/type/report_pm.php
+++ b/phpBB/phpbb/notification/type/report_pm.php
@@ -142,13 +142,16 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function get_email_template_variables()
{
- $user_data = $this->user_loader->get_user($this->get_data('reporter_id'));
+ $user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
return array(
'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
- 'U_VIEW_REPORT' => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details",
+ /** @deprecated 3.2.6-RC1 (to be removed in 4.0.0) use {SUBJECT} instead in report_pm.txt */
+ 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
+
+ 'U_VIEW_REPORT' => generate_board_url() . "/mcp.{$this->php_ext}?r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details",
);
}
@@ -236,8 +239,10 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function users_to_query()
{
- return array($this->get_data('reporter_id'));
- }
+ return array(
+ $this->get_data('from_user_id'),
+ $this->get_data('reporter_id'),
+ ); }
/**
* {@inheritdoc}
diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php
index 671c34fe96..5c42afa8c8 100644
--- a/phpBB/phpbb/notification/type/topic.php
+++ b/phpBB/phpbb/notification/type/topic.php
@@ -261,7 +261,7 @@ class topic extends \phpbb\notification\type\base
*/
public function pre_create_insert_array($post, $notify_users)
{
- if (!sizeof($notify_users) || !$this->inherit_read_status)
+ if (!count($notify_users) || !$this->inherit_read_status)
{
return array();
}
diff --git a/phpBB/phpbb/pagination.php b/phpBB/phpbb/pagination.php
index a5a95b096d..a7086f6691 100644
--- a/phpBB/phpbb/pagination.php
+++ b/phpBB/phpbb/pagination.php
@@ -46,7 +46,7 @@ class pagination
/**
* Generate a pagination link based on the url and the page information
*
- * @param string $base_url is url prepended to all links generated within the function
+ * @param string|array $base_url is url prepended to all links generated within the function
* If you use page numbers inside your controller route, base_url should contains a placeholder (%d)
* for the page. Also be sure to specify the pagination path information into the start_name argument
* @param string $on_page is the page for which we want to generate the link
@@ -69,7 +69,7 @@ class pagination
* set $generate_page_link_override to the new URL value
*
* @event core.pagination_generate_page_link
- * @var string base_url is url prepended to all links generated within the function
+ * @var string|array base_url is url prepended to all links generated within the function
* If you use page numbers inside your controller route, base_url should contains a placeholder (%d)
* for the page. Also be sure to specify the pagination path information into the start_name argument
* @var string on_page is the page for which we want to generate the link
@@ -120,7 +120,7 @@ class pagination
* Generate template rendered pagination
* Allows full control of rendering of pagination with the template
*
- * @param string $base_url is url prepended to all links generated within the function
+ * @param string|array $base_url is url prepended to all links generated within the function
* If you use page numbers inside your controller route, base_url should contains a placeholder (%d)
* for the page. Also be sure to specify the pagination path information into the start_name argument
* @param string $block_var_name is the name assigned to the pagination data block within the template (example: <!-- BEGIN pagination -->)
@@ -132,10 +132,15 @@ class pagination
* @param int $start the item which should be considered currently active, used to determine the page we're on
* @param bool $reverse_count determines whether we weight display of the list towards the start (false) or end (true) of the list
* @param bool $ignore_on_page decides whether we enable an active (unlinked) item, used primarily for embedded lists
- * @return null
+ * @return void
*/
public function generate_template_pagination($base_url, $block_var_name, $start_name, $num_items, $per_page, $start = 1, $reverse_count = false, $ignore_on_page = false)
{
+ if (empty($base_url))
+ {
+ return;
+ }
+
$total_pages = ceil($num_items / $per_page);
$on_page = $this->get_on_page($per_page, $start);
$u_previous_page = $u_next_page = '';
diff --git a/phpBB/phpbb/permissions.php b/phpBB/phpbb/permissions.php
index c9181e6202..7697884b6a 100644
--- a/phpBB/phpbb/permissions.php
+++ b/phpBB/phpbb/permissions.php
@@ -260,6 +260,7 @@ class permissions
// Forum Permissions
'f_list' => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'),
+ 'f_list_topics' => array('lang' => 'ACL_F_LIST_TOPICS', 'cat' => 'actions'),
'f_read' => array('lang' => 'ACL_F_READ', 'cat' => 'actions'),
'f_search' => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'),
'f_subscribe' => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'),
diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php
index ea4b24af56..35b18ddf07 100644
--- a/phpBB/phpbb/profilefields/manager.php
+++ b/phpBB/phpbb/profilefields/manager.php
@@ -230,7 +230,7 @@ class manager
*/
public function update_profile_field_data($user_id, $cp_data)
{
- if (!sizeof($cp_data))
+ if (!count($cp_data))
{
return;
}
@@ -258,7 +258,7 @@ class manager
*/
public function generate_profile_fields_template_headlines($restrict_option = '')
{
- if (!sizeof($this->profile_cache))
+ if (!count($this->profile_cache))
{
$this->build_cache();
}
@@ -318,12 +318,12 @@ class manager
$user_ids = array($user_ids);
}
- if (!sizeof($this->profile_cache))
+ if (!count($this->profile_cache))
{
$this->build_cache();
}
- if (!sizeof($user_ids))
+ if (!count($user_ids))
{
return array();
}
@@ -486,7 +486,7 @@ class manager
$sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value
FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . ' f
WHERE l.lang_id = ' . $this->user->get_iso_lang_id() . '
- ' . ((sizeof($sql_not_in)) ? ' AND ' . $this->db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . '
+ ' . ((count($sql_not_in)) ? ' AND ' . $this->db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . '
AND l.field_id = f.field_id';
$result = $this->db->sql_query($sql);
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index f6f3f17a6c..9c09e27bc4 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -398,7 +398,7 @@ class type_bool extends type_base
public function display_options(&$template_vars, &$field_data)
{
// Initialize these array elements if we are creating a new field
- if (!sizeof($field_data['lang_options']))
+ if (!count($field_data['lang_options']))
{
// No options have been defined for a boolean field.
$field_data['lang_options'][0] = '';
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index 17ae89e1b2..d54404bbb4 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -282,7 +282,7 @@ class type_dropdown extends type_base
*/
public function validate_options_on_submit($error, $field_data)
{
- if (!sizeof($field_data['lang_options']))
+ if (!count($field_data['lang_options']))
{
$error[] = $this->user->lang['NO_FIELD_ENTRIES'];
}
@@ -298,7 +298,7 @@ class type_dropdown extends type_base
if ($step == 2 && $key == 'field_maxlen')
{
// Get the number of options if this key is 'field_maxlen'
- return sizeof(explode("\n", $this->request->variable('lang_options', '', true)));
+ return count(explode("\n", $this->request->variable('lang_options', '', true)));
}
return parent::get_excluded_options($key, $action, $current_value, $field_data, $step);
@@ -310,7 +310,7 @@ class type_dropdown extends type_base
public function display_options(&$template_vars, &$field_data)
{
// Initialize these array elements if we are creating a new field
- if (!sizeof($field_data['lang_options']))
+ if (!count($field_data['lang_options']))
{
// No options have been defined for the dropdown menu
$field_data['lang_options'] = array();
diff --git a/phpBB/phpbb/profilefields/type/type_url.php b/phpBB/phpbb/profilefields/type/type_url.php
index 375cf5b19a..37815b66a5 100644
--- a/phpBB/phpbb/profilefields/type/type_url.php
+++ b/phpBB/phpbb/profilefields/type/type_url.php
@@ -64,11 +64,24 @@ class type_url extends type_string
return false;
}
- if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $field_value))
+ if (!preg_match('#^' . get_preg_expression('url_http') . '$#iu', $field_value))
{
return $this->user->lang('FIELD_INVALID_URL', $this->get_field_name($field_data['lang_name']));
}
return false;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get_profile_value($field_value, $field_data)
+ {
+ if (!preg_match('#^' . get_preg_expression('url_http') . '$#iu', $field_value))
+ {
+ return null;
+ }
+
+ return parent::get_profile_value($field_value, $field_data);
+ }
}
diff --git a/phpBB/phpbb/report/controller/report.php b/phpBB/phpbb/report/controller/report.php
index e1c14afde0..0aa6833dfa 100644
--- a/phpBB/phpbb/report/controller/report.php
+++ b/phpBB/phpbb/report/controller/report.php
@@ -141,7 +141,7 @@ class report
// Handle request
try
{
- if (!empty($submit) && sizeof($error) === 0)
+ if (!empty($submit) && count($error) === 0)
{
$this->report_handler->add_report(
(int) $id,
@@ -273,7 +273,7 @@ class report
}
$this->template->assign_vars(array(
- 'ERROR' => (sizeof($error) > 0) ? implode('<br />', $error) : '',
+ 'ERROR' => (count($error) > 0) ? implode('<br />', $error) : '',
'S_REPORT_POST' => ($mode === 'pm') ? false : true,
'REPORT_TEXT' => $report_text,
'S_HIDDEN_FIELDS' => (!empty($s_hidden_fields)) ? $s_hidden_fields : null,
@@ -302,7 +302,7 @@ class report
$error[] = $visual_confirmation_response;
}
- if (sizeof($error) === 0)
+ if (count($error) === 0)
{
$captcha->reset();
}
diff --git a/phpBB/phpbb/report/report_handler_pm.php b/phpBB/phpbb/report/report_handler_pm.php
index 2f2a697efc..774ca329ad 100644
--- a/phpBB/phpbb/report/report_handler_pm.php
+++ b/phpBB/phpbb/report/report_handler_pm.php
@@ -53,8 +53,8 @@ class report_handler_pm extends report_handler
'user_notify' => $user_notify,
'report_text' => $report_text,
'reported_post_text' => $this->report_data['message_text'],
- 'reported_post_uid' => $this->report_data['bbcode_bitfield'],
- 'reported_post_bitfield' => $this->report_data['bbcode_uid'],
+ 'reported_post_uid' => $this->report_data['bbcode_uid'],
+ 'reported_post_bitfield' => $this->report_data['bbcode_bitfield'],
'reported_post_enable_bbcode' => $this->report_data['enable_bbcode'],
'reported_post_enable_smilies' => $this->report_data['enable_smilies'],
'reported_post_enable_magic_url' => $this->report_data['enable_magic_url'],
diff --git a/phpBB/phpbb/report/report_handler_post.php b/phpBB/phpbb/report/report_handler_post.php
index 5574a16dc0..52f09683ce 100644
--- a/phpBB/phpbb/report/report_handler_post.php
+++ b/phpBB/phpbb/report/report_handler_post.php
@@ -59,8 +59,8 @@ class report_handler_post extends report_handler
'user_notify' => $user_notify,
'report_text' => $report_text,
'reported_post_text' => $this->report_data['post_text'],
- 'reported_post_uid' => $this->report_data['bbcode_bitfield'],
- 'reported_post_bitfield' => $this->report_data['bbcode_uid'],
+ 'reported_post_uid' => $this->report_data['bbcode_uid'],
+ 'reported_post_bitfield' => $this->report_data['bbcode_bitfield'],
'reported_post_enable_bbcode' => $this->report_data['enable_bbcode'],
'reported_post_enable_smilies' => $this->report_data['enable_smilies'],
'reported_post_enable_magic_url' => $this->report_data['enable_magic_url'],
diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php
index 00be8fd381..a0267d1370 100644
--- a/phpBB/phpbb/request/request.php
+++ b/phpBB/phpbb/request/request.php
@@ -150,8 +150,6 @@ class request implements \phpbb\request\request_interface
return;
}
- $this->type_cast_helper->add_magic_quotes($value);
-
// setting to null means unsetting
if ($value === null)
{
diff --git a/phpBB/phpbb/request/type_cast_helper.php b/phpBB/phpbb/request/type_cast_helper.php
index 96e66950ca..912494998d 100644
--- a/phpBB/phpbb/request/type_cast_helper.php
+++ b/phpBB/phpbb/request/type_cast_helper.php
@@ -18,69 +18,6 @@ namespace phpbb\request;
*/
class type_cast_helper implements \phpbb\request\type_cast_helper_interface
{
-
- /**
- * @var string Whether slashes need to be stripped from input
- */
- protected $strip;
-
- /**
- * Initialises the type cast helper class.
- * All it does is find out whether magic quotes are turned on.
- */
- public function __construct()
- {
- if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
- {
- $this->strip = false;
- }
- else
- {
- $this->strip = (@get_magic_quotes_gpc()) ? true : false;
- }
- }
-
- /**
- * Recursively applies addslashes to a variable.
- *
- * @param mixed &$var Variable passed by reference to which slashes will be added.
- */
- public function addslashes_recursively(&$var)
- {
- if (is_string($var))
- {
- $var = addslashes($var);
- }
- else if (is_array($var))
- {
- $var_copy = $var;
- $var = array();
- foreach ($var_copy as $key => $value)
- {
- if (is_string($key))
- {
- $key = addslashes($key);
- }
- $var[$key] = $value;
-
- $this->addslashes_recursively($var[$key]);
- }
- }
- }
-
- /**
- * Recursively applies addslashes to a variable if magic quotes are turned on.
- *
- * @param mixed &$var Variable passed by reference to which slashes will be added.
- */
- public function add_magic_quotes(&$var)
- {
- if ($this->strip)
- {
- $this->addslashes_recursively($var);
- }
- }
-
/**
* Set variable $result to a particular type.
*
@@ -129,8 +66,6 @@ class type_cast_helper implements \phpbb\request\type_cast_helper_interface
$result = preg_replace('/[\x80-\xFF]/', '?', $result);
}
}
-
- $result = ($this->strip) ? stripslashes($result) : $result;
}
}
diff --git a/phpBB/phpbb/request/type_cast_helper_interface.php b/phpBB/phpbb/request/type_cast_helper_interface.php
index 2cb28d021f..9671573bf1 100644
--- a/phpBB/phpbb/request/type_cast_helper_interface.php
+++ b/phpBB/phpbb/request/type_cast_helper_interface.php
@@ -19,20 +19,6 @@ namespace phpbb\request;
interface type_cast_helper_interface
{
/**
- * Recursively applies addslashes to a variable.
- *
- * @param mixed &$var Variable passed by reference to which slashes will be added.
- */
- public function addslashes_recursively(&$var);
-
- /**
- * Recursively applies addslashes to a variable if magic quotes are turned on.
- *
- * @param mixed &$var Variable passed by reference to which slashes will be added.
- */
- public function add_magic_quotes(&$var);
-
- /**
* Set variable $result to a particular type.
*
* @param mixed &$result The variable to fill
diff --git a/phpBB/phpbb/search/base.php b/phpBB/phpbb/search/base.php
index 56de973b65..e7d0774b6c 100644
--- a/phpBB/phpbb/search/base.php
+++ b/phpBB/phpbb/search/base.php
@@ -133,7 +133,7 @@ class base
{
global $cache, $config, $db, $user;
- $length = min(sizeof($id_ary), $config['search_block_size']);
+ $length = min(count($id_ary), $config['search_block_size']);
// nothing to cache so exit
if (!$length)
@@ -148,7 +148,7 @@ class base
if (!($store = $cache->get('_search_results_' . $search_key)))
{
// add the current keywords to the recent searches in the cache which are listed on the search page
- if (!empty($keywords) || sizeof($author_ary))
+ if (!empty($keywords) || count($author_ary))
{
$sql = 'SELECT search_time
FROM ' . SEARCH_RESULTS_TABLE . '
@@ -201,7 +201,7 @@ class base
$store += $store_ids;
// if the cache is too big
- if (sizeof($store) - 2 > 20 * $config['search_block_size'])
+ if (count($store) - 2 > 20 * $config['search_block_size'])
{
// remove everything in front of two blocks in front of the current start index
for ($i = 0, $n = $id_range[0] - 2 * $config['search_block_size']; $i < $n; $i++)
@@ -243,7 +243,7 @@ class base
global $db, $cache, $config;
// clear all searches that searched for the specified words
- if (sizeof($words))
+ if (count($words))
{
$sql_where = '';
foreach ($words as $word)
@@ -264,7 +264,7 @@ class base
}
// clear all searches that searched for the specified authors
- if (is_array($authors) && sizeof($authors))
+ if (is_array($authors) && count($authors))
{
$sql_where = '';
foreach ($authors as $author)
diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php
index da1aad1c3a..1105d0892f 100644
--- a/phpBB/phpbb/search/fulltext_mysql.php
+++ b/phpBB/phpbb/search/fulltext_mysql.php
@@ -188,7 +188,7 @@ class fulltext_mysql extends \phpbb\search\base
}
$sql = 'SHOW VARIABLES
- LIKE \'ft\_%\'';
+ LIKE \'%ft\_%\'';
$result = $this->db->sql_query($sql);
$mysql_info = array();
@@ -198,8 +198,16 @@ class fulltext_mysql extends \phpbb\search\base
}
$this->db->sql_freeresult($result);
- $this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']);
- $this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);
+ if ($engine === 'MyISAM')
+ {
+ $this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']);
+ $this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);
+ }
+ else if ($engine === 'InnoDB')
+ {
+ $this->config->set('fulltext_mysql_max_word_len', $mysql_info['innodb_ft_max_token_size']);
+ $this->config->set('fulltext_mysql_min_word_len', $mysql_info['innodb_ft_min_token_size']);
+ }
return false;
}
@@ -232,9 +240,9 @@ class fulltext_mysql extends \phpbb\search\base
$this->split_words = $matches[1];
// We limit the number of allowed keywords to minimize load on the database
- if ($this->config['max_num_search_keywords'] && sizeof($this->split_words) > $this->config['max_num_search_keywords'])
+ if ($this->config['max_num_search_keywords'] && count($this->split_words) > $this->config['max_num_search_keywords'])
{
- trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], sizeof($this->split_words)));
+ trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], count($this->split_words)));
}
// to allow phrase search, we need to concatenate quoted words
@@ -361,7 +369,7 @@ class fulltext_mysql extends \phpbb\search\base
// remove too short or too long words
$text = array_values($text);
- for ($i = 0, $n = sizeof($text); $i < $n; $i++)
+ for ($i = 0, $n = count($text); $i < $n; $i++)
{
$text[$i] = trim($text[$i]);
if (utf8_strlen($text[$i]) < $this->config['fulltext_mysql_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_mysql_max_word_len'])
@@ -563,12 +571,12 @@ class fulltext_mysql extends \phpbb\search\base
$sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id';
$sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : '';
$field = ($type == 'posts') ? 'post_id' : 'topic_id';
- if (sizeof($author_ary) && $author_name)
+ if (count($author_ary) && $author_name)
{
// first one matches post of registered users, second one guests and deleted users
$sql_author = ' AND (' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
- else if (sizeof($author_ary))
+ else if (count($author_ary))
{
$sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary);
}
@@ -580,7 +588,7 @@ class fulltext_mysql extends \phpbb\search\base
$sql_where_options = $sql_sort_join;
$sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
$sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : '';
- $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_where_options .= (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_where_options .= ' AND ' . $post_visibility;
$sql_where_options .= $sql_author;
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
@@ -591,6 +599,7 @@ class fulltext_mysql extends \phpbb\search\base
WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
$sql_where_options
ORDER BY $sql_sort";
+ $this->db->sql_return_on_error(true);
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
@@ -602,7 +611,7 @@ class fulltext_mysql extends \phpbb\search\base
$id_ary = array_unique($id_ary);
// if the total result count is not cached yet, retrieve it from the db
- if (!$result_count)
+ if (!$result_count && count($id_ary))
{
$sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
$result = $this->db->sql_query($sql_found_rows);
@@ -659,7 +668,7 @@ class fulltext_mysql extends \phpbb\search\base
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No author? No posts
- if (!sizeof($author_ary))
+ if (!count($author_ary))
{
return 0;
}
@@ -736,7 +745,7 @@ class fulltext_mysql extends \phpbb\search\base
{
$sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
- $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@@ -889,7 +898,7 @@ class fulltext_mysql extends \phpbb\search\base
$id_ary = array_unique($id_ary);
}
- if (sizeof($id_ary))
+ if (count($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, $per_page);
@@ -917,6 +926,34 @@ class fulltext_mysql extends \phpbb\search\base
$words = array_unique(array_merge($split_text, $split_title));
+ /**
+ * Event to modify method arguments and words before the MySQL search index is updated
+ *
+ * @event core.search_mysql_index_before
+ * @var string mode Contains the post mode: edit, post, reply, quote
+ * @var int post_id The id of the post which is modified/created
+ * @var string message New or updated post content
+ * @var string subject New or updated post subject
+ * @var int poster_id Post author's user id
+ * @var int forum_id The id of the forum in which the post is located
+ * @var array words List of words added to the index
+ * @var array split_text Array of words from the message
+ * @var array split_title Array of words from the title
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'mode',
+ 'post_id',
+ 'message',
+ 'subject',
+ 'poster_id',
+ 'forum_id',
+ 'words',
+ 'split_text',
+ 'split_title',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_index_before', compact($vars)));
+
unset($split_text);
unset($split_title);
@@ -996,12 +1033,37 @@ class fulltext_mysql extends \phpbb\search\base
$alter_list[] = $alter_entry;
}
- if (sizeof($alter_list))
+ $sql_queries = [];
+
+ foreach ($alter_list as $alter)
{
- foreach ($alter_list as $alter)
- {
- $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
- }
+ $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter);
+ }
+
+ if (!isset($this->stats['post_text']))
+ {
+ $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ADD FULLTEXT post_text (post_text)';
+ }
+
+ $stats = $this->stats;
+
+ /**
+ * Event to modify SQL queries before the MySQL search index is created
+ *
+ * @event core.search_mysql_create_index_before
+ * @var array sql_queries Array with queries for creating the search index
+ * @var array stats Array with statistics of the current index (read only)
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'sql_queries',
+ 'stats',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_create_index_before', compact($vars)));
+
+ foreach ($sql_queries as $sql_query)
+ {
+ $this->db->sql_query($sql_query);
}
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
@@ -1039,9 +1101,37 @@ class fulltext_mysql extends \phpbb\search\base
$alter[] = 'DROP INDEX post_content';
}
- if (sizeof($alter))
+ if (isset($this->stats['post_text']))
{
- $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
+ $alter[] = 'DROP INDEX post_text';
+ }
+
+ $sql_queries = [];
+
+ if (count($alter))
+ {
+ $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter);
+ }
+
+ $stats = $this->stats;
+
+ /**
+ * Event to modify SQL queries before the MySQL search index is deleted
+ *
+ * @event core.search_mysql_delete_index_before
+ * @var array sql_queries Array with queries for deleting the search index
+ * @var array stats Array with statistics of the current index (read only)
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'sql_queries',
+ 'stats',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_delete_index_before', compact($vars)));
+
+ foreach ($sql_queries as $sql_query)
+ {
+ $this->db->sql_query($sql_query);
}
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
@@ -1059,7 +1149,7 @@ class fulltext_mysql extends \phpbb\search\base
$this->get_stats();
}
- return isset($this->stats['post_subject']) && isset($this->stats['post_content']);
+ return isset($this->stats['post_subject']) && isset($this->stats['post_content']) && isset($this->stats['post_text']);
}
/**
@@ -1103,6 +1193,10 @@ class fulltext_mysql extends \phpbb\search\base
{
$this->stats['post_subject'] = $row;
}
+ else if ($row['Key_name'] == 'post_text')
+ {
+ $this->stats['post_text'] = $row;
+ }
else if ($row['Key_name'] == 'post_content')
{
$this->stats['post_content'] = $row;
diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php
index 73dcfce9a5..c83de75eed 100644
--- a/phpBB/phpbb/search/fulltext_native.php
+++ b/phpBB/phpbb/search/fulltext_native.php
@@ -190,7 +190,7 @@ class fulltext_native extends \phpbb\search\base
*/
public function split_keywords($keywords, $terms)
{
- $tokens = '+-|()*';
+ $tokens = '+-|()* ';
$keywords = trim($this->cleanup($keywords, $tokens));
@@ -224,12 +224,10 @@ class fulltext_native extends \phpbb\search\base
$keywords[$i] = '|';
break;
case '*':
- if ($i === 0 || ($keywords[$i - 1] !== '*' && strcspn($keywords[$i - 1], $tokens) === 0))
+ // $i can never be 0 here since $open_bracket is initialised to false
+ if (strpos($tokens, $keywords[$i - 1]) !== false && ($i + 1 === $n || strpos($tokens, $keywords[$i + 1]) !== false))
{
- if ($i === $n - 1 || ($keywords[$i + 1] !== '*' && strcspn($keywords[$i + 1], $tokens) === 0))
- {
- $keywords = substr($keywords, 0, $i) . substr($keywords, $i + 1);
- }
+ $keywords[$i] = '|';
}
break;
}
@@ -264,7 +262,7 @@ class fulltext_native extends \phpbb\search\base
}
}
- if ($open_bracket)
+ if ($open_bracket !== false)
{
$keywords .= ')';
}
@@ -285,7 +283,7 @@ class fulltext_native extends \phpbb\search\base
);
$keywords = preg_replace($match, $replace, $keywords);
- $num_keywords = sizeof(explode(' ', $keywords));
+ $num_keywords = count(explode(' ', $keywords));
// We limit the number of allowed keywords to minimize load on the database
if ($this->config['max_num_search_keywords'] && $num_keywords > $this->config['max_num_search_keywords'])
@@ -301,12 +299,26 @@ class fulltext_native extends \phpbb\search\base
$words = array();
preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $words);
- if (sizeof($words[1]))
+ if (count($words[1]))
{
$keywords = '(' . implode('|', $words[1]) . ')';
}
}
+ // Remove non trailing wildcards from each word to prevent a full table scan (it's now using the database index)
+ $match = '#\*(?!$|\s)#';
+ $replace = '$1';
+ $keywords = preg_replace($match, $replace, $keywords);
+
+ // Only allow one wildcard in the search query to limit the database load
+ $match = '#\*#';
+ $replace = '$1';
+ $count_wildcards = substr_count($keywords, '*');
+
+ // Reverse the string to remove all wildcards except the first one
+ $keywords = strrev(preg_replace($match, $replace, strrev($keywords), $count_wildcards - 1));
+ unset($count_wildcards);
+
// set the search_query which is shown to the user
$this->search_query = $keywords;
@@ -316,7 +328,7 @@ class fulltext_native extends \phpbb\search\base
$common_ids = $words = array();
- if (sizeof($exact_words))
+ if (count($exact_words))
{
$sql = 'SELECT word_id, word_text, word_common
FROM ' . SEARCH_WORDLIST_TABLE . '
@@ -409,8 +421,16 @@ class fulltext_native extends \phpbb\search\base
{
if (strpos($word_part, '*') !== false)
{
- $id_words[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word_part)) . '\'';
- $non_common_words[] = $word_part;
+ $len = utf8_strlen(str_replace('*', '', $word_part));
+ if ($len >= $this->word_length['min'] && $len <= $this->word_length['max'])
+ {
+ $id_words[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word_part)) . '\'';
+ $non_common_words[] = $word_part;
+ }
+ else
+ {
+ $this->common_words[] = $word_part;
+ }
}
else if (isset($words[$word_part]))
{
@@ -426,10 +446,10 @@ class fulltext_native extends \phpbb\search\base
}
}
}
- if (sizeof($id_words))
+ if (count($id_words))
{
sort($id_words);
- if (sizeof($id_words) > 1)
+ if (count($id_words) > 1)
{
$this->{$mode . '_ids'}[] = $id_words;
}
@@ -440,7 +460,7 @@ class fulltext_native extends \phpbb\search\base
}
}
// throw an error if we shall not ignore unexistant words
- else if (!$ignore_no_id && sizeof($non_common_words))
+ else if (!$ignore_no_id && count($non_common_words))
{
trigger_error(sprintf($this->user->lang['WORDS_IN_NO_POST'], implode($this->user->lang['COMMA_SEPARATOR'], $non_common_words)));
}
@@ -480,7 +500,7 @@ class fulltext_native extends \phpbb\search\base
}
// Return true if all words are not common words
- if (sizeof($exact_words) - sizeof($this->common_words) > 0)
+ if (count($exact_words) - count($this->common_words) > 0)
{
return true;
}
@@ -716,7 +736,7 @@ class fulltext_native extends \phpbb\search\base
}
}
- if (sizeof($this->must_not_contain_ids))
+ if (count($this->must_not_contain_ids))
{
$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(SEARCH_WORDMATCH_TABLE => 'm' . $m_num),
@@ -826,7 +846,7 @@ class fulltext_native extends \phpbb\search\base
$sql_where[] = 'p.topic_id = ' . $topic_id;
}
- if (sizeof($author_ary))
+ if (count($author_ary))
{
if ($author_name)
{
@@ -840,7 +860,7 @@ class fulltext_native extends \phpbb\search\base
$sql_where[] = $sql_author;
}
- if (sizeof($ex_fid_ary))
+ if (count($ex_fid_ary))
{
$sql_where[] = $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true);
}
@@ -1010,7 +1030,7 @@ class fulltext_native extends \phpbb\search\base
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No author? No posts
- if (!sizeof($author_ary))
+ if (!count($author_ary))
{
return 0;
}
@@ -1082,7 +1102,7 @@ class fulltext_native extends \phpbb\search\base
{
$sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
- $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@@ -1289,7 +1309,7 @@ class fulltext_native extends \phpbb\search\base
$this->db->sql_freeresult($result);
}
- if (sizeof($id_ary))
+ if (count($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, $per_page);
@@ -1433,6 +1453,38 @@ class fulltext_native extends \phpbb\search\base
$words['del']['post'] = array();
$words['del']['title'] = array();
}
+
+ /**
+ * Event to modify method arguments and words before the native search index is updated
+ *
+ * @event core.search_native_index_before
+ * @var string mode Contains the post mode: edit, post, reply, quote
+ * @var int post_id The id of the post which is modified/created
+ * @var string message New or updated post content
+ * @var string subject New or updated post subject
+ * @var int poster_id Post author's user id
+ * @var int forum_id The id of the forum in which the post is located
+ * @var array words Grouped lists of words added to or remove from the index
+ * @var array split_text Array of words from the message
+ * @var array split_title Array of words from the title
+ * @var array cur_words Array of words currently in the index for comparing to new words
+ * when mode is edit. Empty for other modes.
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'mode',
+ 'post_id',
+ 'message',
+ 'subject',
+ 'poster_id',
+ 'forum_id',
+ 'words',
+ 'split_text',
+ 'split_title',
+ 'cur_words',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_native_index_before', compact($vars)));
+
unset($split_text);
unset($split_title);
@@ -1443,7 +1495,7 @@ class fulltext_native extends \phpbb\search\base
// individual arrays of added and removed words for text and title. What
// we need to do now is add the new words (if they don't already exist)
// and then add (or remove) matches between the words and this post
- if (sizeof($unique_add_words))
+ if (count($unique_add_words))
{
$sql = 'SELECT word_id, word_text
FROM ' . SEARCH_WORDLIST_TABLE . '
@@ -1459,7 +1511,7 @@ class fulltext_native extends \phpbb\search\base
$new_words = array_diff($unique_add_words, array_keys($word_ids));
$this->db->sql_transaction('begin');
- if (sizeof($new_words))
+ if (count($new_words))
{
$sql_ary = array();
@@ -1483,7 +1535,7 @@ class fulltext_native extends \phpbb\search\base
{
$title_match = ($word_in == 'title') ? 1 : 0;
- if (sizeof($word_ary))
+ if (count($word_ary))
{
$sql_in = array();
foreach ($word_ary as $word)
@@ -1512,7 +1564,7 @@ class fulltext_native extends \phpbb\search\base
{
$title_match = ($word_in == 'title') ? 1 : 0;
- if (sizeof($word_ary))
+ if (count($word_ary))
{
$sql = 'INSERT INTO ' . SEARCH_WORDMATCH_TABLE . ' (post_id, word_id, title_match)
SELECT ' . (int) $post_id . ', word_id, ' . (int) $title_match . '
@@ -1543,7 +1595,7 @@ class fulltext_native extends \phpbb\search\base
*/
public function index_remove($post_ids, $author_ids, $forum_ids)
{
- if (sizeof($post_ids))
+ if (count($post_ids))
{
$sql = 'SELECT w.word_id, w.word_text, m.title_match
FROM ' . SEARCH_WORDMATCH_TABLE . ' m, ' . SEARCH_WORDLIST_TABLE . ' w
@@ -1566,7 +1618,7 @@ class fulltext_native extends \phpbb\search\base
}
$this->db->sql_freeresult($result);
- if (sizeof($title_word_ids))
+ if (count($title_word_ids))
{
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
SET word_count = word_count - 1
@@ -1575,7 +1627,7 @@ class fulltext_native extends \phpbb\search\base
$this->db->sql_query($sql);
}
- if (sizeof($message_word_ids))
+ if (count($message_word_ids))
{
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
SET word_count = word_count - 1
@@ -1630,7 +1682,7 @@ class fulltext_native extends \phpbb\search\base
}
$this->db->sql_freeresult($result);
- if (sizeof($sql_in))
+ if (count($sql_in))
{
// Flag the words
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
@@ -1650,7 +1702,7 @@ class fulltext_native extends \phpbb\search\base
unset($sql_in);
}
- if (sizeof($destroy_cache_words))
+ if (count($destroy_cache_words))
{
// destroy cached search results containing any of the words that are now common or were removed
$this->destroy_cache(array_unique($destroy_cache_words));
@@ -1664,20 +1716,43 @@ class fulltext_native extends \phpbb\search\base
*/
public function delete_index($acp_module, $u_action)
{
+ $sql_queries = [];
+
switch ($this->db->get_sql_layer())
{
case 'sqlite3':
- $this->db->sql_query('DELETE FROM ' . SEARCH_WORDLIST_TABLE);
- $this->db->sql_query('DELETE FROM ' . SEARCH_WORDMATCH_TABLE);
- $this->db->sql_query('DELETE FROM ' . SEARCH_RESULTS_TABLE);
+ $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDLIST_TABLE;
+ $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE;
+ $sql_queries[] = 'DELETE FROM ' . SEARCH_RESULTS_TABLE;
break;
default:
- $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE);
- $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE);
- $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
+ $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE;
+ $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE;
+ $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE;
break;
}
+
+ $stats = $this->stats;
+
+ /**
+ * Event to modify SQL queries before the native search index is deleted
+ *
+ * @event core.search_native_delete_index_before
+ * @var array sql_queries Array with queries for deleting the search index
+ * @var array stats Array with statistics of the current index (read only)
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'sql_queries',
+ 'stats',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_native_delete_index_before', compact($vars)));
+
+ foreach ($sql_queries as $sql_query)
+ {
+ $this->db->sql_query($sql_query);
+ }
}
/**
@@ -1685,7 +1760,7 @@ class fulltext_native extends \phpbb\search\base
*/
public function index_created()
{
- if (!sizeof($this->stats))
+ if (!count($this->stats))
{
$this->get_stats();
}
@@ -1698,7 +1773,7 @@ class fulltext_native extends \phpbb\search\base
*/
public function index_stats()
{
- if (!sizeof($this->stats))
+ if (!count($this->stats))
{
$this->get_stats();
}
diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php
index 8dbc7212a1..2f387e791e 100644
--- a/phpBB/phpbb/search/fulltext_postgres.php
+++ b/phpBB/phpbb/search/fulltext_postgres.php
@@ -294,7 +294,7 @@ class fulltext_postgres extends \phpbb\search\base
// remove too short or too long words
$text = array_values($text);
- for ($i = 0, $n = sizeof($text); $i < $n; $i++)
+ for ($i = 0, $n = count($text); $i < $n; $i++)
{
$text[$i] = trim($text[$i]);
if (utf8_strlen($text[$i]) < $this->config['fulltext_postgres_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_postgres_max_word_len'])
@@ -498,16 +498,16 @@ class fulltext_postgres extends \phpbb\search\base
);
extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_keywords_main_query_before', compact($vars)));
- $sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id';
+ $sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id, ' . $sort_by_sql[$sort_key];
$sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : '';
$field = ($type == 'posts') ? 'post_id' : 'topic_id';
- if (sizeof($author_ary) && $author_name)
+ if (count($author_ary) && $author_name)
{
// first one matches post of registered users, second one guests and deleted users
$sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
- else if (sizeof($author_ary))
+ else if (count($author_ary))
{
$sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary);
}
@@ -519,7 +519,7 @@ class fulltext_postgres extends \phpbb\search\base
$sql_where_options = $sql_sort_join;
$sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
$sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : '';
- $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_where_options .= (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_where_options .= ' AND ' . $post_visibility;
$sql_where_options .= $sql_author;
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
@@ -609,7 +609,7 @@ class fulltext_postgres extends \phpbb\search\base
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No author? No posts
- if (!sizeof($author_ary))
+ if (!count($author_ary))
{
return 0;
}
@@ -686,7 +686,7 @@ class fulltext_postgres extends \phpbb\search\base
{
$sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
- $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_fora = (count($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@@ -861,7 +861,7 @@ class fulltext_postgres extends \phpbb\search\base
$id_ary = array_unique($id_ary);
}
- if (sizeof($id_ary))
+ if (count($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, $per_page);
@@ -889,6 +889,34 @@ class fulltext_postgres extends \phpbb\search\base
$words = array_unique(array_merge($split_text, $split_title));
+ /**
+ * Event to modify method arguments and words before the PostgreSQL search index is updated
+ *
+ * @event core.search_postgres_index_before
+ * @var string mode Contains the post mode: edit, post, reply, quote
+ * @var int post_id The id of the post which is modified/created
+ * @var string message New or updated post content
+ * @var string subject New or updated post subject
+ * @var int poster_id Post author's user id
+ * @var int forum_id The id of the forum in which the post is located
+ * @var array words Array of words added to the index
+ * @var array split_text Array of words from the message
+ * @var array split_title Array of words from the title
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'mode',
+ 'post_id',
+ 'message',
+ 'subject',
+ 'poster_id',
+ 'forum_id',
+ 'words',
+ 'split_text',
+ 'split_title',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_index_before', compact($vars)));
+
unset($split_text);
unset($split_title);
@@ -935,14 +963,37 @@ class fulltext_postgres extends \phpbb\search\base
$this->get_stats();
}
+ $sql_queries = [];
+
if (!isset($this->stats['post_subject']))
{
- $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))");
+ $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))";
}
if (!isset($this->stats['post_content']))
{
- $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))");
+ $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))";
+ }
+
+ $stats = $this->stats;
+
+ /**
+ * Event to modify SQL queries before the Postgres search index is created
+ *
+ * @event core.search_postgres_create_index_before
+ * @var array sql_queries Array with queries for creating the search index
+ * @var array stats Array with statistics of the current index (read only)
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'sql_queries',
+ 'stats',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_create_index_before', compact($vars)));
+
+ foreach ($sql_queries as $sql_query)
+ {
+ $this->db->sql_query($sql_query);
}
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
@@ -968,14 +1019,37 @@ class fulltext_postgres extends \phpbb\search\base
$this->get_stats();
}
+ $sql_queries = [];
+
if (isset($this->stats['post_subject']))
{
- $this->db->sql_query('DROP INDEX ' . $this->stats['post_subject']['relname']);
+ $sql_queries[] = 'DROP INDEX ' . $this->stats['post_subject']['relname'];
}
if (isset($this->stats['post_content']))
{
- $this->db->sql_query('DROP INDEX ' . $this->stats['post_content']['relname']);
+ $sql_queries[] = 'DROP INDEX ' . $this->stats['post_content']['relname'];
+ }
+
+ $stats = $this->stats;
+
+ /**
+ * Event to modify SQL queries before the Postgres search index is created
+ *
+ * @event core.search_postgres_delete_index_before
+ * @var array sql_queries Array with queries for deleting the search index
+ * @var array stats Array with statistics of the current index (read only)
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'sql_queries',
+ 'stats',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_delete_index_before', compact($vars)));
+
+ foreach ($sql_queries as $sql_query)
+ {
+ $this->db->sql_query($sql_query);
}
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php
index 59c3d55076..2c2eb84dc7 100644
--- a/phpBB/phpbb/search/fulltext_sphinx.php
+++ b/phpBB/phpbb/search/fulltext_sphinx.php
@@ -292,7 +292,6 @@ class fulltext_sphinx
AND p.post_id >= $start AND p.post_id <= $end'),
array('sql_query_post', ''),
array('sql_query_post_index', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = $maxid WHERE counter_id = 1'),
- array('sql_query_info', 'SELECT * FROM ' . POSTS_TABLE . ' WHERE post_id = $id'),
array('sql_attr_uint', 'forum_id'),
array('sql_attr_uint', 'topic_id'),
array('sql_attr_uint', 'poster_id'),
@@ -304,7 +303,7 @@ class fulltext_sphinx
array('sql_attr_string', 'post_subject'),
),
'source source_phpbb_' . $this->id . '_delta : source_phpbb_' . $this->id . '_main' => array(
- array('sql_query_pre', ''),
+ array('sql_query_pre', 'SET NAMES \'utf8\''),
array('sql_query_range', ''),
array('sql_range_step', ''),
array('sql_query', 'SELECT
@@ -324,6 +323,7 @@ class fulltext_sphinx
WHERE
p.topic_id = t.topic_id
AND p.post_id >= ( SELECT max_doc_id FROM ' . SPHINX_TABLE . ' WHERE counter_id=1 )'),
+ array('sql_query_post_index', ''),
),
'index index_phpbb_' . $this->id . '_main' => array(
array('path', $this->config['fulltext_sphinx_data_path'] . 'index_phpbb_' . $this->id . '_main'),
@@ -332,7 +332,6 @@ class fulltext_sphinx
array('morphology', 'none'),
array('stopwords', ''),
array('min_word_len', '2'),
- array('charset_type', 'utf-8'),
array('charset_table', 'U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF'),
array('min_prefix_len', '0'),
array('min_infix_len', '0'),
@@ -345,14 +344,12 @@ class fulltext_sphinx
array('mem_limit', $this->config['fulltext_sphinx_indexer_mem_limit'] . 'M'),
),
'searchd' => array(
- array('compat_sphinxql_magics' , '0'),
array('listen' , ($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost') . ':' . ($this->config['fulltext_sphinx_port'] ? $this->config['fulltext_sphinx_port'] : '9312')),
array('log', $this->config['fulltext_sphinx_data_path'] . 'log/searchd.log'),
array('query_log', $this->config['fulltext_sphinx_data_path'] . 'log/sphinx-query.log'),
array('read_timeout', '5'),
array('max_children', '30'),
array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'),
- array('max_matches', (string) SPHINX_MAX_MATCHES),
array('binlog_path', $this->config['fulltext_sphinx_data_path']),
),
);
@@ -482,7 +479,7 @@ class fulltext_sphinx
global $user, $phpbb_log;
// No keywords? No posts.
- if (!strlen($this->search_query) && !sizeof($author_ary))
+ if (!strlen($this->search_query) && !count($author_ary))
{
return false;
}
@@ -622,7 +619,7 @@ class fulltext_sphinx
break;
}
- if (sizeof($author_ary))
+ if (count($author_ary))
{
$this->sphinx->SetFilter('poster_id', $author_ary);
}
@@ -632,14 +629,14 @@ class fulltext_sphinx
// but at least it will also cause the same for normal users.
$this->sphinx->SetFilter('post_visibility', array(ITEM_APPROVED));
- if (sizeof($ex_fid_ary))
+ if (count($ex_fid_ary))
{
// All forums that a user is allowed to access
$fid_ary = array_unique(array_intersect(array_keys($this->auth->acl_getf('f_read', true)), array_keys($this->auth->acl_getf('f_search', true))));
// All forums that the user wants to and can search in
$search_forums = array_diff($fid_ary, $ex_fid_ary);
- if (sizeof($search_forums))
+ if (count($search_forums))
{
$this->sphinx->SetFilter('forum_id', $search_forums);
}
@@ -647,7 +644,7 @@ class fulltext_sphinx
$this->sphinx->SetFilter('deleted', array(0));
- $this->sphinx->SetLimits($start, (int) $per_page, SPHINX_MAX_MATCHES);
+ $this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES);
$result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('&quot;', '"', $this->search_query)), $this->indexes);
// Could be connection to localhost:9312 failed (errno=111,
@@ -757,6 +754,28 @@ class fulltext_sphinx
*/
public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
{
+ /**
+ * Event to modify method arguments before the Sphinx search index is updated
+ *
+ * @event core.search_sphinx_index_before
+ * @var string mode Contains the post mode: edit, post, reply, quote
+ * @var int post_id The id of the post which is modified/created
+ * @var string message New or updated post content
+ * @var string subject New or updated post subject
+ * @var int poster_id Post author's user id
+ * @var int forum_id The id of the forum in which the post is located
+ * @since 3.2.3-RC1
+ */
+ $vars = array(
+ 'mode',
+ 'post_id',
+ 'message',
+ 'subject',
+ 'poster_id',
+ 'forum_id',
+ );
+ extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_index_before', compact($vars)));
+
if ($mode == 'edit')
{
$this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int) $post_id => array((int) $forum_id, (int) $poster_id)));
@@ -789,7 +808,7 @@ class fulltext_sphinx
}
$this->db->sql_freeresult($result);
- if (sizeof($post_updates))
+ if (count($post_updates))
{
$this->sphinx->UpdateAttributes($this->indexes, array('topic_last_post_time'), $post_updates);
}
diff --git a/phpBB/phpbb/search/sphinx/config.php b/phpBB/phpbb/search/sphinx/config.php
index 675649b460..3205574b45 100644
--- a/phpBB/phpbb/search/sphinx/config.php
+++ b/phpBB/phpbb/search/sphinx/config.php
@@ -46,7 +46,7 @@ class config
*/
function get_section_by_name($name)
{
- for ($i = 0, $size = sizeof($this->sections); $i < $size; $i++)
+ for ($i = 0, $size = count($this->sections); $i < $size; $i++)
{
// Make sure this is really a section object and not a comment
if (($this->sections[$i] instanceof \phpbb\search\sphinx\config_section) && $this->sections[$i]->get_name() == $name)
@@ -67,7 +67,7 @@ class config
function add_section($name)
{
$this->sections[] = new \phpbb\search\sphinx\config_section($name, '');
- return $this->sections[sizeof($this->sections) - 1];
+ return $this->sections[count($this->sections) - 1];
}
/**
diff --git a/phpBB/phpbb/search/sphinx/config_section.php b/phpBB/phpbb/search/sphinx/config_section.php
index 14ab3a752c..2fc8b2da17 100644
--- a/phpBB/phpbb/search/sphinx/config_section.php
+++ b/phpBB/phpbb/search/sphinx/config_section.php
@@ -87,7 +87,7 @@ class config_section
*/
function get_variable_by_name($name)
{
- for ($i = 0, $size = sizeof($this->variables); $i < $size; $i++)
+ for ($i = 0, $size = count($this->variables); $i < $size; $i++)
{
// Make sure this is a variable object and not a comment
if (($this->variables[$i] instanceof \phpbb\search\sphinx\config_variable) && $this->variables[$i]->get_name() == $name)
@@ -106,7 +106,7 @@ class config_section
*/
function delete_variables_by_name($name)
{
- for ($i = 0, $size = sizeof($this->variables); $i < $size; $i++)
+ for ($i = 0, $size = count($this->variables); $i < $size; $i++)
{
// Make sure this is a variable object and not a comment
if (($this->variables[$i] instanceof \phpbb\search\sphinx\config_variable) && $this->variables[$i]->get_name() == $name)
@@ -129,7 +129,7 @@ class config_section
function create_variable($name, $value)
{
$this->variables[] = new \phpbb\search\sphinx\config_variable($name, $value, '');
- return $this->variables[sizeof($this->variables) - 1];
+ return $this->variables[count($this->variables) - 1];
}
/**
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php
index 6b5b8f2625..31f32af7c4 100644
--- a/phpBB/phpbb/session.php
+++ b/phpBB/phpbb/session.php
@@ -108,7 +108,7 @@ class session
$root_dirs = array_diff_assoc($root_dirs, $intersection);
$page_dirs = array_diff_assoc($page_dirs, $intersection);
- $page_dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs);
+ $page_dir = str_repeat('../', count($root_dirs)) . implode('/', $page_dirs);
if ($page_dir && substr($page_dir, -1, 1) == '/')
{
@@ -127,8 +127,8 @@ class session
// The script path from the webroot to the phpBB root (for example: /phpBB3/)
$script_dirs = explode('/', $script_path);
- array_splice($script_dirs, -sizeof($page_dirs));
- $root_script_path = implode('/', $script_dirs) . (sizeof($root_dirs) ? '/' . implode('/', $root_dirs) : '');
+ array_splice($script_dirs, -count($page_dirs));
+ $root_script_path = implode('/', $script_dirs) . (count($root_dirs) ? '/' . implode('/', $root_dirs) : '');
// We are on the base level (phpBB root == webroot), lets adjust the variables a bit...
if (!$root_script_path)
@@ -584,12 +584,12 @@ class session
$provider = $provider_collection->get_provider();
$this->data = $provider->autologin();
- if ($user_id !== false && sizeof($this->data) && $this->data['user_id'] != $user_id)
+ if ($user_id !== false && isset($this->data['user_id']) && $this->data['user_id'] != $user_id)
{
$this->data = array();
}
- if (sizeof($this->data))
+ if (isset($this->data['user_id']))
{
$this->cookie_data['k'] = '';
$this->cookie_data['u'] = $this->data['user_id'];
@@ -597,7 +597,7 @@ class session
// If we're presented with an autologin key we'll join against it.
// Else if we've been passed a user_id we'll grab data based on that
- if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && !sizeof($this->data))
+ if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && empty($this->data))
{
$sql = 'SELECT u.*
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k
@@ -617,7 +617,7 @@ class session
$db->sql_freeresult($result);
}
- if ($user_id !== false && !sizeof($this->data))
+ if ($user_id !== false && empty($this->data))
{
$this->cookie_data['k'] = '';
$this->cookie_data['u'] = $user_id;
@@ -645,7 +645,7 @@ class session
// User does not exist
// User is inactive
// User is bot
- if (!sizeof($this->data) || !is_array($this->data))
+ if (!is_array($this->data) || !count($this->data))
{
$this->cookie_data['k'] = '';
$this->cookie_data['u'] = ($bot) ? $bot : ANONYMOUS;
@@ -1022,7 +1022,7 @@ class session
}
$db->sql_freeresult($result);
- if (sizeof($del_user_id))
+ if (count($del_user_id))
{
// Delete expired sessions
$sql = 'DELETE FROM ' . SESSIONS_TABLE . '
@@ -1156,7 +1156,7 @@ class session
$where_sql[] = $_sql;
}
- $sql .= (sizeof($where_sql)) ? implode(' AND ', $where_sql) : '';
+ $sql .= (count($where_sql)) ? implode(' AND ', $where_sql) : '';
$result = $db->sql_query($sql, $cache_ttl);
$ban_triggered_by = 'user';
@@ -1299,7 +1299,12 @@ class session
trigger_error($message);
}
- return ($banned && $ban_row['ban_give_reason']) ? $ban_row['ban_give_reason'] : $banned;
+ if (!empty($ban_row))
+ {
+ $ban_row['ban_triggered_by'] = $ban_triggered_by;
+ }
+
+ return ($banned && $ban_row) ? $ban_row : $banned;
}
/**
@@ -1614,13 +1619,15 @@ class session
return;
}
+ // Do not update the session page for ajax requests, so the view online still works as intended
+ $page_changed = $this->update_session_page && $this->data['session_page'] != $this->page['page'] && !$request->is_ajax();
+
// Only update session DB a minute or so after last update or if page changes
- if ($this->time_now - ((isset($this->data['session_time'])) ? $this->data['session_time'] : 0) > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page']))
+ if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed)
{
$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())
+ if ($page_changed)
{
$sql_ary['session_page'] = substr($this->page['page'], 0, 199);
$sql_ary['session_forum_id'] = $this->page['forum'];
diff --git a/phpBB/phpbb/template/assets_bag.php b/phpBB/phpbb/template/assets_bag.php
index 9013061b96..067b0eb8f1 100644
--- a/phpBB/phpbb/template/assets_bag.php
+++ b/phpBB/phpbb/template/assets_bag.php
@@ -71,7 +71,7 @@ class assets_bag
$output = '';
foreach ($this->stylesheets as $stylesheet)
{
- $output .= "<link href=\"{$stylesheet->get_url()}\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />\n";
+ $output .= "<link href=\"{$stylesheet->get_url()}\" rel=\"stylesheet\" media=\"screen\" />\n";
}
return $output;
@@ -87,7 +87,7 @@ class assets_bag
$output = '';
foreach ($this->scripts as $script)
{
- $output .= "<script type=\"text/javascript\" src=\"{$script->get_url()}\"></script>\n";
+ $output .= "<script src=\"{$script->get_url()}\"></script>\n";
}
return $output;
diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php
index 392efd5933..202e29ce00 100644
--- a/phpBB/phpbb/template/context.php
+++ b/phpBB/phpbb/template/context.php
@@ -142,7 +142,7 @@ class context
*/
protected function set_num_rows(&$loop_data)
{
- $s_num_rows = sizeof($loop_data);
+ $s_num_rows = count($loop_data);
foreach ($loop_data as &$mod_block)
{
foreach ($mod_block as $sub_block_name => &$sub_block)
@@ -190,70 +190,51 @@ class context
public function assign_block_vars($blockname, array $vararray)
{
$this->num_rows_is_set = false;
- if (strpos($blockname, '.') !== false)
- {
- // Nested block.
- $blocks = explode('.', $blockname);
- $blockcount = sizeof($blocks) - 1;
-
- $str = &$this->tpldata;
- for ($i = 0; $i < $blockcount; $i++)
- {
- $str = &$str[$blocks[$i]];
- $str = &$str[sizeof($str) - 1];
- }
- $s_row_count = isset($str[$blocks[$blockcount]]) ? sizeof($str[$blocks[$blockcount]]) : 0;
- $vararray['S_ROW_COUNT'] = $vararray['S_ROW_NUM'] = $s_row_count;
+ // For nested block, $blockcount > 0, for top-level block, $blockcount == 0
+ $blocks = explode('.', $blockname);
+ $blockcount = count($blocks) - 1;
- // Assign S_FIRST_ROW
- if (!$s_row_count)
- {
- $vararray['S_FIRST_ROW'] = true;
- }
+ $block = &$this->tpldata;
+ for ($i = 0; $i < $blockcount; $i++)
+ {
+ $pos = strpos($blocks[$i], '[');
+ $name = ($pos !== false) ? substr($blocks[$i], 0, $pos) : $blocks[$i];
+ $block = &$block[$name];
+ $block_count = empty($block) ? 0 : count($block) - 1;
+ $index = (!$pos || strpos($blocks[$i], '[]') === $pos) ? $block_count : (min((int) substr($blocks[$i], $pos + 1, -1), $block_count));
+ $block = &$block[$index];
+ }
- // Assign S_BLOCK_NAME
- $vararray['S_BLOCK_NAME'] = $blocks[$blockcount];
+ // $block = &$block[$blocks[$i]]; // Do not traverse the last block as it might be empty
+ $name = $blocks[$i];
- // Now the tricky part, we always assign S_LAST_ROW and remove the entry before
- // This is much more clever than going through the complete template data on display (phew)
- $vararray['S_LAST_ROW'] = true;
- if ($s_row_count > 0)
- {
- unset($str[$blocks[$blockcount]][($s_row_count - 1)]['S_LAST_ROW']);
- }
+ // Assign S_ROW_COUNT and S_ROW_NUM
+ $s_row_count = isset($block[$name]) ? count($block[$name]) : 0;
+ $vararray['S_ROW_COUNT'] = $vararray['S_ROW_NUM'] = $s_row_count;
- // Now we add the block that we're actually assigning to.
- // We're adding a new iteration to this block with the given
- // variable assignments.
- $str[$blocks[$blockcount]][] = $vararray;
- }
- else
+ // Assign S_FIRST_ROW
+ if (!$s_row_count)
{
- // Top-level block.
- $s_row_count = (isset($this->tpldata[$blockname])) ? sizeof($this->tpldata[$blockname]) : 0;
- $vararray['S_ROW_COUNT'] = $vararray['S_ROW_NUM'] = $s_row_count;
-
- // Assign S_FIRST_ROW
- if (!$s_row_count)
- {
- $vararray['S_FIRST_ROW'] = true;
- }
-
- // Assign S_BLOCK_NAME
- $vararray['S_BLOCK_NAME'] = $blockname;
+ $vararray['S_FIRST_ROW'] = true;
+ }
- // We always assign S_LAST_ROW and remove the entry before
- $vararray['S_LAST_ROW'] = true;
- if ($s_row_count > 0)
- {
- unset($this->tpldata[$blockname][($s_row_count - 1)]['S_LAST_ROW']);
- }
+ // Assign S_BLOCK_NAME
+ $vararray['S_BLOCK_NAME'] = $name;
- // Add a new iteration to this block with the variable assignments we were given.
- $this->tpldata[$blockname][] = $vararray;
+ // Now the tricky part, we always assign S_LAST_ROW and remove the entry before
+ // This is much more clever than going through the complete template data on display (phew)
+ $vararray['S_LAST_ROW'] = true;
+ if ($s_row_count > 0)
+ {
+ unset($block[$name][($s_row_count - 1)]['S_LAST_ROW']);
}
+ // Now we add the block that we're actually assigning to.
+ // We're adding a new iteration to this block with the given
+ // variable assignments.
+ $block[$name][] = $vararray;
+
return true;
}
@@ -285,7 +266,7 @@ class context
{
// For nested block, $blockcount > 0, for top-level block, $blockcount == 0
$blocks = explode('.', $blockname);
- $blockcount = sizeof($blocks) - 1;
+ $blockcount = count($blocks) - 1;
$block = $this->tpldata;
for ($i = 0; $i <= $blockcount; $i++)
@@ -294,19 +275,29 @@ class context
{
$name = substr($blocks[$i], 0, $pos);
+ if (empty($block[$name]))
+ {
+ return array();
+ }
+
if (strpos($blocks[$i], '[]') === $pos)
{
- $index = sizeof($block[$name]) - 1;
+ $index = count($block[$name]) - 1;
}
else
{
- $index = min((int) substr($blocks[$i], $pos + 1, -1), sizeof($block[$name]) - 1);
+ $index = min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1);
}
}
else
{
$name = $blocks[$i];
- $index = sizeof($block[$name]) - 1;
+ if (empty($block[$name]))
+ {
+ return array();
+ }
+
+ $index = count($block[$name]) - 1;
}
$block = $block[$name];
$block = $block[$index];
@@ -355,39 +346,26 @@ class context
{
// For nested block, $blockcount > 0, for top-level block, $blockcount == 0
$blocks = explode('.', $blockname);
- $blockcount = sizeof($blocks) - 1;
+ $blockcount = count($blocks) - 1;
$block = $this->tpldata;
for ($i = 0; $i < $blockcount; $i++)
{
- if (($pos = strpos($blocks[$i], '[')) !== false)
- {
- $name = substr($blocks[$i], 0, $pos);
+ $pos = strpos($blocks[$i], '[');
+ $name = ($pos !== false) ? substr($blocks[$i], 0, $pos) : $blocks[$i];
- if (strpos($blocks[$i], '[]') === $pos)
- {
- $index = sizeof($block[$name]) - 1;
- }
- else
- {
- $index = min((int) substr($blocks[$i], $pos + 1, -1), sizeof($block[$name]) - 1);
- }
- }
- else
- {
- $name = $blocks[$i];
- $index = sizeof($block[$name]) - 1;
- }
if (!isset($block[$name]))
{
return false;
}
- $block = $block[$name];
- if (!isset($block[$index]))
+
+ $index = (!$pos || strpos($blocks[$i], '[]') === $pos) ? (count($block[$name]) - 1) : (min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1));
+
+ if (!isset($block[$name][$index]))
{
return false;
}
- $block = $block[$index];
+ $block = $block[$name][$index];
}
if (!isset($block[$blocks[$i]]))
@@ -397,9 +375,9 @@ class context
$block = $block[$blocks[$i]]; // Traverse the last block
// Change key to zero (change first position) if false and to last position if true
- if ($key === false || $key === true)
+ if (is_bool($key))
{
- return ($key === false) ? 0 : sizeof($block) - 1;
+ return (!$key) ? 0 : count($block) - 1;
}
// Get correct position if array given
@@ -416,7 +394,7 @@ class context
}
}
- return (is_int($key) && ((0 <= $key) && ($key < sizeof($block)))) ? $key : false;
+ return (is_int($key) && ((0 <= $key) && ($key < count($block)))) ? $key : false;
}
/**
@@ -453,7 +431,7 @@ class context
// For nested block, $blockcount > 0, for top-level block, $blockcount == 0
$blocks = explode('.', $blockname);
- $blockcount = sizeof($blocks) - 1;
+ $blockcount = count($blocks) - 1;
$block = &$this->tpldata;
for ($i = 0; $i < $blockcount; $i++)
@@ -464,17 +442,17 @@ class context
if (strpos($blocks[$i], '[]') === $pos)
{
- $index = sizeof($block[$name]) - 1;
+ $index = count($block[$name]) - 1;
}
else
{
- $index = min((int) substr($blocks[$i], $pos + 1, -1), sizeof($block[$name]) - 1);
+ $index = min((int) substr($blocks[$i], $pos + 1, -1), count($block[$name]) - 1);
}
}
else
{
$name = $blocks[$i];
- $index = sizeof($block[$name]) - 1;
+ $index = count($block[$name]) - 1;
}
$block = &$block[$name];
$block = &$block[$index];
@@ -496,7 +474,7 @@ class context
// Change key to zero (change first position) if false and to last position if true
if ($key === false || $key === true)
{
- $key = ($key === false) ? 0 : sizeof($block);
+ $key = ($key === false) ? 0 : count($block);
}
// Get correct position if array given
@@ -526,9 +504,9 @@ class context
if ($mode == 'insert')
{
// Make sure we are not exceeding the last iteration
- if ($key >= sizeof($block))
+ if ($key >= count($block))
{
- $key = sizeof($block);
+ $key = count($block);
unset($block[($key - 1)]['S_LAST_ROW']);
$vararray['S_LAST_ROW'] = true;
}
@@ -543,7 +521,7 @@ class context
$vararray['S_BLOCK_NAME'] = $name;
// Re-position template blocks
- for ($i = sizeof($block); $i > $key; $i--)
+ for ($i = count($block); $i > $key; $i--)
{
$block[$i] = $block[$i-1];
@@ -561,12 +539,12 @@ class context
if ($mode == 'change')
{
// If key is out of bounds, do not change anything
- if ($key > sizeof($block) || $key < 0)
+ if ($key > count($block) || $key < 0)
{
return false;
}
- if ($key == sizeof($block))
+ if ($key == count($block))
{
$key--;
}
@@ -580,26 +558,26 @@ class context
if ($mode == 'delete')
{
// If we are exceeding last iteration, do not delete anything
- if ($key > sizeof($block) || $key < 0)
+ if ($key > count($block) || $key < 0)
{
return false;
}
// If we are positioned at the end, we remove the last element
- if ($key == sizeof($block))
+ if ($key == count($block))
{
$key--;
}
// We are deleting the last element in the block, so remove the block
- if (sizeof($block) === 1)
+ if (count($block) === 1)
{
$block = null; // unset($block); does not work on references
return true;
}
// Re-position template blocks
- for ($i = $key; $i < sizeof($block)-1; $i++)
+ for ($i = $key; $i < count($block)-1; $i++)
{
$block[$i] = $block[$i+1];
$block[$i]['S_ROW_COUNT'] = $block[$i]['S_ROW_NUM'] = $i;
@@ -610,7 +588,7 @@ class context
// Set first and last elements again, in case they were removed
$block[0]['S_FIRST_ROW'] = true;
- $block[sizeof($block)-1]['S_LAST_ROW'] = true;
+ $block[count($block)-1]['S_LAST_ROW'] = true;
return true;
}
@@ -631,13 +609,13 @@ class context
{
// Nested block.
$blocks = explode('.', $blockname);
- $blockcount = sizeof($blocks) - 1;
+ $blockcount = count($blocks) - 1;
$str = &$this->tpldata;
for ($i = 0; $i < $blockcount; $i++)
{
$str = &$str[$blocks[$i]];
- $str = &$str[sizeof($str) - 1];
+ $str = &$str[count($str) - 1];
}
unset($str[$blocks[$blockcount]]);
diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php
index f0e716d697..f6f8e03ca2 100644
--- a/phpBB/phpbb/template/twig/extension.php
+++ b/phpBB/phpbb/template/twig/extension.php
@@ -146,7 +146,7 @@ class extension extends \Twig_Extension
// of items to grab (length)
// Start must always be the actual starting number for this calculation (not negative)
- $start = ($start < 0) ? sizeof($item) + $start : $start;
+ $start = ($start < 0) ? count($item) + $start : $start;
$end = $end - $start;
}
@@ -172,7 +172,7 @@ class extension extends \Twig_Extension
$context_vars = $this->context->get_root_ref();
- if (isset($context_vars['L_' . $key]))
+ if (is_string($key) && isset($context_vars['L_' . $key]))
{
return $context_vars['L_' . $key];
}
diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php
index 6d50eafc9d..12034b7820 100644
--- a/phpBB/phpbb/template/twig/node/includeasset.php
+++ b/phpBB/phpbb/template/twig/node/includeasset.php
@@ -50,7 +50,12 @@ abstract class includeasset extends \Twig_Node
->write("\$asset->set_path(\$local_file, true);\n")
->outdent()
->write("}\n")
- ->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
+ ->outdent()
+ ->write("}\n")
+ ->write("\n")
+ ->write("if (\$asset->is_relative()) {\n")
+ ->indent()
+ ->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
->outdent()
->write("}\n")
->write("\$this->getEnvironment()->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);")
diff --git a/phpBB/phpbb/textformatter/s9e/bbcode_merger.php b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php
new file mode 100644
index 0000000000..a05ca3c2b8
--- /dev/null
+++ b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php
@@ -0,0 +1,183 @@
+<?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\textformatter\s9e;
+
+use phpbb\textformatter\s9e\factory;
+use s9e\TextFormatter\Configurator\Helpers\TemplateHelper;
+use s9e\TextFormatter\Configurator\Items\UnsafeTemplate;
+
+class bbcode_merger
+{
+ /**
+ * @var \s9e\TextFormatter\Configurator $configurator Configurator instance used to inspect BBCodes
+ */
+ protected $configurator;
+
+ /**
+ * @param \phpbb\textformatter\s9e\factory $factory
+ */
+ public function __construct(factory $factory)
+ {
+ $this->configurator = $factory->get_configurator();
+ }
+
+ /**
+ * Merge two BBCode definitions
+ *
+ * All of the arrays contain a "usage" element and a "template" element
+ *
+ * @throws InvalidArgumentException if a definition cannot be interpreted
+ * @throws RuntimeException if something unexpected occurs
+ *
+ * @param array $without BBCode definition without an attribute
+ * @param array $with BBCode definition with an attribute
+ * @return array Merged definition
+ */
+ public function merge_bbcodes(array $without, array $with)
+ {
+ $without = $this->create_bbcode($without);
+ $with = $this->create_bbcode($with);
+
+ // Select the appropriate strategy for merging this BBCode
+ if ($this->is_content_bbcode($without, $with))
+ {
+ $merged = $this->merge_content_bbcode($without, $with);
+ }
+ else
+ {
+ $merged = $this->merge_optional_bbcode($without, $with);
+ }
+
+ $merged['template'] = $this->normalize_template($merged['template']);
+
+ return $merged;
+ }
+
+ /**
+ * Create a custom BBCode for inspection
+ *
+ * @param array $definition Original BBCode definition
+ * @return array Updated definition containing a BBCode object and a Tag
+ */
+ protected function create_bbcode(array $definition)
+ {
+ $bbcode = $this->configurator->BBCodes->addCustom(
+ $definition['usage'],
+ new UnsafeTemplate($definition['template'])
+ );
+
+ $definition['bbcode'] = $bbcode;
+ $definition['tag'] = $this->configurator->tags[$bbcode->tagName];
+
+ return $definition;
+ }
+
+ /**
+ * Indent given template for readability
+ *
+ * @param string $template
+ * @return string
+ */
+ protected function indent_template($template)
+ {
+ $dom = TemplateHelper::loadTemplate($template);
+ $dom->formatOutput = true;
+ $template = TemplateHelper::saveTemplate($dom);
+
+ // Remove the first level of indentation if the template starts with whitespace
+ if (preg_match('(^\\n +)', $template, $m))
+ {
+ $template = str_replace($m[0], "\n", $template);
+ }
+
+ return trim($template);
+ }
+
+ /**
+ * Test whether the two definitions form a "content"-style BBCode
+ *
+ * Such BBCodes include the [URL] BBCode, which uses its text content as
+ * attribute if none is provided
+ *
+ * @param array $without BBCode definition without an attribute
+ * @param array $with BBCode definition with an attribute
+ * @return array Merged definition
+ */
+ protected function is_content_bbcode(array $without, array $with)
+ {
+ // Test whether we find the same non-TEXT token between "]" and "[" in the usage
+ // as between ">" and "<" in the template
+ return (preg_match('(\\]\\s*(\\{(?!TEXT)[^}]+\\})\\s*\\[)', $without['usage'], $m)
+ && preg_match('(>[^<]*?' . preg_quote($m[1]) . '[^>]*?<)s', $without['template']));
+ }
+
+ /**
+ * Merge the two BBCode definitions of a "content"-style BBCode
+ *
+ * @param array $without BBCode definition without an attribute
+ * @param array $with BBCode definition with an attribute
+ * @return array Merged definition
+ */
+ protected function merge_content_bbcode(array $without, array $with)
+ {
+ // Convert [X={X}] into [X={X;useContent}]
+ $usage = preg_replace('(\\})', ';useContent}', $with['usage'], 1);
+
+ // Use the template from the definition that uses an attribute
+ $template = $with['tag']->template;
+
+ return ['usage' => $usage, 'template' => $template];
+ }
+
+ /**
+ * Merge the two BBCode definitions of a BBCode with an optional argument
+ *
+ * Such BBCodes include the [QUOTE] BBCode, which takes an optional argument
+ * but otherwise does not behave differently
+ *
+ * @param array $without BBCode definition without an attribute
+ * @param array $with BBCode definition with an attribute
+ * @return array Merged definition
+ */
+ protected function merge_optional_bbcode(array $without, array $with)
+ {
+ // Convert [X={X}] into [X={X?}]
+ $usage = preg_replace('(\\})', '?}', $with['usage'], 1);
+
+ // Build a template for both versions
+ $template = '<xsl:choose><xsl:when test="@' . $with['bbcode']->defaultAttribute . '">' . $with['tag']->template . '</xsl:when><xsl:otherwise>' . $without['tag']->template . '</xsl:otherwise></xsl:choose>';
+
+ return ['usage' => $usage, 'template' => $template];
+ }
+
+ /**
+ * Normalize a template
+ *
+ * @param string $template
+ * @return string
+ */
+ protected function normalize_template($template)
+ {
+ // Normalize the template to simplify it
+ $template = $this->configurator->templateNormalizer->normalizeTemplate($template);
+
+ // Convert xsl:value-of elements back to {L_} tokens where applicable
+ $template = preg_replace('(<xsl:value-of select="\\$(L_\\w+)"/>)', '{$1}', $template);
+
+ // Beautify the template
+ $template = $this->indent_template($template);
+
+ return $template;
+ }
+}
diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php
index d5ad8283d9..6191b9a315 100644
--- a/phpBB/phpbb/textformatter/s9e/factory.php
+++ b/phpBB/phpbb/textformatter/s9e/factory.php
@@ -78,7 +78,7 @@ class factory implements \phpbb\textformatter\cache_interface
'b' => '[B]{TEXT}[/B]',
'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]',
'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]',
- 'email' => '[EMAIL={EMAIL;useContent} subject={TEXT;optional;postFilter=rawurlencode} body={TEXT;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]',
+ 'email' => '[EMAIL={EMAIL;useContent} subject={TEXT1;optional;postFilter=rawurlencode} body={TEXT2;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]',
'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]',
'i' => '[I]{TEXT}[/I]',
'img' => '[IMG src={IMAGEURL;useContent}]',
@@ -132,6 +132,11 @@ class factory implements \phpbb\textformatter\cache_interface
protected $dispatcher;
/**
+ * @var \phpbb\log\log_interface
+ */
+ protected $log;
+
+ /**
* Constructor
*
* @param \phpbb\textformatter\data_access $data_access
@@ -139,11 +144,12 @@ class factory implements \phpbb\textformatter\cache_interface
* @param \phpbb\event\dispatcher_interface $dispatcher
* @param \phpbb\config\config $config
* @param \phpbb\textformatter\s9e\link_helper $link_helper
+ * @param \phpbb\log\log_interface $log
* @param string $cache_dir Path to the cache dir
* @param string $cache_key_parser Cache key used for the parser
* @param string $cache_key_renderer Cache key used for the renderer
*/
- public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, $cache_dir, $cache_key_parser, $cache_key_renderer)
+ public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, \phpbb\log\log_interface $log, $cache_dir, $cache_key_parser, $cache_key_renderer)
{
$this->link_helper = $link_helper;
$this->cache = $cache;
@@ -153,6 +159,7 @@ class factory implements \phpbb\textformatter\cache_interface
$this->config = $config;
$this->data_access = $data_access;
$this->dispatcher = $dispatcher;
+ $this->log = $log;
}
/**
@@ -266,12 +273,13 @@ class factory implements \phpbb\textformatter\cache_interface
->addParameterByName('logger')
->addParameterByName('max_img_height')
->addParameterByName('max_img_width')
- ->markAsSafeAsURL();
+ ->markAsSafeAsURL()
+ ->setJS('UrlFilter.filter');
// Add default BBCodes
foreach ($this->get_default_bbcodes($configurator) as $bbcode)
{
- $configurator->BBCodes->addCustom($bbcode['usage'], $bbcode['template']);
+ $this->add_bbcode($configurator, $bbcode['usage'], $bbcode['template']);
}
if (isset($configurator->tags['QUOTE']))
{
@@ -298,17 +306,7 @@ class factory implements \phpbb\textformatter\cache_interface
},
$row['bbcode_tpl']
);
-
- try
- {
- $configurator->BBCodes->addCustom($row['bbcode_match'], new UnsafeTemplate($tpl));
- }
- catch (\Exception $e)
- {
- /**
- * @todo log an error?
- */
- }
+ $this->add_bbcode($configurator, $row['bbcode_match'], $tpl);
}
// Load smilies
@@ -355,9 +353,15 @@ class factory implements \phpbb\textformatter\cache_interface
$configurator->registeredVars['max_img_width'] = 0;
// Load the Emoji plugin and modify its tag's template to obey viewsmilies
- $configurator->Emoji->omitImageSize();
- $configurator->Emoji->useSVG();
$tag = $configurator->Emoji->getTag();
+ $tag->template = '<xsl:choose>
+ <xsl:when test="@tseq">
+ <img alt="{.}" class="emoji" draggable="false" src="//twemoji.maxcdn.com/2/svg/{@tseq}.svg"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <img alt="{.}" class="emoji" draggable="false" src="https://cdn.jsdelivr.net/gh/s9e/emoji-assets-twemoji@11.2/dist/svgz/{@seq}.svgz"/>
+ </xsl:otherwise>
+ </xsl:choose>';
$tag->template = '<xsl:choose><xsl:when test="$S_VIEWSMILIES">' . str_replace('class="emoji"', 'class="emoji smilies"', $tag->template) . '</xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose>';
/**
@@ -420,6 +424,26 @@ class factory implements \phpbb\textformatter\cache_interface
}
/**
+ * Add a BBCode to given configurator
+ *
+ * @param Configurator $configurator
+ * @param string $usage
+ * @param string $template
+ * @return void
+ */
+ protected function add_bbcode(Configurator $configurator, $usage, $template)
+ {
+ try
+ {
+ $configurator->BBCodes->addCustom($usage, new UnsafeTemplate($template));
+ }
+ catch (\Exception $e)
+ {
+ $this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]);
+ }
+ }
+
+ /**
* Configure the Autolink / Autoemail plugins used to linkify text
*
* @param \s9e\TextFormatter\Configurator $configurator
diff --git a/phpBB/phpbb/textformatter/s9e/link_helper.php b/phpBB/phpbb/textformatter/s9e/link_helper.php
index 0f44603dec..483794a83e 100644
--- a/phpBB/phpbb/textformatter/s9e/link_helper.php
+++ b/phpBB/phpbb/textformatter/s9e/link_helper.php
@@ -23,14 +23,16 @@ class link_helper
*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
* @param \s9e\TextFormatter\Parser $parser Parser
- * @return bool Whether the tag is valid
+ * @return void
*/
public function cleanup_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser)
{
// Invalidate if the content of the tag matches the text attribute
$text = substr($parser->getText(), $tag->getPos(), $tag->getLen());
-
- return ($text !== $tag->getAttribute('text'));
+ if ($text === $tag->getAttribute('text'))
+ {
+ $tag->invalidate();
+ }
}
/**
@@ -40,7 +42,7 @@ class link_helper
*
* @param \s9e\TextFormatter\Parser\Tag $tag URL tag (start tag)
* @param \s9e\TextFormatter\Parser $parser Parser
- * @return bool Always true to indicate that the tag is valid
+ * @return void
*/
public function generate_link_text_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser)
{
@@ -49,7 +51,7 @@ class link_helper
// the [url] BBCode when its content is used for the URL
if (!$tag->getEndTag() || !$this->should_shorten($tag, $parser->getText()))
{
- return true;
+ return;
}
// Capture the text between the start tag and its end tag
@@ -58,10 +60,10 @@ class link_helper
$length = $end - $start;
$text = substr($parser->getText(), $start, $length);
- // Create a tag that consumes the link's text
- $parser->addSelfClosingTag('LINK_TEXT', $start, $length)->setAttribute('text', $text);
-
- return true;
+ // Create a tag that consumes the link's text and make it depends on this tag
+ $link_text_tag = $parser->addSelfClosingTag('LINK_TEXT', $start, $length);
+ $link_text_tag->setAttribute('text', $text);
+ $tag->cascadeInvalidationTo($link_text_tag);
}
/**
@@ -84,7 +86,7 @@ class link_helper
*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
* @param string $board_url Forum's root URL (with trailing slash)
- * @return bool Always true to indicate that the tag is valid
+ * @return void
*/
public function truncate_local_url(\s9e\TextFormatter\Parser\Tag $tag, $board_url)
{
@@ -93,15 +95,13 @@ class link_helper
{
$tag->setAttribute('text', substr($text, strlen($board_url)));
}
-
- return true;
}
/**
* Truncate the replacement text set in a LINK_TEXT tag
*
* @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag
- * @return bool Always true to indicate that the tag is valid
+ * @return void
*/
public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag)
{
@@ -109,10 +109,7 @@ class link_helper
if (utf8_strlen($text) > 55)
{
$text = utf8_substr($text, 0, 39) . ' ... ' . utf8_substr($text, -10);
+ $tag->setAttribute('text', $text);
}
-
- $tag->setAttribute('text', $text);
-
- return true;
}
}
diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php
index 05ddfffa11..3698dca224 100644
--- a/phpBB/phpbb/textformatter/s9e/parser.php
+++ b/phpBB/phpbb/textformatter/s9e/parser.php
@@ -13,7 +13,7 @@
namespace phpbb\textformatter\s9e;
-use s9e\TextFormatter\Parser\BuiltInFilters;
+use s9e\TextFormatter\Parser\AttributeFilters\UrlFilter;
use s9e\TextFormatter\Parser\Logger;
/**
@@ -196,7 +196,7 @@ class parser implements \phpbb\textformatter\parser_interface
public function get_errors()
{
$errors = array();
- foreach ($this->parser->getLogger()->get() as $entry)
+ foreach ($this->parser->getLogger()->getLogs() as $entry)
{
list(, $msg, $context) = $entry;
@@ -365,7 +365,7 @@ class parser implements \phpbb\textformatter\parser_interface
static public function filter_img_url($url, array $url_config, Logger $logger, $max_height, $max_width)
{
// Validate the URL
- $url = BuiltInFilters::filterUrl($url, $url_config, $logger);
+ $url = UrlFilter::filter($url, $url_config, $logger);
if ($url === false)
{
return false;
diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php
index 27d7bc1f27..2ee6ea2cb3 100644
--- a/phpBB/phpbb/textreparser/base.php
+++ b/phpBB/phpbb/textreparser/base.php
@@ -153,8 +153,8 @@ abstract class base implements reparser_interface
{
// Look for the closing tag inside of a e element, in an element of the same name, e.g.
// <e>[/url]</e></URL>
- $match = '<e>[/' . $bbcode . ']</e></' . strtoupper($bbcode) . '>';
- if (strpos($record['text'], $match) !== false)
+ $match = '<e>[/' . $bbcode . ']</e></' . $bbcode . '>';
+ if (stripos($record['text'], $match) !== false)
{
return true;
}
diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php
index 76d30655c9..5ca8bb063b 100644
--- a/phpBB/phpbb/textreparser/plugins/poll_title.php
+++ b/phpBB/phpbb/textreparser/plugins/poll_title.php
@@ -34,7 +34,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin
$sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
WHERE t.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .'
- AND t.poll_max_options > 0
+ AND t.poll_start > 0
AND p.post_id = t.topic_first_post_id';
return $sql;
diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php
index 7149513fd9..eadd2b3273 100644
--- a/phpBB/phpbb/tree/nestedset.php
+++ b/phpBB/phpbb/tree/nestedset.php
@@ -533,7 +533,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- $diff = ' + ' . ($row[$this->column_right_id] - (int) $item[$this->column_left_id] + 1);
+ $diff = ' + ' . ((int) $row[$this->column_right_id] - (int) $item[$this->column_left_id] + 1);
}
$sql = 'UPDATE ' . $this->table_name . '
@@ -706,7 +706,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface
{
$acquired_new_lock = $this->acquire_lock();
- $diff = sizeof($subset_items) * 2;
+ $diff = count($subset_items) * 2;
$sql_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items);
$sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
@@ -746,7 +746,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface
*/
protected function prepare_adding_subset(array $subset_items, array $new_parent)
{
- $diff = sizeof($subset_items) * 2;
+ $diff = count($subset_items) * 2;
$sql_not_subset_items = $this->db->sql_in_set($this->column_item_id, $subset_items, true);
$set_left_id = $this->db->sql_case($this->column_left_id . ' > ' . (int) $new_parent[$this->column_right_id], $this->column_left_id . ' + ' . $diff, $this->column_left_id);
diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php
index d4097f53ee..7363290e11 100644
--- a/phpBB/phpbb/user.php
+++ b/phpBB/phpbb/user.php
@@ -189,6 +189,9 @@ class user extends \phpbb\session
/**
* Event to load language files and modify user data on every page
*
+ * Note: To load language file with this event, see description
+ * of lang_set_ext variable.
+ *
* @event core.user_setup
* @var array user_data Array with user's data row
* @var string user_lang_name Basename of the user's langauge
@@ -278,24 +281,6 @@ class user extends \phpbb\session
$db->sql_freeresult($result);
}
- // User has wrong style
- if (!$this->style && $style_id == $this->data['user_style'])
- {
- $style_id = $this->data['user_style'] = $config['default_style'];
-
- $sql = 'UPDATE ' . USERS_TABLE . "
- SET user_style = $style_id
- WHERE user_id = {$this->data['user_id']}";
- $db->sql_query($sql);
-
- $sql = 'SELECT *
- FROM ' . STYLES_TABLE . " s
- WHERE s.style_id = $style_id";
- $result = $db->sql_query($sql, 3600);
- $this->style = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
- }
-
if (!$this->style)
{
trigger_error('NO_STYLE_DATA', E_USER_ERROR);
@@ -358,7 +343,7 @@ class user extends \phpbb\session
}
// Is board disabled and user not an admin or moderator?
- if ($config['board_disable'] && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
+ if ($config['board_disable'] && !defined('IN_INSTALL') && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
{
if ($this->data['is_bot'])
{
diff --git a/phpBB/phpbb/user_loader.php b/phpBB/phpbb/user_loader.php
index cdd28329db..9297450f3e 100644
--- a/phpBB/phpbb/user_loader.php
+++ b/phpBB/phpbb/user_loader.php
@@ -64,8 +64,9 @@ class user_loader
* Load user helper
*
* @param array $user_ids
+ * @param array $ignore_types user types to ignore
*/
- public function load_users(array $user_ids)
+ public function load_users(array $user_ids, array $ignore_types = array())
{
$user_ids[] = ANONYMOUS;
@@ -75,11 +76,12 @@ class user_loader
// Do not load users we already have in $this->users
$user_ids = array_diff($user_ids, array_keys($this->users));
- if (sizeof($user_ids))
+ if (count($user_ids))
{
$sql = 'SELECT *
FROM ' . $this->users_table . '
- WHERE ' . $this->db->sql_in_set('user_id', $user_ids);
+ WHERE ' . $this->db->sql_in_set('user_id', $user_ids) . '
+ AND ' . $this->db->sql_in_set('user_type', $ignore_types, true, true);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))