1

im having a little trouble keeping a project update.

I track the code via a private git repo, and for each update I follow those steps (first on stagin, then on production):

  • update all the 3rd pars modules (from drupal.org)
  • Update database (via drush updb)

Then if everything is ok:

  • update my modules (via git repo)
  • update database (drush again)

All works perfectly, except for pages/views exported via Features module: in my module i hav a function like this:

/**
 * Implements hook_default_page_manager_pages().
 */
function mymodule_default_page_manager_pages() {
    // Second page...
    $page = new stdClass();
    // page definition, display, etc..
    $pages['page_machine_name'] = $page;

    // Second page...
    $page = new stdClass();
    // page definition, display, etc..
    $pages['page_machine_name'] = $page;

    return $pages;
}

The structure is the same for views.

I noticed that if i update that function changing something in a previous declared (and imported) page (add a pane, change a configuration on a content, etc..), this one wont get updated! (yeah, i flushed the cache different times both via UI and via drush)

Am I doing something wrong? There is a specific way to update those elements?

1 Answer 1

1

Well, this can not be the best solution but it works:

function mymodule_update_7001(&$sandbox) {
  // Views.
  if (is_callable('views_save_view')) {
    $views = module_invoke_all('views_default_views');
    foreach ($views AS $view_object) {
      views_delete_view($view_object);
    }
    // Rebuild it.
    $views = module_invoke_all('views_default_views');
    foreach ($views AS $view_object) {
      views_save_view($view_object);
    }
  }

  // Pages
  module_load_include('inc', 'page_manager', 'plugins/tasks/page');
  if (is_callable('page_manager_page_save')) {
    $pages = module_invoke_all('default_page_manager_pages');
    foreach ($pages AS $page_object) {
      page_manager_page_delete($page_object);
    }
    // Rebuild it
    $pages = module_invoke_all('default_page_manager_pages');
    foreach ($pages AS $page_object) {
      page_manager_page_save($page_object);
    }
  }
}

Basically just keep updated the views and pages definitions (views_default_views and default_page_manager_pages), the delete and rebuild them.

Obviously, this remove all customizations done via the Drupal's UI, so only do it for the views and pages you need to update!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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