Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Colonel_mortis Posted June 26, 2017 Posted June 26, 2017 Currently, if a hook has a compile error, such as not reflecting the parameters of the method that it overrides (particularly an issue with the backwards-incompatible changes in 4.2), the error is discarded silently, even when IN_DEV. This obviously isn't ideal. Can we kill two birds with one stone and get better exceptions for hooks too, by replacing the monkey patch code with $contents = "namespace {$namespace}; ". str_replace( '_HOOK_CLASS_', $realClass, file_get_contents( ROOT_PATH . '/' . $data['file'] ) ); if (\IPS\IN_DEV) { $filename = tempnam(\IPS\TEMP_DIRECTORY, "HOOK_{$namespace}\\{$finalClass}_{$data['file']}"); $fullContents = "<?php " . $contents; \file_put_contents($filename, $fullContents); register_shutdown_function( function( $temp ) { unlink( $temp ); }, $filename ); require $filename; $realClass = $data['class']; } else { try { if( @eval( $contents ) !== FALSE ) { $realClass = $data['class']; } } catch ( \ParseError $e ) { } } I have tested this code and not encountered any issues (though on windows there might be a problem with the use of \, in which case maybe a replace to - or _ is needed).
bfarber Posted June 29, 2017 Posted June 29, 2017 I'll see if something can be done. Thanks for the suggestion.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.