Download & Extend

taxonomy_term_count_nodes does not cache the 0 result

Project:Drupal core
Version:7.x-dev
Component:taxonomy.module
Category:bug report
Priority:normal
Assigned:Island Usurper
Status:closed (fixed)

Issue Summary

When the query in taxonomy_term_count_nodes returns no rows, $count[$type] is never set. Therefore subsequent calls to this function for that type have to run the query again.

I don't have easy access to cvs and diff, so I'll roll a patch later today. The fix is one line before the while loop:
  $count[$type] = array();

Comments

#1

Status:active» needs review

The long awaited patch is here at last.

AttachmentSizeStatusTest resultOperations
taxonomy_patch.diff770 bytesIgnored: Check issue status.NoneNone

#2

Title:taxonomy_term_count_nodes does not cache the empty result» taxonomy_term_count_nodes does not cache the 0 result
Version:6.x-dev» 5.7
Priority:minor» normal

Updating to show that more people have noticed this bug. Duplicate issue found at #259243: Wrong cache of node count for taxonomy when count is 0 in function taxonomy_term_count_nodes()

#3

Version:5.7» 7.x-dev
Status:needs review» reviewed & tested by the community

Committed to 5.x.

Applies to 6.x and HEAD, so needs to be committed there.

#4

Status:reviewed & tested by the community» fixed

Committed to HEAD and DRUPAL-6.

#5

Status:fixed» closed (fixed)

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

nobody click here