[wp-trac] [WordPress Trac] #51827: When a plugin makes use of the 'automatic_updater_disabled' filter, it causes a PHP Warning to be thrown.

WordPress Trac noreply at wordpress.org
Thu Nov 19 15:53:49 UTC 2020


#51827: When a plugin makes use of the 'automatic_updater_disabled' filter, it
causes a PHP Warning to be thrown.
-----------------------------+-----------------------------
 Reporter:  jamesros161      |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  5.6
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 When using a plugin that makes use of the 'automatic_updater_disabled'
 filter, the following PHP Warning is thrown:

 {{{
 PHP Warning:  Use of undefined constant AUTOMATIC_UPDATER_DISABLED -
 assumed 'AUTOMATIC_UPDATER_DISABLED' (this will throw an Error in a future
 version of PHP) in /var/www/html/wp56tu/wp-admin/update-core.php on line
 327
 PHP Stack trace:
 PHP   1. {main}() /var/www/html/wp56tu/wp-admin/update-core.php:0
 PHP   2. core_auto_updates_settings() /var/www/html/wp56tu/wp-admin
 /update-core.php:1008
 }}}

 Steps to Replicate.
 1. Install a plugin that makes use of the 'automatic_updater_disabled'
 filter, or add the following line to your theme's functions.php:
 {{{#!php
 add_filter( 'automatic_updater_disabled', '__return_false' );
 }}}
 2. Set WP_DEBUG to true.
 2. Go to the Dashboard > Updates page, and see the error presented.



 Suggested Resolution:

 If the following changes are made to lines 324-337, this issue should be
 resolved.

 Change This:
 {{{#!php
 if ( defined( 'AUTOMATIC_UPDATER_DISABLED' )
                 || has_filter( 'automatic_updater_disabled' )
         ) {
                 if ( true === AUTOMATIC_UPDATER_DISABLED
                         /** This filter is documented in wp-admin/includes
 /class-wp-automatic-updater.php */
                         || true === apply_filters(
 'automatic_updater_disabled', false )
                 ) {
                         $upgrade_dev   = false;
                         $upgrade_minor = false;
                         $upgrade_major = false;
                 }
                 // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED
 constant.
                 $can_set_update_option = false;
         }
 }}}

 to:
 {{{#!php
 if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) && true ===
 AUTOMATIC_UPDATER_DISABLED
                 || has_filter( 'automatic_updater_disabled' ) && true ===
 apply_filters( 'automatic_updater_disabled', false )
         ) {
                 $upgrade_dev   = false;
                 $upgrade_minor = false;
                 $upgrade_major = false;
         } else if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) || has_filter(
 'automatic_updater_disabled' ) ) {
                 // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED
 constant.
                 $can_set_update_option = false;
         }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51827>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list