RE: [phplib] Call Time Pass By Reference PROBLEM. From: Ignatius Teo (eyrie88 <email protected>)
Date: 01/15/01

Hi,

I got around this by changing the following two functions below. Basically
you can remove the call by reference construct &$str by resetting $str to
its returned value:

  function serialize($prefix, $str) {
    static $t,$l,$k;

    ## Determine the type of $$prefix
    eval("\$t = gettype(\$$prefix);");
    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(); ";
        while ( "array" == $l ) {
          ## Structural recursion
          $str = $this->serialize($prefix."['".ereg_replace("([\\'])",
"\\\\1", $k)."']", $str);
          eval("\$l = gettype(list(\$k)=each(\$$prefix));");
        }

      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.
          $str = $this->serialize($prefix."->".$l,$str);
          eval("\$l = next(\$${prefix}->persistent_slots);");
        }

      break;
      default:
        ## $$prefix is an atom. Extract it to $l, then generate code.
        eval("\$l = \$$prefix;");
        $str.="\$$prefix = '".ereg_replace("([\\'])", "\\\\1", $l)."'; ";

      break;
    }
                return $str;
  }

  ## freeze():
  ##
  ## freezes all registered things ( scalar variables, arrays, objects )
into
  ## a database table

  function freeze() {
    $str="";

    $str = $this->serialize("this->in",$str);
    $str = $this->serialize("this->pt",$str);

    reset($this->pt);
    while ( list($thing) = each($this->pt) ) {
      $thing=trim($thing);
      if ( $thing ) {
        $str = $this->serialize("GLOBALS['".$thing."']",$str);
      }
    }

    $r = $this->that->ac_store($this->id, $this->name, $str);
    $this->release_lock();
    if(!$r) $this->that->ac_halt("Session: freeze() failed.");
  }

Ignatius
> -----Original Message-----
> From: Matt Friedman [mailto:matt <email protected>]
> Sent: Monday, 15 January 2001 17:20
> To: nathan r. hruby; PHPLIB Mailing List; php general
> Subject: Re: [phplib] Call Time Pass By Reference PROBLEM.
>
>
> Ok, but the warning says that call time pass by reference is deprecated.
>
> Will there be an update at some point to address this in phplib?
>
> Matt Friedman
> Spry New Media
> http://www.sprynewmedia.com
> Lead Programmer/Partner
> email: matt <email protected>
> phone: 250 744 3655
> fax: 250 370 0436
>
>
> ----- Original Message -----
> From: "nathan r. hruby" <nhruby <email protected>>
> To: "Matt Friedman" <matt <email protected>>
> Sent: Sunday, January 14, 2001 9:20 PM
> Subject: Re: [phplib] Call Time Pass By Reference PROBLEM.
>
>
> > On 1/15/01 12:19 AM, "Matt Friedman" <matt <email protected>> wrote:
> >
> > > I just set up phplib on a server with php4.0.4 running.
> > > I'm getting all these warnings from the session class.
> > >
> > > Can I just add an "@" to the argument call in the function???
> > >
> > > Any word on how to fix this or update the class, please let me know.
> > >
> >
> > In php.ini set allow_call_time_pass_reference = true
> >
> > -n
> >
> > ........
> > nathan hruby
> > Webmaster: UGA Department of Drama and Theatre
> > Project Maintainer: phpSlash, Carousel
> > nhruby <email protected>
> > ........
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: phplib-unsubscribe <email protected>
> For additional commands, e-mail: phplib-help <email protected>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>