I have deployed user generated views to a production site using Views (6.x-2.12) bulk export feature; that is, views are saved in the code as mymodule.module and mymodule.views_default.inc, the latter of which contains 12 views in more than 11,000 lines.

Sometimes, one or more views suddenly disappear from the site. Flushing all caches usually fixes it, but it is hard to duplicate the issue and it bothers me that it may happen again in the worst time.

Possible causes that I think of are:

  • Does the .inc file have too many lines (> 11K)?
  • I have saved the .inc file with Windows new lines, while the server is Linux.

Could one of these be the cause? Anyone experienced a similar issue?

  • How did you fix this. It doesn't seem that simply moving your views into separate modules would work? – Stewart Robinson Aug 30 '11 at 15:02

Solution for the "to many lines" problem:

function YOURMODULE_views_default_views() {
    $files = file_scan_directory((drupal_get_path('module','YOURMODULE').'/views','.view'));
    foreach($files as $absolute => $file) {
        require $absolute;
        if(isset($view)) {
            $views[$view->name] = $view;
    return $views;

This way every view-code can be stored in it's own file inside a views subfolder inside YOURMODULE as some_name.view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.