Problem/Motivation
StatementPrefetch::fetch() has some code that allows emulating different PDO fetch modes, since all data is prefetched on execution in FETCH_ASSOC format, and needs to be re-formatted according to the fetch mode used in each fetch. This code could be reused for contrib drivers that are not based on PDO.
Also, the initialization of a FETCH_CLASS fetch object with constructor arguments is based on reflection - since PHP 5.6 we could have been using the splat operator (...) instead.
Proposed resolution
- Extract the fetch emulation code in a trait with appropriate protected methods that can be used in statement classes.
- Implement that in the StatementPrefetch.
Remaining tasks
User interface changes
none
API changes
A new trait with protected methods.
Data model changes
none
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3347497
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3347497-introduce-a-fetchmodetrait
changes, plain diff MR !3676
Comments
Comment #2
mondrakePatch built on top of #3265086: Implement statement classes using \Iterator to fix memory usage regression and prevent rewinding, suggest to wait for that to happen first.
Comment #4
mondrakeParent got committed. Put the patch in a MR, for review.
Comment #5
daffie commentedAll code changes look good to me.
We already have testing for all the changes in the database FetchTest.
For me it is RTBC.
Comment #6
mondrakeFWIW, just implemented the trait in the mysqli driver on Github, https://github.com/mondrake/mysqli/commit/52da30ef0f1ab47d18ace0c7f4e89d...
All good.
Comment #8
amber himes matzLooks like this MR needs a rebase, as the merge is blocked. It might work to just click the Rebase button in the MR link.
Comment #9
mondrakeDone
Comment #11
catchLooks good to me, will make more sense once we add the mysqli driver but chicken-and-egg with that.
Committed/pushed to 11.x, thanks!