SqlBase::prepareQuery() should be called also on count

Created on 5 December 2016, over 7 years ago
Updated 12 October 2023, 9 months ago

Problem/Motivation

Suppose that in a source plugin, extending from SqlBase, you want to override SqlBase::prepareQuery() and use that to add additional tags or meta-data to the query. You don't do that in ::query() method for some good reasons (for example you want to apply tags & meta-data only after the query was defined). If a hook_query_TAG_alter() that uses those tags adds a new condition then SqlBase::count() is lying.

For this reason, this is a blocker for #3069776: SQL source plugins: allow defining conditions and join in migration yml β†’ , which introduces some query modifications in ::prepareQuery() method.

Proposed resolution

Make SqlBase::count() aware of SqlBase::prepareQuery().

Remaining tasks

Review / commit.

There are no User interface, API, or data model changes.

πŸ› Bug report
Status

Needs work

Version

10.0 ✨

Component
MigrationΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States douggreen Winchester, VA

    Attached is an equivalent fix for D7.

    I do wonder if the preExecute() should be done on the original query before clone is called, so that the hook_query_tag_alter()'s get called once instead of twice, when the same query is used for both a count and an execute... But the D9 version does it here in the counting, so I've kept it the same here.

  • last update 9 months ago
    2,161 pass
Production build 0.69.0 2024