Skip to content

Commit

Permalink
Remove specific code for PHP < 7.3
Browse files Browse the repository at this point in the history
Fixes #32808
  • Loading branch information
dregad committed Nov 4, 2023
1 parent c2ba77b commit 8eea8d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
20 changes: 0 additions & 20 deletions core/gpc_api.php
Expand Up @@ -391,16 +391,6 @@ function gpc_set_cookie( $p_name, $p_value, $p_expire = false, $p_path = null, $
$p_samesite = config_get_global( 'cookie_samesite' );
}

if ( PHP_VERSION_ID < 70300 ) {
# Take advantage of PHP bug #69948 (fixed in PHP 7.3) to inject the
# Samesite attribute in the cookie's path
if( $p_samesite ) {
$p_path .= '; samesite=' . $p_samesite;
}
return setcookie( $p_name, $p_value, $p_expire, $p_path, $p_domain, $g_cookie_secure_flag_enabled, $p_httponly );
}

# Use new function signature available since PHP 7.3
$t_options = array(
'expires' => $p_expire,
'path' => $p_path,
Expand Down Expand Up @@ -441,16 +431,6 @@ function gpc_clear_cookie( $p_name, $p_path = null, $p_domain = null, $p_samesit
# Cookie “<PREFIX>_collapse_settings” has been rejected because it is already expired.
# apparently this is due to bug https://bugzilla.mozilla.org/show_bug.cgi?id=1676651

if( PHP_VERSION_ID < 70300 ) {
# Take advantage of PHP bug #69948 (fixed in PHP 7.3) to inject the
# Samesite attribute in the cookie's path
if( $p_samesite ) {
$p_path .= '; samesite=' . $p_samesite;
}
return setcookie( $p_name, '', 1, $p_path, $p_domain );
}

# Use new function signature available since PHP 7.3
$t_options = array(
'expires' => 1,
'path' => $p_path,
Expand Down
25 changes: 9 additions & 16 deletions core/session_api.php
Expand Up @@ -130,22 +130,15 @@ function __construct( $p_session_id = null ) {
$t_path = config_get_global( 'cookie_path' );
$t_domain = config_get_global( 'cookie_domain' );
$t_samesite = config_get_global( 'cookie_samesite' );
if (PHP_VERSION_ID < 70300) {
# Take advantage of PHP bug #69948 (fixed in PHP 7.3) to inject the
# Samesite attribute in the cookie's path
$t_path .= '; samesite=' . $t_samesite;
session_set_cookie_params( 0, $t_path, $t_domain, $g_cookie_secure_flag_enabled, true );
} else {
$t_options = array(
'lifetime' => 0,
'path' => $t_path,
'domain' => $t_domain,
'samesite' => $t_samesite,
'secure' => $g_cookie_secure_flag_enabled,
'httponly' => true,
);
session_set_cookie_params( $t_options );
}
$t_options = array(
'lifetime' => 0,
'path' => $t_path,
'domain' => $t_domain,
'samesite' => $t_samesite,
'secure' => $g_cookie_secure_flag_enabled,
'httponly' => true,
);
session_set_cookie_params( $t_options );

# Handle existent session ID
if( !is_null( $p_session_id ) ) {
Expand Down

0 comments on commit 8eea8d2

Please sign in to comment.