From 3e23adf030329fac3746251c54c85d3061ec69d1 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sun, 1 Sep 2019 09:19:33 +0200 Subject: [ticket/16144] Provide extra fallback to board's default style for $user PHPBB3-16144 --- phpBB/language/en/common.php | 2 +- phpBB/phpbb/user.php | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 8df8fc630b..4ea3f015a9 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -519,7 +519,7 @@ $lang = array_merge($lang, array( 'NO_POSTS_TIME_FRAME' => 'No posts exist inside this topic for the selected time frame.', 'NO_FEED_ENABLED' => 'Feeds are not available on this board.', 'NO_FEED' => 'The requested feed is not available.', - 'NO_STYLE_DATA' => 'Could not get style data', + 'NO_STYLE_DATA' => 'Could not get style data for user_style %s and set for user_id %s', 'NO_STYLE_CFG' => 'Could not get the style configuration file for: %s', 'NO_SUBJECT' => 'No subject specified', // Used for posts having no subject defined but displayed within management pages. 'NO_SUCH_SEARCH_MODULE' => 'The specified search backend doesn’t exist.', diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 7363290e11..8e2b278650 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -281,9 +281,48 @@ class user extends \phpbb\session $db->sql_freeresult($result); } + /** + * Something went very bad this time. + * Fallback to board's default style upon its strict verification. + */ + if (!$this->style) + { + /** Verify default style exists in the database */ + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_id = ' . (int) $config['default_style']; + $result = $db->sql_query($sql); + $style_id = (int) $db->sql_fetchfield('style_id'); + $db->sql_freeresult($result); + + $style_id = $style_id ?: false; + + if ($style_id > 0) + { + $db->sql_transaction('begin'); + + /** Update $user row */ + $sql = 'SELECT * + FROM ' . STYLES_TABLE . ' + WHERE style_id = ' . (int) $config['default_style']; + $result = $db->sql_query($sql); + $this->style = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + /** Update user style preference */ + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = ' . (int) $style_id . ' + WHERE user_id = ' . (int) $this->data['user_id']; + $db->sql_query($sql); + + $db->sql_transaction('commit'); + } + } + + /** This should never happens */ if (!$this->style) { - trigger_error('NO_STYLE_DATA', E_USER_ERROR); + trigger_error($this->language->lang('NO_STYLE_DATA', $this->data['user_style'], $this->data['user_id']), E_USER_ERROR); } // Now parse the cfg file and cache it -- cgit v1.2.1 From 942bfd65065e753cc602cce4976c7076aba4e7cb Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sun, 22 Sep 2019 20:10:53 +0200 Subject: [ticket/16144] As per request PHPBB3-16144 --- phpBB/phpbb/user.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 8e2b278650..e6e8e7f167 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -281,13 +281,10 @@ class user extends \phpbb\session $db->sql_freeresult($result); } - /** - * Something went very bad this time. - * Fallback to board's default style upon its strict verification. - */ + // Fallback to board's default style if (!$this->style) { - /** Verify default style exists in the database */ + // Verify default style exists in the database $sql = 'SELECT style_id FROM ' . STYLES_TABLE . ' WHERE style_id = ' . (int) $config['default_style']; @@ -295,13 +292,11 @@ class user extends \phpbb\session $style_id = (int) $db->sql_fetchfield('style_id'); $db->sql_freeresult($result); - $style_id = $style_id ?: false; - if ($style_id > 0) { $db->sql_transaction('begin'); - /** Update $user row */ + // Update $user row $sql = 'SELECT * FROM ' . STYLES_TABLE . ' WHERE style_id = ' . (int) $config['default_style']; @@ -309,7 +304,7 @@ class user extends \phpbb\session $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result); - /** Update user style preference */ + // Update user style preference $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = ' . (int) $style_id . ' WHERE user_id = ' . (int) $this->data['user_id']; @@ -319,7 +314,7 @@ class user extends \phpbb\session } } - /** This should never happens */ + // This should never happens if (!$this->style) { trigger_error($this->language->lang('NO_STYLE_DATA', $this->data['user_style'], $this->data['user_id']), E_USER_ERROR); -- cgit v1.2.1 From a84e4b5ab4cdbbb241004e5c1621b42490e6ba94 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Mon, 23 Sep 2019 18:54:45 +0200 Subject: [ticket/16144] Provide extra fallback to board's default style for $user PHPBB3-16144 --- phpBB/phpbb/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index e6e8e7f167..9817e40edb 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -314,7 +314,7 @@ class user extends \phpbb\session } } - // This should never happens + // This should never happen if (!$this->style) { trigger_error($this->language->lang('NO_STYLE_DATA', $this->data['user_style'], $this->data['user_id']), E_USER_ERROR); -- cgit v1.2.1