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

John Korchok jkorchok at hotmail.com
Tue Aug 17 20:19:23 PDT 2010


> -----Original Message-----
> From: macports-users-bounces at lists.macosforge.org 
> [mailto:macports-users-bounces at lists.macosforge.org] On 
> Behalf Of Bradley Giesbrecht
> Sent: Tuesday, August 17, 2010 10:12 PM
> To: macports-users at lists.macosforge.org ()
> Subject: Re: Tangential Topic: MacPorts PHP code broken by OS 
> X update?
> 
> 
> 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
> 
Thank you for the tips. I had already used require_once exclusively when I
built the code, knowing that this could be a problem. That's why I was
baffled that a security update could trip such an error message. However,
the if(!class_exists'ClassName') construct solves it, so I'll give up
wondering why...

John



More information about the macports-users mailing list