Lỗi constant wp_debug already defined in wp-config.php on line 97 năm 2024

This problem is caused by a Theme that added this WP code/constant: define['WP_MEMORY_LIMIT', '512M']; at the bottom of the wp-config.php file after the require_once[ABSPATH . 'wp-settings.php']; code in the wp-config.php file. No code is supposed to go after this line of code in the wp-config.php file. All custom code in the wp-config.php file needs to be above this line of code.

j’ai rencontré une erreur critique sur un site que je gère [//blog.partiprof.fr]. J’ai donc reçu un mail m’indiquant que le problème venait de l’extension YoastSEO et avec un lien permettant de se connecter en mode sans échec. Cela m’a permis de désactiver l’extension et de rendre le site à nouveau accessible.

Toutefois j’ai maintenant 3 avertissements qui s’affichent pour tous les visiteurs :

Notice: Constant WP_DEBUG already defined in /home/wwwparti/public_html/blog/wp-config.php on line 94

Notice: Constant WP_DEBUG_DISPLAY already defined in /home/wwwparti/public_html/blog/wp-config.php on line 96

Notice: Constant WP_DEBUG_LOG already defined in /home/wwwparti/public_html/blog/wp-config.php on line 98

Ces messages indiquent donc que les 3 constantes « WP-DEBUG », « WP_DEBUG_DISPLAY » et « WP_DEBUG_LOG » sont déjà définies. Mais je n’arrive pas à voir où.

Dans le fichier wp-config.php indiqué par les messages, j’ai en fin de fichier :

define['WP_DEBUG', false];

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if [ !defined['ABSPATH'] ]
  define['ABSPATH', dirname[__FILE__] . '/'];

/** Sets up WordPress vars and included files. */
require_once[ABSPATH . 'wp-settings.php'];

Ce fichier appelle ensuite le fichier wp-settings.php, dans lequel on a pour la partie qui nous intéresse :

// Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE.
wp_initial_constants[];

Et en allant chercher la fonction wp_initial_constants, qui se trouve dans le fichier « default-constants.php » de « wp-includes », j’ai :

if [ ! defined[ 'WP_CONTENT_DIR' ] ] {
    define[ 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ]; // No trailing slash, full paths only - WP_CONTENT_URL is defined further down.
  }

  // Add define[ 'WP_DEBUG', true ]; to wp-config.php to enable display of notices during development.
  if [ ! defined[ 'WP_DEBUG' ] ] {
    if [ 'development' === wp_get_environment_type[] ] {
      define[ 'WP_DEBUG', true ];
    } else {
      define[ 'WP_DEBUG', false ];
    }
  }

  // Add define[ 'WP_DEBUG_DISPLAY', null ]; to wp-config.php to use the globally configured setting
  // for 'display_errors' and not force errors to be displayed. Use false to force 'display_errors' off.
  if [ ! defined[ 'WP_DEBUG_DISPLAY' ] ] {
    define[ 'WP_DEBUG_DISPLAY', true ];
  }

  // Add define[ 'WP_DEBUG_LOG', true ]; to enable error logging to wp-content/debug.log.
  if [ ! defined[ 'WP_DEBUG_LOG' ] ] {
    define[ 'WP_DEBUG_LOG', false ];
  }

  if [ ! defined[ 'WP_CACHE' ] ] {
    define[ 'WP_CACHE', false ];
  }

  // Add define[ 'SCRIPT_DEBUG', true ]; to wp-config.php to enable loading of non-minified,
  // non-concatenated scripts and stylesheets.
  if [ ! defined[ 'SCRIPT_DEBUG' ] ] {
    if [ ! empty[ $wp_version ] ] {
      $develop_src = false !== strpos[ $wp_version, '-src' ];
    } else {
      $develop_src = false;
    }

    define[ 'SCRIPT_DEBUG', $develop_src ];
  }

J’ai essayé plusieurs choses :

  • de remplacer temporairement « define[‘WP_DEBUG’, false]; » de wp-config.php par

ini_set['display_errors','Off'];
ini_set['error_reporting', E_ALL ];
define['WP_DEBUG', false];
define['WP_DEBUG_DISPLAY', false];

  • de supprimer la ligne « define[‘WP_DEBUG’, false]; » de wp-config.php pour éviter de la définir plusieurs fois.
  • d’indiquer false pour les variables de « default-constants.php ».
  • de mettre en commentaire la partie définissant les constantes de « default-constants.php » pour que celles-ci ne soient pas définies.

Mais le problème reste toujours le même. Ces constantes sont apparemment définies ailleurs, mais je ne vois pas où.

When configuring WPML in a multisite website, the website crashed in the last step and has been offline since then. In order to reactivate the many web pages of the multisite, I would like to know what I have to delete via FTP so that the website can be loaded again. Currently, I only have FTP access to the website.

The browser gives the following error message:

Gateway Timeout The gateway did not receive a timely response from the upstream server or application.

The provider's web error log has returned this error message: 2023-07-07 17:32:20 2001:818:dcd2:6700:5492:bf71:570c:f869 proxy_fcgi:error 9585 [70007]The timeout specified has expired: AH01075: Error dispatching request to : [polling] 2023-07-07 17:29:52 185.196.220.26 core:error 11149 AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 2023-07-07 17:29:52 185.196.220.26 core:error 11149 AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

The PHP log has these error messages:

2023-07-07 17:29:03 PHP Warning Constant WP_DEBUG already defined in /home/sites/site100019687/web/www.academicwebs.com/wp-config.php on line 95 2023-07-07 17:29:03 PHP Warning Constant WP_AUTO_UPDATE_CORE already defined in /home/sites/site100019687/web/www.academicwebs.com/wp-config.php on line 97

I would be very thankful, if you could help me fast with a solution, to re-activate the Multisite.

Best,

Jens

jensH-30

I could resolve the issue by changing the PHP version from 8.1 to 8.2.

Andreas W.

Supporter

Sprachen: Englisch [English ] Deutsch [Deutsch ]

Zeitzone: America/Lima [GMT-05:00]

Hello,

Please also take note that according to the error, two constants were declared twice in wp-config.php.

Chủ Đề