Activer WP_DEBUG et lire debug.log sans casser le site en production
Un site qui plante sans rien dire est un site qui vous cache la réponse. WordPress la connaît, il refuse simplement de l'afficher, et c'est voulu : montrer une trace PHP à vos visiteurs révélerait vos chemins de fichiers et vos versions logicielles. Il existe un réglage qui écrit l'erreur dans un fichier au lieu de l'afficher. C'est celui-là qu'il faut, et pas l'autre. Les trois constantes, et…
WordPress can display a "planted site" with no warning, hiding the answer. It intentionally refuses to show the PHP trace to your visitors, revealing file paths and software versions. The setting to write errors to a file instead of displaying them is the one you need. The three constants in wp-config.php before the comment line are WP_DEBUG (true) to enable debug mode, WP_DEBUG_LOG (true) to write errors to wp-content/debug.log, and WP_DEBUG_DISPLAY (false) to display nothing to visitors.
The third constant is the most important in production, as it prevents WordPress from displaying errors at the top of your pages to clients and search engines. A growing debug.log file can saturate your hosting quota and be accessible to anyone on the web. To diagnose the issue, activate WP_DEBUG, generate an error, and check the created debug.log file.
Three key pieces of information are displayed: Fatal error for critical issues, Warning for less severe problems, and Notice for minor warnings. The file path after in shows whether the error is caused by a plugin (plugins), theme (themes), core (wp-includes, wp-admin), or the site itself. The thrown in line indicates the exact location where the error occurred, more reliable than the first line when the error traces through multiple files.
The middle stack trace shows the sequence of function calls leading to the error, helping identify the culprit. The most common message after an update is "Call to undefined function," meaning an extension is calling a function that no longer exists due to a recent WordPress or PHP version change. The solution is to update or replace the extension, not to fix the file.
After identifying the problem, set WP_DEBUG to false and delete the debug.log file, as it will not empty itself and retains information about your installation paths. If the trace points to a core file rather than an extension, do not modify it, as it is usually a symptom of something else and touching the core can break the next update.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.