Browse Source

d.o. #871970: allow multiple view "require": remove require_once.

FGM 13 years ago
parent
commit
8b747d35bf
1 changed files with 11 additions and 2 deletions
  1. 11 2
      views/fgcf.views_default.inc

+ 11 - 2
views/fgcf.views_default.inc

@@ -14,6 +14,7 @@
 function fgcf_views_default_views() {
   // Needed to avoid fatal 'class view not found' error when Features
   // checks the status of the feature.
+  // http://drupal.org/node/509174#comment-2715130
   views_include('view');
 
   $info = fgcf_views_api();
@@ -31,9 +32,17 @@ function fgcf_views_default_views() {
       continue;
     }
 
-    require_once $name; // will define $view and $handler
-    $views[$view->name] = $view;
+    // Cannot use require_once, as scanning may load them once before entering
+    // here, and they need to be reported each time.
+    require $name; // will define $view and $handler
+    if (!isset($view) || !isset($view->name)) {
+      watchdog('fgcf', 'Ill-formed view @name.', array('@name' => $name), WATCHDOG_NOTICE);
+    }
+    else {
+      $views[$view->name] = $view;
+    }
     unset($view, $handler);
+
   }
 
   return $views;