Closes the three problems that blocked the consolidation and records the rest
as tasks.
Licence: GPLv2 or later (WordPress.org compatible)
LICENSE is now the full GPLv2 text and NOTICE is gone (it was Apache
specific). All 101 SPDX headers read GPL-2.0-or-later and every shipped
header says "GPLv2 or later".
This also fixes an inconsistency that predated the consolidation: the theme's
style.css declared GPLv2 while its PHP files carried Apache headers.
Old/ and archive/pre-umbra-releases/ keep their original Apache headers on
purpose -- they are frozen snapshots, not shipped code.
Schema: the catalogue schema is canonical for bd_books and bd_series
Adds Umbra_Schema_Migration. The catalogue and library modules previously
both created those two tables with different columns, so whichever plugin
activated first won and the other read and wrote against the wrong shape.
The migration detects a library-shaped table, RENAMES it aside (never drops
it), creates the canonical table and copies rows across:
- book IDs preserved, keeping bd_book_meta, bd_reviews, bd_ratings and
bd_review_shortlinks valid
- title/slug/description resolved from the linked post
- the library's single isbn/asin land on the ebook columns; amazon_asin is
also set so existing product links keep working
- series migrated first so books.series_id still resolves
- post linkage rewritten as _bd_bookshelf_book_id (preserved meta key)
- publish_date kept as _bd_bookshelf_publish_date (no catalogue column)
- bd_ratings goodreads/amazon folded into rating_goodreads/rating_amazon
- rows whose post is gone are skipped with a log line, not turned into
unusable books
- duplicate slugs de-duplicated, since catalogue slug is UNIQUE
It runs before dbDelta, and on admin_init as well as activation, because
plugin updates do not re-run activation hooks. Ordering matters: dbDelta adds
columns but never drops them, so pointed at a library-shaped table it would
graft on catalogue columns and leave a table satisfying neither schema.
Umbra_Bookshelf_Helper_Install no longer creates bd_books or bd_series.
Scraping: Goodreads only, one implementation
There were three Goodreads implementations and two Amazon ones; both library
"scrapers" were empty stubs attached to cron events that fired on schedule to
do nothing, and both real scraper classes were never called at all.
Umbra_Amazon_Scraper is deleted and the duplicate HTML parsing is gone from
Umbra_Rating_Sync, which now delegates to Umbra_Goodreads_Scraper. The two
library stubs and their cron registrations are removed. One schedule
survives: bd_bookshelf_sync_ratings, every 12 hours.
The rating_amazon column is retained (it holds data and is populated during
migration) and Amazon retail links are unaffected.
A new rating fetch failure keeps the last known value instead of writing zero.
The admin ratings notice no longer warns about Amazon scraping.
Umbra_SEO is now instantiated
It registers its hooks from a constructor and the bootstrap never constructed
it, so the class was dead code and no SEO output was produced. Its meta, Open
Graph, Twitter card and sitemap hooks now attach. Completing SEO for generated
book detail pages is docs/TASKS.md #2.
Assets that 404'd
- assets/images/default-cover.png now holds a real 512x815 cover
(WorkingTitleCover_512x815.png). The helper returned this path but the
repository contained no images at all.
- email/assets/js/admin.js is committed as an empty placeholder. It was
enqueued on every email admin page but had never been committed.
Tests
- tests/schema_migration_test.php: 42 checks against a real database, driven
through the sqlite3 CLI on a throwaway file. Covers shape detection, row
mapping, ID preservation, orphan handling, rating folding, idempotency and
slug collisions.
- tests/run_all.sh runs every suite.
- The declared version is now checked against the plugin header rather than a
literal, so a version bump cannot silently break the suite.
Docs
- KNOWN-ISSUES.md rewritten: three resolved, three remaining.
- TASKS.md added: email admin behaviour, book detail page SEO, batching the
rating sync, reclaiming legacy tables, reconciling the two book models,
retiring the Old/ archive.
- SPEC and ARCHITECTURE updated for schema ownership, the migration ordering
constraint, and the single scraper.
Version 1.1.0.
82 lines
3.9 KiB
Markdown
82 lines
3.9 KiB
Markdown
# Architecture
|
|
|
|
## Why one plugin
|
|
|
|
Three plugins shipped the same product surface under three admin menus and
|
|
shared two cron hooks. Users installed, updated and deactivated them
|
|
independently while the code assumed all three were present. Consolidating into
|
|
one plugin makes the dependency explicit and lets one activation hook set up a
|
|
consistent state.
|
|
|
|
The trade-off is that three independent `add_menu_page` calls, three sets of
|
|
admin assets and three activation routines now share a single namespace. Every
|
|
one of those collided, and each collision is recorded in `KNOWN-ISSUES.md`.
|
|
|
|
## Layers
|
|
|
|
```
|
|
umbra-bookshelf.php (bootstrap)
|
|
├── constants one UMBRA_BOOKSHELF_* set
|
|
├── requires 21 class files, three modules
|
|
├── plugins_loaded construct modules
|
|
├── init text domain
|
|
└── admin_menu(9) single top-level menu
|
|
│
|
|
┌──────────────────────────┼──────────────────────────┐
|
|
│ │ │
|
|
includes/books includes/library includes/email
|
|
Umbra_Database *owns bd_books/bd_series* Umbra_Simple_Email
|
|
Umbra_Book_Manager …_Helper_Admin …_Admin
|
|
Umbra_Authors …_Helper_Install …_Install
|
|
Umbra_Series Umbra_Email_Sender
|
|
Umbra_Retail_Sites
|
|
Umbra_Rating_Sync
|
|
Umbra_Shortcodes
|
|
Umbra_SEO assets: admin/, public/, library/, email/
|
|
Umbra_GDPR assets/
|
|
Umbra_Goodreads_Scraper (only scraper)
|
|
Umbra_Admin
|
|
Umbra_Migration
|
|
Umbra_Theme_Compatibility -> class_alias BD_BookShelfHelper
|
|
|
|
includes/class-umbra-schema-migration.php reconciles pre-consolidation schemas
|
|
```
|
|
|
|
## Design rules
|
|
|
|
**One owner per name.** Every class, constant, asset handle, menu slug and AJAX
|
|
action is owned by exactly one module. The bootstrap owns the top-level menu and
|
|
the shared constants; modules own their submenus and assets.
|
|
|
|
**Persistence is not part of the identity.** Anything written to the database or
|
|
embedded in published content keeps its historical name. The rename covers
|
|
headers, text domains, classes, constants, handles, slugs and JS globals — never
|
|
table names, option keys, meta keys, cron hooks, nonces, shortcodes, post types,
|
|
taxonomies or cookies. See §2.2 of the specification for the full list.
|
|
|
|
**Registration order is explicit.** The top-level menu registers at
|
|
`admin_menu` priority 9 so the parent exists before modules append submenus at
|
|
the default 10. Modules construct on `plugins_loaded` so their own `init`
|
|
callbacks are registered before `init` fires.
|
|
|
|
**Compatibility shims are explicit.** `Umbra_Theme_Compatibility` exposes the
|
|
static API the unmodified theme calls, and re-exports the legacy
|
|
`BD_BookShelfHelper` name via `class_alias()`.
|
|
|
|
**One owner per table.** `bd_books` and `bd_series` belong to the catalogue. The
|
|
library module deliberately no longer creates them. Where an installation was
|
|
built on the old library schema, `Umbra_Schema_Migration` renames the old table
|
|
aside, creates the canonical one, and copies rows across preserving IDs.
|
|
|
|
**Schema work happens before `dbDelta`, never after.** `dbDelta` adds columns but
|
|
never drops them, so pointing it at a table of the wrong shape produces a table
|
|
that satisfies neither schema. Reconciliation therefore runs first, and the
|
|
migration is what guarantees the invariant.
|
|
|
|
## Still to reconcile
|
|
|
|
Making the catalogue schema canonical removed the *table* conflict. The two
|
|
modules still model a book differently — the catalogue as a row in `bd_books`,
|
|
the library as a `book` custom post type with per-post meta — and nothing keeps
|
|
them in step. See `TASKS.md` §5.
|