当前位置: 首页>>代码示例>>PHP>>正文


PHP drupal_set_installed_schema_version函数代码示例

本文整理汇总了PHP中drupal_set_installed_schema_version函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_set_installed_schema_version函数的具体用法?PHP drupal_set_installed_schema_version怎么用?PHP drupal_set_installed_schema_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drupal_set_installed_schema_version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: listMigrations

 /**
  * @return array
  *
  * @see update_batch()
  */
 public function listMigrations()
 {
     // Resolve any update dependencies to determine the actual updates that will
     // be run and the order they will be run in.
     require_once DRUPAL_ROOT . '/includes/update.inc';
     $startingUpdates = $this->listUpdates();
     $updates = update_resolve_dependencies($startingUpdates);
     // Store the dependencies for each update function in an array which the
     // batch API can pass in to the batch operation each time it is called. (We
     // do not store the entire update dependency array here because it is
     // potentially very large.)
     $dependencyMap = array();
     foreach ($updates as $function => $update) {
         $dependencyMap[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
     }
     $migrations = array();
     foreach ($updates as $update) {
         if ($update['allowed']) {
             // Set the installed version of each module so updates will start at the
             // correct place. (The updates are already sorted, so we can simply base
             // this on the first one we come across in the above foreach loop.)
             if (isset($startingUpdates[$update['module']])) {
                 drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
                 unset($startingUpdates[$update['module']]);
             }
             // Add this update function to the batch.
             $function = $update['module'] . '_update_' . $update['number'];
             $migrations[] = array('module' => $update['module'], 'number' => $update['number'], 'dependencyMap' => $dependencyMap[$function]);
         }
     }
     return $migrations;
 }
开发者ID:Briareos,项目名称:Oxygen,代码行数:37,代码来源:DatabaseMigrateAction.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /*      drupal_set_installed_schema_version('sample', '8000');
             exit();*/
     include_once DRUPAL_ROOT . '/core/includes/install.inc';
     include_once DRUPAL_ROOT . '/core/includes/update.inc';
     $module = $input->getArgument('module');
     $update_n = $input->getArgument('update-n');
     $module_handler = $this->getModuleHandler();
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     if ($module != 'all') {
         if (!isset($updates[$module])) {
             $output->writeln('[-] <error>' . sprintf($this->trans('commands.update.execute.messages.no-module-updates'), $module) . '</error>');
             return;
         } else {
             // filter to execute only a specific module updates
             $updates = [$module => $updates[$module]];
             if ($update_n && !isset($updates[$module]['pending'][$update_n])) {
                 $output->writeln('[-] <info>' . sprintf($this->trans('commands.update.execute.messages.module-update-function-not-found'), $module, $update_n) . '</info>');
             }
         }
     }
     $output->writeln('[-] <info>' . $this->trans('commands.site.maintenance.description') . '</info>');
     \Drupal::state()->set('system.maintenance_mode', true);
     foreach ($updates as $module_name => $module_updates) {
         foreach ($module_updates['pending'] as $update_number => $update) {
             if ($module != 'all' && $update_n != null and $update_n != $update_number) {
                 continue;
             }
             //Executing all pending updates
             if ($update_n > $module_updates['start']) {
                 $output->writeln('[-] <info>' . $this->trans('commands.update.execute.messages.executing-required-previous-updates') . '</info>');
             }
             for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) {
                 $output->writeln('[-] <info>' . sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name) . '</info>');
                 try {
                     $module_handler->invoke($module_name, 'update_' . $update_index);
                 } catch (\Exception $e) {
                     watchdog_exception('update', $e);
                     $output->writeln('<error>' . $e->getMessage() . '</error>');
                 }
                 //Update module schema version
                 drupal_set_installed_schema_version($module_name, $update_index);
             }
         }
     }
     \Drupal::state()->set('system.maintenance_mode', false);
     $output->writeln('[-] <info>' . $this->trans('commands.site.maintenance.messages.maintenance-off') . '</info>');
     $this->getHelper('chain')->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:xsw3ws,项目名称:DrupalConsole,代码行数:52,代码来源:UpdateExecuteCommand.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->getDrupalHelper()->loadLegacyFile('/core/includes/install.inc');
     $this->getDrupalHelper()->loadLegacyFile('/core/includes/update.inc');
     $module = $input->getArgument('module');
     $update_n = $input->getArgument('update-n');
     $module_handler = $this->getModuleHandler();
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     if ($module != 'all') {
         if (!isset($updates[$module])) {
             $io->error(sprintf($this->trans('commands.update.execute.messages.no-module-updates'), $module));
             return;
         } else {
             // filter to execute only a specific module updates
             $updates = [$module => $updates[$module]];
             if ($update_n && !isset($updates[$module]['pending'][$update_n])) {
                 $io->info(sprintf($this->trans('commands.update.execute.messages.module-update-function-not-found'), $module, $update_n));
             }
         }
     }
     $io->info($this->trans('commands.site.maintenance.description'));
     $state = $this->getService('state');
     $state->set('system.maintenance_mode', true);
     foreach ($updates as $module_name => $module_updates) {
         foreach ($module_updates['pending'] as $update_number => $update) {
             if ($module != 'all' && $update_n !== null && $update_n != $update_number) {
                 continue;
             }
             //Executing all pending updates
             if ($update_n > $module_updates['start']) {
                 $io->info($this->trans('commands.update.execute.messages.executing-required-previous-updates'));
             }
             for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) {
                 $io->info(sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name));
                 try {
                     $module_handler->invoke($module_name, 'update_' . $update_index);
                 } catch (\Exception $e) {
                     watchdog_exception('update', $e);
                     $io->error($e->getMessage());
                 }
                 //Update module schema version
                 drupal_set_installed_schema_version($module_name, $update_index);
             }
         }
     }
     $state->set('system.maintenance_mode', false);
     $io->info($this->trans('commands.site.maintenance.messages.maintenance-off'));
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:52,代码来源:ExecuteCommand.php

