Skip to content

Instantly share code, notes, and snippets.

@retlehs
Created February 17, 2016 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save retlehs/a73d5c9cd04ebac951bb to your computer and use it in GitHub Desktop.
Save retlehs/a73d5c9cd04ebac951bb to your computer and use it in GitHub Desktop.
diff U3 a/wp/wp-includes/load.php b/wp/wp-includes/load.php
--- a/wp/wp-includes/load.php Tue Feb 02 19:38:52 2016
+++ b/wp/wp-includes/load.php Tue Feb 02 19:58:21 2016
@@ -285,7 +285,7 @@
*/
function wp_debug_mode() {
if ( WP_DEBUG ) {
- error_reporting( E_ALL );
+ error_reporting( E_ALL & ~E_DEPRECATED );
if ( WP_DEBUG_DISPLAY )
ini_set( 'display_errors', 1 );
@retlehs
Copy link
Author

retlehs commented Feb 17, 2016

@cclass
Copy link

cclass commented Mar 10, 2016

I've followed the instructions at https://roots.io/disable-php-7-deprecated-notices-from-wordpress-plugins/ but I'm getting a Could not apply patch! Skipping. error:

sudo composer install
Gathering patches for root package.
Removing package johnpbloch/wordpress so that it can be re-installed and re-patched.
  - Removing johnpbloch/wordpress (4.4.2)
Loading composer repositories with package information
Updating dependencies (including require-dev)
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing johnpbloch/wordpress (4.4.2)
    Loading from cache

  - Applying patches for johnpbloch/wordpress
    wordpress.patch (Prevent E_DEPRECATED error messages when debug is enabled)
   Could not apply patch! Skipping.

Writing lock file
Generating autoload files

Here is what's in my composer.json:

  "require": {
    "php": ">=5.5",
    "composer/installers": "~1.0.12",
    "vlucas/phpdotenv": "^2.0.1",
    "cweagans/composer-patches": "~1.0",
    "johnpbloch/wordpress": "4.4.2",
    "oscarotero/env": "^1.0",
    "roots/wp-password-bcrypt": "1.0.0"
  },
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "wordpress-install-dir": "web/wp",
    "patches": {
      "johnpbloch/wordpress": {
        "Prevent E_DEPRECATED error messages when debug is enabled": "wordpress.patch"
      }
    }
  }

Any suggestions on debugging this?

@cfxd
Copy link

cfxd commented Mar 12, 2016

--- web/wp/wp-includes/load.php 2016-03-12 01:51:09.000000000 -0500
+++ web/wp/wp-includes/load.php 2016-03-12 01:51:20.000000000 -0500
@@ -285,7 +285,7 @@
  */
 function wp_debug_mode() {
    if ( WP_DEBUG ) {
-       error_reporting( E_ALL );
+       error_reporting( E_ALL  & ~E_DEPRECATED );

        if ( WP_DEBUG_DISPLAY )
            ini_set( 'display_errors', 1 );

That's what worked for me. Make sure it's in your site/ dir.

@cclass
Copy link

cclass commented May 13, 2016

@cfxd thanks!

@mike-sheppard
Copy link

--- web/wp/wp-includes/load.php
+++ web/wp/wp-includes/load.php
@@ -457,7 +457,7 @@ function wp_debug_mode() {
 	}

 	if ( WP_DEBUG ) {
-		error_reporting( E_ALL );
+		error_reporting( E_ALL  & ~E_DEPRECATED );

 		if ( WP_DEBUG_DISPLAY ) {
 			ini_set( 'display_errors', 1 );

Copied @cfxd path fix + updated diff for WP v5.9.1

@dalepgrant
Copy link

--- web/wp/wp-includes/load.php
+++ web/wp/wp-includes/load.php
@@ -569,7 +569,7 @@ function wp_debug_mode() {
	}

	if ( WP_DEBUG ) {
-		error_reporting( E_ALL );
+		error_reporting( E_ALL & ~E_DEPRECATED );

		if ( WP_DEBUG_DISPLAY ) {
			ini_set( 'display_errors', 1 );

Line number updated for WP 6.4.1 & 6.3.1, possibly earlier versions.

If you get errors like Could not apply patch! Skipping. The error was: Cannot apply patch wordpress.patch, make sure the patch is targeting roots/wordpress-no-content and make your editor isn't converting tabs to spaces or otherwise changing the indentation in your patch file.

    "wordpress-install-dir": "web/wp",
    "patches": {
      "roots/wordpress-no-content": {
        "Prevent E_DEPRECATED error messages when debug is enabled": "wordpress.patch"
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment