Skip to content

[Bug]: Fatal error in pagination-helper.php:74 when wp_parse_url() returns false (PHP 8.x) #23057

@ProjectEli

Description

@ProjectEli

Prerequisites

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

Environment:

  • WordPress 6.9.1
  • PHP 8.3
  • Yoast SEO (latest stable)
  • Bitnami WordPress on AWS Lightsail (Apache + proxy_fcgi)

Reproduction steps, expected results, actual results: see below.

Suggested fix:

// pagination-helper.php, around line 74
$url_parts = \wp_parse_url( $url );
if ( ! is_array( $url_parts ) ) {
    return $url;
}
$has_url_params = \array_key_exists( 'query', $url_parts );

Notes:

  • The root cause of the malformed URL is Bitnami's wp-config.php default template, but Yoast should still handle wp_parse_url() returning false as a standard failure case.

Step-by-step reproduction instructions

Steps to reproduce:

  1. Install Yoast SEO on a Bitnami WordPress instance where WP_HOME is dynamically set via $_SERVER['HTTP_HOST']
  2. A request arrives without the Host HTTP header (e.g., from a bot, internal proxy, or health check)
  3. WP_HOME becomes http:/// (empty host)
  4. On the frontend, Yoast calls Pagination_Helper->get_paginated_url() which calls wp_parse_url($url)
  5. wp_parse_url('http:///') returns false
  6. array_key_exists('query', false) throws a TypeError on PHP 8.x

Expected results

Yoast should gracefully handle the case where wp_parse_url() returns false, instead of passing it to array_key_exists().

Actual results

Error message:

PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, false given
in wordpress-seo/src/helpers/pagination-helper.php:74
Stack trace:
#0 .../archive-adjacent-trait.php(77): Pagination_Helper->get_paginated_url()
#1 .../abstract-presentation.php(66): Indexable_Home_Page_Presentation->generate_rel_next()

Screenshots, screen recording, code snippet

No response

Which editor is affected (or editors)

  • Block Editor
  • Gutenberg Editor
  • Elementor Editor
  • Classic Editor
  • Other (please specify in additional info)

Which browser is affected (or browsers)

  • Chrome
  • Firefox
  • Safari
  • Other (please specify in additional info)

Device you are using

No response

Operating system

No response

PHP version

No response

WordPress version

6.9.1

WordPress Theme

No response

Yoast SEO version

27.1.1

Gutenberg plugin version (if relevant)

No response

Elementor plugin version (if relevant)

No response

Classic Editor plugin version (if relevant)

No response

Relevant plugins in case of a bug

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions