Tangential Topic: MacPorts PHP code broken by OS X update?

Bradley Giesbrecht brad at pixilla.com
Tue Aug 17 19:12:17 PDT 2010


On Aug 17, 2010, at 1:42 PM, Scott Haneda wrote:

> On Aug 17, 2010, at 9:54 AM, "John Korchok" <jkorchok at hotmail.com>  
> wrote:
>
>> I am using MacPorts PHP 5.3 on Leopard. I have lots of code that  
>> was working perfectly fine until I applied the 2010-004 security  
>> update (among others) this past weekend. Now I am getting:
>>
>> "Fatal error: Cannot redeclare class EmployeeTable in /Library/ 
>> WebServer/Documents/profile/EmployeeTable.php on line 4"
>>
>> after signing in. None of the PHP has been changed.
>
> Maybe it was always this way and certain conditions are causing this  
> now.
>
> Can you wrap the EmployeeTable class in an if (class_exists(...))  
> type of condition, and print or log both sides of the condition, or  
> move to using include_once/require_once?

Good thought. Write some die/vardump function and step through your  
code with "mydie(get_defined_classes());".

Where mydie could look like:

if ( !function_exists ( "mydie" ) ) {

	function mydie (  ) { $this_file = __FILE__ ; $this_line = __LINE__ ;
	
		$buffer = array (  ) ;
		$trace_calls = "" ;

		ob_start (  ) ;
		debug_print_backtrace (  ) ;
		$buffer[ "0" ] = ob_get_contents (  ) ;
		ob_end_clean (  ) ;

		ksort ( $buffer[ "0" ] ) ;

		$trace_calls = implode ( ")\n\tcalled at [" , $buffer[ "0" ] ) ;

		unset ( $buffer ) ;

		echo "<pre>function " . __FUNCTION__ . " lives here:{$this_file}: 
{$this_line}</pre>" ;
		echo ( "<pre>" . print_r( func_get_args (  ) , true ) . "</pre>" ) ; 	
		if ( $trace_calls == "" ) $trace_calls = "No functions were called." ;
		echo ( "<pre>" . $trace_calls . "</pre>" ) ; 	
		die ;

	}
	
}

// Brad

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-users/attachments/20100817/54ba068f/attachment.html>


More information about the macports-users mailing list