diff options
| author | 3D-I <480857+3D-I@users.noreply.github.com> | 2019-09-01 09:19:33 +0200 | 
|---|---|---|
| committer | 3D-I <480857+3D-I@users.noreply.github.com> | 2019-09-01 09:20:22 +0200 | 
| commit | 3e23adf030329fac3746251c54c85d3061ec69d1 (patch) | |
| tree | 74549a811c0c3ba764dbd10e7462b541adf254fa /phpBB/phpbb | |
| parent | 9c15594fe498a8a1640bb89aa0c93800918a9798 (diff) | |
| download | forums-3e23adf030329fac3746251c54c85d3061ec69d1.tar forums-3e23adf030329fac3746251c54c85d3061ec69d1.tar.gz forums-3e23adf030329fac3746251c54c85d3061ec69d1.tar.bz2 forums-3e23adf030329fac3746251c54c85d3061ec69d1.tar.xz forums-3e23adf030329fac3746251c54c85d3061ec69d1.zip | |
[ticket/16144] Provide extra fallback to board's default style for $user
PHPBB3-16144
Diffstat (limited to 'phpBB/phpbb')
| -rw-r--r-- | phpBB/phpbb/user.php | 41 | 
1 files changed, 40 insertions, 1 deletions
| 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 | 