示例4: testWith7x

 function testWith7x()
 {
     // Ensure that the minimum schema version is 8000, despite 7200 update
     // hooks and a 7XXX hook_update_last_removed().
     $this->assertEqual(drupal_get_installed_schema_version('update_test_with_7x'), 8000);
     // Try to manually set the schema version to 7110 and ensure that no
     // updates are allowed.
     drupal_set_installed_schema_version('update_test_with_7x', 7110);
     // Click through update.php with 'administer software updates' permission.
     $this->drupalLogin($this->update_user);
     $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
     $this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.'));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:13,代码来源:UpdatesWith7xTest.php

示例5: update_batch

function update_batch()
{
    global $base_url;
    $operations = array();
    // Set the installed version so updates start at the correct place.
    foreach ($_POST['start'] as $module => $version) {
        drupal_set_installed_schema_version($module, $version - 1);
        $updates = drupal_get_schema_versions($module);
        $max_version = max($updates);
        if ($version <= $max_version) {
            foreach ($updates as $update) {
                if ($update >= $version) {
                    $operations[] = array('update_do_one', array($module, $update));
                }
            }
        }
    }
    $batch = array('operations' => $operations, 'title' => 'Updating', 'init_message' => 'Starting updates', 'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.', 'finished' => 'update_finished');
    batch_set($batch);
    batch_process($base_url . '/update.php?op=results', $base_url . '/update.php');
}
开发者ID:nguyennamtien,项目名称:system_settings,代码行数:21,代码来源:recovery.php

示例6: testStatusPage

 /**
  * Tests that the status page returns.
  */
 public function testStatusPage()
 {
     // Go to Administration.
     $this->drupalGet('admin/reports/status');
     $this->assertResponse(200, 'The status page is reachable.');
     $phpversion = phpversion();
     $this->assertText($phpversion, 'Php version is shown on the page.');
     // Checks if the suggestion to update to php 5.5.21 or 5.6.5 for disabling
     // multiple statements is present when necessary.
     if (\Drupal::database()->driver() === 'mysql' && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) {
         $this->assertText(t('PHP (multiple statement disabling)'));
     } else {
         $this->assertNoText(t('PHP (multiple statement disabling)'));
     }
     if (function_exists('phpinfo')) {
         $this->assertLinkByHref(Url::fromRoute('system.php')->toString());
     } else {
         $this->assertNoLinkByHref(Url::fromRoute('system.php')->toString());
     }
     // If a module is fully installed no pending updates exists.
     $this->assertNoText(t('Out of date'));
     // The global $config_directories is not properly formed.
     $this->assertRaw(t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', array('%file' => $this->siteDirectory . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY)));
     // Set the schema version of update_test_postupdate to a lower version, so
     // update_test_postupdate_update_8001() needs to be executed.
     drupal_set_installed_schema_version('update_test_postupdate', 8000);
     $this->drupalGet('admin/reports/status');
     $this->assertText(t('Out of date'));
     // Now cleanup the executed post update functions.
     drupal_set_installed_schema_version('update_test_postupdate', 8001);
     /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
     $post_update_registry = \Drupal::service('update.post_update_registry');
     $post_update_registry->filterOutInvokedUpdatesByModule('update_test_postupdate');
     $this->drupalGet('admin/reports/status');
     $this->assertText(t('Out of date'));
     $this->drupalGet('admin/reports/status/php');
     $this->assertResponse(200, 'The phpinfo page is reachable.');
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:41,代码来源:StatusTest.php

示例7: testStatusPage

 /**
  * Tests that the status page returns.
  */
 public function testStatusPage()
 {
     // Go to Administration.
     $this->drupalGet('admin/reports/status');
     $this->assertResponse(200, 'The status page is reachable.');
     $phpversion = phpversion();
     $this->assertText($phpversion, 'Php version is shown on the page.');
     // Checks if the suggestion to update to php 5.5.21 or 5.6.5 for disabling
     // multiple statements is present when necessary.
     if (\Drupal::database()->driver() === 'mysql' && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) {
         $this->assertText(t('PHP (multiple statement disabling)'));
     } else {
         $this->assertNoText(t('PHP (multiple statement disabling)'));
     }
     if (function_exists('phpinfo')) {
         $this->assertLinkByHref(Url::fromRoute('system.php')->toString());
     } else {
         $this->assertNoLinkByHref(Url::fromRoute('system.php')->toString());
     }
     // If a module is fully installed no pending updates exists.
     $this->assertNoText(t('Out of date'));
     // Set the schema version of update_test_postupdate to a lower version, so
     // update_test_postupdate_update_8001() needs to be executed.
     drupal_set_installed_schema_version('update_test_postupdate', 8000);
     $this->drupalGet('admin/reports/status');
     $this->assertText(t('Out of date'));
     // Now cleanup the executed post update functions.
     drupal_set_installed_schema_version('update_test_postupdate', 8001);
     /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
     $post_update_registry = \Drupal::service('update.post_update_registry');
     $post_update_registry->filterOutInvokedUpdatesByModule('update_test_postupdate');
     $this->drupalGet('admin/reports/status');
     $this->assertText(t('Out of date'));
     $this->drupalGet('admin/reports/status/php');
     $this->assertResponse(200, 'The phpinfo page is reachable.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:39,代码来源:StatusTest.php

示例8: updateScriptTest

 /**
  * Helper function to run updates via the browser.
  */
 protected function updateScriptTest($maintenance_mode)
 {
     $schema_version = drupal_get_installed_schema_version('update_script_test');
     $this->assertEqual($schema_version, 8001, 'update_script_test is initially installed with schema version 8001.');
     // Set the installed schema version to one less than the current update.
     drupal_set_installed_schema_version('update_script_test', $schema_version - 1);
     $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
     $this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.');
     // Click through update.php with 'administer software updates' permission.
     $this->drupalLogin($this->updateUser);
     if ($maintenance_mode) {
         $this->assertText('Operating in maintenance mode.');
     } else {
         $this->assertNoText('Operating in maintenance mode.');
     }
     $this->drupalGet($this->updateUrl, array('external' => TRUE));
     $this->clickLink(t('Continue'));
     $this->clickLink(t('Apply pending updates'));
     // Verify that updates were completed successfully.
     $this->assertText('Updates were attempted.');
     $this->assertLink('site');
     $this->assertText('The update_script_test_update_8001() update was executed successfully.');
     // Verify that no 7.x updates were run.
     $this->assertNoText('The update_script_test_update_7200() update was executed successfully.');
     $this->assertNoText('The update_script_test_update_7201() update was executed successfully.');
     // Verify that there are no links to different parts of the workflow.
     $this->assertNoLink('Administration pages');
     $this->assertNoLinkByHrefInMainRegion('update.php', 0);
     $this->assertNoLink('logged');
     // Verify the front page can be visited following the upgrade.
     $this->clickLink('Front page');
     $this->assertResponse(200);
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:36,代码来源:UpdateScriptTest.php

示例9: install


//.........这里部分代码省略.........
                 } else {
                     $module_path = drupal_get_path('module', $name);
                     $pathname = "{$module_path}/{$name}.info.yml";
                     $filename = file_exists($module_path . "/{$name}.module") ? "{$name}.module" : NULL;
                     $module_filenames[$name] = new Extension('module', $pathname, $filename);
                 }
             }
             // Update the module handler in order to load the module's code.
             // This allows the module to participate in hooks and its existence to
             // be discovered by other modules.
             // The current ModuleHandler instance is obsolete with the kernel
             // rebuild below.
             $this->setModuleList($module_filenames);
             $this->load($module);
             module_load_install($module);
             // Clear the static cache of system_rebuild_module_data() to pick up the
             // new module, since it merges the installation status of modules into
             // its statically cached list.
             drupal_static_reset('system_rebuild_module_data');
             // Update the kernel to include it.
             // This reboots the kernel to register the module's bundle and its
             // services in the service container. The $module_filenames argument is
             // taken over as %container.modules% parameter, which is passed to a
             // fresh ModuleHandler instance upon first retrieval.
             // @todo install_begin_request() creates a container without a kernel.
             if ($kernel = \Drupal::service('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
                 $kernel->updateModules($module_filenames, $module_filenames);
             }
             // Refresh the schema to include it.
             drupal_get_schema(NULL, TRUE);
             // Allow modules to react prior to the installation of a module.
             $this->invokeAll('module_preinstall', array($module));
             // Now install the module's schema if necessary.
             drupal_install_schema($module);
             // Clear plugin manager caches and flag router to rebuild if requested.
             \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
             \Drupal::service('router.builder_indicator')->setRebuildNeeded();
             // Set the schema version to the number of the last update provided by
             // the module, or the minimum core schema version.
             $version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION;
             $versions = drupal_get_schema_versions($module);
             if ($versions) {
                 $version = max(max($versions), $version);
             }
             // Notify the entity manager that this module's entity types are new,
             // so that it can notify all interested handlers. For example, a
             // SQL-based storage handler can use this as an opportunity to create
             // the necessary database tables.
             $entity_manager = \Drupal::entityManager();
             foreach ($entity_manager->getDefinitions() as $entity_type) {
                 if ($entity_type->getProvider() == $module) {
                     $entity_manager->onEntityTypeCreate($entity_type);
                 }
             }
             // Install default configuration of the module.
             $config_installer = \Drupal::service('config.installer');
             if ($sync_status) {
                 $config_installer->setSyncing(TRUE)->setSourceStorage($source_storage);
             } else {
                 // If we're not in a config synchronisation reset the source storage
                 // so that the extension install storage will pick up the new
                 // configuration.
                 $config_installer->resetSourceStorage();
             }
             \Drupal::service('config.installer')->installDefaultConfig('module', $module);
             // If the module has no current updates, but has some that were
             // previously removed, set the version to the value of
             // hook_update_last_removed().
             if ($last_removed = $this->invoke($module, 'update_last_removed')) {
                 $version = max($version, $last_removed);
             }
             drupal_set_installed_schema_version($module, $version);
             // Record the fact that it was installed.
             $modules_installed[] = $module;
             // file_get_stream_wrappers() needs to re-register Drupal's stream
             // wrappers in case a module-provided stream wrapper is used later in
             // the same request. In particular, this happens when installing Drupal
             // via Drush, as the 'translations' stream wrapper is provided by
             // Interface Translation module and is later used to import
             // translations.
             \Drupal::service('stream_wrapper_manager')->register();
             // Update the theme registry to include it.
             drupal_theme_rebuild();
             // Modules can alter theme info, so refresh theme data.
             // @todo ThemeHandler cannot be injected into ModuleHandler, since that
             //   causes a circular service dependency.
             // @see https://drupal.org/node/2208429
             \Drupal::service('theme_handler')->refreshInfo();
             // Allow the module to perform install tasks.
             $this->invoke($module, 'install');
             // Record the fact that it was installed.
             \Drupal::logger('system')->info('%module module installed.', array('%module' => $module));
         }
     }
     // If any modules were newly installed, invoke hook_modules_installed().
     if (!empty($modules_installed)) {
         $this->invokeAll('modules_installed', array($modules_installed));
     }
     return TRUE;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:101,代码来源:ModuleHandler.php

示例10: testSuccessfulUpdateFunctionality

 /**
  * Tests update.php after performing a successful update.
  */
 function testSuccessfulUpdateFunctionality()
 {
     $schema_version = drupal_get_installed_schema_version('update_script_test');
     $this->assertEqual($schema_version, 8001, 'update_script_test is initially installed with schema version 8001.');
     // Set the installed schema version to one less than the current update.
     drupal_set_installed_schema_version('update_script_test', $schema_version - 1);
     $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
     $this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.');
     // Click through update.php with 'administer software updates' permission.
     $this->drupalLogin($this->updateUser);
     $this->drupalGet($this->updateUrl, array('external' => TRUE));
     $this->clickLink(t('Continue'));
     $this->clickLink(t('Apply pending updates'));
     // Verify that updates were completed successfully.
     $this->assertText('Updates were attempted.');
     $this->assertLink('site');
     $this->assertText('The update_script_test_update_8001() update was executed successfully.');
     // Verify that no 7.x updates were run.
     $this->assertNoText('The update_script_test_update_7200() update was executed successfully.');
     $this->assertNoText('The update_script_test_update_7201() update was executed successfully.');
     // Verify that there are no links to different parts of the workflow.
     $this->assertNoLink('Administration pages');
     $this->assertNoLinkByHref('update.php', 0);
     $this->assertNoLink('logged');
     // Verify the front page can be visited following the upgrade.
     $this->clickLink('Front page');
     $this->assertResponse(200);
     // Reset the static cache to ensure we have the most current setting.
     $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
     $this->assertEqual($schema_version, 8001, 'update_script_test schema version is 8001 after updating.');
     // Set the installed schema version to one less than the current update.
     drupal_set_installed_schema_version('update_script_test', $schema_version - 1);
     $schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
     $this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.');
     // Click through update.php with 'access administration pages' and
     // 'access site reports' permissions.
     $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode'));
     $this->drupalLogin($admin_user);
     $this->drupalGet($this->updateUrl, array('external' => TRUE));
     $this->clickLink(t('Continue'));
     $this->clickLink(t('Apply pending updates'));
     $this->assertText('Updates were attempted.');
     $this->assertLink('logged');
     $this->assertLink('Administration pages');
     $this->assertNoLinkByHref('update.php', 1);
     $this->clickLink('Administration pages');
     $this->assertResponse(200);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:51,代码来源:UpdateScriptTest.php

示例11: update_batch

function update_batch()
{
    global $base_url;
    // During the update, toggle site maintenance so that schema changes do not
    // affect visiting users.
    $_SESSION['site_offline'] = variable_get('site_offline', FALSE);
    if ($_SESSION['site_offline'] == FALSE) {
        variable_set('site_offline', TRUE);
    }
    $operations = array();
    // Set the installed version so updates start at the correct place.
    foreach ($_POST['start'] as $module => $version) {
        drupal_set_installed_schema_version($module, $version - 1);
        $updates = drupal_get_schema_versions($module);
        $max_version = max($updates);
        if ($version <= $max_version) {
            foreach ($updates as $update) {
                if ($update >= $version) {
                    $operations[] = array('update_do_one', array($module, $update));
                }
            }
        }
    }
    $batch = array('operations' => $operations, 'title' => 'Updating', 'init_message' => 'Starting updates', 'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.', 'finished' => 'update_finished');
    batch_set($batch);
    batch_process($base_url . '/update.php?op=results', $base_url . '/update.php');
}
开发者ID:Emiliano-zz,项目名称:drupal,代码行数:27,代码来源:update.php

示例12: runUpdates

 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param $updates
  */
 private function runUpdates(DrupalStyle $io, $updates)
 {
     $module_handler = $this->getDrupalService('module_handler');
     foreach ($updates as $module_name => $module_updates) {
         $modulePath = $this->getApplication()->getSite()->getModulePath($this->module);
         $this->get('site')->loadLegacyFile($modulePath . '/' . $this->module . '.install', false);
         foreach ($module_updates['pending'] as $update_number => $update) {
             if ($this->module != 'all' && $this->update_n !== null && $this->update_n != $update_number) {
                 continue;
             }
             if ($this->update_n > $module_updates['start']) {
                 $io->info($this->trans('commands.update.execute.messages.executing-required-previous-updates'));
             }
             for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) {
                 $io->info(sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name));
                 try {
                     $module_handler->invoke($module_name, 'update_' . $update_index);
                 } catch (\Exception $e) {
                     watchdog_exception('update', $e);
                     $io->error($e->getMessage());
                 }
                 drupal_set_installed_schema_version($module_name, $update_index);
             }
         }
     }
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:30,代码来源:ExecuteCommand.php

示例13: triggerBatch

 /**
  * Starts the database update batch process.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request object.
  */
 protected function triggerBatch(Request $request)
 {
     // During the update, bring the site offline so that schema changes do not
     // affect visiting users.
     $maintenance_mode = $this->config('system.maintenance')->get('enabled');
     if (isset($maintenance_mode)) {
         $_SESSION['maintenance_mode'] = $maintenance_mode;
     }
     if (empty($_SESSION['maintenance_mode'])) {
         $this->state->set('system.maintenance_mode', TRUE);
     }
     $operations = array();
     // First of all perform entity definition updates, which will update
     // storage schema if needed, so that module update functions work with
     // the correct entity schema.
     if ($this->entityDefinitionUpdateManager->needsUpdates()) {
         $operations[] = array('update_entity_definitions', array('system', '0 - Update entity definitions'));
     }
     // Resolve any update dependencies to determine the actual updates that will
     // be run and the order they will be run in.
     $start = $this->getModuleUpdates();
     $updates = update_resolve_dependencies($start);
     // Store the dependencies for each update function in an array which the
     // batch API can pass in to the batch operation each time it is called. (We
     // do not store the entire update dependency array here because it is
     // potentially very large.)
     $dependency_map = array();
     foreach ($updates as $function => $update) {
         $dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
     }
     // Determine updates to be performed.
     foreach ($updates as $update) {
         if ($update['allowed']) {
             // Set the installed version of each module so updates will start at the
             // correct place. (The updates are already sorted, so we can simply base
             // this on the first one we come across in the above foreach loop.)
             if (isset($start[$update['module']])) {
                 drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
                 unset($start[$update['module']]);
             }
             // Add this update function to the batch.
             $function = $update['module'] . '_update_' . $update['number'];
             $operations[] = array('update_do_one', array($update['module'], $update['number'], $dependency_map[$function]));
         }
     }
     $batch['operations'] = $operations;
     $batch += array('title' => $this->t('Updating'), 'init_message' => $this->t('Starting updates'), 'error_message' => $this->t('An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.'), 'finished' => array('\\Drupal\\system\\Controller\\DbUpdateController', 'batchFinished'));
     batch_set($batch);
     return batch_process('update.php/results', Url::fromRoute('system.db_update', array('op' => 'start')));
 }
开发者ID:brstde,项目名称:gap1,代码行数:56,代码来源:DbUpdateController.php

示例14: update_update_page

function update_update_page()
{
    // Set the installed version so updates start at the correct place.
    foreach ($_POST['start'] as $module => $version) {
        drupal_set_installed_schema_version($module, $version - 1);
        $updates = drupal_get_schema_versions($module);
        $max_version = max($updates);
        if ($version <= $max_version) {
            foreach ($updates as $update) {
                if ($update >= $version) {
                    $_SESSION['update_remaining'][] = array('module' => $module, 'version' => $update);
                }
            }
        }
    }
    // Keep track of total number of updates
    $_SESSION['update_total'] = count($_SESSION['update_remaining']);
    if ($_POST['has_js']) {
        return update_progress_page();
    } else {
        return update_progress_page_nojs();
    }
}
开发者ID:naryga,项目名称:alm-familyfellowship-com,代码行数:23,代码来源:update.php

示例15: install


//.........这里部分代码省略.........
             // its statically cached list.
             drupal_static_reset('system_rebuild_module_data');
             // Update the kernel to include it.
             $this->updateKernel($module_filenames);
             // Allow modules to react prior to the installation of a module.
             $this->moduleHandler->invokeAll('module_preinstall', array($module));
             // Now install the module's schema if necessary.
             drupal_install_schema($module);
             // Clear plugin manager caches.
             \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
             // Set the schema version to the number of the last update provided by
             // the module, or the minimum core schema version.
             $version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION;
             $versions = drupal_get_schema_versions($module);
             if ($versions) {
                 $version = max(max($versions), $version);
             }
             // Notify interested components that this module's entity types and
             // field storage definitions are new. For example, a SQL-based storage
             // handler can use this as an opportunity to create the necessary
             // database tables.
             // @todo Clean this up in https://www.drupal.org/node/2350111.
             $entity_manager = \Drupal::entityManager();
             $update_manager = \Drupal::entityDefinitionUpdateManager();
             foreach ($entity_manager->getDefinitions() as $entity_type) {
                 if ($entity_type->getProvider() == $module) {
                     $update_manager->installEntityType($entity_type);
                 } elseif ($entity_type->isSubclassOf(FieldableEntityInterface::CLASS)) {
                     // The module being installed may be adding new fields to existing
                     // entity types. Field definitions for any entity type defined by
                     // the module are handled in the if branch.
                     foreach ($entity_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) {
                         if ($storage_definition->getProvider() == $module) {
                             // If the module being installed is also defining a storage key
                             // for the entity type, the entity schema may not exist yet. It
                             // will be created later in that case.
                             try {
                                 $update_manager->installFieldStorageDefinition($storage_definition->getName(), $entity_type->id(), $module, $storage_definition);
                             } catch (EntityStorageException $e) {
                                 watchdog_exception('system', $e, 'An error occurred while notifying the creation of the @name field storage definition: "!message" in %function (line %line of %file).', ['@name' => $storage_definition->getName()]);
                             }
                         }
                     }
                 }
             }
             // Install default configuration of the module.
             $config_installer = \Drupal::service('config.installer');
             if ($sync_status) {
                 $config_installer->setSyncing(TRUE)->setSourceStorage($source_storage);
             }
             \Drupal::service('config.installer')->installDefaultConfig('module', $module);
             // If the module has no current updates, but has some that were
             // previously removed, set the version to the value of
             // hook_update_last_removed().
             if ($last_removed = $this->moduleHandler->invoke($module, 'update_last_removed')) {
                 $version = max($version, $last_removed);
             }
             drupal_set_installed_schema_version($module, $version);
             // Ensure that all post_update functions are registered already.
             /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
             $post_update_registry = \Drupal::service('update.post_update_registry');
             $post_update_registry->registerInvokedUpdates($post_update_registry->getModuleUpdateFunctions($module));
             // Record the fact that it was installed.
             $modules_installed[] = $module;
             // Drupal's stream wrappers needs to be re-registered in case a
             // module-provided stream wrapper is used later in the same request. In
             // particular, this happens when installing Drupal via Drush, as the
             // 'translations' stream wrapper is provided by Interface Translation
             // module and is later used to import translations.
             \Drupal::service('stream_wrapper_manager')->register();
             // Update the theme registry to include it.
             drupal_theme_rebuild();
             // Modules can alter theme info, so refresh theme data.
             // @todo ThemeHandler cannot be injected into ModuleHandler, since that
             //   causes a circular service dependency.
             // @see https://www.drupal.org/node/2208429
             \Drupal::service('theme_handler')->refreshInfo();
             // In order to make uninstalling transactional if anything uses routes.
             \Drupal::getContainer()->set('router.route_provider.old', \Drupal::service('router.route_provider'));
             \Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.lazy_builder'));
             // Allow the module to perform install tasks.
             $this->moduleHandler->invoke($module, 'install');
             // Record the fact that it was installed.
             \Drupal::logger('system')->info('%module module installed.', array('%module' => $module));
         }
     }
     // If any modules were newly installed, invoke hook_modules_installed().
     if (!empty($modules_installed)) {
         \Drupal::getContainer()->set('router.route_provider', \Drupal::service('router.route_provider.old'));
         if (!\Drupal::service('router.route_provider.lazy_builder')->hasRebuilt()) {
             // Rebuild routes after installing module. This is done here on top of
             // \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on
             // fastCGI which executes ::destruct() after the module installation
             // page was sent already.
             \Drupal::service('router.builder')->rebuild();
         }
         $this->moduleHandler->invokeAll('modules_installed', array($modules_installed));
     }
     return TRUE;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:101,代码来源:ModuleInstaller.php


注:本文中的drupal_set_installed_schema_version函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。