Skip to content

Add DB migration + filter back-compat for inline_glossary rename - #56

Open
ilicfilip wants to merge 1 commit into
rename/inline-glossaryfrom
rename/inline-glossary-migration
Open

Add DB migration + filter back-compat for inline_glossary rename#56
ilicfilip wants to merge 1 commit into
rename/inline-glossaryfrom
rename/inline-glossary-migration

Conversation

@ilicfilip

Copy link
Copy Markdown
Contributor

Stacks onto #55. That PR renames all code identifiers to inline_glossary but, as its own description flags, leaves DB-stored identifiers unmigrated — so any existing install would silently orphan its glossary entries and settings on upgrade. This adds the migration to fix that, plus filter back-compat.

What this adds

DB migration (migrate_to_1_4_0) — gated on db_version < 1.4.0, renames the stored identifiers so data carries over:

Identifier Old New
Post type pp_glossary inline_glossary
Meta key _pp_glossary_data _inline_glossary_data
Option pp_glossary_settings inline_glossary_settings
Block name in post_content wp:pp-glossary/glossary-list wp:inline-glossary/glossary-list

Flushes rewrite rules afterward (post type slug changed). run_migrations() now also falls back to the old option name when reading db_version, so the upgrade path is detected.

Bug fix in the 1.1.0 migration#55 renamed the legacy read keys (_pp_glossary_short_description, etc.) to _inline_glossary_*. Those keys only ever existed under the pp_glossary prefix, so the consolidation would never match real pre-1.1.0 data. Reverted those reads to the legacy names; the consolidation runs in the pp_glossary namespace and the later 1.4.0 step renames to inline_glossary.

Filter back-compatpp_glossary_excluded_tags and pp_glossary_disabled_post_types still fire, with _doing_it_wrong notices pointing to the inline_glossary_* names.

Version bump 1.3.1 → 1.4.0 — the bump is what actually fires the migration on existing installs. Updates the header, INLINE_GLOSSARY_VERSION, Stable tag, and adds a changelog entry.

Verification

composer lint, composer phpstan, and composer check-cs all pass.

Note

The migration uses direct $wpdb queries (post type may not be registered under the old slug at migration time) and is not idempotent-guarded beyond the version gate — it relies on db_version to run once, consistent with the existing 1.1.0 migration. A site already on inline_glossary data with no db_version bump won't be affected since there's nothing under the old names to rename.

🤖 Generated with Claude Code

Existing installs on the old pp_glossary identifiers would orphan their
data on upgrade. This adds a 1.4.0 migration that renames the stored DB
identifiers so entries and settings carry over:

- Post type:  pp_glossary        -> inline_glossary
- Meta key:   _pp_glossary_data  -> _inline_glossary_data
- Option:     pp_glossary_settings -> inline_glossary_settings
- Block name in post content: wp:pp-glossary/... -> wp:inline-glossary/...

Also:
- Fix the 1.1.0 consolidation migration to read the legacy _pp_glossary_*
  meta keys (they only ever existed under the pp_glossary prefix).
- Deprecate the pp_glossary_excluded_tags and pp_glossary_disabled_post_types
  filters with _doing_it_wrong notices; old names still work.
- Bump version 1.3.1 -> 1.4.0 (the bump is what fires the migration) and
  add a changelog entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>
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.

1 participant