|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-03-25 16:31 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2021-03-25 16:31 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 21 10:00:01 2025 UTC |
Description: ------------ This adds additional diagnostics for memcache(d) errors: Output with the patch when memcached is down: # php -d"session.save_path='tcp://localhost:11211?report_errors=1'" -r 'session_start ();' Warning: session_start(): Server localhost (tcp 11211, udp 0) failed with: Connection refused (111) in Command line code on line 1 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at Command line code:1) in Command line code on line 1 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at Command line code:1) in Command line code on line 1 Warning: Unknown: Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct (tcp://localhost:11211?report_errors=1) in Unknown on line 0 Without the patch: # php -d"session.save_path='tcp://localhost:11211'" -r 'session_start ();' Warning: Unknown: Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct (tcp://localhost:11211?report_errors=0) in Unknown on line 0 Reproduce code: --------------- Index: memcache_session.c =================================================================== --- memcache_session.c (revision 312942) +++ memcache_session.c (working copy) @@ -39,6 +39,12 @@ PS_MOD(memcache) }; +static void php_mmc_session_failure_callback(mmc_pool_t *pool, mmc_t *mmc, void *param TSRMLS_DC) /* {{{ */ +{ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Server %s (tcp %d, udp %d) failed with: %s (%d)", + mmc->host, mmc->tcp.port, mmc->udp.port, mmc->error, mmc->errnum); +} + /* {{{ PS_OPEN_FUNC */ PS_OPEN_FUNC(memcache) @@ -122,6 +128,13 @@ retry_interval = Z_LVAL_PP(param); } + if (zend_hash_find(Z_ARRVAL_P(params), "report_errors", sizeof("report_errors"), (void **) ¶m) != FAILURE) { + convert_to_boolean_ex(param); + if (Z_BVAL_PP(param)) { + pool->failure_callback = &php_mmc_session_failure_callback; + } + } + zval_ptr_dtor(¶ms); }