Revert "Fix DeviceDetectorHelper when no user agent (#7365)"

This reverts commit d0b0803a
This commit is contained in:
gevorgmansuryan 2025-01-06 01:13:22 +04:00
parent 4ec293a61f
commit b2fbfca9c4
3 changed files with 9 additions and 25 deletions

View File

@ -1,16 +1,6 @@
HumHub Changelog
================
1.17.0-beta.5 (Unreleased)
---------------------------------
- Fix #7365: `DeviceDetectorHelper::isMobile()` and `DeviceDetectorHelper::isTablet()` when no user agent
1.18 (TBA)
------------------------------
- Enh #7328: `Mailer`, `User` and `Cache` configs removed from `dynamic.php`
- Enh #7332: Optimized `DynamicConfig` to store and read database information only
- Enh #7338: Remove `horImageScrollOnMobile` config option
- Enh #7367: Changed Auto Debug Mode Detection
1.17.0-beta.4 (December 24, 2024)
---------------------------------

View File

@ -42,7 +42,7 @@ $logTargetConfig = [
$config = [
'name' => 'HumHub',
'version' => '1.17.0-beta.5',
'version' => '1.17.0-beta.4',
'minRecommendedPhpVersion' => '8.1',
'minSupportedPhpVersion' => '8.1',
'basePath' => dirname(__DIR__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR,

View File

@ -20,8 +20,11 @@ class DeviceDetectorHelper
{
public static function isMobile(): bool
{
$detect = new MobileDetect();
$detect->setUserAgent(Yii::$app->request->getUserAgent());
try {
return (bool)static::getMobileDetect()?->isMobile();
return $detect->isMobile();
} catch (MobileDetectException $e) {
Yii::error('DeviceDetectorHelper::isMobile() error: ' . $e->getMessage());
return false;
@ -30,26 +33,17 @@ class DeviceDetectorHelper
public static function isTablet(): bool
{
$detect = new MobileDetect();
$detect->setUserAgent(Yii::$app->request->getUserAgent());
try {
return (bool)static::getMobileDetect()?->isTablet();
return $detect->isTablet();
} catch (MobileDetectException $e) {
Yii::error('DeviceDetectorHelper::isTablet() error: ' . $e->getMessage());
return false;
}
}
private static function getMobileDetect(): ?MobileDetect
{
$userAgent = Yii::$app->request->getUserAgent();
if (!$userAgent) {
return null;
}
$detect = new MobileDetect();
$detect->setUserAgent($userAgent);
return $detect;
}
public static function isAppRequest(): bool
{
return