Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
As the db_change_field()
method is deprecated, we should no longer use it in Drupal core.
Proposed resolution
Let's replace with \Drupal::database()->schema()->changeField()
.
Remaining tasks
- Replace db_change_field() in documentation.
- Replace db_change_field() with \Drupal::database()->schema()->changeField(); in code
Follow-up issue will be needed to inject the proper service after all the replacing is done.
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#31 | interdiff_30-31.txt | 2.39 KB | mondrake |
#31 | 2820179-31.patch | 5.97 KB | mondrake |
Comments
Comment #2
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedAdded first patch for revision.
Comment #3
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedComment #4
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedComment #6
cilefen CreditAttribution: cilefen commentedI am reparenting this to the meta of all things replacing db_
Comment #7
daffie CreditAttribution: daffie commentedPatch looks good, but I do have some remarks:
You cannot have more then 80 characters on a line with documentation.
Please use
\Drupal::database()
instead ofDatabase::getConnection()
.Can we change this also to
\Drupal::database()->schema()->changeField()
.Comment #8
darkdimChanged
Comment #9
darkdimComment #10
darkdimFixed correction in #7 comment
Comment #11
cilefen CreditAttribution: cilefen commentedThis is probably not happening in 8.3 and note that we are trying to move doc changes to #2849745: Replace documentation recommending db_*() wrappers.
Comment #12
daffie CreditAttribution: daffie commentedThe patch is the same as the patch from comment #10, only without the documentation changes. Those will be done in #2849745: Replace documentation recommending db_*() wrappers.
Comment #13
daffie CreditAttribution: daffie commentedAll code changes are good.
All instances of the usage of
db_drop_table()
are replaced.The patch looks good to me.
Because the patch was written by @darkdim, am I allowed to change the status to RTBC.
Comment #14
xjmThanks all. Those two usages are the self-tests of this function. So, this issue should maybe be closed as a duplicate of the docs one and whatever issue we file to look at the SchemaTest and other DB Kernel tests as a whole.
Comment #17
andypostIn #2848817-28: Replace all calls to db_table_exists, which is deprecated. I found one more test for refactoring
Actually docs issue is blocked on #2319859: [META] Deprecate contents of database.inc so here needs work to throw exception, working on it
Comment #18
andypostKind of that should be enough
Comment #20
andypostMaybe it makes sense to create a separate test class for all deprecated functions testing?
Anyway this needs to be annotated with
@group legacy
to test expected exceptions but this makes all patches with such deprecated to require reroll if one commited like #2848952-33: Replace all calls to db_merge(), which is deprecatedComment #22
andypostAs #2848812: Replace all calls to db_set_active, which is deprecated. better to annotate per method
Also fixed version
Comment #24
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedFixed expectedDeprecation annotation
Comment #26
Mile23Patch no longer applies.
Comment #27
Mile23Comment #28
volegerPostponed on #2991542: Introduce a DatabaseLegacyTest class for deprecation testing and #2991337: Document the recommended ways to obtain the database connection object
Comment #29
mondrakeHere's a reroll + fixes to documentation.
We still miss a CR reference in the deprecation message. How about doing #2947946: Create change record for all deprecated db_* functions first and having a single Change Record with all the db* functions deprecated + directions on how to get the database connection being discussed in #2991337: Document the recommended ways to obtain the database connection object, instead of as many CRs as the deprecation issues?
Comment #30
mondrakeComment #31
mondrakeAdded reference to CR https://www.drupal.org/node/2993033
I think this is done now?
Comment #32
andypostLooks it ready
Comment #34
catchCommitted dcbb276 and pushed to 8.7.x. Thanks!