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.
Comment | File | Size | Author |
---|---|---|---|
#51 | interdiff-2873684.txt | 552 bytes | catch |
#49 | interdiff.2873684.41-49.txt | 3.17 KB | longwave |
#49 | 2873684-49.drupal.Replace-all-calls-to-dbselect-which-is-deprecated.patch | 103.75 KB | longwave |
Comments
Comment #2
jeetendrakumar CreditAttribution: jeetendrakumar as a volunteer and at HyTechPro.com commentedComment #3
jeetendrakumar CreditAttribution: jeetendrakumar as a volunteer and at HyTechPro.com commentedComment #6
volegerReroll for 8.6.x
Reverted changes for SelectTest.
Comment #7
joelpittetThere are a few comment references and
core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
Are those meant to be replaced in this patch as well?Comment #8
volegerThis is from meta issue #2848161: [meta] Replace calls to deprecated db_*() wrappers:
So, as I understand, calls inside tests that cover that function shouldn't be replaced.
Comment #10
andypostComment #11
volegerRerolled
Added legacy test
Applied recommendations from #2991337: Document the recommended ways to obtain the database connection object
Comment #12
volegerComment #14
andypostthis is controller - needs DI
Comment #15
volegerRerolled after #2996441: Replace all calls to db_query_temporary, which is deprecated.
Also #2996441: Replace all calls to db_query_temporary, which is deprecated. addressed #14 so patch is ready for review
Comment #17
volegerJust reroll, no changes
Comment #19
andypostqueued for retest mysql cos failure looks unrelated
Comment #20
longwaveProbably should postpone on #2853118: Replace all calls to db_insert, which is deprecated as it is just going to need another reroll, all these db_* deprecation patches keep clashing in DatabaseLegacyTest.
Comment #21
andypostyep, better to reroll it after db_insert patch
Comment #22
volegerPostponed on #2853118: Replace all calls to db_insert, which is deprecated
Comment #23
longwavedb_insert is in, so rerolled this one hopefully for the final time.
Comment #24
andypostHope it is green!
Comment #25
andypostAdjust credits -
@jeetendrakumar
somehow was excludedComment #27
volegerreroll after #2996030: Convert web tests to browser tests for node module - round 2
Comment #28
mondrakeI am not so sure about this. The replica target is dealt with in db_select by selecting a different connection through Database::getConnection:
Database::getConnection($options['target'])->select($table, $alias, $options);
but
$this->connection->select('test_task', 'tt', ['target' => 'replica'])
is not changing the connection AFAICS.
We should address #2947775: Move setting default target out of db_merge() and other deprecated db_* functions first?
More eyes please...
Comment #29
volegerAddressed #28
Comment #30
longwaveIs it worth catching the 'target' option being accidentally passed to Query::_construct() and triggering an error on this? This would mean modifying all the deprecated db_*() functions slightly to remove that from the array, but it would catch bugs elsewhere now this parameter has moved.
Comment #31
andypostas you affect this lines, please use
ViewsSearchQuery::class
directly instead of stringComment #32
mondrake#30 but that would practically mean that we are deprecating passing the 'target' key in the $options array, no? And creating a BC break.
IMHO we should try to address this in lower level in Connection::query / prepareQuery / prepare so that when the 'target' key is set, the statement is prepared against the target connection and not the default one. In other words, swap the used connection on lower level and keep BC.
Comment #33
andypost@mondrake Good point about keeping BC
On one hand it is "strange" to change connection withing connection object
otoh functional wrappers were working this way... but "database::select/query" do not
So allowing changing connection through options is API addition and not very useful
But makes sense to update CR about that - db_select & database::select already works this way since 8.0
Comment #34
volegerSo, should this issue be postponed to #2947775: Move setting default target out of db_merge() and other deprecated db_* functions?
Comment #35
mondrakeTagging "Needs framework manager review" as I think direction is needed here now.
Comment #36
mondrakeYes let's postpone.
Comment #37
mondrakeComment #38
volegerComment #39
longwaveWhy is this a BC break? 'target' isn't currently supported anyway when called via the OO route, you have to explicitly specify the target when calling getConnection(). If not an error we could log a warning or a silenced error?
Comment #40
catchUnpostponing based on the discussion in #2947775: Move setting default target out of db_merge() and other deprecated db_* functions - using Database::getconnection() when you need to specify the target is fine for conversions.
Comment #41
volegerRerolled and addressed #31
Comment #42
longwaveComment #43
mondrakeStrange it looks like in the interdiff these were reverted but it seems the patch is OK. Back to RTBC.
Comment #44
mondrakeJust confirming that applying the patch and checking with
git grep db_select
there are no more occurences in code. There's a bunch of leftover references in comments and in test messages but I suppose these can be addressed in a follow-up documentation issue.Comment #45
andypostThis is no-go cos \Drupal::database() has no $target argument, so it needs to use other "factory"
Comment #46
mondrakeThis is postponed now.
Comment #47
mondrakeComment #48
catchI don't think it needs to be postponed, we can use Database::getConnection() in the places that need it, then the database factory service issue can either convert or have a follow-up to convert those cases.
Comment #49
longwaveChanged replica connections to
Database::getConnection()
as per #48Comment #50
volegerLooks good
Comment #51
catchFixed this docs issue on commit, and pushed to 8.7.x, thanks! This issue flushed quite a lot of other issues out, see you in the follow-ups.