Re: small patch to DB/common.php

From: Date: Sat, 13 Sep 2003 00:34:45 +0000
Subject: Re: small patch to DB/common.php
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-21457@lists.php.net to get a copy of this message
I would like to make another plea to someone to make this fix. - the DB library is part of the standard PHP distribution - as it goes out now, it cannot be used for the most simple things - the fix alters 4 lines, and makes no appreciable difference to current installations i have been demonstrating some PHP 5 code to people lately, and if i have to send it to them to try to get running on their own machines, the first thing they run into is this bug. having to tell them that they have to go patch the DB library by hand to make it work makes them rather dubious of the whole enterprise... and then, of course, they ask me why it's like that. there are two places in DB/common.php where it does a 'return new SomethingOrOther', and two where it returns a Pear::Error static call that generates an object, within functions that are declared as returning a reference. all it takes to fix it is to change that to return $bla =& new SomethingOrOther or make the assignment and then return it separately if that is more in line with the coding standard. thanks. > Brad Bulger wrote: > > php 5 does not allow 'return new FooClass;' from a method > > declared as returning a reference ('function &getMyFoo()'). > > DB does this in a couple places. The patch just changes it > > to do > > > > $dbr =& new Whatever; > > return $dbr; > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > Index: common.php > > =================================================================== > > RCS file: /repository/pear/DB/DB/common.php,v > > retrieving revision 1.22 > > diff -u -u -r1.22 common.php > > --- common.php 22 Jul 2003 21:54:16 -0000 1.22 > > +++ common.php 25 Jul 2003 07:12:57 -0000 > > @@ -565,7 +565,8 @@ > > if (DB::isError($result) || $result === DB_OK) { > > return $result; > > } else { > > - return new DB_result($this, $result); > > + $dbr =& new DB_result($this, $result); > > + return $dbr; > > } > > } > > > > @@ -763,7 +764,8 @@ > > if (DB::isError($result) || $result === DB_OK) { > > return $result; > > } else { > > - return new DB_result($this, $result); > > + $dbr =& new DB_result($this, $result); > > + return $dbr; > > } > > } > > } > > > > > > > -- > Can you help out? > Need Consulting Services or Know of a Job? > http://www.akbkhome.com >

« previous php.pear.dev (#21457) next »