Created
September 25, 2025 14:28
-
-
Save juanmanavarro/7d1f008c56f4eb33f1353f3dd04d8017 to your computer and use it in GitHub Desktop.
A drop-in snippet for wp-config.php that forces PHP/WordPress to print any fatal error directly to the browser—even when logs can’t be written (locked file permissions, open_basedir, readonly hosts, etc.).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // === DEBUG DURO: imprime cualquier fatal en pantalla === | |
| @ini_set('display_errors', '1'); | |
| @ini_set('display_startup_errors', '1'); | |
| @ini_set('log_errors', '0'); // desactiva logging si no se puede escribir | |
| @ini_set('zlib.output_compression', '0'); | |
| error_reporting(E_ALL); | |
| // Vacía buffers por si algo los está escondiendo | |
| while (function_exists('ob_get_level') && ob_get_level() > 0) { @ob_end_flush(); } | |
| @ob_implicit_flush(true); | |
| // Manejadores para errores/ excepciones | |
| set_error_handler(function($errno, $errstr, $errfile, $errline) { | |
| // deja que PHP siga su curso para warnings/notices si quieres: return false; | |
| echo "\n[PHP-$errno] $errstr in $errfile:$errline\n"; | |
| return false; | |
| }); | |
| set_exception_handler(function($ex) { | |
| header('Content-Type: text/plain; charset=utf-8'); | |
| echo "Uncaught ".get_class($ex).": ".$ex->getMessage()." in ".$ex->getFile().":".$ex->getLine()."\n".$ex->getTraceAsString()."\n"; | |
| }); | |
| // Captura FATALES (E_ERROR/E_PARSE/E_COMPILE_ERROR/etc.) | |
| register_shutdown_function(function() { | |
| $e = error_get_last(); | |
| if ($e && in_array($e['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR])) { | |
| header('Content-Type: text/plain; charset=utf-8'); | |
| echo "=== FATAL ERROR ===\n"; | |
| echo $e['message']."\n"; | |
| echo "File: ".$e['file']."\nLine: ".$e['line']."\n"; | |
| } | |
| }); | |
| // Señales de vida | |
| echo "__WP_CONFIG_REACHED__\n"; | |
| // Fuerza el modo ver en pantalla dentro de WP (aunque no pueda loguear) | |
| define('WP_DEBUG', true); | |
| define('WP_DEBUG_DISPLAY', true); | |
| define('WP_DEBUG_LOG', false); | |
| define('WP_DISABLE_FATAL_ERROR_HANDLER', true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment