Skip to content

wp-abilities: Registrar::register_category() re-registers an existing category -> "already registered" _doing_it_wrong #55567

Backlog

Description

@HFigarella

projects/packages/wp-abilities/src/class-registrar.php, register_category() (trunk, around line 140) calls wp_register_ability_category( $slug, ... ) without checking whether the category already exists. When more than one Jetpack module/plugin shares a category slug, every later call logs a core _doing_it_wrong "Ability category ... is already registered" notice on each request.

register_abilities() in the same class already guards with wp_has_ability_category() (around line 170). Proposed fix, mirroring that:

if ( function_exists( 'wp_has_ability_category' ) && wp_has_ability_category( $slug ) ) {
	return;
}
wp_register_ability_category( $slug, static::get_category_definition() );

Seen with the Jetpack nightlies (Beta Tester, bleeding edge) on WordPress 7.2 trunk, PHP 8.6.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions