Skip to content

Add PrimaryReplicaFeature; deprecate MasterSlaveFeature - #187

Merged
simon-mundy merged 3 commits into
php-db:0.6.xfrom
simon-mundy:feature/111-primary-replica-feature
Sep 28, 2026
Merged

simon-mundy merged 3 commits into
php-db:0.6.xfrom
simon-mundy:feature/111-primary-replica-feature

Conversation

@simon-mundy

Copy link
Copy Markdown
Member

Introduces PrimaryReplicaFeature with the neutral primary/replica terminology, carrying the full behaviour previously implemented by MasterSlaveFeature.

MasterSlaveFeature now extends PrimaryReplicaFeature and is marked @deprecated. Its constructor keeps the original parameter names so named arguments continue to work, and getSlaveAdapter()/getSlaveSql() proxy to getReplicaAdapter()/getReplicaSql(). It is slated for removal in the next major release.

Regenerates the mago lint and analyzer baselines.

Closes #111

Types of changes

  • Documentation improvement
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • RFC (Request for Comments, a discussion topic)
  • QA improvement (unit/integration tests, CS fixes, etc.) that does not change code behavior

Checklist:

  • An issue has been created for this pull request.
  • I have added tests for my changes.
  • All new and existing tests passed.
  • Documentation has been updated accordingly.
  • This pull request targets the correct branch.

@simon-mundy
simon-mundy requested a review from tyrsson September 28, 2026 01:04
@simon-mundy simon-mundy self-assigned this Sep 28, 2026
@simon-mundy simon-mundy added documentation Improvements or additions to documentation enhancement New feature or request qa Improvements in quality assurance of the project Platform migration Changes related to platform migrations next minor Target next minor release. labels Sep 28, 2026
@github-project-automation github-project-automation Bot moved this to Todo in @phpdb Sep 28, 2026
@simon-mundy simon-mundy added this to the 0.6.0 milestone Sep 28, 2026
Introduces PrimaryReplicaFeature with the neutral primary/replica
terminology, carrying the full behaviour of MasterSlaveFeature including
the nullable Sql state and the postInitialize()/postSelect() guard
clauses.

MasterSlaveFeature now extends PrimaryReplicaFeature and is marked
@deprecated. Its constructor keeps the original parameter names so named
arguments continue to work, and getSlaveAdapter()/getSlaveSql() proxy to
getReplicaAdapter()/getReplicaSql(). It is slated for removal in the next
major release.

Note that the RuntimeException message raised by postSelect() now refers
to the "primary" Sql instance rather than the "master" one.

Closes php-db#111
@simon-mundy
simon-mundy force-pushed the feature/111-primary-replica-feature branch from a072b78 to 1830c9f Compare September 28, 2026 01:13
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The Mago QA job fails on 0.6.x independently of any feature work: the
pinned toolchain is now mago 1.50.0, whose analyzer emits codes and
inferred types that the committed baselines predate, and two multi-line
conditions in AbstractTableGateway drifted from the formatter.

Reformats those conditions and regenerates both baselines so format,
lint and analyze pass again.

The regenerated analyzer baseline absorbs 15 genuine type-precision
complaints in Profiler, PredicateSet, AbstractSql and CreateTable. They
are suppressed here only to restore a green build; each still warrants
fixing on its own merit.
@simon-mundy
simon-mundy merged commit 253bc2c into php-db:0.6.x Sep 28, 2026
14 checks passed
simon-mundy added a commit to simon-mundy/phpdb that referenced this pull request Sep 28, 2026
…ructors

All 36 throw sites in src/TableGateway and src/RowGateway now call a named
constructor. Message text is byte-identical apart from the magic-access
messages noted below, verified template by template against the originals.

- Add 19 templates and factories to TableGateway\Exception\RuntimeException,
  4 to its InvalidArgumentException, 5 to RowGateway\Exception\RuntimeException
  and 2 to its InvalidArgumentException
- Cover PrimaryReplicaFeature, added by php-db#187. Its first guard reuses
  MISSING_SQL_INSTANCE; its second reports the primary rather than the master,
  so MISSING_MASTER_SQL becomes MISSING_PRIMARY_SQL. MasterSlaveFeature no
  longer throws, since php-db#187 left it delegating to the replacement
- Collapse the four "table name of the provided X object" copies onto one
  template taking the statement name
- Report the concrete class in the magic access messages: AbstractTableGateway
  interpolated self::class, so a TableGateway named its abstract parent. The
  three messages now carry static::class
- Point SequenceFeature at TableGateway\Exception\RuntimeException; it was
  throwing the root PhpDb\Exception\RuntimeException from inside the component
- Rename the test__* methods to testMagicGet, testMagicSet and testMagicCall
  forms and drop the codingStandardsIgnore pairs they needed
- Cover every factory with a template test, and derive the message assertions
  from the templates rather than restating them
- Re-attribute the baselined mixed-operand concatenation entry in
  AbstractRowGateway to the factory that now receives the argument, exclude
  src/TableGateway/Exception/ from too-many-methods, and baseline the halstead
  reading AbstractTableGateway shifts

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
simon-mundy added a commit to simon-mundy/phpdb that referenced this pull request Sep 29, 2026
…ructors

All 36 throw sites in src/TableGateway and src/RowGateway now call a named
constructor. Message text is byte-identical apart from the magic-access
messages noted below, verified template by template against the originals.

- Add 19 templates and factories to TableGateway\Exception\RuntimeException,
  4 to its InvalidArgumentException, 5 to RowGateway\Exception\RuntimeException
  and 2 to its InvalidArgumentException
- Cover PrimaryReplicaFeature, added by php-db#187. Its first guard reuses
  MISSING_SQL_INSTANCE; its second reports the primary rather than the master,
  so MISSING_MASTER_SQL becomes MISSING_PRIMARY_SQL. MasterSlaveFeature no
  longer throws, since php-db#187 left it delegating to the replacement
- Collapse the four "table name of the provided X object" copies onto one
  template taking the statement name
- Report the concrete class in the magic access messages: AbstractTableGateway
  interpolated self::class, so a TableGateway named its abstract parent. The
  three messages now carry static::class
- Point SequenceFeature at TableGateway\Exception\RuntimeException; it was
  throwing the root PhpDb\Exception\RuntimeException from inside the component
- Rename the test__* methods to testMagicGet, testMagicSet and testMagicCall
  forms and drop the codingStandardsIgnore pairs they needed
- Cover every factory with a template test, and derive the message assertions
  from the templates rather than restating them
- Re-attribute the baselined mixed-operand concatenation entry in
  AbstractRowGateway to the factory that now receives the argument, exclude
  src/TableGateway/Exception/ from too-many-methods, and baseline the halstead
  reading AbstractTableGateway shifts

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request next minor Target next minor release. Platform migration Changes related to platform migrations qa Improvements in quality assurance of the project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[RFC]: Rename MasterSlaveFeature to PrimaryReplicaFeature

2 participants