Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12916 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16807 invoked by uid 1010); 20 Sep 2004 17:36:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 16749 invoked by uid 1007); 20 Sep 2004 17:36:09 -0000 Message-ID: <20040920173608.16748.qmail@pb1.pair.com> To: internals@lists.php.net Date: Mon, 20 Sep 2004 10:34:59 -0700 Lines: 40 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Posted-By: 68.26.112.164 Subject: User defined session handlers From: pollita@php.net ("Sara Golemon") The sessions extension allows customizable modules for session storage via callbacks. Module callbacks expect SUCCESS or FAILURE as return values as illustrated in the use of session opener below: if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name) TSRMLS_CC) == FAILURE) { However, in the user defined session module (ext/session/mod_user.c), each callback (after calling the user defined function) terminates with a call to the "FINISH" macro which, if no retval was given returns SUCCESS or FAILURE depending on whether or not the user callback worked (fine and dandy). #define FINISH \ if (retval) { \ convert_to_long(retval); \ ret = Z_LVAL_P(retval); \ zval_ptr_dtor(&retval); \ } \ return ret However, if a return value is given, then the lval of that return value is used instead. Now, say true was given to indicate that the callback succeeded, true's lval is 1. Remembering that: #define SUCCESS 0 #define FAILURE 1 We see that the logic is flipped upside down. Here false means success and true means failure. Question: Should the macro be fixed to match documentation? Or should documentation be fixed to match behavior? Option C: Am I out of my mind and missed something obvious which means that all this actually works. -Sara