Skip to content

Conversation

@michael-sumner
Copy link
Member

@michael-sumner michael-sumner commented Dec 15, 2025

Description of the Change

When accessing the /wp-admin/ there is a PHP error that can appear:

Warning: Trying to access array offset on value of type bool in /var/www/html/wp-content/plugins/headstartwp/includes/classes/Links.php on line 67

The error occurs because:

  1. get_object_taxonomies( $post_type, 'object' ) returns taxonomy objects
  2. Some taxonomies have $taxonomy->rewrite set to false instead of an array
  3. The original code attempted to access $taxonomy->rewrite['slug'] without checking if rewrite is an array
  4. PHP 7.4+ throws a warning when accessing array offset on boolean false

How to test the Change

  1. Clear rewrite rules: delete_option( 'rewrite_rules' )
  2. Access /wp-admin: Should regenerate rules without errors
  3. Check error logs: No PHP warnings should appear
  4. Verify rewrite rules: Check that valid taxonomies still have rules generated
  5. Test with problematic taxonomy: Register taxonomy with rewrite => false and show_in_rest => true, verify no errors
  • Create taxonomy with rewrite => false and show_in_rest => true
  • Access /wp-admin after clearing rewrite rules
  • Manually flush rewrite rules via Settings → Permalinks
  • Activate/deactivate plugins that register taxonomies
  • Test with multiple post types and taxonomies
  • Verify no PHP warnings in error logs
  • Verify rewrite rules are generated correctly

Changelog Entry

Fixed - error when taxonomy rewrite is not an array

Credits

Props @michael-sumner

Checklist:


Note

Add a check to skip taxonomies with non-array or missing rewrite['slug'] when building rewrite rules to avoid PHP warnings.

  • Links (wp/headless-wp/includes/classes/Links.php):
    • In create_taxonomy_rewrites, skip taxonomies when rewrite is not an array or rewrite['slug'] is empty, preventing access of array offsets on non-arrays and limiting rule generation to valid taxonomies.

Written by Cursor Bugbot for commit 82cf7d6. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

⚠️ No Changeset found

Latest commit: 82cf7d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Dec 15, 2025

@michael-sumner is attempting to deploy a commit to the tenup-internal Team on Vercel.

A member of the Team first needs to authorize it.

@michael-sumner michael-sumner added the bug Something isn't working label Dec 15, 2025
@nicholasio
Copy link
Member

@michael-sumner could you add a changelog? run npx changeset and select the plugin and add a short changelog. This will bump the plugin version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants