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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Damien Tournoud’s picture

Status: Active » Needs review
FileSize
1.15 KB

I 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).

Status: Needs review » Needs work

The last submitted patch, 978144-get-getmultiple-inconsistencies.patch, failed testing.

Eric_A’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 978144-get-getmultiple-inconsistencies.patch, failed testing.

Eric_A’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 978144-get-getmultiple-inconsistencies.patch, failed testing.

Eric_A’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 978144-get-getmultiple-inconsistencies.patch, failed testing.

Eric_A’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 978144-get-getmultiple-inconsistencies.patch, failed testing.

Eric_A’s picture

After 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

Eric_A’s picture

Eric_A’s picture

Status: Needs work » Needs review

I just found #851136: Make the database autoloading more robust. It just got committed.

Eric_A’s picture

Eric_A’s picture

Eric_A’s picture

Status: Needs review » Reviewed & tested by the community

This "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.

webchick’s picture

Testbot appears to be stuck.

Dries’s picture

I don't see a reason not to simplify the code like this.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Me neither. Just wanted to make sure testbot was cool with it, since it was frozen for awhile yesterday.

Committed to HEAD. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.