notice: Undefined variable: view in og_views.views_default.inc
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #404100. --> Reported by: [dave reid](https://www.drupal.org/user/53892) >>> <p>I have the og_views module enabled, but not the search module. On every page load I get the following error:</p> <p>notice: Undefined variable: view in /home/dave/Projects/www/drupal6dev/sites/all/modules/og/modules/og_views/og_views.views_default.inc on line 12.</p> <p>Related code:</p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br></span><span style="color: #007700">function </span><span style="color: #0000BB">og_views_default_views</span><span style="color: #007700">() {<br>&nbsp; </span><span style="color: #0000BB">$files </span><span style="color: #007700">= </span><span style="color: #0000BB">file_scan_directory</span><span style="color: #007700">(</span><span style="color: #0000BB">drupal_get_path</span><span style="color: #007700">(</span><span style="color: #DD0000">'module'</span><span style="color: #007700">, </span><span style="color: #DD0000">'og_views'</span><span style="color: #007700">). </span><span style="color: #DD0000">'/views'</span><span style="color: #007700">, </span><span style="color: #DD0000">'.view'</span><span style="color: #007700">);<br>&nbsp; foreach (</span><span style="color: #0000BB">$files </span><span style="color: #007700">as </span><span style="color: #0000BB">$absolute </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$file</span><span style="color: #007700">) {<br>&nbsp;&nbsp;&nbsp; require </span><span style="color: #0000BB">$absolute</span><span style="color: #007700">;<br>&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$views</span><span style="color: #007700">[</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">)] = </span><span style="color: #0000BB">$view</span><span style="color: #007700">;<br>&nbsp; }<br>&nbsp; return </span><span style="color: #0000BB">$views</span><span style="color: #007700">;<br>}<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <p>The variable $view was undefined when the og_views/views/og.og_search.view was the file being included in the code. At the top of og.og_search.view is:</p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br></span><span style="color: #007700">if (!</span><span style="color: #0000BB">module_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'search'</span><span style="color: #007700">)) {<br>&nbsp; return;<br>}<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <p>So therefore, it doesn't get to define $view.</p>
issue