Library Hooks extending classes with the same names
Submitted stoo2000, Jul 20 2011 03:16 PM | Last updated Jul 20 2011 03:16 PM
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.
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
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']; }And before or after installing, i dont really understand.
Thanks and sorry for my english.