[php-maint] Bug#418598: php4: return by reference of an array element of a class don't work

Matteo Nastasi nastasi at alternativeoutput.it
Tue Apr 10 19:08:57 UTC 2007


Package: php4
Version: 4:4.4-8+etch1
Severity: important


This little fragment of code work or not if you set TRUE or FALSE
the define at the top of the script.
I suppose that it MUST work in both cases.

Do you agree? Regards, Matteo.

On Sarge works fine, not the same on Etch.

All the experiments are executed on Intel Core 2 Duo Machine.

---- begin example ----
<?php 

define(WITH_AMP, FALSE);

class Two {
  var $bleble;
  var $name;
  function Two($i) {
    $this->bleble = "bleble";
    $this->name = "name".$i;
  }
}

class One {
  var $twoarr;
  var $blabla;

  function One() {
    $this->twoarr = array();
    $this->blabla = "blabla";
    if (WITH_AMP)
      for ($i = 0 ; $i < 10 ; $i++)
	$this->twoarr[$i] =& new Two($i);
    else
      for ($i = 0 ; $i < 10 ; $i++)
	$this->twoarr[$i] = new Two($i);

  }

  function &getTwoEl($i)
  {
    return ($this->twoarr[$i]);
  }
}

function & init_data() {
  $ret =& new One();
  return ($ret);
}

/* 
 *    MAIN
 */
$one =& init_data();
$user =& $one->getTwoEl(0);
$one->twoarr[0]->name .= "POST";
echo "USER: [".$user->name."]  ONE: [".$one->twoarr[0]->name."]";
exit;
?>

---- end example ----

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.8-2-k7-smp
Locale: LANG=it_IT at euro, LC_CTYPE=it_IT at euro (charmap=ISO-8859-15)

Versions of packages php4 depends on:
ii  libapache-mod-php4           4:4.3.10-18 server-side, HTML-embedded scripti
ii  libapache2-mod-php4          4:4.3.10-18 server-side, HTML-embedded scripti
ii  php4-common                  4:4.3.10-18 Common files for packages built fr

-- no debconf information




More information about the pkg-php-maint mailing list