You appear to be a bot. Output may be restricted
Description
Log missing filesIn my symlinked environment in Windows I often get reports that a file does not exist when it pretty certainly does, albeit a symlinked file. This code, which used to be in the oik_boot shared library attempts to report what's wrong. But it created serious problems for REST APIs which only expect to see JSON responses. I changed it to check for WP_DEBUG before echoing anything. Then I realised that I needed better information for problem determination so I chose to log the output to the PHP error log using the error_log() function. The 'you're having me on' function is now a builtin callback function that may eventually be deprecated once the problem determination is complete. In most cases, where oik_require() has been invoked correctly we do expect the file to exist. The second test checks that the file really doesn't exist.
Usage
$string = oik_yourehavingmeon( $file );
Parameters
- $file
- ( string ) required – the fully qualified file name
Returns
string some additional information that may help debugging.Source
File name: oik-libs/libs/bwtrace_log.phpLines:
function oik_yourehavingmeon( $file ) { if ( file_exists( $file ) ) { $file = "exists now"; return $file; } if ( defined( 'WP_DEBUG') && WP_DEBUG ) { $type = bw_array_get( $_SERVER, 'request_type', null ); if ( $type != 'rest' ) { echo "<!-- File does not exist:$file! -->" ; if ( !is_file( $file ) ) { echo "<!-- File is not a real file:$file! -->" ; } echo "<!-- "; echo __FILE__ ; echo PHP_EOL; print_r( debug_backtrace() ); echo " -->"; } } if ( file_exists( $file ) ) { //gob(); this is not expected... but perhaps that's part of the problem! if ( defined( 'WP_DEBUG') && WP_DEBUG && $type != 'rest' ) { echo "<!-- Oh. And now it does exist! $file -->"; } $file = "exists a bit later"; } return( $file ); }View on GitHub