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.
The cache objects returned by cache_get_multiple() have a cid property, while the cache object returned by cache_get() does not. That's quite a WTF.
I'm not sure why in DrupalDatabaseCache::getMultiple the cid column is retrieved. If it is because of SQL standards regarding the IN operator, then one solution would be to just unset this property afterwards, although removal could perhaps be considered an API change. See also #333171: Optimize the field cache.
A different approach would be to fix this in cache_get() at the cost of a little extra resource usage.
Comment | File | Size | Author |
---|---|---|---|
#17 | 978144-get-getmultiple-inconsistencies.patch | 1.15 KB | webchick |
#1 | 978144-get-getmultiple-inconsistencies.patch | 1.15 KB | Damien Tournoud |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedI see no reason not to simply do this (it's not like this is a cheap function and that the additional call could possibly matter).
Comment #3
Eric_A CreditAttribution: Eric_A commented#1: 978144-get-getmultiple-inconsistencies.patch queued for re-testing.
Comment #5
Eric_A CreditAttribution: Eric_A commented#1: 978144-get-getmultiple-inconsistencies.patch queued for re-testing.
Comment #7
Eric_A CreditAttribution: Eric_A commented#1: 978144-get-getmultiple-inconsistencies.patch queued for re-testing.
Comment #9
Eric_A CreditAttribution: Eric_A commented#1: 978144-get-getmultiple-inconsistencies.patch queued for re-testing.
Comment #11
Eric_A CreditAttribution: Eric_A commentedAfter applying this patch locally on my standard profile install I got
Fatal error: Class 'SelectQuery_mysql' not found in C:\xampplite\htdocs\drupal\includes\database\database.inc on line 685
Comment #12
Eric_A CreditAttribution: Eric_A commentedI created #983132: DrupalDatabaseCache::getMultiple assumes it can rely on class autoloading.
Comment #13
Eric_A CreditAttribution: Eric_A commentedI just found #851136: Make the database autoloading more robust. It just got committed.
Comment #14
Eric_A CreditAttribution: Eric_A commented#1: 978144-get-getmultiple-inconsistencies.patch queued for re-testing.
Comment #15
Eric_A CreditAttribution: Eric_A commented#1: 978144-get-getmultiple-inconsistencies.patch queued for re-testing.
Comment #16
Eric_A CreditAttribution: Eric_A commentedThis "approach" needs to be taken sooner or later.
#851136: Make the database autoloading more robust was rolled back and then committed again with parts of it extended for pgsql and sqllite. I pushed the button again, waiting for the green.
Comment #17
webchickTestbot appears to be stuck.
Comment #18
Dries CreditAttribution: Dries commentedI don't see a reason not to simplify the code like this.
Comment #19
webchickMe neither. Just wanted to make sure testbot was cool with it, since it was frozen for awhile yesterday.
Committed to HEAD. Thanks!