1 doctorwatson Feb 17, 2007 19:43
3 smpdawg Feb 18, 2007 00:57
He is using PHP 4.4.1.
That is just a notice that can be rectified by either removing the ampersand before the new like this:
$t = & new Object();
becomes
$t = new Object();
Or turning off E_NOTICE.
error_reporting(E_ALL & ~E_NOTICE);
4 blueyed Feb 18, 2007 01:31
smpdawg wrote:
He is using PHP 4.4.1.
How do you know?
smpdawg wrote:
That is just a notice that can be rectified by either removing the ampersand before the new like this:
$t = & new Object();
becomes$t = new Object();
Or turning off E_NOTICE.
error_reporting(E_ALL & ~E_NOTICE);
Hmm, I've thought that it is already being used without the ampersand (and an explicit ampersand would be needed to work around this PHP bug). This is the relevant code from blogs/inc/MODEL/dataobjects/_dataobjectcache.class.php (in the v-1-9 branch). Line 121 is the "return" line.
function & new_obj( $row = NULL )
{
$objtype = $this->objtype;
// Instantiate a custom object
$obj = new $objtype( $row ); // COPY !!
return $obj;
}
5 smpdawg Feb 18, 2007 01:50
I looked at the response headers from his server with the developers tool in Firefox. Information/View response headers.
I changed this in my code to get rid of the message.
function new_obj( $row = NULL )
6 edb Feb 18, 2007 02:00
Plus it's pretty easy to guess that a new installation might have a folder that should be deleted, then point to phpinfo.php in the deletable folder.
Not that I have any clue what's going on here!
7 smpdawg Feb 18, 2007 02:05
And an easier way was discovered ;)
8 blueyed Feb 18, 2007 04:44
Oh well, two ways I did not thought about.
Additionally, even the PHP notice has fooled me: the problem is not in the method itself, but somewhere else, where new_obj() gets called!
Please try the following patch instead (for 1.9.x):
Index: ./blogs/inc/MODEL/dataobjects/_dataobjectcache.class.php
===================================================================
RCS file: /cvsroot/evocms/b2evolution/blogs/inc/MODEL/dataobjects/_dataobjectcache.class.php,v
retrieving revision 1.6.2.2
diff -u -r1.6.2.2 _dataobjectcache.class.php
--- ./blogs/inc/MODEL/dataobjects/_dataobjectcache.class.php 4 Nov 2006 19:54:53 -0000 1.6.2.2
+++ ./blogs/inc/MODEL/dataobjects/_dataobjectcache.class.php 18 Feb 2007 03:43:54 -0000
@@ -254,7 +254,8 @@
}
else
{ // Not already cached, add new object:
- $this->add( $this->new_obj( $db_row ) );
+ $tmp = & $this->new_obj( $db_row ); // workaround for PHP 4.4.1 and others maybe
+ $this->add( $tmp );
}
return $this->cache[$obj_ID];
@@ -392,9 +393,8 @@
if( ! isset( $this->cache[$resolved_ID] ) )
{ // Object is not already in cache:
$Debuglog->add( 'Adding to cache...', 'dataobjects' );
- //$Obj = new $this->objtype( $row ); // COPY !!
- //if( ! $this->add( $this->new_obj( $db_row ) ) )
- if( ! $this->add( $this->new_obj( $db_row ) ) )
+ $tmp = & $this->new_obj( $db_row ); // workaround for PHP 4.4.1 and others maybe
+ if( ! $this->add( $tmp ) )
{ // could not add
$Debuglog->add( 'Could not add() object to cache!', 'dataobjects' );
}
9 doctorwatson Feb 18, 2007 07:26
Oh dear ! As I said I am a total newbie and what you guys (gurus ?) are discussing still is very much like ancient Latin to me - but I'll do my very best ...
However, thanks for this quick response already. I will try to provide some more information.
- Php : when I log in to my php admin, it shows "php 2.7.0-pl2". Is that the version number ?
- It also shows : "MySQL 4.0.16 running …."
- The database has been set up through the services provided by my host Dot5Hosting.
- smpdawg mentions Firefox : can there be a problem when using Firefox? (I am using Firefox).
But there is something I have noticed myself : after uploading b2evolution (using SmartFTP), all "file permissions" have been set to 644. That's "write protected" isn't it ? Can this have anything to do with the problem ?
10 edb Feb 18, 2007 08:21
DoctorWatson check out http://m-v-p.net/journal/install/phpinfo.php and you'll see all sorts of groovy stuff about your server stuff. Also please please please delete the install folder! Actually you could delete everything in it except the phpinfo.php file if you want to keep that one handy just in case one day you need something from it, but you absolutely need to get rid of most of the files in that folder.
As to the stuff blueyed wrote: he's way smart. WAY smart. I don't really understand diff files much, so I could be a bit wrong here, but he's telling you to edit inc/MODEL/dataobjects/_dataobjectcache.class.php and find the bit that looks like the stuff with a minus sign in front of it, then replace it with the bit with a plus sign in front of it. Be CAREFUL when doing that stuff! Make a backup of the existing file, then tinker with it slowly until you have something that looks like the end result the diff file would make. Your file will NOT have the minuses and pluses in front of the lines - they are there only to help track changes.
It's a developer thing. When many people are working on a code they can use several tools to make sure that one person's changes don't stomp on someone else's changes. One of those tools is a line-by-line comparison and difference thing - the diff file.
11 doctorwatson Feb 19, 2007 09:19
I did remove the install folder, but the "Notice: Only variable references ..." problem is still there.
EdB, I tried to "find the bit that looks like the stuff ... " but I can't make any sense out of it. I am but an humble amateur, certainly not a core developer.
As the problem is located in the _dataobjectcache.class.php file, I have attached a copy of it.
I had to add .zip to the name, as this forum does not allow to upload files with a .php extension. So it's only renamed, not a zip file at all.
Would one of you "gurus" - blueyed perhaps - be so kind as to make the necessary modifications and post it back ?
Greetings,
12 edb Feb 19, 2007 09:51
Making the mods was not a big deal after all. Now lets see if I can figure out how to upload stuff...
edit: the file is patched wrong.. see below.. -- blueyed
13 doctorwatson Feb 19, 2007 13:33
Hi EdB
Thanks, but I am at my office now and I cannot upload the modified file from here (@#@#!! Big Brother). I will keep you informed.
14 doctorwatson Feb 19, 2007 19:47
Hi again.
I have uploaded the modified _dataobjectcache.class.php, but there is no change. The errors keep coming back.
Something strange I just noticed : there is a difference when the page is called with Firefox 2 or with Internet Explorer (Firefox shows more error lines).
15 balupton Feb 19, 2007 20:52
Ok i'm gonna jump on board.
correct
function & gimme_a_Obj ( ) {
$Obj = new Obj();
return $Obj;
}
$Obj = gimme_a_Obj();
wrong
function & gimme_a_Obj ( ) {
$Obj = new Obj();
return $Obj;
}
$Obj = & gimme_a_Obj();
wrong
function & gimme_a_Obj ( ) {
$Obj = new Obj();
return & $Obj;
}
wrong
function gimme_a_Obj ( ) {
$Obj = new Obj();
return & $Obj;
}
this post is just for the gurus....
16 balupton Feb 19, 2007 21:02
DoctorWatson i've included fixes for the following files in the attached zip.
/inc/MODEL/generic/_genericcache.class.php
/inc/CONTROL/generic/inc/_gerneric_recursive_listeditor.php
/inc/CONTROL/generic/inc/_gerneric_listeditor.php
/inc/MODEL/dataobjects/_dataobjectcache.class.php
edit: Please note that the "patches" below are not supported and probably are "not the right fix" anyway. --blueyed
17 blueyed Feb 19, 2007 22:53
balupton wrote:
Ok i'm gonna jump on board.
correct
function & gimme_a_Obj ( ) { $Obj = new Obj(); return $Obj; } $Obj = gimme_a_Obj();
wrong
function & gimme_a_Obj ( ) { $Obj = new Obj(); return $Obj; } $Obj = & gimme_a_Obj();
Wrong! See http://www.php.net/manual/en/language.references.return.php
The first one works too, but does not give you a reference, likely.
The followings are parse errors, yeah.
wrong
function & gimme_a_Obj ( ) { $Obj = new Obj(); return & $Obj; }
wrong
function gimme_a_Obj ( ) { $Obj = new Obj(); return & $Obj; }
this post is just for the gurus....
This is related, though irrelevant and wrong. Please stop it.. :)
This seems to be all about a bug with PHP 4.4 and I'll look into it.
18 blueyed Feb 19, 2007 22:56
Here's the file which EdB already tried to patch, but now corrected.
Please try this one.
19 balupton Feb 19, 2007 23:02
Hehehe, shouldn't of made some posts when i just got back from drinking.
20 blueyed Feb 19, 2007 23:05
It _may_ also be a Zend Optimizer bug, see: http://codex.gallery2.org/Gallery2:FAQ#I_get_.22Notice:_Only_variable_references_should_be_returned_by_reference_in_.22.2C_what.27s_wrong.3F
21 edb Feb 19, 2007 23:10
blueyed wrote:
Here's the file which EdB already tried to patch, but now corrected.
Please try this one.
oops. It's too bad I already deleted the copy of that file from my desktop. Comparing the proper correction to my effort might have learned me a thing or two. ah well. such is life.
EDIT: turns out I still had it. My mistake was not in understanding what to do: it was purely in the implementation of it. Like TOTALLY wrong place to put the new stuff. duh...
22 blueyed Feb 19, 2007 23:17
It's still attached to your post. I've not replaced it.
For the original topic, please refer to
http://forums.b2evolution.net/viewtopic.php?t=10133 - there are so many threads about the problem already!!
What PHP version are you using? It seems it's buggy.
Also, search for "Only variable references should be returned" and you should find quite some threads here.
See here: http://forums.b2evolution.net/viewtopic.php?p=49036#49036
And PLEASE report what PHP version you're using.