In nodequeue_save() we have the code:

    if (function_exists('views_invalidate_cache')) {
      views_invalidate_cache();
    }

That will lead to errors when these conditions are met:

* Your site uses both nodequeue and views.
* One of your modules depend on nodequeue but not on views (also no indirect dependency).
* That module implements a DrupalWebTestCase.
* The test case will now fail.

Why?

The function_exists('views_invalidate_cache') call will return TRUE because your system has views enabled and hence views_invalidate_cache() will be executed. But views_invalidate_cache() will fail because it expects the database table {cache_views} to be present. The {cache_views} table will not be present when executing the test case because the test case uses a prefixed database and since the test case has not installed views there is no {cache_views} in the prefixed database.

If we use module_exists('views') instead we get the correct behaviour because test cases rebuilds the list of enabled modules.

CommentFileSizeAuthor
#1 nodequeue-module-exists-1984026-1.patch377 bytesarnested

Comments

arnested’s picture

Status: Active » Needs review
StatusFileSize
new377 bytes
arnested’s picture

There is a number of other usages of function_exists() in nodequeue.module (and one i nodequeue_generate.module) but they all rely on function names derived from $queue->owner.

I think we can assume those to work unless someone has implemented really obscure usages of nodequeues.

gielfeldt’s picture

I haven't investigated this, but if the function_exists() is used because of compatibility between the nodequeue module and different versions of views, then there should probably be a check for both module_exists() and function_exists().

arnested’s picture

Good point, @gielfeldt.

views_invalidate_cache() has been in views at least since October 2009 (as far back as I can see in git) so I don't think we need to check with both module_exists() and function_exists() in this case.

  • fizk committed 3738b2c on 7.x-2.x authored by arnested
    Issue #1984026 by arnested: Use module_exists() instead of...
fizk’s picture

Issue summary: View changes
Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

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