Skip to content

Commit

Permalink
Fix deprecation error in PHP 8.x when path or domain is null in setco…
Browse files Browse the repository at this point in the history
…okie()
  • Loading branch information
kijin committed Jun 16, 2023
1 parent 22abeb7 commit 180ed42
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion classes/context/Context.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public static function init()
$lang_type = preg_replace('/[^a-zA-Z0-9_-]/', '', $lang_type);
if ($set_lang_cookie)
{
setcookie('lang_type', $lang_type, time() + 86400 * 365, \RX_BASEURL, null, !!config('session.use_ssl_cookies'));
setcookie('lang_type', $lang_type, time() + 86400 * 365, \RX_BASEURL, '', !!config('session.use_ssl_cookies'));
}

if(!$lang_type || !isset($enabled_langs[$lang_type]))
Expand Down
4 changes: 2 additions & 2 deletions classes/mobile/Mobile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function isFromMobilePhone()
$m = Context::get('m');
$cookie = isset($_COOKIE['rx_uatype']) ? $_COOKIE['rx_uatype'] : null;
$uahash = base64_encode_urlsafe(md5($_SERVER['HTTP_USER_AGENT'] ?? '', true));
if (strncmp($cookie, $uahash . ':', strlen($uahash) + 1) !== 0)
if (strncmp($cookie ?? '', $uahash . ':', strlen($uahash) + 1) !== 0)
{
$cookie = null;
}
Expand All @@ -72,7 +72,7 @@ public static function isFromMobilePhone()
$uatype = $uahash . ':' . (self::$_ismobile ? '1' : '0');
if ($cookie !== $uatype)
{
setcookie('rx_uatype', $uatype, 0, \RX_BASEURL, null, !!config('session.use_ssl_cookies'));
setcookie('rx_uatype', $uatype, 0, \RX_BASEURL, '', !!config('session.use_ssl_cookies'));
$_COOKIE['rx_uatype'] = $uatype;
}

Expand Down
2 changes: 1 addition & 1 deletion common/framework/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ protected static function _setCookie($name, $value, array $options = [])
* @param string $domain (optional)
* @return bool
*/
protected static function _unsetCookie($name, $path = null, $domain = null)
protected static function _unsetCookie($name, $path = '', $domain = '')
{
$result = setcookie($name, 'deleted', time() - (86400 * 366), $path, $domain, false, false);
if ($result)
Expand Down
4 changes: 2 additions & 2 deletions common/framework/UA.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@ public static function setColorScheme(string $color_scheme)
if (in_array($color_scheme, ['light', 'dark']))
{
$_COOKIE['rx_color_scheme'] = $color_scheme;
setcookie('rx_color_scheme', $color_scheme, time() + 86400 * 365, \RX_BASEURL, null, !!config('session.use_ssl_cookies'));
setcookie('rx_color_scheme', $color_scheme, time() + 86400 * 365, \RX_BASEURL, '', !!config('session.use_ssl_cookies'));
}
else
{
unset($_COOKIE['rx_color_scheme']);
setcookie('rx_color_scheme', 'deleted', time() - 86400, \RX_BASEURL, null);
setcookie('rx_color_scheme', 'deleted', time() - 86400, \RX_BASEURL);
}
}
}

0 comments on commit 180ed42

Please sign in to comment.