WordPress.org

Make WordPress Core

Opened 4 weeks ago

Closed 4 weeks ago

#47560 closed defect (bug) (duplicate)

PHP 7.3 compact(): Undefined variable: limits in class-wp-comment-query.php on line 853

Reported by: Andy Schmidt Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.8
Component: Comments Keywords: needs-patch
Focuses: Cc:

Description

4.9.10 with PHP 7.3
compact() now requires all parameters to have existing variables.

PHP 7.3 was released in 2018, it is recommended version by WordPress -- so there should no longer be any lingering syntax notices.

Change History (4)

#1 @Andy Schmidt
4 weeks ago

Obviously - short of a proper logic fix, this patch can be used in front of
compact( array() )
constructs.

<?php
                $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
                // patch starts: 
                foreach( $pieces as $item ) {
                        if ( isset( $$item ) )
                                continue;        // variable already defined and non-null.
                        $$item = null;           // (Re)define variable in case missing, or already null.
                }


Last edited 4 weeks ago by Andy Schmidt (previous) (diff)

#2 @swissspidy
4 weeks ago

  • Severity changed from major to normal

Hi @andy-schmidt, thanks for your report.

Would you be able to create a patch file with your suggested change? See https://make.wordpress.org/core/handbook/contribute/ for documentation about how to create patches using Git or Subversion.

#3 @earnjam
4 weeks ago

WordPress 5.0 was released around the same time as PHP 7.3, and was the first version with designated PHP 7.3 support.

I'm not against this per se, but I'm not sure if backporting PHP compatibility updates to older WP versions is something we typically do. I'd lean toward closing this, but I defer to those with more experience in this area.

#4 @jorbin
4 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #44416.

This was fixed in [43819]. 5.0 is the first version that supported PHP 7.3. WordPress 4.9 is now 3 versions behind, I would encourage you to update to the latest version.

Note: See TracTickets for help on using tickets.