Make WordPress Core

#58821 closed defect (bug) (fixed)

add_option() called using deprecated parameter in upgrade_630()

Reported by: gudmdharalds's profile gudmdharalds Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.3 Priority: normal
Severity: normal Version: 6.3
Component: Upgrade/Install Keywords: has-patch commit
Focuses: Cc:

Description

Changeset [55854] ensures that option can_compress_scripts autoloads. The changeset includes the upgrade_630() function that will record a new option value in the database to preserve what value may have been saved previously there. However, that function incorrectly invokes add_option() using a deprecated parameter.

The upgrade_630() function looks like this in revision 56176:

function upgrade_630() {
       global $wp_current_db_version;
	
        if ( $wp_current_db_version < 55853 ) {
                if ( ! is_multisite() ) {
                        // Replace non-autoload option can_compress_scripts with autoload option, see #55270
                        $can_compress_scripts = get_option( 'can_compress_scripts', false );
                        if ( false !== $can_compress_scripts ) {
                                delete_option( 'can_compress_scripts' );
                                add_option( 'can_compress_scripts', $can_compress_scripts, 'yes' );
                        }
                }
        }
}

add_option() is called using the third parameter, which is deprecated. The upgrade code will cause a deprecation warning to be thrown when executed and WordPress is in debug mode. The value will be preserved nevertheless.

Patch is attached to resolve this.

Attachments (1)

upgrade_630_add_option.patch (575 bytes) - added by gudmdharalds 19 months ago.

Download all attachments as: .zip

Change History (5)

#1 @costdev
19 months ago

  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 6.3

Nicely spotted @gudmdharalds!

The patch looks good to me.

Note to reviewers: While 'yes' is the default value for the $autoload parameter, and could therefore be removed here entirely, it was discussed in the original ticket and considered more explanatory to be explicit.

I don't think this one needs testing. The issue is quite apparent. Adding for commit consideration.

#2 @mukesh27
19 months ago

  • Owner set to spacedmonkey
  • Status changed from new to assigned

Thanks @gudmdharalds for the ticket and patch.

Agree with @costdev for testing. Assign to @spacedmonkey for final review and commit.

#3 @spacedmonkey
19 months ago

I will have to commit this tomorrow.

#4 @spacedmonkey
19 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 56258:

Upgrade/Install: Add correct parameters to add_option in upgrade_630

Introduced in [55854], upgrade_630 function was introduced to update can_compress_scripts option to autoload. However the function add_option was invoked incorrectly, passing 3 parameters and not 4. The third parameter, which is deprecated, triggers a deprecated argument warning. In this change, pass 4 parameters instead of 3.

Props gudmdharalds, spacedmonkey, costdev, mukesh27.
Fixes #58821.

Note: See TracTickets for help on using tickets.