Skip to content

Commit a0de1ac

Browse files
committed
ext/session: refactor session_write_close()
By making the underlying function return a bool and not do duplicate checks
1 parent 8926dc0 commit a0de1ac

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES
9797
. Dropped session_options parameter from all methods in mysqlnd_auth.
9898
The same information is present in conn->options and should be used instead.
9999

100+
- ext/session:
101+
. php_session_flush() now returns a bool rather than a zend_result.
102+
100103
- ext/standard:
101104
. _php_error_log() now has a formal return type of zend_result.
102105
. _php_error_log() now accepts zend_string* values instead of char*.

ext/session/php_session.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ PHPAPI zend_result php_session_register_serializer(const char *name,
263263
zend_result (*decode)(PS_SERIALIZER_DECODE_ARGS));
264264

265265
PHPAPI zend_result php_session_start(void);
266-
PHPAPI zend_result php_session_flush(bool write);
266+
PHPAPI bool php_session_flush(bool write);
267267
PHPAPI php_session_status php_get_session_status(void);
268268

269269
PHPAPI const ps_module *_php_find_ps_module(const char *name);

ext/session/session.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,14 +1720,14 @@ PHPAPI zend_result php_session_start(void)
17201720
return SUCCESS;
17211721
}
17221722

1723-
PHPAPI zend_result php_session_flush(bool write)
1723+
PHPAPI bool php_session_flush(bool write)
17241724
{
17251725
if (PS(session_status) == php_session_active) {
17261726
php_session_save_current_state(write);
17271727
PS(session_status) = php_session_none;
1728-
return SUCCESS;
1728+
return true;
17291729
}
1730-
return FAILURE;
1730+
return false;
17311731
}
17321732

17331733
PHPAPI php_session_status php_get_session_status(void)
@@ -2724,11 +2724,7 @@ PHP_FUNCTION(session_write_close)
27242724
RETURN_THROWS();
27252725
}
27262726

2727-
if (PS(session_status) != php_session_active) {
2728-
RETURN_FALSE;
2729-
}
2730-
php_session_flush(true);
2731-
RETURN_TRUE;
2727+
RETURN_BOOL(php_session_flush(true));
27322728
}
27332729

27342730
/* Abort session and end session. Session data will not be written */

0 commit comments

Comments
 (0)