Date: 11/06/99
- Next message: kk: "[PHPLIB-DEV] cvs commit"
- Previous message: Kristian Koehntopp: "Re: [PHPLIB-DEV] Is there a FAQ or HOWTO"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: kk
Date: Sat Nov 6 21:40:55 1999
Modified files:
php-lib/CHANGES
php-lib/php/session.inc
Log message:
Session mods as documented in CHANGES.
Index: php-lib/CHANGES
diff -u php-lib/CHANGES:1.142 php-lib/CHANGES:1.143
--- php-lib/CHANGES:1.142 Sat Nov 6 21:03:49 1999
+++ php-lib/CHANGES Sat Nov 6 21:40:24 1999
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.142 1999/11/06 20:03:49 kk Exp $
+$Id: CHANGES,v 1.143 1999/11/06 20:40:24 kk Exp $
06-Nov-1999 kk
- Menu_Button now has mouseover capabilities; button.php3
@@ -8,6 +8,13 @@
I integrated an auth_sql.inc into the distribution. Incompatible
changes will follow: auth_sql.inc works with a new auth_user table,
which integrates the old auth_user and auth_user_md5 tables.
+ - Alternative serializer() in Session modelled after input from
+ Teo and Sascha. The new serializer produces a longer data
+ representation and still requires eval. I would like to see this
+ benchmarked and tested.
+ - Change to the traditional serializer: We now serialize all
+ slots in objects that have no persistent_slots defined. Code
+ from Boris.
05-Nov-1999 kir
- Changed decoding function for "slashes" mode from stripslashes to strval
Index: php-lib/php/session.inc
diff -u php-lib/php/session.inc:1.53 php-lib/php/session.inc:1.54
--- php-lib/php/session.inc:1.53 Thu Nov 4 00:36:24 1999
+++ php-lib/php/session.inc Sat Nov 6 21:40:24 1999
@@ -5,7 +5,7 @@
* Copyright (c) 1998,1999 NetUSE GmbH
* Boris Erdmann, Kristian Koehntopp
*
- * $Id: session.inc,v 1.53 1999/11/03 23:36:24 athompso Exp $
+ * $Id: session.inc,v 1.54 1999/11/06 20:40:24 kk Exp $
*
*/
@@ -264,45 +264,107 @@
## a variable $classname (containing the name of the class as string)
## and a variable $persistent_slots (containing the names of the slots
## to be saved as an array of strings).
- ##
- ## You don't need to know...
- function serialize($prefix, $str) {
+
+ ## helper function for alternative serializer
+ function u($v) {
+ return unserialize(stripslashes($v));
+ }
+
+ ## this alternative serializer may be faster, but produces
+ ## longer serialized data.
+ function alternative_serialize($var, &$ser) {
+ static $k;
+
+ eval('$k = gettype($'.$var.');');
+ switch ( $k ) {
+
+ case "integer":
+ case "double":
+ case "string":
+ case "array":
+ eval("\$l = \$$var;");
+ $ser .= "\$$var=\$this->u('".addslashes(serialize($l))."');";
+ break;
+
+ case "object":
+
+ eval('
+ $ser.="$$var=new ".$'.$var.'->classname.";";
+ if ( is_array($'.$var.'->persistent_slots) ) {
+ reset($'.$var.'->persistent_slots);
+ while ( list(,$k) = each($'.$var.'->persistent_slots) ) {
+ $this->serialize( "${var}->".$k, $ser );
+ }
+ } else {
+ reset($'.$var.');
+ while ( list($k) = each($'.$var.') ) {
+ $this->serialize( "${var}->".$k, $ser );
+ }
+ }
+
+ ');
+
+ break;
+ default:
+ ;
+ break;
+ }
+ }
+
+ ## traditional serializer (patched 'object' handler)
+ function serialize($var, &$str) {
static $t,$l,$k;
- ## Determine the type of $$prefix
- eval("\$t = gettype(\$$prefix);");
+ ## Determine the type of $$var
+ eval("\$t = gettype(\$$var);");
switch ( $t ) {
case "array":
- ## $$prefix is an array. Enumerate the elements and serialize them.
- eval("reset(\$$prefix); \$l = gettype(list(\$k)=each(\$$prefix));");
- $str .= "\$$prefix = array(); ";
+ ## $$var is an array. Enumerate the elements and serialize them.
+ eval("reset(\$$var); \$l = gettype(list(\$k)=each(\$$var));");
+ $str .= "\$$var = array(); ";
while ( "array" == $l ) {
## Structural recursion
- $this->serialize($prefix."['".ereg_replace("([\\'])", "\\\\1", $k)."']", &$str);
- eval("\$l = gettype(list(\$k)=each(\$$prefix));");
+ $this->serialize($var."['".ereg_replace("([\\'])", "\\\\1", $k)."']", $str);
+ eval("\$l = gettype(list(\$k)=each(\$$var));");
}
break;
case "object":
- ## $$prefix is an object. Enumerate the slots and serialize them.
- eval("\$k = \$${prefix}->classname; \$l = reset(\$${prefix}->persistent_slots);");
- $str.="\$$prefix = new $k; ";
- while ( $l ) {
- ## Structural recursion.
- $this->serialize($prefix."->".$l,&$str);
- eval("\$l = next(\$${prefix}->persistent_slots);");
- }
-
+ eval('
+ $str.="$$var=new ".$'.$var.'->classname.";";
+ if ( is_array($'.$var.'->persistent_slots) ) {
+ reset($'.$var.'->persistent_slots);
+ while ( list(,$k) = each($'.$var.'->persistent_slots) ) {
+ $this->serialize( "${var}->".$k, $str );
+ }
+ } else {
+ reset($'.$var.');
+ while ( list($k) = each($'.$var.') ) {
+ $this->serialize( "${var}->".$k, $str );
+ }
+ }
+
+ ');
+
+## old 'object' handler (will be gone)
+## ## $$var is an object. Enumerate the slots and serialize them.
+## eval("\$k = \$${var}->classname; \$l = reset(\$${var}->persistent_slots);");
+## $str.="\$$var = new $k; ";
+## while ( $l ) {
+## ## Structural recursion.
+## $this->serialize($var."->".$l, $str);
+## eval("\$l = next(\$${var}->persistent_slots);");
+## }
break;
default:
- ## $$prefix is an atom. Extract it to $l, then generate code.
- eval("\$l = \$$prefix;");
- $str.="\$$prefix = '".ereg_replace("([\\'])", "\\\\1", $l)."'; ";
-
-
+ ## $$var is an atom. Extract it to $l, then generate code.
+ eval("\$l = \$$var;");
+ $str.="\$$var = '".ereg_replace("([\\'])", "\\\\1", $l)."'; ";
break;
}
+
+# print "<br>var $var t $t str $str<br>\n";
}
function get_lock() {
@@ -345,7 +407,6 @@
$this->get_lock();
$vals = $this->that->ac_get_value($this->id, $this->name);
-
eval(sprintf(";%s",$vals));
}
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: kk: "[PHPLIB-DEV] cvs commit"
- Previous message: Kristian Koehntopp: "Re: [PHPLIB-DEV] Is there a FAQ or HOWTO"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

