From a2407ce978a5b65deec7be9e701be26ffb367bfd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 18 Dec 2018 21:06:51 +0100 Subject: [PATCH 1/3] [ticket/15911] Prevent errors when trying to delete from non-existent tables This can happen when migrating to the latest version from versions before 3.0.14. PHPBB3-15911 --- phpBB/includes/functions_user.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d019b867fa..26bb987561 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -666,8 +666,29 @@ function user_delete($mode, $user_ids, $retain_username = true) delete_posts('poster_id', $user_ids); } - $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE, PRIVMSGS_FOLDER_TABLE, PRIVMSGS_RULES_TABLE, $phpbb_container->getParameter('tables.auth_provider_oauth_token_storage'), $phpbb_container->getParameter('tables.auth_provider_oauth_states'), $phpbb_container->getParameter('tables.auth_provider_oauth_account_assoc')); + $table_ary = [ + USERS_TABLE, + USER_GROUP_TABLE, + TOPICS_WATCH_TABLE, + FORUMS_WATCH_TABLE, + ACL_USERS_TABLE, + TOPICS_TRACK_TABLE, + TOPICS_POSTED_TABLE, + FORUMS_TRACK_TABLE, + PROFILE_FIELDS_DATA_TABLE, + MODERATOR_CACHE_TABLE, + DRAFTS_TABLE, + BOOKMARKS_TABLE, + SESSIONS_KEYS_TABLE, + PRIVMSGS_FOLDER_TABLE, + PRIVMSGS_RULES_TABLE, + $phpbb_container->getParameter('tables.auth_provider_oauth_token_storage'), + $phpbb_container->getParameter('tables.auth_provider_oauth_states'), + $phpbb_container->getParameter('tables.auth_provider_oauth_account_assoc') + ]; + // Ignore errors on deleting from non-existent tables, e.g. when migrating + $db->sql_return_on_error(true); // Delete the miscellaneous (non-post) data for the user foreach ($table_ary as $table) { @@ -675,6 +696,7 @@ function user_delete($mode, $user_ids, $retain_username = true) WHERE " . $user_id_sql; $db->sql_query($sql); } + $db->sql_return_on_error(); $cache->destroy('sql', MODERATOR_CACHE_TABLE); From 304750a88b5a1c20cbfebbe97f71c65cd464d374 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 18 Dec 2018 21:07:41 +0100 Subject: [PATCH 2/3] [ticket/15911] Resolve warnings when updating from 3.0.0 to latest PHPBB3-15911 --- phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php | 7 +++++-- phpBB/phpbb/notification/method/email.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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 c018adab46..8838c55620 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 @@ -58,9 +58,12 @@ 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/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']); } /** From 68489b2c135a1ec75d142851e82ee9683f8177db Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 18 Dec 2018 21:28:15 +0100 Subject: [PATCH 3/3] [ticket/15911] Add missing braces PHPBB3-15911 --- phpBB/phpbb/db/migration/data/v30x/release_3_0_8_rc1.php | 2 ++ 1 file changed, 2 insertions(+) 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 8838c55620..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 @@ -61,7 +61,9 @@ class release_3_0_8_rc1 extends \phpbb\db\migration\migration while ($row = $this->db->sql_fetchrow($result)) { if (empty($row['lang_dir'])) + { continue; + } $lang_dir = basename($row['lang_dir']);