Skip to main content
Topic: DetectBrowser() (Read 1903 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

DetectBrowser()

It is called in numerous locations but the only place it seems that it needs to be called is in isBrowser(). I prefer to lazy load it. So remove it from everywhere else.

The only place that I can see that would need to be fixed would be Debug.class.php:
Code: [Select]
		$this->_system['browser'] = $context['browser_body_id'] . ' <em>(' . implode('</em>, <em>', array_reverse(array_keys($context['browser'], true))) . ')</em>';

Also, any place where isBrowser($browser) is used, they should be changed to $browser->is$browser() and isPossibleRobot() should be added to the class

Re: DetectBrowser()

Reply #1

Here's the big one that doesn't make much sense now:

Code: [Select]
	// Attachments don't require the entire theme to be loaded.
if ($_req->getQuery('action') === 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest']) && (empty($maintenance) || allowedTo('admin_forum')))
detectBrowser();
// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
else
loadTheme();

Just invert that condition and make it for loadTheme() only. Everything else will load the browser info when it is needed. This would require some testing so I don't want to just go right in to it without knowing what tests would need to be done.