Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -90,15 +90,30 @@ class ExtensionDiscovery {
*/
protected $fileCache;
/**
* The site path.
*
* @var string
*/
protected $sitePath;
/**
* Constructs a new ExtensionDiscovery object.
*
* @param string $root
* The app root.
* @param bool $use_file_cache
* Whether file cache should be used.
* @param string[] $profile_directories
* The available profile directories
* @param string $site_path
* The path to the site.
*/
public function __construct($root) {
public function __construct($root, $use_file_cache = TRUE, $profile_directories = NULL, $site_path = NULL) {
$this->root = $root;
$this->fileCache = FileCacheFactory::get('extension_discovery');
$this->fileCache = $use_file_cache ? FileCacheFactory::get('extension_discovery') : NULL;
$this->profileDirectories = $profile_directories;
$this->sitePath = $site_path;
}
/**
@ -172,7 +187,7 @@ class ExtensionDiscovery {
$searchdirs[static::ORIGIN_SITE] = \Drupal::service('site.path');
}
else {
$searchdirs[static::ORIGIN_SITE] = DrupalKernel::findSitePath(Request::createFromGlobals());
$searchdirs[static::ORIGIN_SITE] = $this->sitePath ?: DrupalKernel::findSitePath(Request::createFromGlobals());
}
// Unless an explicit value has been passed, manually check whether we are
@ -180,7 +195,7 @@ class ExtensionDiscovery {
// Test extensions can also be included for debugging purposes by setting a
// variable in settings.php.
if (!isset($include_tests)) {
$include_tests = drupal_valid_test_ua() || Settings::get('extension_discovery_scan_tests');
$include_tests = Settings::get('extension_discovery_scan_tests') || drupal_valid_test_ua();
}
$files = array();
@ -427,7 +442,7 @@ class ExtensionDiscovery {
continue;
}
if ($cached_extension = $this->fileCache->get($fileinfo->getPathName())) {
if ($this->fileCache && $cached_extension = $this->fileCache->get($fileinfo->getPathName())) {
$files[$cached_extension->getType()][$key] = $cached_extension;
continue;
}
@ -467,7 +482,10 @@ class ExtensionDiscovery {
$extension->origin = $dir;
$files[$type][$key] = $extension;
$this->fileCache->set($fileinfo->getPathName(), $extension);
if ($this->fileCache) {
$this->fileCache->set($fileinfo->getPathName(), $extension);
}
}
return $files;
}

View file

@ -9,7 +9,6 @@ namespace Drupal\Core\Extension;
use Drupal\Component\Serialization\Yaml;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Component\Utility\SafeMarkup;
/**
* Parses dynamic .info.yml files that might change during the page request.
@ -28,13 +27,11 @@ class InfoParserDynamic implements InfoParserInterface {
$parsed_info = Yaml::decode(file_get_contents($filename));
}
catch (InvalidDataTypeException $e) {
$message = SafeMarkup::format("Unable to parse !file: !error", array('!file' => $filename, '!error' => $e->getMessage()));
throw new InfoParserException($message);
throw new InfoParserException("Unable to parse $filename " . $e->getMessage());
}
$missing_keys = array_diff($this->getRequiredKeys(), array_keys($parsed_info));
if (!empty($missing_keys)) {
$message = SafeMarkup::format('Missing required keys (!missing_keys) in !file.', array('!missing_keys' => implode(', ', $missing_keys), '!file' => $filename));
throw new InfoParserException($message);
throw new InfoParserException('Missing required keys (' . implode(', ', $missing_keys) . ') in ' . $filename);
}
if (isset($parsed_info['version']) && $parsed_info['version'] === 'VERSION') {
$parsed_info['version'] = \Drupal::VERSION;

View file

@ -260,6 +260,11 @@ class ModuleInstaller implements ModuleInstallerInterface {
}
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;
@ -445,6 +450,10 @@ class ModuleInstaller implements ModuleInstallerInterface {
$schema_store = \Drupal::keyValue('system.schema');
$schema_store->delete($module);
/** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
$post_update_registry = \Drupal::service('update.post_update_registry');
$post_update_registry->filterOutInvokedUpdatesByModule($module);
}
\Drupal::service('router.builder')->setRebuildNeeded();
drupal_get_installed_schema_version(NULL, TRUE);

View file

@ -9,12 +9,30 @@ namespace Drupal\Core\Extension;
/**
* Common interface for module uninstall validators.
*
* A module uninstall validator must implement this interface and be defined in
* a Drupal @link container service @endlink that is tagged
* module_install.uninstall_validator.
*/
interface ModuleUninstallValidatorInterface {
/**
* Determines the reasons a module can not be uninstalled.
*
* Example implementation:
* @code
* public function validate($module) {
* $entity_types = $this->entityManager->getDefinitions();
* $reasons = array();
* foreach ($entity_types as $entity_type) {
* if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
* $reasons[] = $this->t('There is content for the entity type: @entity_type', array('@entity_type' => $entity_type->getLabel()));
* }
* }
* return $reasons;
* }
* @endcode
*
* @param string $module
* A module name.
*
@ -23,7 +41,7 @@ interface ModuleUninstallValidatorInterface {
* Each reason should not end with any punctuation since multiple reasons
* can be displayed together.
*
* @see theme_system_modules_uninstall()
* @see template_preprocess_system_modules_uninstall()
*/
public function validate($module);
}

View file

@ -7,7 +7,6 @@
namespace Drupal\Core\Extension;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\State\StateInterface;
@ -22,10 +21,7 @@ class ThemeHandler implements ThemeHandlerInterface {
* @var array
*/
protected $defaultFeatures = array(
'logo',
'favicon',
'name',
'slogan',
'node_user_picture',
'comment_user_picture',
'comment_user_verification',
@ -256,6 +252,7 @@ class ThemeHandler implements ThemeHandlerInterface {
// Set defaults for theme info.
$defaults = array(
'engine' => 'twig',
'base theme' => 'stable',
'regions' => array(
'sidebar_first' => 'Left sidebar',
'sidebar_second' => 'Right sidebar',
@ -286,6 +283,11 @@ class ThemeHandler implements ThemeHandlerInterface {
$theme->status = (int) isset($installed[$key]);
$theme->info = $this->infoParser->parse($theme->getPathname()) + $defaults;
// Remove the default Stable base theme when 'base theme: false' is set in
// a theme .info.yml file.
if ($theme->info['base theme'] === FALSE) {
unset($theme->info['base theme']);
}
// Add the info file modification time, so it becomes available for
// contributed modules to use for ordering theme lists.
@ -431,7 +433,7 @@ class ThemeHandler implements ThemeHandlerInterface {
if (!isset($themes[$theme])) {
throw new \InvalidArgumentException("Requested the name of a non-existing theme $theme");
}
return SafeMarkup::checkPlain($themes[$theme]->info['name']);
return $themes[$theme]->info['name'];
}
/**

View file

@ -131,13 +131,18 @@ function hook_module_implements_alter(&$implementations, $hook) {
}
/**
* Alter the information parsed from module and theme .info.yml files
* Alter the information parsed from module and theme .info.yml files.
*
* This hook is invoked in _system_rebuild_module_data() and in
* \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). A module
* may implement this hook in order to add to or alter the data generated by
* reading the .info.yml file with \Drupal\Core\Extension\InfoParser.
*
* Using implementations of this hook to make modules required by setting the
* $info['required'] key is discouraged. Doing so will slow down the module
* installation and uninstallation process. Instead, use
* \Drupal\Core\Extension\ModuleUninstallValidatorInterface.
*
* @param array $info
* The .info.yml file contents, passed by reference so that it can be altered.
* @param \Drupal\Core\Extension\Extension $file
@ -145,6 +150,8 @@ function hook_module_implements_alter(&$implementations, $hook) {
* @param string $type
* Either 'module' or 'theme', depending on the type of .info.yml file that
* was passed.
*
* @see \Drupal\Core\Extension\ModuleUninstallValidatorInterface
*/
function hook_system_info_alter(array &$info, \Drupal\Core\Extension\Extension $file, $type) {
// Only fill this in if the .info.yml file does not define a 'datestamp'.
@ -659,6 +666,71 @@ function hook_update_N(&$sandbox) {
return t('All foo bars were updated with the new suffix');
}
/**
* Executes an update which is intended to update data, like entities.
*
* These implementations have to be placed in a MODULE.post_update.php file.
*
* These updates are executed after all hook_update_N() implementations. At this
* stage Drupal is already fully repaired so you can use any API as you wish.
*
* NAME can be arbitrary machine names. In contrast to hook_update_N() the order
* of functions in the file is the only thing which ensures the execution order
* of those functions.
*
* Drupal also ensures to not execute the same hook_post_update_NAME() function
* twice.
*
* @param array $sandbox
* Stores information for batch updates. See above for more information.
*
* @throws \Drupal\Core\Utility\UpdateException|PDOException
* In case of error, update hooks should throw an instance of
* \Drupal\Core\Utility\UpdateException with a meaningful message for the
* user. If a database query fails for whatever reason, it will throw a
* PDOException.
*
* @return string|null
* Optionally, hook_post_update_NAME() hooks may return a translated string
* that will be displayed to the user after the update has completed. If no
* message is returned, no message will be presented to the user.
*
* @ingroup update_api
*
* @see hook_update_N()
*/
function hook_post_update_NAME(&$sandbox) {
// Example of updating some content.
$node = \Drupal\node\Entity\Node::load(123);
$node->setTitle('foo');
$node->save();
$result = t('Node %nid saved', ['%nid' => $node->id()]);
// Example of disabling blocks with missing condition contexts. Note: The
// block itself is in a state which is valid at that point.
// @see block_update_8001()
// @see block_post_update_disable_blocks_with_missing_contexts()
$block_update_8001 = \Drupal::keyValue('update_backup')->get('block_update_8001', []);
$block_ids = array_keys($block_update_8001);
$block_storage = \Drupal::entityManager()->getStorage('block');
$blocks = $block_storage->loadMultiple($block_ids);
/** @var $blocks \Drupal\block\BlockInterface[] */
foreach ($blocks as $block) {
// This block has had conditions removed due to an inability to resolve
// contexts in block_update_8001() so disable it.
// Disable currently enabled blocks.
if ($block_update_8001[$block->id()]['status']) {
$block->setStatus(FALSE);
$block->save();
}
}
return $result;
}
/**
* Return an array of information about module update dependencies.
*
@ -874,17 +946,17 @@ function hook_requirements($phase) {
$cron_last = \Drupal::state()->get('system.cron_last');
if (is_numeric($cron_last)) {
$requirements['cron']['value'] = t('Last run !time ago', array('!time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
$requirements['cron']['value'] = t('Last run @time ago', array('@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)));
}
else {
$requirements['cron'] = array(
'description' => t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'https://www.drupal.org/cron')),
'description' => t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href=":url">configuring cron jobs</a>.', array(':url' => 'https://www.drupal.org/cron')),
'severity' => REQUIREMENT_ERROR,
'value' => t('Never run'),
);
}
$requirements['cron']['description'] .= ' ' . t('You can <a href="@cron">run cron manually</a>.', array('@cron' => \Drupal::url('system.run_cron')));
$requirements['cron']['description'] .= ' ' . t('You can <a href=":cron">run cron manually</a>.', array(':cron' => \Drupal::url('system.run_cron')));
$requirements['cron']['title'] = t('Cron maintenance tasks');
}