rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

Fatal error: Redirections admin screen with MySQL 8+ #242

Open MikeNGarrett opened 1 year ago

MikeNGarrett commented 1 year ago

Describe the bug Visiting /wp-admin/admin.php?page=rank-math-redirections throws a fatal error.

Fatal error: Uncaught Error: array_map(): Argument #2 ($array) must be of type array, null given
in /wp-content/plugins/seo-by-rank-math/includes/modules/redirections/class-db.php on line 50

To Reproduce Steps to reproduce the behavior:

  1. Go to /wp-admin/admin.php?page=rank-math-redirections
  2. See error

Expected behavior Seeing the admin UI for redirections.

Screenshots Mysql 5.7 (or equivalent)

Screenshot 2023-09-08 at 11 54 30 PM

Mysql 8.0+ (with ANSI_QUOTES not set to false)

Screenshot 2023-09-08 at 11 54 38 PM

Additional context Rank Math SEO (not pro) version 1.0.201.1 Mysql 8 with ANSI_QUOTES enabled.

Fix Change

        $redirction_counts = self::table()
            ->selectSum( 'status = "active"', 'active' )
            ->selectSum( 'status = "inactive"', 'inactive' )
            ->selectSum( 'status = "trashed"', 'trashed' )
            ->one( ARRAY_A );

to

        $redirction_counts = self::table()
            ->selectSum( "status = 'active'", 'active' )
            ->selectSum( "status = 'inactive'", 'inactive' )
            ->selectSum( "status = 'trashed'", 'trashed' )
            ->one( ARRAY_A );