#47638 [Opn]: Random fatal error while using callback through array_udiff_assoc

From: Date: Fri, 13 Mar 2009 01:03:51 +0000
Subject: #47638 [Opn]: Random fatal error while using callback through array_udiff_assoc
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-134654@lists.php.net to get a copy of this message
 ID:               47638
 Updated by:       felipe@php.net
 Reported By:      luke at cywh dot com
 Status:           Open
 Bug Type:         *Compile Issues
 Operating System: Linux, Mac OS X
 PHP Version:      5.2.9
 New Comment:

I can't reproduce it.


Previous Comments:
------------------------------------------------------------------------

[2009-03-12 17:02:10] luke at cywh dot com

Description:
------------
When making a callback through array_udiff_assoc to a static function 
this fatal error is produced, but randomly:

Fatal error: Non-static method (null)::(null)() cannot be called 
statically in /opt/local/apache2/htdocs/site/cc.php on line 12

This error only occurs about 1/3 of the time or less, and usually 
seems to happen right after saving a file. At first I thought it was 
an eAccelerator issue as I could product this error almost every time 
after re-saving the file (with or without changes), but I was also 
able to reproduce this on my MacBook which I had installed the 5.2 
branch on without any cache engines.

On a stock PHP installation with no extras it is mighty difficult to 
reproduce this error. I was able to make it occur several times if I 
refreshed the page 5-20 times after saving.

In the callback I'm referencing the function as a string: 
"XC::greaterthan". I *think* using array('XC', 'greaterthan') corrects

the problem, but I am unsure as this error seems to occur completely 
at random, and I have yet to have a 100% solid way of reproducing it.

The code below is the best way I was able to reproduce the occurrence.

Reproduce code:
---------------
class XC {
	static public function greaterthan($value1, $value2) {
		return $value1 > $value2;
	}
}

class test {
	function tester($num1, $num2) {
		var_dump(array_intersect(
			array_keys(
				array_udiff_assoc(array('if' => $num1), array('if' => $num2),
'XC::greaterthan')
			), array('if')
		));
	}
}

$t = new test();

for($i=0; $i<10; $i++) {
	$num1 = mt_rand(1, 100);
	$num2 = mt_rand(1, 100);
	$t->tester($num1, $num2);
}

Expected result:
----------------
No fatal error, just var dumps.

Actual result:
--------------
Fatal error: Non-static method (null)::(null)() cannot be called 
statically in /opt/local/apache2/htdocs/site/cc.php on line 12

(Which points to the array_udiff_assoc function)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47638&edit=1



Thread (8 messages)

« previous php.bugs (#134654) next »