Skip to content

fix(terms): erase generated terms via the correct flag option key - #228

Merged
bordoni merged 1 commit into
mainfrom
fix/219-erase-terms-key-mismatch
Jul 16, 2026
Merged

bordoni merged 1 commit into
mainfrom
fix/219-erase-terms-key-mismatch

Conversation

@bordoni

@bordoni bordoni commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Fixes #219

Problem

The "Erase faked data" tool did not delete generated Categories (or any terms); all other faked data was removed correctly.

Root cause

Term generation flags terms in the option fakerpress.module_flag.terms (plural, via get_slug()):

update_option( 'fakerpress.module_flag.' . $this::get_slug(), $flagged ); // ...terms

But fetch() and delete() hard-coded the singular key:

public static function fetch( array $args = [] ): array {
    return get_option( 'fakerpress.module_flag.term', [] ); // singular -> always []
}

So the erase routine always received an empty set and never called wp_delete_term().

Fix

Align fetch()/delete() to the same get_slug()-based key that generation writes. Terms generated before the fix were stored under the plural key, so they are now correctly picked up.

Tests

TermEraseTest covers the flag → fetch → delete cycle: fetch() returns the flagged terms, and delete() removes both a category and a tag and clears the flag option.

Milestone: 0.9.2

Term generation flags terms in the option fakerpress.module_flag.terms
(plural, via get_slug()), but fetch()/delete() read and cleared the singular
fakerpress.module_flag.term, so 'Erase faked data' always collected an empty
set and never removed generated categories/tags. Align fetch()/delete() to the
plural key with regression coverage for the flag -> fetch -> delete cycle.

Fixes #219
@bordoni bordoni added this to the 0.9.2 milestone Jul 16, 2026
@bordoni
bordoni merged commit 0791e31 into main Jul 16, 2026
3 of 5 checks passed
@bordoni
bordoni deleted the fix/219-erase-terms-key-mismatch branch July 16, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

“Erase faked data” does not delete generated categories

1 participant