Skip to content

Migrate model layer to b8 models (2.3.5) - #526

Merged
towfiq1997 merged 14 commits into
masterfrom
release/2.3.5
Jul 16, 2026
Merged

Migrate model layer to b8 models (2.3.5)#526
towfiq1997 merged 14 commits into
masterfrom
release/2.3.5

Conversation

@sultann

@sultann sultann commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Implements #525 — migrate the model layer to b8 models, ahead of the framework swap.

Status: foundation complete & green; the model conversion itself is the next commit and needs a design check (below) before I execute it — hence draft.

Done & verified (commits so far)

  1. src/ → includes/ consolidation — 35 files moved as tracked renames, autoload narrowed to includes/, every class verified resolving to the new path.
  2. PHPUnit harness + baseline suite (from tests/phpunit-baseline, bytekit-native) — green: 42 tests, 130 assertions on the current framework-model code. This is the behavior oracle the migration must keep green.
  3. byteever/models wired (dev-master) with Strauss prefixing → WooCommerceSerialNumbers\B8\Models\Model; baseline still 42 green with it installed.

Remaining: the model conversion (Key, Activation) — plan + landmines

The conversion surface is small (~34 accessors, ~20 static/CRUD calls) but carries real divergences I want your call on before writing it:

  • insert() param order — framework-model insert($data, $wp_error); b8 insert($data, $search, $wp_error). functions.php:165 Key::insert($args, $wp_error) must become Key::insert($args, null, $wp_error) or it silently passes $wp_error as $search.
  • get()find() — Key overrides get() to encrypt serial_key before lookup (Key.php:583). b8 has no get(); this override + its call sites (self::get, parent::get, functions.php) convert to find().
  • prepare_where_query() — framework-model's custom WHERE hook has no direct b8 equivalent; b8 uses fluent where() + the query_clauses filter. Key's custom query logic (encrypted-key lookup, custom clauses) needs re-implementing against b8's pipeline. This is the main re-write and the highest-risk piece.
  • view context — Activation getters default to 'view', which in framework-model applies a per-prop filter; b8 get() doesn't. Need to preserve (filter) or confirm unused.
  • save() return — framework-model returns true|WP_Error; b8 returns static|WP_Error. Call sites checking true === save() must move to is_wp_error().
  • Accessorsget_prop/set_prop/set_date_prop (34 sites). Decision needed: faithful instance adapters on the SN Model base (preserves contract + view filtering, smaller/safer, but a transitional adapter) vs full native conversion to $this->get()/set() (aligns with the convert-to-native preference, ~34 edits, drops view filtering unless re-added).

Gate before this leaves draft

  • Baseline stays 42 green through the conversion; add result-equivalence (old vs new Key) + pagination (paged) tests.
  • Build swap (esbuild/sass + autoprefixer, same paths) lands after the model conversion.
  • Tag byteever/models 1.0.0 and pin (drop dev-master) before release.

@towfiq1997
towfiq1997 marked this pull request as ready for review July 16, 2026 08:15
@towfiq1997
towfiq1997 merged commit 499eb7b into master Jul 16, 2026
17 checks passed
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.

2 participants