Hi,

I just created my first test using :

- condition -> String: URL path
- variant based on path mutation
- success condition -> form submit

When i visit the url of either my original (defined in the condition path) or variant 1, i get 'Fatal error: Call to undefined function list_themes() in /var/www/sites/all/modules/contrib/ctools/includes/plugins.inc on line 551 '.
The stacktrace shows me that the culprit is multivariate_boot(), calling multivariate_get_running_tests(), which calls some ctools functions too soon i guess...?

So yeah, tests aren't running for me in this setup.

CommentFileSizeAuthor
#3 fix_list_themes-1949122-3.patch759 bytesdeciphered

Comments

pieterdt’s picture

so, a solution that checks the availability of the ctools function before calling it seems to solve the fatal error:

function multivariate_get_running_tests() {
  static $running_tests = NULL;

  if (isset($running_tests)) {
    return $running_tests;
  }

  module_load_include('module', 'ctools', 'ctools');

  if (function_exists('list_themes')) {
    ctools_include('context');
    $running_tests = array();
    foreach (multivariate_get_enabled() as $test) {
      if (!empty($test->run_condition['plugins']) && ctools_access($test->run_condition)) {
        $running_tests[] = $test;
      }
    }
  }

  return $running_tests;
}

But then the A/B testing doesn't get triggered ever anymore.

Removing the condition, then lets the test work, but once cache is cleared, the fatal error returns.

making sure that the module weight of the multivariate modules is higher then those of ctools doesn't solve the issue.

So what seems to be the case:

  • calling ctools_include('context') fails when it happens too early on a clean cache
  • calling it on a warm cache of ctools functions, this seems to work.
pivica’s picture

Seems to me that Drupal core includes/theme.inc is not loaded and function list_themes(), from that file, is called.

Try to find out who is calling that list_themes() first - I see it is called from _ctools_list_themes() but who call it?

If you can copy&paste whole stack trace error infos here so I can take a look.

Note that multivariate has a lot of problems when it is running - because it need to do a lot of stuff before full Drupal bootstrap. Check multivariate_initialize_drupal() that is doing Drupal initialization for running tests. Maybe there we are missing theme.inc include for else scope?

deciphered’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new759 bytes

For the site I'm working on the issue is due to a CTools plugin being checked after via the Multivariate hook_boot(), so after Multivariates bootstrap alternative. The plugin checks against list_theme() but Multivariate doesn't include the two files needed for this function to run.

There are a variety of files not being included via Multivariates bootstrap alternative, but the attached patch only includes the two to deal with this issue.

deciphered’s picture

Title: Fatal error: Call to undefined function list_themes() » Some contribs need core file.inc/theme.inc included in boot phase
RecursiveMeta’s picture

I was receiving the error and I applied the patch successfully.

#3 fix_list_themes-1949122-3.patch solved the error for me.

QB89Dragon’s picture

I am also affected by this issue and the patch worked. Can we apply this upstream to ensure that future updates don't take down my site? I hit the white page of doom if this isn't applied.

deciphered’s picture

Someone (not the creator of the patch) needs to review the patch (confirm it works and doesn't break things) then mark this issue as RTBC.

bisonbleu’s picture

Status: Needs review » Reviewed & tested by the community

I reported a similar issue. I was getting a fatal error when saving a test on a clean Drupal 7.42 install (Simplytest.me). The patch in #3 fixes this issue. Setting to RTBC.

Note: without this patch, Multivariate is broken.

Thanks @Deciphered!