php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59839 Adding report_errors parameter to session handler
Submitted: 2011-07-05 17:48 UTC Modified: 2021-03-25 16:31 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:3 (100.0%)
From: mkoppanen@php.net Assigned: cmb (profile)
Status: Closed Package: memcache (PECL)
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mkoppanen@php.net
New email:
PHP Version: OS:

 

 [2011-07-05 17:48 UTC] mkoppanen@php.net
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 **) &param) != FAILURE) {
+                                       convert_to_boolean_ex(param);
+                                       if (Z_BVAL_PP(param)) {
+                                               pool->failure_callback = &php_mmc_session_failure_callback;
+                                       }
+                               }
+
                                zval_ptr_dtor(&params);
                        }
 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [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
The official bug tracker for PECL/memcache is now at
<https://github.com/websupport-sk/pecl-memcache/issues>.

So, if this is still an issue with either of the current memcache
versions (4 or 8), please file an issue there.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 02:01:36 2025 UTC