Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 296414

Unable to access views inside hook_cron

$
0
0

Problem/Motivation

When trying to access a view result from inside hook_cron, no result is returned.

Steps to reproduce

The following code runs fine within hook_form_alter but not within hook_cron:

$view = \Drupal\views\Views::getView('my_view');
$view->execute();
$view_result = $view->result;
if ($view->result) {
  drupal_set_message("Yay!");
}

I tested it from /admin/config/system/cron page and ran the cron manually.


Viewing all articles
Browse latest Browse all 296414

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>