Skip to content

Fatal error: Uncaught TypeError: Cannot access offset of type string - possible interaction with AAA Option Optimizer #10573

@tacoverdo

Description

@tacoverdo

Bug Description

When running Site Kit (v1.149.1) and AAA Option Optimizer (v1.3.1) while running WordPress 6.8-RC1, a fatal error is thrown on the AAA Option Optimizer admin page.

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /.../wp-content/plugins/google-site-kit/includes/Core/Modules/Modules.php:939
Stack trace:
#0 /.../wp-content/plugins/google-site-kit/includes/Core/Util/Method_Proxy_Trait.php(25): Google\Site_Kit\Core\Modules\Modules->populate_default_shared_ownership_module_settings()
#1 /.../wp-includes/class-wp-hook.php(326): Google\Site_Kit\Core\Modules\Modules->Google\Site_Kit\Core\Util\{closure}()
#2 /.../wp-includes/plugin.php(205): WP_Hook->apply_filters()
#3 /.../wp-includes/option.php(199): apply_filters()
#4 /.../wp-content/plugins/aaa-option-optimizer/src/class-admin-page.php(270): get_option()
#5 /.../wp-includes/class-wp-hook.php(324): Emilia\OptionOptimizer\Admin_Page->render_admin_page()
#6 /.../wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#7 /.../wp-includes/plugin.php(517): WP_Hook->do_action()
#8 /.../wp-admin/admin.php(260): do_action()
#9 /.../wp-admin/tools.php(40): require_once('/home/u83550p78...')
#10 {main} thrown in /.../wp-content/plugins/google-site-kit/includes/Core/Modules/Modules.php on line 939

Steps to reproduce

  1. Install and activate AAA Option Optimizer & Site Kit.
  2. Go to Tools -> Option Optimizer
  3. See error

Screenshots

Image

Additional Context

  • PHP Version: 8.1.29 (Supports 64bit values)
  • OS: MacOS Sequoia 15.4
  • Browser: [e.g. chrome, safari] Chrome (version 134.0.6998.166 (Official Build) (arm64))
  • Plugin Version: 1.149.1
  • Device: Apple M3 Pro

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • All usage of default_filter_$option should be reviewed for type safety and updated to avoid potential errors related to mismatch of types.
    It is not safe to assume the option value in the filter callback will have the same type as the registered default since a provided $default when calling get_option will take precedence.

Implementation Brief

  • In includes/Core/Modules/Modules.php:
    • Update the populate_default_shared_ownership_module_settings method:
      • In the beginning, check if the passed $sharing_settings is an array. If not, cast it to an empty array.
  • In includes/Modules/Search_Console/Settings.php:
    • In the register method, update the filter callback for the 'default_option_' . self::OPTION hook:
      • In the beginning, check if the passed $default_option is an array. If not, cast it to the get_default method.

Test Coverage

  • No tests need to be added or updated.

QA Brief

  1. Install and activate AAA Option Optimizer & Site Kit.
  2. Go to Tools -> Option Optimizer
  3. No error should appear

Changelog entry

  • Fix bug that can occur when AAA Option Optimizer plugin is installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Medium priorityPHPTeam SIssues for Squad 1Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions