Jump to content


Photo

Library Hooks extending classes with the same names


See Terabyte for more information.

If you have a hook extending topicsLibrary in Forums, and one extending topicsLibrary in Downloads, the hook system will try to chain them together because it lacks an application check. In the end this causes a fatal error when trying to use one of the hooks.

Status: Fixed
Version: 3.2.0
Fixed In: 3.2.1


4 Comments

I'm working on a fix already, leave this for me.
In "admin_core_applications_hooks" replace this code:
if( $source )
   			 {
   				 $hook_data    = unserialize( $file['hook_data'] );
   				 $overload    = $hook_data['classToOverload'];
   				 $newClass    = $overload;

   				 if( isset( $usedActions[ $overload ] ) )
   				 {
   					 $newClass = $usedActions[ $overload ];
   				 }
   				 else if( $file['hook_type'] == 'skinHooks' )
   				 {
   					 $newClass .= "(~id~)";
   				 }

   				 $source = str_replace( "(~extends~)", $newClass, $source );
   		 
   				 file_put_contents( IPS_HOOKS_PATH . $file['hook_file_stored'], $source );
   				 
   				 $usedActions[ $hook_data['classToOverload'] ] = $file['hook_classname'];
   			 }

With this:
if( $source )
   		     {
   			     $hook_data    = unserialize( $file['hook_data'] );
   			     $overload    = $hook_data['classToOverload'];
   			     $newClass    = $overload;
   			     
   			     $app = ( $file['hook_type'] == 'libraryHooks' ) ? trim($hook_data['libApplication']) : '~_NO_APP_~';
   			     
   			     if( isset( $usedActions[ $app ][ $overload ] ) )
   			     {
   				     $newClass = $usedActions[ $app ][ $overload ];
   			     }
   			     else if( $file['hook_type'] == 'skinHooks' )
   			     {
   				     $newClass .= "(~id~)";
   			     }
 
   			     $source = str_replace( "(~extends~)", $newClass, $source );
   	     
   			     file_put_contents( IPS_HOOKS_PATH . $file['hook_file_stored'], $source );
   			     
   			     $usedActions[ $app ][ $hook_data['classToOverload'] ] = $file['hook_classname'];
   		     }
Do i have this to do also for version 3.2.3 ?

And before or after installing, i dont really understand.

Thanks and sorry for my english.
This fix is already included in IP.Board since version 3.2.1, no need to edit the 3.2.3 files.