diff --git a/core/core.services.yml b/core/core.services.yml index f371585..4c0553f 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -137,10 +137,10 @@ services: factory_class: Drupal\Component\Utility\Settings factory_method: getSingleton state: - class: Drupal\Core\KeyValueStore\KeyValueStoreInterface - factory_method: get - factory_service: keyvalue - arguments: [state] + class: Drupal\Core\KeyValueStore\State + arguments: ['@keyvalue'] + tags: + - { name: persist } queue: class: Drupal\Core\Queue\QueueFactory arguments: ['@settings'] diff --git a/core/includes/common.inc b/core/includes/common.inc index fc46b9b..138c11a 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -399,15 +399,14 @@ function drupal_add_feed($url = NULL, $title = '') { if (isset($url)) { $stored_feed_links[$url] = theme('feed_icon', array('url' => $url, 'title' => $title)); - $build['#attached']['drupal_add_html_head_link'][][] = array( + drupal_add_html_head_link(array( 'rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => $title, // Force the URL to be absolute, for consistency with other tags // output by Drupal. 'href' => url($url, array('absolute' => TRUE)), - ); - drupal_render($build); + )); } return $stored_feed_links; } diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 36b6b14..e0fa799 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -453,10 +453,8 @@ function install_begin_request(&$install_state) { $settings['keyvalue_default'] = 'keyvalue.memory'; new Settings($settings); - $container->register('state', 'Drupal\Core\KeyValueStore\KeyValueStoreInterface') - ->setFactoryService(new Reference('keyvalue')) - ->setFactoryMethod('get') - ->addArgument('state'); + $container->register('state', 'Drupal\Core\KeyValueStore\State') + ->addArgument(new Reference('keyvalue')); // Register Twig template engine for use during install. CoreServiceProvider::registerTwig($container); diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 98be6de..e6326d8 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1268,14 +1268,8 @@ function template_preprocess_status_messages(&$variables) { * is used as its CSS class. Each link should be itself an array, with the * following elements: * - title: The link text. - * - route_name: (optional) The name of the route to link to. If omitted - * (and if 'href' is omitted as well), the 'title' is shown as - * a plain text item in the links list. - * - route_parameters: (optional) An array of route parameters for the link. - * - href: (optional) The link URL. It is preferred to use 'route_name' and - * 'route parameters' for internal links. Use 'href' for links to external - * URLs. If omitted (and if 'route_name' is omitted as well), the 'title' - * is shown as a plain text item in the links list. + * - href: The link URL. If omitted, the 'title' is shown as a plain text + * item in the links list. * - html: (optional) Whether or not 'title' is HTML. If set, the title * will not be passed through * \Drupal\Component\Utility\String::checkPlain(). @@ -2221,12 +2215,7 @@ function template_preprocess_html(&$variables) { if (theme_get_setting('features.favicon')) { $favicon = theme_get_setting('favicon.url'); $type = theme_get_setting('favicon.mimetype'); - $build['#attached']['drupal_add_html_head_link'][][] = array( - 'rel' => 'shortcut icon', - 'href' => Url::stripDangerousProtocols($favicon), - 'type' => $type, - ); - drupal_render($build); + drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => Url::stripDangerousProtocols($favicon), 'type' => $type)); } $site_config = \Drupal::config('system.site'); @@ -2509,12 +2498,7 @@ function template_preprocess_maintenance_page(&$variables) { if (theme_get_setting('features.favicon')) { $favicon = theme_get_setting('favicon.url'); $type = theme_get_setting('favicon.mimetype'); - $build['#attached']['drupal_add_html_head_link'][][] = array( - 'rel' => 'shortcut icon', - 'href' => Url::stripDangerousProtocols($favicon), - 'type' => $type, - ); - drupal_render($build); + drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => Url::stripDangerousProtocols($favicon), 'type' => $type)); } // Get all region content set with drupal_add_region_content(). diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index a03ee24..5441e30 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -288,7 +288,7 @@ public static function keyValue($collection) { * needs to be the same across development, production, etc. environments * (for example, the system maintenance message) should use \Drupal::config() instead. * - * @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @return \Drupal\Core\KeyValueStore\StateInterface */ public static function state() { return static::$container->get('state'); diff --git a/core/lib/Drupal/Component/Plugin/PluginBag.php b/core/lib/Drupal/Component/Plugin/PluginBag.php index 8ab051a..23d2d26 100644 --- a/core/lib/Drupal/Component/Plugin/PluginBag.php +++ b/core/lib/Drupal/Component/Plugin/PluginBag.php @@ -9,6 +9,9 @@ /** * Defines an object which stores multiple plugin instances to lazy load them. + * + * The \ArrayAccess implementation is only for backwards compatibility, it is + * deprecated and should not be used by new code. */ abstract class PluginBag implements \Iterator, \Countable { @@ -27,7 +30,7 @@ protected $instanceIDs = array(); /** - * Initializes and stores a plugin. + * Initializes a plugin and stores the result in $this->pluginInstances. * * @param string $instance_id * The ID of the plugin instance to initialize. @@ -82,7 +85,7 @@ public function set($instance_id, $value) { /** * Removes an initialized plugin. * - * The plugin can still be used; it will be reinitialized. + * The plugin can still be used, it will be reinitialized. * * @param string $instance_id * The ID of the plugin instance to remove. @@ -92,7 +95,7 @@ public function remove($instance_id) { } /** - * Adds an instance ID to the available instance IDs. + * Adds an instance ID to the array of available instance IDs. * * @param string $id * The ID of the plugin instance to add. @@ -114,7 +117,7 @@ public function getInstanceIds() { } /** - * Sets all instance IDs. + * Sets the instance IDs property. * * @param array $instance_ids * An associative array of instance IDs. @@ -135,28 +138,28 @@ public function removeInstanceId($instance_id) { } /** - * {@inheritdoc} + * Implements \Iterator::current(). */ public function current() { return $this->get($this->key()); } /** - * {@inheritdoc} + * Implements \Iterator::next(). */ public function next() { next($this->instanceIDs); } /** - * {@inheritdoc} + * Implements \Iterator::key(). */ public function key() { return key($this->instanceIDs); } /** - * {@inheritdoc} + * Implements \Iterator::valid(). */ public function valid() { $key = key($this->instanceIDs); @@ -164,14 +167,14 @@ public function valid() { } /** - * {@inheritdoc} + * Implements \Iterator::rewind(). */ public function rewind() { reset($this->instanceIDs); } /** - * {@inheritdoc} + * Implements \Countable::count(). */ public function count() { return count($this->instanceIDs); diff --git a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php index 5d43231..5bc4a7d 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php @@ -8,6 +8,7 @@ use Drupal\Core\Asset\AssetCollectionOptimizerInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Optimizes CSS assets. @@ -38,7 +39,7 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface { /** * The state key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -51,10 +52,10 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface { * The optimizer for a single CSS asset. * @param \Drupal\Core\Asset\AssetDumperInterface * The dumper for optimized CSS assets. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @param \Drupal\Core\KeyValueStore\StateInterface * The state key/value store. */ - public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, KeyValueStoreInterface $state) { + public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state) { $this->grouper = $grouper; $this->optimizer = $optimizer; $this->dumper = $dumper; diff --git a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php index 09846c1..e1cb3cd 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php @@ -6,9 +6,8 @@ namespace Drupal\Core\Asset; -use Drupal\Core\Asset\AssetCollectionRendererInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Drupal\Component\Utility\String; +use Drupal\Core\KeyValueStore\StateInterface; /** * Renders CSS assets. @@ -18,17 +17,17 @@ class CssCollectionRenderer implements AssetCollectionRendererInterface { /** * The state key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; /** * Constructs a CssCollectionRenderer. * - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @param \Drupal\Core\KeyValueStore\StateInterface * The state key/value store. */ - public function __construct(KeyValueStoreInterface $state) { + public function __construct(StateInterface $state) { $this->state = $state; } diff --git a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php index bf4cbf6..4d39a2e 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php @@ -6,8 +6,7 @@ namespace Drupal\Core\Asset; -use Drupal\Core\Asset\AssetCollectionOptimizerInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** @@ -39,7 +38,7 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface { /** * The state key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -52,10 +51,10 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface { * The optimizer for a single JS asset. * @param \Drupal\Core\Asset\AssetDumperInterface * The dumper for optimized JS assets. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @param \Drupal\Core\KeyValueStore\StateInterface * The state key/value store. */ - public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, KeyValueStoreInterface $state) { + public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state) { $this->grouper = $grouper; $this->optimizer = $optimizer; $this->dumper = $dumper; diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php index 443387a..b9de5f8 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php @@ -6,8 +6,7 @@ namespace Drupal\Core\Asset; -use Drupal\Core\Asset\AssetCollectionRendererInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Renders JavaScript assets. @@ -17,17 +16,17 @@ class JsCollectionRenderer implements AssetCollectionRendererInterface { /** * The state key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; /** * Constructs a CssCollectionRenderer. * - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @param \Drupal\Core\KeyValueStore\StateInterface * The state key/value store. */ - public function __construct(KeyValueStoreInterface $state) { + public function __construct(StateInterface $state) { $this->state = $state; } diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index bf178c5..52c9aa5 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -204,11 +204,14 @@ public function listAll($prefix = '') { throw new StorageException($this->directory . '/ not found.'); } $extension = '.' . static::getFileExtension(); - $files = glob($this->directory . '/' . $prefix . '*' . $extension); - $clean_name = function ($value) use ($extension) { - return basename($value, $extension); - }; - return array_map($clean_name, $files); + $files = new \GlobIterator(DRUPAL_ROOT . '/' . $this->directory . '/' . $prefix . '*' . $extension); + + $names = array(); + foreach ($files as $file) { + $names[] = $file->getBasename($extension); + } + + return $names; } /** diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index e8442ea..16bcc1c 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -134,10 +134,9 @@ public function getComponentNames($type, array $list) { foreach ($list as $name) { $directory = $this->getComponentFolder($type, $name); if (file_exists($directory)) { - $files = glob($directory . '/*' . $extension); - foreach ($files as $filename) { - $name = basename($filename, $extension); - $folders[$name] = $directory; + $files = new \GlobIterator(DRUPAL_ROOT . '/' . $directory . '/*' . $extension); + foreach ($files as $file) { + $folders[$file->getBasename($extension)] = $directory; } } } diff --git a/core/lib/Drupal/Core/Extension/CachedModuleHandler.php b/core/lib/Drupal/Core/Extension/CachedModuleHandler.php index 6e09432..0def7f3 100644 --- a/core/lib/Drupal/Core/Extension/CachedModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/CachedModuleHandler.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Extension; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Class that manages enabled modules in a Drupal installation. @@ -18,7 +18,7 @@ class CachedModuleHandler extends ModuleHandler implements CachedModuleHandlerIn /** * State key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -39,7 +39,7 @@ class CachedModuleHandler extends ModuleHandler implements CachedModuleHandlerIn /** * Constructs a new CachedModuleHandler object. */ - public function __construct(array $module_list = array(), KeyValueStoreInterface $state, CacheBackendInterface $bootstrap_cache) { + public function __construct(array $module_list = array(), StateInterface $state, CacheBackendInterface $bootstrap_cache) { parent::__construct($module_list); $this->state = $state; $this->bootstrapCache = $bootstrap_cache; diff --git a/core/lib/Drupal/Core/KeyValueStore/State.php b/core/lib/Drupal/Core/KeyValueStore/State.php new file mode 100644 index 0000000..36a7973 --- /dev/null +++ b/core/lib/Drupal/Core/KeyValueStore/State.php @@ -0,0 +1,125 @@ +keyValueStore = $key_value_factory->get('state'); + } + + /** + * {@inheritdoc} + */ + public function getMultiple(array $keys) { + $values = array(); + $load = array(); + foreach ($keys as $key) { + // Check if we have a value in the cache. + if (isset($this->cache[$key])) { + $values[$key] = $this->cache[$key]; + } + // Load the value if we don't have an explicit NULL value. + elseif (!array_key_exists($key, $this->cache)) { + $load[] = $key; + } + } + + if ($load) { + $loaded_values = $this->keyValueStore->getMultiple($load); + foreach ($load as $key) { + // If we find a value, even one that is NULL, add it to the cache and + // return it. + if (isset($loaded_values[$key]) || array_key_exists($key, $loaded_values)) { + $values[$key] = $loaded_values[$key]; + $this->cache[$key] = $loaded_values[$key]; + } + else { + $this->cache[$key] = NULL; + } + } + } + + return $values; + } + + /** + * {@inheritdoc} + */ + public function set($key, $value) { + $this->cache[$key] = $value; + $this->keyValueStore->set($key, $value); + } + + /** + * {@inheritdoc} + */ + public function deleteMultiple(array $keys) { + foreach ($keys as $key) { + unset($this->cache[$key]); + } + $this->keyValueStore->deleteMultiple($keys); + } + + + /** + * {@inheritdoc} + */ + public function get($key, $default = NULL) { + $values = $this->getMultiple(array($key)); + return isset($values[$key]) ? $values[$key] : $default; + } + + /** + * {@inheritdoc} + */ + public function setMultiple(array $data) { + foreach ($data as $key => $value) { + $this->cache[$key] = $value; + } + $this->keyValueStore->setMultiple($data); + } + + /** + * {@inheritdoc} + */ + public function delete($key) { + $this->deleteMultiple(array($key)); + } + + /** + * {@inheritdoc} + */ + public function resetCache() { + $this->cache = array(); + } + +} diff --git a/core/lib/Drupal/Core/KeyValueStore/StateInterface.php b/core/lib/Drupal/Core/KeyValueStore/StateInterface.php new file mode 100644 index 0000000..7584abc --- /dev/null +++ b/core/lib/Drupal/Core/KeyValueStore/StateInterface.php @@ -0,0 +1,80 @@ +state = $state; $this->moduleHandler = $module_handler; } diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index 72e5707..151bb23 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -21,13 +21,6 @@ class AliasManager implements AliasManagerInterface { protected $connection; /** - * The Key/Value Store to use for state - * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface - */ - protected $state; - - /** * Language manager for retrieving the default langcode when none is specified. * * @var \Drupal\Core\Language\LanguageManager diff --git a/core/lib/Drupal/Core/Path/AliasWhitelist.php b/core/lib/Drupal/Core/Path/AliasWhitelist.php index 9e3a6a1..2c151b5 100644 --- a/core/lib/Drupal/Core/Path/AliasWhitelist.php +++ b/core/lib/Drupal/Core/Path/AliasWhitelist.php @@ -11,7 +11,7 @@ use Drupal\Core\Cache\CacheCollector; use Drupal\Core\Database\Connection; use Drupal\Core\DestructableInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Utility\CacheArray; @@ -23,7 +23,7 @@ class AliasWhitelist extends CacheCollector { /** * The Key/Value Store to use for state. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -43,12 +43,12 @@ class AliasWhitelist extends CacheCollector { * The cache backend. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state keyvalue store. * @param \Drupal\Core\Database\Connection $connection * The database connection. */ - public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, KeyValueStoreInterface $state, Connection $connection) { + public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, StateInterface $state, Connection $connection) { parent::__construct($cid, $cache, $lock); $this->state = $state; $this->connection = $connection; diff --git a/core/lib/Drupal/Core/PrivateKey.php b/core/lib/Drupal/Core/PrivateKey.php index fd8bb55..762a664 100644 --- a/core/lib/Drupal/Core/PrivateKey.php +++ b/core/lib/Drupal/Core/PrivateKey.php @@ -7,7 +7,7 @@ namespace Drupal\Core; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Component\Utility\Crypt; /** @@ -18,17 +18,17 @@ class PrivateKey { /** * The state service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; /** * Constructs the token generator. * - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state service. */ - function __construct(KeyValueStoreInterface $state) { + function __construct(StateInterface $state) { $this->state = $state; } diff --git a/core/modules/action/action.views.inc b/core/modules/action/action.views.inc index b38eead..9bdb3d3 100644 --- a/core/modules/action/action.views.inc +++ b/core/modules/action/action.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provides views data for action.module. + * Provides views data and handlers for action.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/aggregator/aggregator.views.inc b/core/modules/aggregator/aggregator.views.inc index 28e6b28..5d87034 100644 --- a/core/modules/aggregator/aggregator.views.inc +++ b/core/modules/aggregator/aggregator.views.inc @@ -3,6 +3,8 @@ /** * @file * Provides views data for aggregator.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php index 2e4a4c6..9921f27 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php @@ -75,6 +75,7 @@ public function testLanguageBlockVisibility() { // Reset the static cache of the language list. drupal_static_reset('language_list'); + \Drupal::state()->resetCache(); // Check that a page has a block. $this->drupalget('', array('language' => language_load('en'))); diff --git a/core/modules/book/book.module b/core/modules/book/book.module index c9fccf5..cd7d714 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -696,43 +696,28 @@ function template_preprocess_book_navigation(&$variables) { if ($book_link['mlid']) { $variables['tree'] = book_children($book_link); - $build = array(); - if ($prev = book_prev($book_link)) { $prev_href = url($prev['href']); - $build['#attached']['drupal_add_html_head_link'][][] = array( - 'rel' => 'prev', - 'href' => $prev_href, - ); + drupal_add_html_head_link(array('rel' => 'prev', 'href' => $prev_href)); $variables['prev_url'] = $prev_href; $variables['prev_title'] = check_plain($prev['title']); } if ($book_link['plid'] && $parent = book_link_load($book_link['plid'])) { $parent_href = url($parent['link_path']); - $build['#attached']['drupal_add_html_head_link'][][] = array( - 'rel' => 'up', - 'href' => $parent_href, - ); + drupal_add_html_head_link(array('rel' => 'up', 'href' => $parent_href)); $variables['parent_url'] = $parent_href; $variables['parent_title'] = check_plain($parent['title']); } if ($next = book_next($book_link)) { $next_href = url($next['href']); - $build['#attached']['drupal_add_html_head_link'][][] = array( - 'rel' => 'next', - 'href' => $next_href, - ); + drupal_add_html_head_link(array('rel' => 'next', 'href' => $next_href)); $variables['next_url'] = $next_href; $variables['next_title'] = check_plain($next['title']); } } - if (!empty($build)) { - drupal_render($build); - } - $variables['has_links'] = FALSE; // Link variables to filter for values and set state of the flag variable. $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title'); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php index bc0dc61..3eefd37 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php @@ -320,9 +320,9 @@ public function getLangcodes() { if (empty($langcodes)) { $langcodes = array(); // Collect languages included with CKEditor based on file listing. - $ckeditor_languages = glob(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js'); - foreach ($ckeditor_languages as $language_filename) { - $langcode = basename($language_filename, '.js'); + $ckeditor_languages = new \GlobIterator(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js'); + foreach ($ckeditor_languages as $language_file) { + $langcode = $language_file->getBasename('.js'); $langcodes[$langcode] = $langcode; } cache('ckeditor.languages')->set('langcodes', $langcodes); diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index fa38bfb..9f8b282 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1731,20 +1731,3 @@ function comment_library_info() { ); return $libraries; } - -/** - * #post_render_cache callback; replaces the placeholder with the comment form. - * - * @param array $context - * An array with the following keys: - * - entity_type: an entity type - * - entity_id: an entity ID - * - field_name: a comment field name - * - * @return array $element - * The updated $element. - */ -function comment_replace_form_placeholder(array $context) { - $entity = entity_load($context['entity_type'], $context['entity_id']); - return comment_add($entity, $context['field_name']); -} diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index ed8f85a..663704b 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for comment.module. + * Provide views data and handlers for comment.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index be1b6db..ff0e346 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -138,24 +138,7 @@ public function viewElements(FieldItemListInterface $items) { if ($status == COMMENT_OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW) { // Only show the add comment form if the user has permission. if ($this->currentUser->hasPermission('post comments')) { - // All users in the "anonymous" role can use the same form: it is fine - // for this form to be stored in the render cache. - if ($this->currentUser->isAnonymous()) { - $output['comment_form'] = comment_add($entity, $field_name); - } - // All other users need a user-specific form, which would break the - // render cache: hence use a #post_render_cache callback. - else { - $output['comment_form'] = array( - '#type' => 'render_cache_placeholder', - '#callback' => 'comment_replace_form_placeholder', - '#context' => array( - 'entity_type' => $entity->entityType(), - 'entity_id' => $entity->id(), - 'field_name' => $field_name - ), - ); - } + $output['comment_form'] = comment_add($entity, $field_name); } } diff --git a/core/modules/contact/contact.views.inc b/core/modules/contact/contact.views.inc index 1560362..6795b0e 100644 --- a/core/modules/contact/contact.views.inc +++ b/core/modules/contact/contact.views.inc @@ -3,6 +3,8 @@ /** * @file * Provide views data for contact.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/contextual/contextual.views.inc b/core/modules/contextual/contextual.views.inc index 528b3bb..ea8088a 100644 --- a/core/modules/contextual/contextual.views.inc +++ b/core/modules/contextual/contextual.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for contextual.module. + * Provide views data and handlers for contextual.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/contextual/css/contextual.theme.css b/core/modules/contextual/css/contextual.theme.css index 7475a1d..be6d44a 100644 --- a/core/modules/contextual/css/contextual.theme.css +++ b/core/modules/contextual/css/contextual.theme.css @@ -91,7 +91,9 @@ } .contextual-region .contextual .contextual-links a { background-color: #fff; - color: #333; + /* This is an unfortunately necessary use of !important to prevent white + * links on a white background or some similar illegible combination. */ + color: #333 !important; display: block; font-family: sans-serif; font-size: small; diff --git a/core/modules/dblog/dblog.views.inc b/core/modules/dblog/dblog.views.inc index 90be37c..2198783 100644 --- a/core/modules/dblog/dblog.views.inc +++ b/core/modules/dblog/dblog.views.inc @@ -3,6 +3,8 @@ /** * @file * Provide views data for dblog.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/field/field.views.inc b/core/modules/field/field.views.inc index ae87873..b2f33c1 100644 --- a/core/modules/field/field.views.inc +++ b/core/modules/field/field.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide Views data for field.module. + * Provide Views data and handlers for field.module. + * + * @ingroup views_module_handlers */ use Drupal\Component\Utility\NestedArray; diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php index 5d8fa9c..d88e6b1 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php @@ -16,7 +16,7 @@ use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Extension\ModuleHandler; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Controller class for field instances. @@ -45,7 +45,7 @@ class FieldInstanceStorageController extends ConfigStorageController { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -68,10 +68,10 @@ class FieldInstanceStorageController extends ConfigStorageController { * The entity manager. * @param \Drupal\Core\Extension\ModuleHandler $module_handler * The module handler. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, KeyValueStoreInterface $state) { + public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, StateInterface $state) { parent::__construct($entity_type, $entity_info, $config_factory, $config_storage, $entity_query_factory, $uuid_service); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; diff --git a/core/modules/field/lib/Drupal/field/FieldStorageController.php b/core/modules/field/lib/Drupal/field/FieldStorageController.php index 24db2c2..0da91aa 100644 --- a/core/modules/field/lib/Drupal/field/FieldStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldStorageController.php @@ -16,7 +16,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Extension\ModuleHandler; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Controller class for fields. @@ -40,7 +40,7 @@ class FieldStorageController extends ConfigStorageController { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -63,10 +63,10 @@ class FieldStorageController extends ConfigStorageController { * The entity manager. * @param \Drupal\Core\Extension\ModuleHandler $module_handler * The module handler. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, KeyValueStoreInterface $state) { + public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, StateInterface $state) { parent::__construct($entity_type, $entity_info, $config_factory, $config_storage, $entity_query_factory, $uuid_service); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc index 7adc194..3ba4cc7 100644 --- a/core/modules/file/file.views.inc +++ b/core/modules/file/file.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for file.module. + * Provide views data and handlers for file.module. + * + * @ingroup views_module_handlers */ use Drupal\Core\Entity\FieldableDatabaseStorageController; diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php index 96305bd..b6fb820 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php @@ -38,6 +38,8 @@ function setUp() { * 'insert', etc. */ function assertFileHooksCalled($expected) { + \Drupal::state()->resetCache(); + // Determine which hooks were called. $actual = array_keys(array_filter(file_test_get_all_calls())); diff --git a/core/modules/forum/forum.views.inc b/core/modules/forum/forum.views.inc index fa7174f..fb79907 100644 --- a/core/modules/forum/forum.views.inc +++ b/core/modules/forum/forum.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for forum.module. + * Provide views data and handlers for forum.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/history/history.views.inc b/core/modules/history/history.views.inc index 50e12aa..ed36820 100644 --- a/core/modules/history/history.views.inc +++ b/core/modules/history/history.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for history.module. + * Provide views data and handlers for history.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index 5babb6a..2fbcddb 100644 --- a/core/modules/image/image.views.inc +++ b/core/modules/image/image.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for image.module. + * Provide views data and handlers for image.module. + * + * @ingroup views_module_handlers */ use Drupal\Core\Entity\FieldableDatabaseStorageController; diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php index 1fb8c85..3381d44 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php @@ -72,6 +72,8 @@ function testLanguageConfiguration() { ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->assertOptionSelected('edit-site-default-language', 'fr', 'Default language updated.'); + + \Drupal::state()->resetCache(); $this->assertEqual($this->getUrl(), url('admin/config/regional/settings', array('absolute' => TRUE)), 'Correct page redirection.'); // Check if a valid language prefix is added after changing the default diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php index ba50def..4123fc0 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageFallbackTest.php @@ -26,7 +26,7 @@ public static function getInfo() { /** * The state storage service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index 8b2190d..6b0f130 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -72,6 +72,7 @@ function testLanguageList() { ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->assertNoOptionSelected('edit-site-default-language', 'en', 'Default language updated.'); + \Drupal::state()->resetCache(); $this->assertEqual($this->getUrl(), url($path, array('absolute' => TRUE)), 'Correct page redirection.'); // Ensure we can't delete the default language. @@ -96,6 +97,7 @@ function testLanguageList() { 'site_default_language' => 'en', ); $this->drupalPostForm($path, $edit, t('Save configuration')); + \Drupal::state()->resetCache(); // Ensure 'delete' link works. $this->drupalGet('admin/config/regional/language'); $this->clickLink(t('Delete')); @@ -109,6 +111,7 @@ function testLanguageList() { // Delete the language for real. This a confirm form, we do not need any // fields changed. $this->drupalPostForm('admin/config/regional/language/delete/' . $langcode, array(), t('Delete')); + \Drupal::state()->resetCache(); // We need raw here because %language and %langcode will add HTML. $t_args = array('%language' => $name, '%langcode' => $langcode); $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.'); @@ -125,6 +128,7 @@ function testLanguageList() { $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete')); // Get the count of languages. drupal_static_reset('language_list'); + \Drupal::state()->resetCache(); $languages = language_list(); // We need raw here because %language and %langcode will add HTML. $t_args = array('%language' => 'French', '%langcode' => 'fr'); @@ -149,6 +153,7 @@ function testLanguageList() { 'direction' => '0', ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); + \Drupal::state()->resetCache(); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.'); $this->assertText($name, 'Name found.'); diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php index c33da33..ea4c9ce 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php @@ -11,7 +11,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\locale\StringStorageInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -31,7 +31,7 @@ /** * The state store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -54,12 +54,12 @@ * * @param \Drupal\locale\StringStorageInterface $locale_storage * The locale storage. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state service. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. */ - public function __construct(StringStorageInterface $locale_storage, KeyValueStoreInterface $state, LanguageManager $language_manager) { + public function __construct(StringStorageInterface $locale_storage, StateInterface $state, LanguageManager $language_manager) { $this->localeStorage = $locale_storage; $this->state = $state; $this->languageManager = $language_manager; diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 8cd217b..dff7ec3 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -136,6 +136,7 @@ function testStandalonePoFile() { $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $this->assertNoText(t('No strings available.'), 'String overwritten by imported string.'); // This import should have changed number of plural forms. + \Drupal::state()->resetCache(); $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); $this->assert($locale_plurals['fr']['plurals'] == 3, 'Plural numbers changed.'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php index 3d20f6d..1ed7800 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php @@ -130,6 +130,7 @@ function testUpdateCheckStatus() { // Get status of translation sources at both local and remote locations. $this->drupalGet('admin/reports/translations/check'); + \Drupal::state()->resetCache(); $result = locale_translation_get_status(); $this->assertEqual($result['contrib_module_one']['de']->type, LOCALE_TRANSLATION_REMOTE, 'Translation of contrib_module_one found'); $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found'); diff --git a/core/modules/migrate/config/migrate.migration.d6_system_cron.yml b/core/modules/migrate/config/migrate.migration.d6_system_cron.yml deleted file mode 100644 index 736af9b..0000000 --- a/core/modules/migrate/config/migrate.migration.d6_system_cron.yml +++ /dev/null @@ -1,13 +0,0 @@ -id: d6_system_cron -source: - plugin: drupal6_variable - variables: - - cron_threshold_warning - - cron_threshold_error - - cron_last -process: - 'threshold:warning': cron_threshold_warning - 'threshold:error': cron_threshold_error -destination: - plugin: d8_config - config_name: system.cron diff --git a/core/modules/migrate/config/migrate.migration.d6_system_rss.yml b/core/modules/migrate/config/migrate.migration.d6_system_rss.yml deleted file mode 100644 index acce5e2..0000000 --- a/core/modules/migrate/config/migrate.migration.d6_system_rss.yml +++ /dev/null @@ -1,10 +0,0 @@ -id: d6_system_rss -source: - plugin: drupal6_variable - variables: - - feed_default_items -process: - 'items:limit': feed_default_items -destination: - plugin: d8_config - config_name: system.rss diff --git a/core/modules/migrate/config/migrate.migration.d6_system_site.yml b/core/modules/migrate/config/migrate.migration.d6_system_site.yml deleted file mode 100644 index bcfb712..0000000 --- a/core/modules/migrate/config/migrate.migration.d6_system_site.yml +++ /dev/null @@ -1,24 +0,0 @@ -id: d6_system_site -source: - plugin: drupal6_variable - variables: - - site_name - - site_mail - - site_slogan - - site_frontpage - - site_403 - - site_404 - - drupal_weight_select_max - - admin_compact_mode -process: - name: site_name - mail: site_mail - slogan: site_slogan - 'page:front': site_frontpage - 'page:403': site_403 - 'page:404': site_404 - weight_select_max: drupal_weight_select_max - admin_compact_mode: admin_compact_mode -destination: - plugin: d8_config - config_name: system.site diff --git a/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php b/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php deleted file mode 100644 index 5d48ed0..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php +++ /dev/null @@ -1,288 +0,0 @@ -sourcePlugin)) { - $this->sourcePlugin = \Drupal::service('plugin.manager.migrate.source')->createInstance($this->source['plugin'], $this->source, $this); - } - return $this->sourcePlugin; - } - - /** - * {@inheritdoc} - */ - public function getProcessPlugins(array $process = NULL) { - if (!isset($process)) { - $process = $this->process; - } - $process_plugins = array(); - foreach ($this->getProcessNormalized($process) as $property => $configurations) { - $process_plugins[$property] = array(); - foreach ($configurations as $configuration) { - if (isset($configuration['source'])) { - $process_plugins[$property][] = \Drupal::service('plugin.manager.migrate.process')->createInstance('get', $configuration, $this); - } - // Get is already handled. - if ($configuration['plugin'] != 'get') { - $process_plugins[$property][] = \Drupal::service('plugin.manager.migrate.process')->createInstance($configuration['plugin'], $configuration, $this); - } - if (!$process_plugins[$property]) { - throw new MigrateException("Invalid process configuration for $property"); - } - } - } - return $process_plugins; - } - - /** - * Resolve shorthands into a list of plugin configurations. - * - * @param array $process - * A process configuration array. - * - * @return array - * The normalized process configuration. - */ - protected function getProcessNormalized(array $process) { - $normalized_configurations = array(); - foreach ($process as $destination => $configuration) { - if (is_string($configuration)) { - $configuration = array( - 'plugin' => 'get', - 'source' => $configuration, - ); - } - if (isset($configuration['plugin'])) { - $configuration = array($configuration); - } - $normalized_configurations[$destination] = $configuration; - } - return $normalized_configurations; - } - - /** - * {@inheritdoc} - */ - public function getDestinationPlugin() { - if (!isset($this->destinationPlugin)) { - $this->destinationPlugin = \Drupal::service('plugin.manager.migrate.destination')->createInstance($this->destination['plugin'], $this->destination, $this); - } - return $this->destinationPlugin; - } - - /** - * {@inheritdoc} - */ - public function getIdMap() { - if (!isset($this->idMapPlugin)) { - $configuration = $this->idMap; - $plugin = isset($configuration['plugin']) ? $configuration['plugin'] : 'sql'; - $this->idMapPlugin = \Drupal::service('plugin.manager.migrate.id_map')->createInstance($plugin, $configuration, $this); - } - return $this->idMapPlugin; - } - - /** - * @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface - */ - protected function getHighWaterStorage() { - if (!isset($this->highwaterStorage)) { - $this->highwaterStorage = \Drupal::keyValue('migrate:highwater'); - } - return $this->highwaterStorage; - } - - public function getHighwater() { - return $this->getHighWaterStorage()->get($this->id()); - } - - public function saveHighwater($highwater) { - $this->getHighWaterStorage()->set($this->id(), $highwater); - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Entity/MigrationInterface.php b/core/modules/migrate/lib/Drupal/migrate/Entity/MigrationInterface.php deleted file mode 100644 index 1fa3dad..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Entity/MigrationInterface.php +++ /dev/null @@ -1,92 +0,0 @@ -level = $level; - $this->status = $status; - parent::__construct($message); - } - - /** - * Gets the level. - * - * @return int - */ - public function getLevel() { - return $this->level; - } - - /** - * Gets the status of the current item. - * - * @return int - */ - public function getStatus() { - return $this->status; - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/MigrateExecutable.php b/core/modules/migrate/lib/Drupal/migrate/MigrateExecutable.php deleted file mode 100644 index 9246ffe..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/MigrateExecutable.php +++ /dev/null @@ -1,538 +0,0 @@ -migration = $migration; - $this->message = $message; - $this->migration->getIdMap()->setMessage($message); - // Record the memory limit in bytes - $limit = trim(ini_get('memory_limit')); - if ($limit == '-1') { - $this->memoryLimit = PHP_INT_MAX; - } - else { - if (!is_numeric($limit)) { - $last = strtolower(substr($limit, -1)); - switch ($last) { - case 'g': - $limit *= 1024; - case 'm': - $limit *= 1024; - case 'k': - $limit *= 1024; - break; - default: - throw new MigrateException($this->t('Invalid PHP memory_limit !limit', - array('!limit' => $limit))); - } - } - $this->memoryLimit = $limit; - } - } - - /** - * @return \Drupal\migrate\Source - */ - public function getSource() { - if (!isset($this->source)) { - $this->source = new Source($this->migration, $this); - } - return $this->source; - } - - /** - * The rollback action to be saved for the current row. - * - * @var int - */ - public $rollbackAction; - - /** - * An array of counts. Initially used for cache hit/miss tracking. - * - * @var array - */ - protected $counts = array(); - - /** - * When performing a bulkRollback(), the maximum number of items to pass in - * a single call. Can be overridden in derived class constructor. - * - * @var int - */ - protected $rollbackBatchSize = 50; - - /** - * The object currently being constructed - * @var \stdClass - */ - protected $destinationValues; - - /** - * The current data row retrieved from the source. - * @var \stdClass - */ - protected $sourceValues; - - /** - * Perform an import operation - migrate items from source to destination. - */ - public function import() { - $return = MigrationInterface::RESULT_COMPLETED; - $source = $this->getSource(); - $destination = $this->migration->getDestinationPlugin(); - $id_map = $this->migration->getIdMap(); - - try { - $source->rewind(); - } - catch (\Exception $e) { - $this->message->display( - $this->t('Migration failed with source plugin exception: !e', - array('!e' => $e->getMessage()))); - return MigrationInterface::RESULT_FAILED; - } - while ($source->valid()) { - $row = $source->current(); - if ($this->sourceIdValues = $row->getSourceIdValues()) { - // Wipe old messages, and save any new messages. - $id_map->delete($row->getSourceIdValues(), TRUE); - $this->saveQueuedMessages(); - } - - $this->processRow($row); - - try { - $destination_id_values = $destination->import($row); - // @TODO handle the successful but no ID case like config. - if ($destination_id_values) { - $id_map->saveIdMapping($row, $destination_id_values, $this->needsUpdate, $this->rollbackAction); - $this->successes_since_feedback++; - $this->total_successes++; - } - else { - $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED, $this->rollbackAction); - if ($id_map->messageCount() == 0) { - $message = $this->t('New object was not saved, no error provided'); - $this->saveMessage($message); - $this->message->display($message); - } - } - } - catch (MigrateException $e) { - $this->migration->getIdMap()->saveIdMapping($row, array(), $e->getStatus(), $this->rollbackAction); - $this->saveMessage($e->getMessage(), $e->getLevel()); - $this->message->display($e->getMessage()); - } - catch (\Exception $e) { - $this->migration->getIdMap()->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED, $this->rollbackAction); - $this->handleException($e); - } - $this->total_processed++; - $this->processed_since_feedback++; - if ($highwater_property = $this->migration->get('highwaterProperty')) { - $this->migration->saveHighwater($row->getSourceProperty($highwater_property['name'])); - } - - // Reset row properties. - unset($sourceValues, $destinationValues); - $this->needsUpdate = MigrateIdMapInterface::STATUS_IMPORTED; - - // TODO: Temporary. Remove when http://drupal.org/node/375494 is committed. - // TODO: Should be done in MigrateDestinationEntity - if (!empty($destination->entityType)) { - entity_get_controller($destination->entityType)->resetCache(); - } - - if (($return = $this->checkStatus()) != MigrationInterface::RESULT_COMPLETED) { - break; - } - if ($this->timeOptionExceeded()) { - break; - } - try { - $source->next(); - } - catch (\Exception $e) { - $this->message->display( - $this->t('Migration failed with source plugin exception: !e', - array('!e' => $e->getMessage()))); - return MigrationInterface::RESULT_FAILED; - } - } - - /** - * @TODO uncomment this - */ - #$this->progressMessage($return); - - return $return; - } - - /** - * @param Row $row - * The $row to be processed. - * @param array $process - * A process pipeline configuration. If not set, the top level process - * configuration in the migration entity is used. - * @param mixed $value - * Optional initial value of the pipeline for the first destination. - * Usually setting this is not necessary as $process typically starts with - * a 'get'. This is useful only when the $process contains a single - * destination and needs to access a value outside of the source. See - * \Drupal\migrate\Plugin\migrate\process\Iterator::transformKey for an - * example. - */ - public function processRow(Row $row, array $process = NULL, $value = NULL) { - foreach ($this->migration->getProcessPlugins($process) as $destination => $plugins) { - foreach ($plugins as $plugin) { - $value = $plugin->transform($value, $this, $row, $destination); - } - $row->setDestinationProperty($destination, $value); - // Reset the value. - $value = NULL; - } - } - - /** - * Fetch the key array for the current source record. - * - * @return array - */ - protected function currentSourceIds() { - return $this->getSource()->getCurrentIds(); - } - - /** - * Test whether we've exceeded the designated time limit. - * - * @return boolean - * TRUE if the threshold is exceeded, FALSE if not. - */ - protected function timeOptionExceeded() { - if (!$time_limit = $this->getTimeLimit()) { - return FALSE; - } - $time_elapsed = time() - REQUEST_TIME; - if ($time_elapsed >= $time_limit) { - return TRUE; - } - else { - return FALSE; - } - } - - public function getTimeLimit() { - if (isset($this->options['limit']) && - ($this->options['limit']['unit'] == 'seconds' || $this->options['limit']['unit'] == 'second')) { - return $this->options['limit']['value']; - } - else { - return NULL; - } - } - - /** - * Pass messages through to the map class. - * - * @param string $message - * The message to record. - * @param int $level - * Optional message severity (defaults to MESSAGE_ERROR). - */ - public function saveMessage($message, $level = MigrationInterface::MESSAGE_ERROR) { - $this->migration->getIdMap()->saveMessage($this->sourceIdValues, $message, $level); - } - - /** - * Queue messages to be later saved through the map class. - * - * @param string $message - * The message to record. - * @param int $level - * Optional message severity (defaults to MESSAGE_ERROR). - */ - public function queueMessage($message, $level = MigrationInterface::MESSAGE_ERROR) { - $this->queuedMessages[] = array('message' => $message, 'level' => $level); - } - - /** - * Save any messages we've queued up to the message table. - */ - public function saveQueuedMessages() { - foreach ($this->queuedMessages as $queued_message) { - $this->saveMessage($queued_message['message'], $queued_message['level']); - } - $this->queuedMessages = array(); - } - - /** - * Standard top-of-loop stuff, common between rollback and import - check - * for exceptional conditions, and display feedback. - */ - protected function checkStatus() { - if ($this->memoryExceeded()) { - return MigrationInterface::RESULT_INCOMPLETE; - } - if ($this->timeExceeded()) { - return MigrationInterface::RESULT_INCOMPLETE; - } - /* - * @TODO uncomment this - if ($this->getStatus() == MigrationInterface::STATUS_STOPPING) { - return MigrationBase::RESULT_STOPPED; - } - */ - // If feedback is requested, produce a progress message at the proper time - /* - * @TODO uncomment this - if (isset($this->feedback)) { - if (($this->feedback_unit == 'seconds' && time() - $this->lastfeedback >= $this->feedback) || - ($this->feedback_unit == 'items' && $this->processed_since_feedback >= $this->feedback)) { - $this->progressMessage(MigrationInterface::RESULT_INCOMPLETE); - } - } - */ - - return MigrationInterface::RESULT_COMPLETED; - } - - /** - * Test whether we've exceeded the desired memory threshold. If so, output a message. - * - * @return boolean - * TRUE if the threshold is exceeded, FALSE if not. - */ - protected function memoryExceeded() { - $usage = memory_get_usage(); - $pct_memory = $usage / $this->memoryLimit; - if ($pct_memory > $this->memoryThreshold) { - $this->message->display( - $this->t('Memory usage is !usage (!pct% of limit !limit), resetting statics', - array('!pct' => round($pct_memory*100), - '!usage' => format_size($usage), - '!limit' => format_size($this->memoryLimit))), - 'warning'); - // First, try resetting Drupal's static storage - this frequently releases - // plenty of memory to continue - drupal_static_reset(); - $usage = memory_get_usage(); - $pct_memory = $usage/$this->memoryLimit; - // Use a lower threshold - we don't want to be in a situation where we keep - // coming back here and trimming a tiny amount - if ($pct_memory > (.90 * $this->memoryThreshold)) { - $this->message->display( - $this->t('Memory usage is now !usage (!pct% of limit !limit), not enough reclaimed, starting new batch', - array('!pct' => round($pct_memory*100), - '!usage' => format_size($usage), - '!limit' => format_size($this->memoryLimit))), - 'warning'); - return TRUE; - } - else { - $this->message->display( - $this->t('Memory usage is now !usage (!pct% of limit !limit), reclaimed enough, continuing', - array('!pct' => round($pct_memory*100), - '!usage' => format_size($usage), - '!limit' => format_size($this->memoryLimit))), - 'warning'); - return FALSE; - } - } - else { - return FALSE; - } - } - - /** - * Test whether we're approaching the PHP time limit. - * - * @return boolean - * TRUE if the threshold is exceeded, FALSE if not. - */ - protected function timeExceeded() { - if ($this->timeLimit == 0) { - return FALSE; - } - $time_elapsed = time() - REQUEST_TIME; - $pct_time = $time_elapsed / $this->timeLimit; - if ($pct_time > $this->timeThreshold) { - return TRUE; - } - else { - return FALSE; - } - } - - /** - * Takes an Exception object and both saves and displays it, pulling additional - * information on the location triggering the exception. - * - * @param \Exception $exception - * Object representing the exception. - * @param boolean $save - * Whether to save the message in the migration's mapping table. Set to FALSE - * in contexts where this doesn't make sense. - */ - public function handleException($exception, $save = TRUE) { - $result = _drupal_decode_exception($exception); - $message = $result['!message'] . ' (' . $result['%file'] . ':' . $result['%line'] . ')'; - if ($save) { - $this->saveMessage($message); - } - $this->message->display($message); - } - - /** - * Translates a string to the current language or to a given language. - * - * See the t() documentation for details. - */ - protected function t($string, array $args = array(), array $options = array()) { - return $this->translationManager()->translate($string, $args, $options); - } - - /** - * Gets the translation manager. - * - * @return \Drupal\Core\StringTranslation\TranslationInterface - * The translation manager. - */ - protected function translationManager() { - if (!$this->translationManager) { - $this->translationManager = \Drupal::translation(); - } - return $this->translationManager; - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/MigrateMessage.php b/core/modules/migrate/lib/Drupal/migrate/MigrateMessage.php deleted file mode 100644 index d90297e..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/MigrateMessage.php +++ /dev/null @@ -1,27 +0,0 @@ -alterInfo($module_handler, 'migrate_' . $type . '_info'); - $this->setCacheBackend($cache_backend, $language_manager, 'migrate_plugins_' . $type); - } - - /** - * {@inheritdoc} - * - * A specific createInstance method is necessary to pass the migration on. - */ - public function createInstance($plugin_id, array $configuration = array(), MigrationInterface $migration = NULL) { - $plugin_definition = $this->discovery->getDefinition($plugin_id); - $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition); - // If the plugin provides a factory method, pass the container to it. - if (is_subclass_of($plugin_class, 'Drupal\Core\Plugin\ContainerFactoryPluginInterface')) { - return $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition, $migration); - } - return new $plugin_class($configuration, $plugin_id, $plugin_definition, $migration); - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/MigrateProcessInterface.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/MigrateProcessInterface.php deleted file mode 100644 index 74da652..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/MigrateProcessInterface.php +++ /dev/null @@ -1,36 +0,0 @@ -config = $config; - } - - public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('config.factory')->get($configuration['config_name']) - ); - } - - /** - * {@inheritdoc} - */ - public function import(Row $row) { - $this->config - ->setData($row->getDestination()) - ->save(); - } - - /** - * @param array $destination_keys - * - * @throws \Drupal\migrate\MigrateException - */ - public function rollbackMultiple(array $destination_keys) { - throw new MigrateException('Configuration can not be rolled back'); - } - - /** - * Derived classes must implement fields(), returning a list of available - * destination fields. - * - * @todo Review the cases where we need the Migration parameter, can we avoid that? - * - * @param Migration $migration - * Optionally, the migration containing this destination. - * @return array - * - Keys: machine names of the fields - * - Values: Human-friendly descriptions of the fields. - */ - public function fields(Migration $migration = NULL) { - // @todo Dynamically fetch fields using Config Schema API. - } - - public function getIdsSchema() { - return array($this->config->getName() => array()); - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/DestinationBase.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/DestinationBase.php deleted file mode 100644 index 7cdf11b..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/DestinationBase.php +++ /dev/null @@ -1,53 +0,0 @@ -migration = $migration; - $machine_name = $migration->id(); - - // Default generated table names, limited to 63 characters. - $prefixLength = strlen($this->getDatabase()->tablePrefix()) ; - $this->mapTable = 'migrate_map_' . Unicode::strtolower($machine_name); - $this->mapTable = Unicode::substr($this->mapTable, 0, 63 - $prefixLength); - $this->messageTable = 'migrate_message_' . Unicode::strtolower($machine_name); - $this->messageTable = Unicode::substr($this->messageTable, 0, 63 - $prefixLength); - $this->sourceIds = $migration->get('sourceIds'); - $this->destinationIds = $migration->get('destinationIds'); - - // Build the source and destination identifier maps. - $this->sourceIdFields = array(); - $count = 1; - foreach ($this->sourceIds as $field => $schema) { - $this->sourceIdFields[$field] = 'sourceid' . $count++; - } - $this->destinationIdFields = array(); - $count = 1; - foreach ($this->destinationIds as $field => $schema) { - $this->destinationIdFields[$field] = 'destid' . $count++; - } - $this->ensureTables(); - } - - /** - * Qualifying the map table name with the database name makes cross-db joins - * possible. Note that, because prefixes are applied after we do this (i.e., - * it will prefix the string we return), we do not qualify the table if it has - * a prefix. This will work fine when the source data is in the default - * (prefixed) database (in particular, for simpletest), but not if the primary - * query is in an external database. - * - * @return string - */ - public function getQualifiedMapTable() { - $options = $this->getDatabase()->getConnectionOptions(); - $prefix = $this->getDatabase()->tablePrefix($this->mapTable); - if ($prefix) { - return $this->mapTable; - } - else { - return $options['database'] . '.' . $this->mapTable; - } - } - - /** - * Gets the database connection. - * - * @return \Drupal\Core\Database\Connection - */ - protected function getDatabase() { - if (!isset($this->database)) { - $this->database = SqlBase::getDatabaseConnection($this->migration->id(), $this->configuration); - } - return $this->database; - } - - /** - * {@inheritdoc} - */ - public function setMessage(MigrateMessageInterface $message) { - $this->message = $message; - } - - /** - * Create the map and message tables if they don't already exist. - */ - protected function ensureTables() { - if (!$this->ensured) { - if (!$this->getDatabase()->schema()->tableExists($this->mapTable)) { - // Generate appropriate schema info for the map and message tables, - // and map from the source field names to the map/msg field names. - $count = 1; - $source_id_schema = array(); - $pks = array(); - foreach ($this->sourceIds as $field_schema) { - $mapkey = 'sourceid' . $count++; - $source_id_schema[$mapkey] = $field_schema; - $pks[] = $mapkey; - } - - $fields = $source_id_schema; - - // Add destination identifiers to map table. - // TODO: How do we discover the destination schema? - $count = 1; - foreach ($this->destinationIds as $field_schema) { - // Allow dest identifier fields to be NULL (for IGNORED/FAILED - // cases). - $field_schema['not null'] = FALSE; - $mapkey = 'destid' . $count++; - $fields[$mapkey] = $field_schema; - } - $fields['needs_update'] = array( - 'type' => 'int', - 'size' => 'tiny', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => MigrateIdMapInterface::STATUS_IMPORTED, - 'description' => 'Indicates current status of the source row', - ); - $fields['rollback_action'] = array( - 'type' => 'int', - 'size' => 'tiny', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => MigrateIdMapInterface::ROLLBACK_DELETE, - 'description' => 'Flag indicating what to do for this item on rollback', - ); - $fields['last_imported'] = array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'UNIX timestamp of the last time this row was imported', - ); - $fields['hash'] = array( - 'type' => 'varchar', - 'length' => '32', - 'not null' => FALSE, - 'description' => 'Hash of source row data, for detecting changes', - ); - $schema = array( - 'description' => 'Mappings from source identifier value(s) to destination identifier value(s).', - 'fields' => $fields, - ); - if ($pks) { - $schema['primary key'] = $pks; - } - $this->getDatabase()->schema()->createTable($this->mapTable, $schema); - - // Now do the message table. - $fields = array(); - $fields['msgid'] = array( - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ); - $fields += $source_id_schema; - - $fields['level'] = array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1, - ); - $fields['message'] = array( - 'type' => 'text', - 'size' => 'medium', - 'not null' => TRUE, - ); - $schema = array( - 'description' => 'Messages generated during a migration process', - 'fields' => $fields, - 'primary key' => array('msgid'), - ); - if ($pks) { - $schema['indexes']['sourcekey'] = $pks; - } - $this->getDatabase()->schema()->createTable($this->messageTable, $schema); - } - else { - // Add any missing columns to the map table. - if (!$this->getDatabase()->schema()->fieldExists($this->mapTable, - 'rollback_action')) { - $this->getDatabase()->schema()->addField($this->mapTable, - 'rollback_action', array( - 'type' => 'int', - 'size' => 'tiny', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'Flag indicating what to do for this item on rollback', - )); - } - if (!$this->getDatabase()->schema()->fieldExists($this->mapTable, 'hash')) { - $this->getDatabase()->schema()->addField($this->mapTable, 'hash', array( - 'type' => 'varchar', - 'length' => '32', - 'not null' => FALSE, - 'description' => 'Hash of source row data, for detecting changes', - )); - } - } - $this->ensured = TRUE; - } - } - - /** - * {@inheritdoc} - */ - public function getRowBySource(array $source_id_value) { - $query = $this->getDatabase()->select($this->mapTable, 'map') - ->fields('map'); - foreach ($this->sourceIdFields as $source_id) { - $query = $query->condition("map.$source_id", array_shift($source_id_value), '='); - } - $result = $query->execute(); - return $result->fetchAssoc(); - } - - /** - * {@inheritdoc} - */ - public function getRowByDestination(array $destination_id_values) { - $query = $this->getDatabase()->select($this->mapTable, 'map') - ->fields('map'); - foreach ($this->destinationIdFields as $destination_id) { - $query = $query->condition("map.$destination_id", array_shift($destination_id_values), '='); - } - $result = $query->execute(); - return $result->fetchAssoc(); - } - - /** - * {@inheritdoc} - */ - public function getRowsNeedingUpdate($count) { - $rows = array(); - $result = $this->getDatabase()->select($this->mapTable, 'map') - ->fields('map') - ->condition('needs_update', MigrateIdMapInterface::STATUS_NEEDS_UPDATE) - ->range(0, $count) - ->execute(); - foreach ($result as $row) { - $rows[] = $row; - } - return $rows; - } - - /** - * {@inheritdoc} - */ - public function lookupSourceID(array $destination_id) { - $query = $this->getDatabase()->select($this->mapTable, 'map') - ->fields('map', $this->sourceIdFields); - foreach ($this->destinationIdFields as $key_name) { - $query = $query->condition("map.$key_name", array_shift($destination_id), '='); - } - $result = $query->execute(); - $source_id = $result->fetchAssoc(); - return $source_id; - } - - /** - * {@inheritdoc} - */ - public function lookupDestinationID(array $source_id) { - $query = $this->getDatabase()->select($this->mapTable, 'map') - ->fields('map', $this->destinationIdFields); - foreach ($this->sourceIdFields as $key_name) { - $query = $query->condition("map.$key_name", array_shift($source_id), '='); - } - $result = $query->execute(); - $destination_id = $result->fetchAssoc(); - return $destination_id; - } - - /** - * {@inheritdoc} - */ - public function saveIdMapping(Row $row, array $destination_id_values, $needs_update = MigrateIdMapInterface::STATUS_IMPORTED, $rollback_action = MigrateIdMapInterface::ROLLBACK_DELETE) { - // Construct the source key. - $source_id_values = $row->getSourceIdValues(); - // Construct the source key and initialize to empty variable keys. - $keys = array(); - foreach ($this->sourceIdFields as $field_name => $key_name) { - // A NULL key value will fail. - if (!isset($source_id_values[$field_name])) { - $this->message->display(t( - 'Could not save to map table due to NULL value for key field !field', - array('!field' => $field_name))); - return; - } - $keys[$key_name] = $source_id_values[$field_name]; - } - - $fields = array( - 'needs_update' => (int) $needs_update, - 'rollback_action' => (int) $rollback_action, - 'hash' => $row->getHash(), - ); - $count = 1; - foreach ($destination_id_values as $dest_id) { - $fields['destid' . $count++] = $dest_id; - } - if ($this->migration->get('trackLastImported')) { - $fields['last_imported'] = time(); - } - if ($keys) { - $this->getDatabase()->merge($this->mapTable) - ->key($keys) - ->fields($fields) - ->execute(); - } - } - - /** - * {@inheritdoc} - */ - public function saveMessage(array $source_id_values, $message, $level = MigrationInterface::MESSAGE_ERROR) { - $count = 1; - foreach ($source_id_values as $id_value) { - $fields['sourceid' . $count++] = $id_value; - // If any key value is empty, we can't save - print out and abort. - if (empty($id_value)) { - print($message); - return; - } - } - $fields['level'] = $level; - $fields['message'] = $message; - $this->getDatabase()->insert($this->messageTable) - ->fields($fields) - ->execute(); - } - - /** - * {@inheritdoc} - */ - public function prepareUpdate() { - $this->getDatabase()->update($this->mapTable) - ->fields(array('needs_update' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE)) - ->execute(); - } - - /** - * {@inheritdoc} - */ - public function processedCount() { - return $this->getDatabase()->select($this->mapTable) - ->countQuery() - ->execute() - ->fetchField(); - } - - /** - * {@inheritdoc} - */ - public function importedCount() { - return $this->getDatabase()->select($this->mapTable) - ->condition('needs_update', array(MigrateIdMapInterface::STATUS_IMPORTED, MigrateIdMapInterface::STATUS_NEEDS_UPDATE), 'IN') - ->countQuery() - ->execute() - ->fetchField(); - } - - /** - * {@inheritdoc} - */ - public function updateCount() { - return $this->countHelper(MigrateIdMapInterface::STATUS_NEEDS_UPDATE); - } - - /** - * {@inheritdoc} - */ - public function errorCount() { - return $this->countHelper(MigrateIdMapInterface::STATUS_FAILED); - } - - /** - * {@inheritdoc} - */ - public function messageCount() { - return $this->countHelper(NULL, $this->messageTable); - } - - /** - * Counts records in a table. - * - * @param $status - * An integer for the needs_update column. - * @param $table - * The table to work - * @return int - * The number of records. - */ - protected function countHelper($status, $table = NULL) { - $query = $this->getDatabase()->select($table ?: $this->mapTable); - if (isset($status)) { - $query->condition('needs_update', $status); - } - return $query->countQuery()->execute()->fetchField(); - } - - /** - * {@inheritdoc} - */ - public function delete(array $source_id_values, $messages_only = FALSE) { - if (empty($source_id_values)) { - throw new MigrateException('Without source identifier values it is impossible to find the row to delete.'); - } - if (!$messages_only) { - $map_query = $this->getDatabase()->delete($this->mapTable); - } - $message_query = $this->getDatabase()->delete($this->messageTable); - $count = 1; - foreach ($source_id_values as $id_value) { - if (!$messages_only) { - $map_query->condition('sourceid' . $count, $id_value); - } - $message_query->condition('sourceid' . $count, $id_value); - $count++; - } - - if (!$messages_only) { - $map_query->execute(); - } - $message_query->execute(); - } - - /** - * {@inheritdoc} - */ - public function deleteDestination(array $destination_id) { - $map_query = $this->getDatabase()->delete($this->mapTable); - $message_query = $this->getDatabase()->delete($this->messageTable); - $source_id = $this->lookupSourceID($destination_id); - if (!empty($source_id)) { - $count = 1; - foreach ($destination_id as $key_value) { - $map_query->condition('destid' . $count, $key_value); - $count++; - } - $map_query->execute(); - $count = 1; - foreach ($source_id as $key_value) { - $message_query->condition('sourceid' . $count, $key_value); - $count++; - } - $message_query->execute(); - } - } - - /** - * {@inheritdoc} - */ - public function setUpdate(array $source_id) { - if (empty($source_ids)) { - throw new MigrateException('No source identifiers provided to update.'); - } - $query = $this->getDatabase() - ->update($this->mapTable) - ->fields(array('needs_update' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE)); - $count = 1; - foreach ($source_id as $key_value) { - $query->condition('sourceid' . $count++, $key_value); - } - $query->execute(); - } - - /** - * {@inheritdoc} - */ - public function deleteBulk(array $source_id_values) { - // If we have a single-column key, we can shortcut it. - if (count($this->sourceIds) == 1) { - $sourceids = array(); - foreach ($source_id_values as $source_id) { - $sourceids[] = $source_id; - } - $this->getDatabase()->delete($this->mapTable) - ->condition('sourceid1', $sourceids, 'IN') - ->execute(); - $this->getDatabase()->delete($this->messageTable) - ->condition('sourceid1', $sourceids, 'IN') - ->execute(); - } - else { - foreach ($source_id_values as $source_id) { - $map_query = $this->getDatabase()->delete($this->mapTable); - $message_query = $this->getDatabase()->delete($this->messageTable); - $count = 1; - foreach ($source_id as $key_value) { - $map_query->condition('sourceid' . $count, $key_value); - $message_query->condition('sourceid' . $count++, $key_value); - } - $map_query->execute(); - $message_query->execute(); - } - } - } - - /** - * {@inheritdoc} - */ - public function clearMessages() { - $this->getDatabase()->truncate($this->messageTable)->execute(); - } - - /** - * {@inheritdoc} - */ - public function destroy() { - $this->getDatabase()->schema()->dropTable($this->mapTable); - $this->getDatabase()->schema()->dropTable($this->messageTable); - } - - /** - * Implementation of Iterator::rewind(). - * - * This is called before beginning a foreach loop. - * - * @todo Support idlist, itemlimit. - */ - public function rewind() { - $this->currentRow = NULL; - $fields = array(); - foreach ($this->sourceIdFields as $field) { - $fields[] = $field; - } - foreach ($this->destinationIdFields as $field) { - $fields[] = $field; - } - - // @todo Make this work. - /* - if (isset($this->options['itemlimit'])) { - $query = $query->range(0, $this->options['itemlimit']); - } - */ - $this->result = $this->getDatabase()->select($this->mapTable, 'map') - ->fields('map', $fields) - ->execute(); - $this->next(); - } - - /** - * Implementation of Iterator::current(). - * - * This is called when entering a loop iteration, returning the current row. - */ - public function current() { - return $this->currentRow; - } - - /** - * Implementation of Iterator::key(). - * - * This is called when entering a loop iteration, returning the key of the - * current row. It must be a scalar - we will serialize to fulfill the - * requirement, but using getCurrentKey() is preferable. - */ - public function key() { - return serialize($this->currentKey); - } - - /** - * Implementation of Iterator::next(). - * - * This is called at the bottom of the loop implicitly, as well as explicitly - * from rewind(). - */ - public function next() { - $this->currentRow = $this->result->fetchObject(); - $this->currentKey = array(); - if (!is_object($this->currentRow)) { - $this->currentRow = NULL; - } - else { - foreach ($this->sourceIdFields as $map_field) { - $this->currentKey[$map_field] = $this->currentRow->$map_field; - // Leave only destination fields. - unset($this->currentRow->$map_field); - } - } - } - - /** - * Implementation of Iterator::valid(). - * - * This is called at the top of the loop, returning TRUE to process the loop - * and FALSE to terminate it. - */ - public function valid() { - // @todo Check numProcessed against itemlimit. - return !is_null($this->currentRow); - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/DefaultValue.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/DefaultValue.php deleted file mode 100644 index 580eed8..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/DefaultValue.php +++ /dev/null @@ -1,29 +0,0 @@ -configuration['default_value']; - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/Get.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/Get.php deleted file mode 100644 index 6f2f51e..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/process/Get.php +++ /dev/null @@ -1,55 +0,0 @@ -configuration['source']; - $properties = is_string($source) ? array($source) : $source; - $return = array(); - foreach ($properties as $property) { - if (empty($property)) { - $return[] = $value; - } - else { - $is_source = TRUE; - if ($property[0] == '@') { - $property = preg_replace_callback('/^(@?)((?:@@)*)([^@]|$)/', function ($matches) use (&$is_source) { - // If there are an odd number of @ in the beginning, it's a - // destination. - $is_source = empty($matches[1]); - // Remove the possible escaping and do not lose the terminating - // non-@ either. - return str_replace('@@', '@', $matches[2]) . $matches[3]; - }, $property); - } - if ($is_source) { - $return[] = $row->getSourceProperty($property); - } - else { - $return[] = $row->getDestinationProperty($property); - } - } - } - return is_string($source) ? $return[0] : $return; - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/D6Variable.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/D6Variable.php deleted file mode 100644 index 3160d53..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/D6Variable.php +++ /dev/null @@ -1,59 +0,0 @@ -variables = $this->configuration['variables']; - } - - protected function runQuery() { - return new \ArrayIterator(array(array_map('unserialize', $this->query()->execute()->fetchAllKeyed()))); - } - - public function count() { - return intval($this->query()->countQuery()->execute()->fetchField() > 0); - } - - /** - * {@inheritdoc} - */ - public function fields() { - return drupal_map_assoc($this->variables); - } - - /** - * {@inheritdoc} - */ - function query() { - return $this->getDatabase() - ->select('variable', 'v') - ->fields('v', array('name', 'value')) - ->condition('name', $this->variables, 'IN'); - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/SourcePluginBase.php deleted file mode 100644 index 78eb2fa..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/SourcePluginBase.php +++ /dev/null @@ -1,54 +0,0 @@ -migration = $migration; - } - - /** - * @return \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected function getModuleHandler() { - if (!isset($this->moduleHandler)) { - $this->moduleHandler = \Drupal::moduleHandler(); - } - return $this->moduleHandler; - } - - /** - * {@inheritdoc} - */ - public function prepareRow(Row $row) { - $this->getModuleHandler()->invokeAll('migrate_prepare_row', $row, $this, $this->migration); - $this->getModuleHandler()->invokeAll('migrate_ '. $this->migration->id() . '_prepare_row', $row, $this, $this->migration); - return TRUE; - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/SqlBase.php deleted file mode 100644 index 9a17436..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/SqlBase.php +++ /dev/null @@ -1,192 +0,0 @@ -mapJoinable = TRUE; - } - - /** - * @return \Drupal\Core\Database\Connection - */ - function __toString() { - return (string) $this->query; - } - - /** - * @return \Drupal\Core\Database\Connection - */ - public function getDatabase() { - if (!isset($this->database)) { - $this->database = static::getDatabaseConnection($this->migration->id(), $this->configuration); - } - return $this->database; - } - - public static function getDatabaseConnection($id, array $configuration) { - if (isset($configuration['database'])) { - $key = 'migrate_' . $id; - Database::addConnectionInfo($key, 'default', $configuration['database']); - } - else { - $key = 'default'; - } - return Database::getConnection('default', $key); - } - - protected function select($table, $alias = NULL, array $options = array()) { - $options['fetch'] = \PDO::FETCH_ASSOC; - return $this->getDatabase()->select($table, $alias, $options); - } - - /** - * Implementation of MigrateSource::performRewind(). - * - * We could simply execute the query and be functionally correct, but - * we will take advantage of the PDO-based API to optimize the query up-front. - */ - protected function runQuery() { - $this->query = clone $this->query(); - $this->query->addTag('migrate'); - $this->query->addTag('migrate_' . $this->migration->id()); - $this->query->addMetaData('migration', $this->migration); - $highwaterProperty = $this->migration->get('highwaterProperty'); - - // Get the key values, for potential use in joining to the map table, or - // enforcing idlist. - $keys = array(); - foreach ($this->migration->get('sourceIds') as $field_name => $field_schema) { - if (isset($field_schema['alias'])) { - $field_name = $field_schema['alias'] . '.' . $field_name; - } - $keys[] = $field_name; - } - - // The rules for determining what conditions to add to the query are as - // follows (applying first applicable rule) - // 1. If idlist is provided, then only process items in that list (AND key - // IN (idlist)). Only applicable with single-value keys. - if ($id_list = $this->migration->get('idlist')) { - $this->query->condition($keys[0], $id_list, 'IN'); - } - else { - // 2. If the map is joinable, join it. We will want to accept all rows - // which are either not in the map, or marked in the map as NEEDS_UPDATE. - // Note that if highwater fields are in play, we want to accept all rows - // above the highwater mark in addition to those selected by the map - // conditions, so we need to OR them together (but AND with any existing - // conditions in the query). So, ultimately the SQL condition will look - // like (original conditions) AND (map IS NULL OR map needs update - // OR above highwater). - $conditions = $this->query->orConditionGroup(); - $condition_added = FALSE; - if ($this->mapJoinable) { - // Build the join to the map table. Because the source key could have - // multiple fields, we need to build things up. - $count = 1; - $map_join = ''; - $delimiter = ''; - foreach ($this->migration->get('sourceIds') as $field_name => $field_schema) { - if (isset($field_schema['alias'])) { - $field_name = $field_schema['alias'] . '.' . $field_name; - } - $map_join .= "$delimiter$field_name = map.sourceid" . $count++; - $delimiter = ' AND '; - } - - $alias = $this->query->leftJoin($this->migration->getIdMap()->getQualifiedMapTable(), 'map', $map_join); - $conditions->isNull($alias . '.sourceid1'); - $conditions->condition($alias . '.needs_update', MigrateIdMapInterface::STATUS_NEEDS_UPDATE); - $condition_added = TRUE; - - // And as long as we have the map table, add its data to the row. - $n = count($this->migration->get('sourceIds')); - for ($count = 1; $count <= $n; $count++) { - $map_key = 'sourceid' . $count; - $this->query->addField($alias, $map_key, "migrate_map_$map_key"); - } - $n = count($this->migration->get('destinationIds')); - for ($count = 1; $count <= $n; $count++) { - $map_key = 'destid' . $count++; - $this->query->addField($alias, $map_key, "migrate_map_$map_key"); - } - $this->query->addField($alias, 'needs_update', 'migrate_map_needs_update'); - } - // 3. If we are using highwater marks, also include rows above the mark. - // But, include all rows if the highwater mark is not set. - if (isset($highwaterProperty['name']) && ($highwater = $this->migration->getHighwater()) !== '') { - if (isset($highwaterProperty['alias'])) { - $highwater = $highwaterProperty['alias'] . '.' . $highwaterProperty['name']; - } - else { - $highwater = $highwaterProperty['name']; - } - $conditions->condition($highwater, $highwater, '>'); - $condition_added = TRUE; - } - if ($condition_added) { - $this->query->condition($conditions); - } - } - - return new \IteratorIterator($this->query->execute()); - } - - /** - * @return \Drupal\Core\Database\Query\SelectInterface - */ - abstract function query(); - - /** - * {@inheritdoc} - */ - public function count() { - return $this->query()->countQuery()->execute()->fetchField(); - } - - /** - * Returns the iterator that will yield the row arrays to be processed. - * - * @return \Iterator - */ - public function getIterator() { - if (!isset($this->iterator)) { - $this->iterator = $this->runQuery(); - } - return $this->iterator; - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/d6/Drupal6SqlBase.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/d6/Drupal6SqlBase.php deleted file mode 100644 index 579d87a..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/source/d6/Drupal6SqlBase.php +++ /dev/null @@ -1,82 +0,0 @@ -database - ->select('system', 's') - ->fields('s') - ->execute(); - foreach ($results as $result) { - $system_data[$result['type']][$result['name']] = $result; - } - return $system_data; - } - - /** - * Get a module schema_version value in the source installation. - * - * @param string $module - * Name of module. - * - * @return mixed - * The current module schema version on the origin system table or FALSE if - * not found. - */ - protected function getModuleSchemaVersion($module) { - $system_data = $this->getSystemData(); - return isset($system_data['module'][$module]['schema_version']) ? $system_data['module'][$module]['schema_version'] : FALSE; - } - - /** - * Check to see if a given module is enabled in the source installation. - * - * @param string $module - * Name of module to check. - * - * @return bool - * TRUE if module is enabled on the origin system, FALSE if not. - */ - protected function moduleExists($module) { - return isset($system_data['module'][$module]['status']) ? (bool) $system_data['module'][$module]['status'] : FALSE; - } - - protected function variableGet($name, $default) { - try { - $result = $this->database - ->query('SELECT value FROM {variable} WHERE name = :name', array(':name' => $name)) - ->fetchField(); - } - // The table might not exist. - catch (\Exception $e) { - $result = FALSE; - } - return $result !== FALSE ? unserialize($result) : $default; - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Row.php b/core/modules/migrate/lib/Drupal/migrate/Row.php deleted file mode 100644 index 53ad14d..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Row.php +++ /dev/null @@ -1,264 +0,0 @@ - '', - 'hash' => '', - 'needs_update' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE, - ); - - /** - * Whether the source has been frozen already. - * - * Once frozen the source can not be changed any more. - * - * @var bool - */ - protected $frozen = FALSE; - - /** - * Constructs a \Drupal\Migrate\Row object. - * - * @param array $values - * An array of values to add as properties on the object. - * @param array $source_ids - * An array containing the IDs of the source using the keys as the field - * names. - * - * @throws \InvalidArgumentException - * Thrown when a source ID property does not exist. - */ - public function __construct(array $values, array $source_ids) { - $this->source = $values; - $this->sourceIds = $source_ids; - foreach (array_keys($source_ids) as $id) { - if (!$this->hasSourceProperty($id)) { - throw new \InvalidArgumentException("$id has no value"); - } - } - } - - /** - * Retrieves the values of the source identifiers. - * - * @return array - * An array containing the values of the source identifiers. - */ - public function getSourceIdValues() { - return array_intersect_key($this->source, $this->sourceIds); - } - - /** - * Determines whether a source has a property. - * - * @param string $property - * A property on the source. - * - * @return bool - * TRUE if the source has property; FALSE otherwise. - */ - public function hasSourceProperty($property) { - return isset($this->source[$property]) || array_key_exists($property, $this->source); - } - - /** - * Retrieves a source property. - * - * @param string $property - * A property on the source. - * - * @return mixed|null - * The found returned property or NULL if not found. - */ - public function getSourceProperty($property) { - if (isset($this->source[$property])) { - return $this->source[$property]; - } - } - - /** - * Returns the whole source array. - * - * @return array - * An array of source plugins. - */ - public function getSource() { - return $this->source; - } - - /** - * Sets a source property. - * - * This can only be called from the source plugin. - * - * @param string $property - * A property on the source. - * @param mixed $data - * The property value to set on the source. - * - * @throws \Exception - */ - public function setSourceProperty($property, $data) { - if ($this->frozen) { - throw new \Exception("The source is frozen and can't be changed any more"); - } - else { - $this->source[$property] = $data; - } - } - - /** - * Freezes the source. - */ - public function freezeSource() { - $this->frozen = TRUE; - } - - /** - * Tests if destination property exists. - * - * @param array|string $property - * An array of properties on the destination. - * - * @return boolean - * TRUE if the destination property exists. - */ - public function hasDestinationProperty($property) { - return NestedArray::keyExists($this->destination, explode(':', $property)); - } - - /** - * Sets destination properties. - * - * @param string $property - * The name of the destination property. - * @param mixed $value - * The property value to set on the destination. - */ - public function setDestinationProperty($property, $value) { - NestedArray::setValue($this->destination, explode(':', $property), $value, TRUE); - } - - /** - * Returns the whole destination array. - * - * @return array - * An array of destination values. - */ - public function getDestination() { - return $this->destination; - } - - /** - * Returns the value of a destination property. - * - * @param array|string $property - * An array of properties on the destination. - * - * @return mixed - * The destination value. - */ - public function getDestinationProperty($property) { - return NestedArray::getValue($this->destination, explode(':', $property)); - } - - /** - * Sets the Migrate ID mappings. - * - * @param array $id_map - * An array of mappings between source ID and destination ID. - */ - public function setIdMap(array $id_map) { - $this->idMap = $id_map; - } - - /** - * Retrieves the Migrate ID mappings. - * - * @return array - * An array of mapping between source and destination identifiers. - */ - public function getIdMap() { - return $this->idMap; - } - - /** - * Recalculates the hash for the row. - */ - public function rehash() { - $this->idMap['original_hash'] = $this->idMap['hash']; - $this->idMap['hash'] = hash('sha256', serialize($this->source)); - } - - /** - * Checks whether the row has changed compared to the original ID map. - * - * @return bool - * TRUE if the row has changed, FALSE otherwise. If setIdMap() was not - * called, this always returns FALSE. - */ - public function changed() { - return $this->idMap['original_hash'] != $this->idMap['hash']; - } - - /** - * Returns if this row needs an update. - * - * @return bool - * TRUE if the row needs updating, FALSE otherwise. - */ - public function needsUpdate() { - return $this->idMap['needs_update'] == MigrateIdMapInterface::STATUS_NEEDS_UPDATE; - } - - /** - * Returns the hash for the source values.. - * - * @return mixed - * The hash of the source values. - */ - public function getHash() { - return $this->idMap['hash']; - } - -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Source.php b/core/modules/migrate/lib/Drupal/migrate/Source.php deleted file mode 100644 index ebec104..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Source.php +++ /dev/null @@ -1,413 +0,0 @@ -currentIds; - } - - public function getIgnored() { - return $this->numIgnored; - } - - public function getProcessed() { - return $this->numProcessed; - } - - /** - * Reset numIgnored back to 0. - */ - public function resetStats() { - $this->numIgnored = 0; - } - - /** - * Return a count of available source records, from the cache if appropriate. - * Returns -1 if the source is not countable. - * - * @param boolean $refresh - * @return int - */ - public function count($refresh = FALSE) { - if ($this->skipCount) { - return -1; - } - $source = $this->migration->getSourcePlugin(); - - if (!isset($this->cacheKey)) { - $this->cacheKey = hash('sha256', (string) $source); - } - - // If a refresh is requested, or we're not caching counts, ask the derived - // class to get the count from the source. - if ($refresh || !$this->cacheCounts) { - $count = $source->count(); - $this->cache->set($this->cacheKey, $count, 'cache'); - } - else { - // Caching is in play, first try to retrieve a cached count. - $cache_object = $this->cache->get($this->cacheKey, 'cache'); - if (is_object($cache_object)) { - // Success - $count = $cache_object->data; - } - else { - // No cached count, ask the derived class to count 'em up, and cache - // the result - $count = $source->count(); - $this->cache->set($this->cacheKey, $count, 'cache'); - } - } - return $count; - } - - /** - * Class constructor. - * - * @param \Drupal\migrate\Entity\MigrationInterface $migration - * @param \Drupal\migrate\MigrateExecutable $migrate_executable - */ - function __construct(MigrationInterface $migration, MigrateExecutable $migrate_executable) { - $this->migration = $migration; - $this->migrateExecutable = $migrate_executable; - $configuration = $migration->get('source'); - if (!empty($configuration['cache_counts'])) { - $this->cacheCounts = TRUE; - } - if (!empty($configuration['skip_count'])) { - $this->skipCount = TRUE; - } - if (!empty($configuration['cache_key'])) { - $this->cacheKey = $configuration['cache_key']; - } - if (!empty($configuration['track_changes'])) { - $this->trackChanges = $configuration['track_changes']; - } - } - - /** - * @return \Drupal\Core\Cache\CacheBackendInterface - */ - protected function getCache() { - if (!isset($this->cache)) { - $this->cache = \Drupal::cache('migrate'); - } - return $this->cache; - } - - /** - * @return \Iterator - */ - protected function getIterator() { - if (!isset($this->iterator)) { - $this->iterator = $this->migration->getSourcePlugin()->getIterator(); - } - return $this->iterator; - } - - /** - * {@inheritdoc} - */ - public function current() { - return $this->currentRow; - } - - /** - * Implementation of Iterator::key - called when entering a loop iteration, returning - * the key of the current row. It must be a scalar - we will serialize - * to fulfill the requirement, but using getCurrentIds() is preferable. - */ - public function key() { - return serialize($this->currentIds); - } - - /** - * Implementation of Iterator::valid() - called at the top of the loop, returning - * TRUE to process the loop and FALSE to terminate it - */ - public function valid() { - return isset($this->currentRow); - } - - /** - * Implementation of Iterator::rewind() - subclasses of MigrateSource should - * implement performRewind() to do any class-specific setup for iterating - * source records. - */ - public function rewind() { - $this->idMap = $this->migration->getIdMap(); - $this->numProcessed = 0; - $this->numIgnored = 0; - $this->originalHighwater = $this->migration->getHighwater(); - $this->highwaterProperty = $this->migration->get('highwaterProperty'); - if ($id_list = $this->migration->get('idlist')) { - $this->idList = $id_list; - } - $this->getIterator()->rewind(); - $this->next(); - } - - /** - * {@inheritdoc} - */ - public function next() { - $this->currentIds = NULL; - $this->currentRow = NULL; - - while ($this->getIterator()->valid()) { - $row_data = $this->getIterator()->current(); - $this->getIterator()->next(); - $row = new Row($row_data, $this->migration->get('sourceIds'), $this->migration->get('destinationIds')); - - // Populate the source key for this row - $this->currentIds = $row->getSourceIdValues(); - - // Pick up the existing map row, if any, unless getNextRow() did it. - if (!$this->mapRowAdded && ($id_map = $this->idMap->getRowBySource($this->currentIds))) { - $row->setIdMap($id_map); - } - - // First, determine if this row should be passed to prepareRow(), or - // skipped entirely. The rules are: - // 1. If there's an explicit idlist, that's all we care about (ignore - // highwaters and map rows). - $prepared = FALSE; - if (!empty($this->idList)) { - if (in_array(reset($this->currentIds), $this->idList)) { - // In the list, fall through. - } - else { - // Not in the list, skip it - continue; - } - } - // 2. If the row is not in the map (we have never tried to import it - // before), we always want to try it. - elseif (!$row->getIdMap()) { - // Fall through - } - // 3. If the row is marked as needing update, pass it. - elseif ($row->needsUpdate()) { - // Fall through - } - // 4. At this point, we have a row which has previously been imported and - // not marked for update. If we're not using highwater marks, then we - // will not take this row. Except, if we're looking for changes in the - // data, we need to go through prepareRow() before we can decide to - // skip it. - elseif (!empty($highwater['field'])) { - if ($this->trackChanges) { - if ($this->prepareRow($row) !== FALSE) { - if ($row->changed()) { - // This is a keeper - $this->currentRow = $row; - break; - } - else { - // No change, skip it. - continue; - } - } - else { - // prepareRow() told us to skip it. - continue; - } - } - else { - // No highwater and not tracking changes, skip. - continue; - } - } - // 5. The initial highwater mark, before anything is migrated, is ''. We - // want to make sure we don't mistakenly skip rows with a highwater - // field value of 0, so explicitly handle '' here. - elseif ($this->originalHighwater === '') { - // Fall through - } - // 6. So, we are using highwater marks. Take the row if its highwater - // field value is greater than the saved mark, otherwise skip it. - else { - // Call prepareRow() here, in case the highwaterField needs preparation - if ($this->prepareRow($row) !== FALSE) { - if ($row->getSourceProperty($this->highwaterProperty['name']) > $this->originalHighwater) { - $this->currentRow = $row; - break; - } - else { - // Skip - continue; - } - } - $prepared = TRUE; - } - - // Allow the Migration to prepare this row. prepareRow() can return boolean - // FALSE to ignore this row. - if (!$prepared) { - if ($this->prepareRow($row) !== FALSE) { - // Finally, we've got a keeper. - $this->currentRow = $row; - break; - } - else { - $this->currentRow = NULL; - } - } - } - if ($this->currentRow) { - $this->currentRow->freezeSource(); - } - else { - $this->currentIds = NULL; - } - } - - /** - * Source classes should override this as necessary and manipulate $keep. - * - * @param \Drupal\migrate\Row $row - */ - protected function prepareRow(Row $row) { - // We're explicitly skipping this row - keep track in the map table - if ($this->migration->getSourcePlugin()->prepareRow($row) === FALSE) { - // Make sure we replace any previous messages for this item with any - // new ones. - $id_map = $this->migration->getIdMap(); - $id_map->delete($this->currentIds, TRUE); - $this->migrateExecutable->saveQueuedMessages(); - $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_IGNORED, $this->migrateExecutable->rollbackAction); - $this->numIgnored++; - $this->currentRow = NULL; - $this->currentIds = NULL; - } - else { - // When tracking changed data, We want to quietly skip (rather than - // "ignore") rows with changes. The caller needs to make that decision, - // so we need to provide them with the necessary information (before and - // after hashes). - if ($this->trackChanges) { - $row->rehash(); - } - } - $this->numProcessed++; - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemCron.php b/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemCron.php deleted file mode 100644 index 9171fff..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemCron.php +++ /dev/null @@ -1,59 +0,0 @@ -schema()->createTable('variable', array( - 'fields' => array( - 'name' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - ), - 'value' => array( - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - 'translatable' => TRUE, - ), - ), - 'primary key' => array( - 'name', - ), - 'module' => 'system', - 'name' => 'variable', - )); - $database->insert('variable')->fields(array( - 'name', - 'value', - )) - ->values(array( - 'name' => 'cron_threshold_warning', - 'value' => 'i:172800;', - )) - ->values(array( - 'name' => 'cron_threshold_error', - 'value' => 'i:1209600;', - )) - ->execute(); - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemRss.php b/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemRss.php deleted file mode 100644 index da4468f..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemRss.php +++ /dev/null @@ -1,55 +0,0 @@ -schema()->createTable('variable', array( - 'fields' => array( - 'name' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - ), - 'value' => array( - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - 'translatable' => TRUE, - ), - ), - 'primary key' => array( - 'name', - ), - 'module' => 'system', - 'name' => 'variable', - )); - $database->insert('variable')->fields(array( - 'name', - 'value', - )) - ->values(array( - 'name' => 'feed_default_items', - 'value' => 'i:10;', - )) - ->execute(); - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemSite.php b/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemSite.php deleted file mode 100644 index 69ef685..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Tests/Dump/Drupal6SystemSite.php +++ /dev/null @@ -1,75 +0,0 @@ -schema()->createTable('variable', array( - 'fields' => array( - 'name' => array( - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - ), - 'value' => array( - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - 'translatable' => TRUE, - ), - ), - 'primary key' => array( - 'name', - ), - 'module' => 'system', - 'name' => 'variable', - )); - $database->insert('variable')->fields(array( - 'name', - 'value', - )) - ->values(array( - 'name' => 'site_name', - 'value' => 's:6:"drupal";', - )) - ->values(array( - 'name' => 'site_mail', - 'value' => 's:17:"admin@example.com";', - )) - ->values(array( - 'name' => 'site_slogan', - 'value' => 's:13:"Migrate rocks";', - )) - ->values(array( - 'name' => 'site_frontpage', - 'value' => 's:12:"anonymous-hp";', - )) - ->values(array( - 'name' => 'site_403', - 'value' => 's:4:"user";', - )) - ->values(array( - 'name' => 'site_404', - 'value' => 's:14:"page-not-found";', - )) - ->values(array( - 'name' => 'drupal_weight_select_max', - 'value' => 'i:99;', - )) - ->values(array( - 'name' => 'admin_compact_mode', - 'value' => 'b:0;', - )) - ->execute(); - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Tests/MigrateSystemConfigsTest.php b/core/modules/migrate/lib/Drupal/migrate/Tests/MigrateSystemConfigsTest.php deleted file mode 100644 index 09529c1..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Tests/MigrateSystemConfigsTest.php +++ /dev/null @@ -1,75 +0,0 @@ - 'Migrate variables to system.*.yml', - 'description' => 'Upgrade variables to system.*.yml', - 'group' => 'Migrate', - ); - } - - function testSystemSite() { - $migration = entity_load('migration', 'd6_system_site'); - $dumps = array( - drupal_get_path('module', 'migrate') . '/lib/Drupal/migrate/Tests/Dump/Drupal6SystemSite.php', - ); - $this->prepare($migration, $dumps); - $executable = new MigrateExecutable($migration, new MigrateMessage); - $executable->import(); - $config = \Drupal::config('system.site'); - $this->assertIdentical($config->get('name'), 'drupal'); - $this->assertIdentical($config->get('mail'), 'admin@example.com'); - $this->assertIdentical($config->get('slogan'), 'Migrate rocks'); - $this->assertIdentical($config->get('page.front'), 'anonymous-hp'); - $this->assertIdentical($config->get('page.403'), 'user'); - $this->assertIdentical($config->get('page.404'), 'page-not-found'); - $this->assertIdentical($config->get('weight_select_max'), 99); - $this->assertIdentical($config->get('admin_compact_mode'), FALSE); - } - - /** - * Tests migration of system (cron) variables to system.cron.yml. - */ - public function testSystemCron() { - $migration = entity_load('migration', 'd6_system_cron'); - $dumps = array( - drupal_get_path('module', 'migrate') . '/lib/Drupal/migrate/Tests/Dump/Drupal6SystemCron.php', - ); - $this->prepare($migration, $dumps); - $executable = new MigrateExecutable($migration, new MigrateMessage()); - $executable->import(); - $config = \Drupal::config('system.cron'); - $this->assertIdentical($config->get('threshold.warning'), 172800); - $this->assertIdentical($config->get('threshold.error'), 1209600); - } - - /** - * Tests migration of system (rss) variables to system.rss.yml. - */ - public function testSystemRss() { - $migration = entity_load('migration', 'd6_system_rss'); - $dumps = array( - drupal_get_path('module', 'migrate') . '/lib/Drupal/migrate/Tests/Dump/Drupal6SystemRss.php', - ); - $this->prepare($migration, $dumps); - $executable = new MigrateExecutable($migration, new MigrateMessage()); - $executable->import(); - $config = \Drupal::config('system.rss'); - $this->assertIdentical($config->get('items.limit'), 10); - } -} diff --git a/core/modules/migrate/lib/Drupal/migrate/Tests/MigrateTestBase.php b/core/modules/migrate/lib/Drupal/migrate/Tests/MigrateTestBase.php deleted file mode 100644 index 5b67e5a..0000000 --- a/core/modules/migrate/lib/Drupal/migrate/Tests/MigrateTestBase.php +++ /dev/null @@ -1,60 +0,0 @@ - $value) { - $connection_info[$target]['prefix'] = array( - 'default' => $value['prefix']['default'] . $databasePrefix, - ); - } - $database = SqlBase::getDatabaseConnection($migration->id(), array('database' => $connection_info['default'])); - foreach (array('source', 'destination', 'idMap') as $key) { - $configuration = $migration->get($key); - $configuration['database'] = $database; - $migration->set($key, $configuration); - } - - // Load the database from the portable PHP dump. - // The files may be gzipped. - foreach ($files as $file) { - if (substr($file, -3) == '.gz') { - $file = "compress.zlib://$file"; - require $file; - } - preg_match('/^namespace (.*);$/m', file_get_contents($file), $matches); - $class = $matches[1] . '\\' . basename($file, '.php'); - $class::load($database); - } - return $database; - } -} diff --git a/core/modules/migrate/migrate.api.php b/core/modules/migrate/migrate.api.php deleted file mode 100644 index a2d2cb5..0000000 --- a/core/modules/migrate/migrate.api.php +++ /dev/null @@ -1,37 +0,0 @@ -id() == 'drupal6_filter_formats') { - $value = $source->getDatabase()->query('SELECT value FROM {variable} WHERE name = :name', array(':name' => 'mymodule_filter_foo_' . $row->getSourceProperty('format')))->fetchField(); - if ($value) { - $row->setSourceProperty('settings:mymodule:foo', unserialize($value)); - } - } -} - -/** - * @} End of "addtogroup hooks". - */ diff --git a/core/modules/migrate/migrate.info.yml b/core/modules/migrate/migrate.info.yml deleted file mode 100644 index 460f66b..0000000 --- a/core/modules/migrate/migrate.info.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: Migrate -type: module -description: 'Handles migrations' -package: Core -version: VERSION -core: 8.x -;configure: admin/structure/migrate diff --git a/core/modules/migrate/migrate.module b/core/modules/migrate/migrate.module deleted file mode 100644 index e69de29..0000000 diff --git a/core/modules/migrate/migrate.services.yml b/core/modules/migrate/migrate.services.yml deleted file mode 100644 index 28848df..0000000 --- a/core/modules/migrate/migrate.services.yml +++ /dev/null @@ -1,23 +0,0 @@ -services: - cache.migrate: - class: Drupal\Core\Cache\CacheBackendInterface - tags: - - { name: cache.bin } - factory_method: get - factory_service: cache_factory - arguments: [migrate] - plugin.manager.migrate.source: - class: Drupal\migrate\Plugin\MigratePluginManager - arguments: [source, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] - plugin.manager.migrate.process: - class: Drupal\migrate\Plugin\MigratePluginManager - arguments: [process, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] - plugin.manager.migrate.destination: - class: Drupal\migrate\Plugin\MigratePluginManager - arguments: [destination, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] - plugin.manager.migrate.id_map: - class: Drupal\migrate\Plugin\MigratePluginManager - arguments: [id_map, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] - plugin.manager.migrate.entity_field: - class: Drupal\migrate\Plugin\MigratePluginManager - arguments: [entity_field, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/ConditionResolver.php b/core/modules/migrate/tests/Drupal/migrate/Tests/ConditionResolver.php deleted file mode 100644 index 875f13e..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/ConditionResolver.php +++ /dev/null @@ -1,93 +0,0 @@ -conditions(); - $and = $conditions['#conjunction'] == 'AND'; - unset($conditions['#conjunction']); - $match = TRUE; - foreach ($conditions as $condition) { - $match = $condition['field'] instanceof Condition ? static::matchGroup($row, $condition['field']) : static::matchSingle($row, $condition); - // For AND, finish matching on the first fail. For OR, finish on first - // success. - if ($and != $match) { - break; - } - } - return $match; - } - - /** - * Match a single row and its condition. - * - * @param \Drupal\migrate\tests\DatabaseRowInterface $row - * The row to match. - * - * @param array $condition - * An array representing a single condition. - * - * @return bool - * TRUE if the condition matches. - * - * @throws \Exception - * - */ - protected static function matchSingle(DatabaseRowInterface $row, array $condition) { - $row_value = $row->getValue($condition['field']); - switch ($condition['operator']) { - case '=': - return $row_value == $condition['value']; - - case '<=': - return $row_value <= $condition['value']; - - case '>=': - return $row_value >= $condition['value']; - - case '!=': - return $row_value != $condition['value']; - - case '<>': - return $row_value != $condition['value']; - - case '<': - return $row_value < $condition['value']; - - case '>': - return $row_value > $condition['value']; - - case 'IN': - return in_array($row_value, $condition['value']); - - case 'IS NULL': - return !isset($row_value); - - case 'IS NOT NULL': - return isset($row_value); - - default: - throw new \Exception(sprintf('operator %s is not supported', $condition['operator'])); - } - } - -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/D6VariableTest.php b/core/modules/migrate/tests/Drupal/migrate/Tests/D6VariableTest.php deleted file mode 100644 index cc903bf..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/D6VariableTest.php +++ /dev/null @@ -1,75 +0,0 @@ - 'test', - 'highwaterProperty' => array('field' => 'test'), - 'idlist' => array(), - 'source' => array( - 'plugin' => 'drupal6_variable', - 'variables' => array( - 'foo', - 'bar', - ), - ), - 'sourceIds' => array(), - 'destinationIds' => array(), - ); - - protected $mapJoinable = FALSE; - - protected $expectedResults = array( - array( - 'foo' => 1, - 'bar' => FALSE, - ), - ); - - protected $databaseContents = array( - 'variable' => array( - array('name' => 'foo', 'value' => 'i:1;'), - array('name' => 'bar', 'value' => 'b:0;'), - ), - ); - - /** - * {@inheritdoc} - */ - public static function getInfo() { - return array( - 'name' => 'D6 variable source functionality', - 'description' => 'Tests D6 variable source plugin.', - 'group' => 'Migrate', - ); - } - -} - -namespace Drupal\migrate\Tests\source; - -use Drupal\Core\Database\Connection; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\migrate\Plugin\migrate\source\D6Variable; - -class TestD6Variable extends D6Variable { - function setDatabase(Connection $database) { - $this->database = $database; - } - function setModuleHandler(ModuleHandlerInterface $module_handler) { - $this->moduleHandler = $module_handler; - } -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/DatabaseRow.php b/core/modules/migrate/tests/Drupal/migrate/Tests/DatabaseRow.php deleted file mode 100644 index 1c8cf76..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/DatabaseRow.php +++ /dev/null @@ -1,19 +0,0 @@ -row = $row; - } - - public function getValue($field) { - return $this->row[$field]; - } -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/DatabaseRowInterface.php b/core/modules/migrate/tests/Drupal/migrate/Tests/DatabaseRowInterface.php deleted file mode 100644 index cddfa8b..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/DatabaseRowInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -fieldsWithTable = $fieldsWithTable; - $this->fields = $fields; - parent::__construct($row); - } - - public function getValue($field) { - $field_info = isset($this->fieldsWithTable[$field]) ? $this->fieldsWithTable[$field] : $this->fields[$field]; - if (array_key_exists($field_info['field'], $this->row[$field_info['table']]['result'])) { - $index = 'result'; - } - else { - $index = 'all'; - } - return $this->row[$field_info['table']][$index][$field_info['field']]; - } -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/FakeDatabaseSchema.php b/core/modules/migrate/tests/Drupal/migrate/Tests/FakeDatabaseSchema.php deleted file mode 100644 index 1433f18..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/FakeDatabaseSchema.php +++ /dev/null @@ -1,149 +0,0 @@ -uniqueIdentifier = uniqid('', TRUE); - // @todo Maybe we can generate an internal representation. - $this->databaseContents = $database_contents; - } - - public function tableExists($table) { - return in_array($table, array_keys($this->databaseContents)); - } - - public function prefixNonTable($table) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function addField($table, $field, $spec, $keys_new = array()) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function addIndex($table, $name, $fields) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function addPrimaryKey($table, $fields) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function addUniqueKey($table, $name, $fields) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function changeField($table, $field, $field_new, $spec, $keys_new = array()) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function __clone() { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function copyTable($source, $destination) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function createTable($name, $table) { - #throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function dropField($table, $field) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function dropIndex($table, $name) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function dropPrimaryKey($table) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function dropTable($table) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function dropUniqueKey($table, $name) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function fieldExists($table, $column) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function fieldNames($fields) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function fieldSetDefault($table, $field, $default) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function fieldSetNoDefault($table, $field) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function findTables($table_expression) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function getFieldTypeMap() { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function indexExists($table, $name) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function nextPlaceholder() { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function prepareComment($comment, $length = NULL) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function renameTable($table, $new_name) { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - public function uniqueIdentifier() { - throw new \Exception(sprintf('Unsupported method "%s"', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public static function getInfo() { - return array( - 'name' => 'Fake database schema', - 'description' => 'Tests for fake database schema plugin.', - 'group' => 'Migrate', - ); - } - -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/FakeSelect.php b/core/modules/migrate/tests/Drupal/migrate/Tests/FakeSelect.php deleted file mode 100644 index 9b79234..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/FakeSelect.php +++ /dev/null @@ -1,511 +0,0 @@ - array( - * array( - * 'uid' => 1, - * 'name' => 'admin', - * ), - * array( - * 'uid' => 2, - * 'name' => 'alice', - * ), - * ), - * 'node' => array( - * array( - * 'nid' => 1, - * ) - * ) - * ) - * @endcode - * - * @var array - */ - protected $databaseContents; - - protected $countQuery = FALSE; - protected $fieldsWithTable = array(); - - /** - * Constructs a new FakeSelect. - * - * @param string $table - * The base table name used within fake select. - * - * @param string $alias - * The base table alias used within fake select. - * - * @param array $database_contents - * An array of mocked database content. - * - * @param string $conjunction - * The operator to use to combine conditions: 'AND' or 'OR'. - */ - public function __construct($table, $alias, array $database_contents, $conjunction = 'AND') { - $this->addJoin(NULL, $table, $alias); - $this->where = new Condition($conjunction); - $this->having = new Condition($conjunction); - $this->databaseContents = $database_contents; - } - - /** - * {@inheritdoc} - */ - public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { - return $this->addJoin('LEFT', $table, $alias, $condition, $arguments); - } - - /** - * {@inheritdoc} - */ - public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) { - if ($table instanceof SelectInterface) { - // @todo implement this. - throw new \Exception('Subqueries are not supported at this moment.'); - } - $alias = parent::addJoin($type, $table, $alias, $condition, $arguments); - if (isset($type)) { - if ($type != 'INNER' && $type != 'LEFT') { - throw new \Exception(sprintf('%s type not supported, only INNER and LEFT.', $type)); - } - if (!preg_match('/(\w+)\.(\w+)\s*=\s*(\w+)\.(\w+)/', $condition, $matches)) { - throw new \Exception('Only x.field1 = y.field2 conditions are supported.' . $condition); - } - if ($matches[1] == $alias) { - $this->tables[$alias] += array( - 'added_field' => $matches[2], - 'original_table_alias' => $matches[3], - 'original_field' => $matches[4], - ); - } - elseif ($matches[3] == $alias) { - $this->tables[$alias] += array( - 'added_field' => $matches[4], - 'original_table_alias' => $matches[1], - 'original_field' => $matches[2], - ); - } - else { - throw new \Exception('The JOIN condition does not contain the alias of the joined table.'); - } - } - return $alias; - } - - /** - * {@inheritdoc} - */ - public function execute() { - // @todo: Implement distinct() handling. - - // Single table count queries often do not contain fields which this class - // does not support otherwise, so add a shortcut. - if (count($this->tables) == 1 && $this->countQuery) { - $table_info = reset($this->tables); - $where = $this->where; - if (!empty($this->databaseContents[$table_info['table']])) { - $results = array_filter($this->databaseContents[$table_info['table']], function ($row_array) use ($where) { - return ConditionResolver::matchGroup(new DatabaseRow($row_array), $where); - }); - } - else { - $results = array(); - } - } - else { - $all_rows = $this->executeJoins(); - $all_rows = $this->resolveConditions($this->where, $all_rows); - if (!empty($this->order)) { - usort($all_rows, array($this, 'sortCallback')); - } - // Now flatten the rows so that each row becomes a field alias => value - // array. - $results = array(); - foreach ($all_rows as $table_rows) { - $result_row = array(); - foreach ($table_rows as $row) { - $result_row += $row['result']; - } - $results[] = $result_row; - } - } - if (!empty($this->range)) { - $results = array_slice($results, $this->range['start'], $this->range['length']); - } - if ($this->countQuery) { - $results = array(array(count($results))); - } - return new FakeStatement($results); - } - - /** - * Create an initial result set by executing the joins and picking fields. - * - * @return array - * A multidimensional array, the first key are table aliases, the second - * are field aliases, the values are the database contents or NULL in case - * of JOINs. - */ - protected function executeJoins() { - // @TODO add support for all_fields. - $fields = array(); - foreach ($this->fields as $field_info) { - $this->fieldsWithTable[$field_info['table'] . '.' . $field_info['field']] = $field_info; - $fields[$field_info['table']][$field_info['field']] = NULL; - } - foreach ($this->tables as $alias => $table_info) { - if ($table = reset($this->databaseContents[$table_info['table']])) { - foreach (array_keys($table) as $field) { - if (!isset($this->fields[$field])) { - $this->fieldsWithTable[$field] = array( - 'table' => $alias, - 'field' => $field, - ); - } - } - } - } - // This will contain a multiple dimensional array. The first key will be a - // table alias, the second either result or all, the third will be a field - // alias. all contains every field in the table with the original field - // names while result contains only the fields requested. This allows for - // filtering on fields that were not added via addField(). - $results = array(); - foreach ($this->tables as $table_alias => $table_info) { - // The base table for this query. - if (empty($table_info['join type'])) { - foreach ($this->databaseContents[$table_info['table']] as $candidate_row) { - $results[] = $this->getNewRow($table_alias, $fields, $candidate_row); - } - } - else { - $new_rows = array(); - - // Dynamically build a set of joined rows. Check existing rows and see - // if they can be joined with incoming rows. - foreach ($results as $row) { - $joined = FALSE; - foreach ($this->databaseContents[$table_info['table']] as $candidate_row) { - if ($row[$table_info['original_table_alias']]['result'][$table_info['original_field']] == $candidate_row[$table_info['added_field']]) { - $joined = TRUE; - $new_rows[] = $this->getNewRow($table_alias, $fields, $candidate_row, $row); - } - } - if (!$joined && $table_info['join type'] == 'LEFT') { - // Because PHP doesn't scope their foreach statements, - // $candidate_row may contain the last value assigned to it from the - // previous statement. - // @TODO: empty tables? Those are a problem. - $keys = array_keys($candidate_row); - $values = array_fill(0, count($keys), NULL); - $new_row = array( - 'result' => $fields[$table_alias], - 'all' => array_combine($keys, $values), - ); - $new_rows[] = array($table_alias => $new_row) + $row; - } - } - $results = $new_rows; - } - } - return $results; - } - - /** - * Retrieves a new row. - * - * @param string $table_alias - * @param array $fields - * @param array $candidate_row - * @param array $row - * - * @return array - */ - protected function getNewRow($table_alias, $fields, $candidate_row, $row = array()) { - $new_row[$table_alias]['all'] = $candidate_row; - foreach ($fields[$table_alias] as $field => $v) { - $new_row[$table_alias]['result'][$field] = $candidate_row[$field]; - } - return $new_row + $row; - } - - /** - * {@inheritdoc} - */ - public function countQuery() { - $query = clone $this; - return $query->setCountQuery(); - } - - /** - * Set this query to be a count query. - */ - protected function setCountQuery() { - $this->countQuery = TRUE; - return $this; - } - - /** - * usort callback to order the results. - */ - protected function sortCallback($a, $b) { - $a_row = new DatabaseRowSelect($a, $this->fieldsWithTable, $this->fields); - $b_row = new DatabaseRowSelect($b, $this->fieldsWithTable, $this->fields); - foreach ($this->order as $field => $direction) { - $a_value = $a_row->getValue($field); - $b_value = $b_row->getValue($field); - if ($a_value != $b_value) { - return (($a_value < $b_value) == ($direction == 'ASC')) ? -1 : 1; - } - } - return 0; - } - - /** - * Resolves conditions by removing non-matching rows. - * - * @param \Drupal\Core\Database\Query\Condition $condition_group - * The condition group to check. - * @param array $rows - * An array of rows excluding non-matching rows. - */ - protected function resolveConditions(Condition $condition_group, array &$rows) { - $fields_with_table = $this->fieldsWithTable; - $fields = $this->fields; - return array_filter($rows, function ($row_array) use ($condition_group, $fields_with_table, $fields) { - $row = new DatabaseRowSelect($row_array, $fields_with_table, $fields); - return ConditionResolver::matchGroup($row, $condition_group); - }); - } - - /** - * {@inheritdoc} - */ - public function orderBy($field, $direction = 'ASC') { - $this->order[$field] = strtoupper($direction); - return $this; - } - - // ================== we could support these. - /** - * {@inheritdoc} - */ - public function groupBy($field) { - // @todo: Implement groupBy() method. - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function havingCondition($field, $value = NULL, $operator = NULL) { - // @todo: Implement havingCondition() method. - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function uniqueIdentifier() { - // TODO: Implement uniqueIdentifier() method. - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - // ================== the rest won't be supported, ever. - /** - * {@inheritdoc} - */ - public function nextPlaceholder() { - // TODO: Implement nextPlaceholder() method. - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function isPrepared() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function preExecute(SelectInterface $query = NULL) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function where($snippet, $args = array()) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function extend($extender_name) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function &getExpressions() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function &getGroupBy() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function &getUnion() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function forUpdate($set = TRUE) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function &conditions() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function orderRandom() { - // We could implement this but why bother. - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function union(SelectInterface $query, $type = '') { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function addExpression($expression, $alias = NULL, $arguments = array()) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function &getTables() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function getArguments(PlaceholderInterface $query_place_holder = NULL) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function &getOrderBy() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function &getFields() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function exists(SelectInterface $select) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function notExists(SelectInterface $select) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function arguments() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function compile(Connection $connection, PlaceholderInterface $query_place_holder) { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public function compiled() { - throw new \Exception(sprintf('Method "%s" is not supported', __METHOD__)); - } - - /** - * {@inheritdoc} - */ - public static function getInfo() { - return array( - 'name' => 'Fake select test', - 'description' => 'Tests for fake select plugin.', - 'group' => 'Migrate', - ); - } - -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/FakeStatement.php b/core/modules/migrate/tests/Drupal/migrate/Tests/FakeStatement.php deleted file mode 100644 index 9088c50..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/FakeStatement.php +++ /dev/null @@ -1,103 +0,0 @@ -count(); - } - - /** - * {@inheritdoc} - */ - public function fetchField($index = 0) { - $row = array_values($this->current()); - $return = $row[$index]; - $this->next(); - return $return; - } - - /** - * {@inheritdoc} - */ - public function fetchAssoc() { - $return = $this->current(); - $this->next(); - return $return; - } - - /** - * {@inheritdoc} - */ - public function fetchCol($index = 0) { - $return = array(); - foreach ($this as $row) { - $row = array_values($row); - $return[] = $row[$index]; - } - return $return; - } - - /** - * {@inheritdoc} - */ - public function fetchAllKeyed($key_index = 0, $value_index = 1) { - $return = array(); - foreach ($this as $row) { - $row = array_values($row); - $return[$row[$key_index]] = $row[$value_index]; - } - return $return; - } - - /** - * {@inheritdoc} - */ - public function fetchAllAssoc($key, $fetch = NULL) { - $return = array(); - foreach ($this as $row) { - $return[$row[$key]] = $row; - } - return $return; - } - - /** - * {@inheritdoc} - */ - public static function getInfo() { - return array( - 'name' => 'Fake statement test', - 'description' => 'Tests for fake statement plugin.', - 'group' => 'Migrate', - ); - } - -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateExecutableTest.php b/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateExecutableTest.php deleted file mode 100644 index 295ed6d..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateExecutableTest.php +++ /dev/null @@ -1,104 +0,0 @@ - 'Migrate executable', - 'description' => 'Tests the migrate executable.', - 'group' => 'Migrate', - ); - } - - protected function setUp() { - $this->migration = $this->getMock('Drupal\migrate\Entity\MigrationInterface'); - $this->message = $this->getMock('Drupal\migrate\MigrateMessageInterface'); - $id_map = $this->getMock('Drupal\migrate\Plugin\MigrateIdMapInterface'); - - $this->migration->expects($this->any()) - ->method('getIdMap') - ->will($this->returnValue($id_map)); - - $this->executable = new TestMigrateExecutable($this->migration, $this->message); - $this->executable->setTranslationManager($this->getStringTranslationStub()); - } - - /** - * Tests an import with an incomplete rewinding. - */ - public function testImportWithFailingRewind() { - $iterator = $this->getMock('\Iterator'); - $iterator->expects($this->once()) - ->method('valid') - ->will($this->returnCallback(function() { - throw new \Exception('invalid source iteration'); - })); - $source = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface'); - $source->expects($this->any()) - ->method('getIterator') - ->will($this->returnValue($iterator)); - - $this->migration->expects($this->any()) - ->method('getSourcePlugin') - ->will($this->returnValue($source)); - - // Ensure that a message with the proper message was added. - $this->message->expects($this->once()) - ->method('display') - ->with('Migration failed with source plugin exception: invalid source iteration'); - - $result = $this->executable->import(); - $this->assertEquals(MigrationInterface::RESULT_FAILED, $result); - } - -} - -class TestMigrateExecutable extends MigrateExecutable { - - public function setTranslationManager(TranslationInterface $translation_manager) { - $this->translationManager = $translation_manager; - } -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateSqlSourceTestCase.php b/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateSqlSourceTestCase.php deleted file mode 100644 index 1456977..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateSqlSourceTestCase.php +++ /dev/null @@ -1,88 +0,0 @@ -getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface') - ->disableOriginalConstructor() - ->getMock(); - - $migration = $this->getMigration(); - $migration->expects($this->any()) - ->method('getHighwater') - ->will($this->returnValue(static::ORIGINAL_HIGHWATER)); - // Need the test class, not the original because we need a setDatabase method. This is not pretty :/ - $plugin_class = preg_replace('/^(Drupal\\\\\w+\\\\)Plugin\\\\migrate(\\\\source(\\\\.+)?\\\\)([^\\\\]+)$/', '\1Tests\2Test\4', static::PLUGIN_CLASS); - $plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], array(), $migration); - $plugin->setDatabase($this->getDatabase($this->databaseContents + array('test_map' => array()))); - $plugin->setModuleHandler($module_handler); - $migration->expects($this->any()) - ->method('getSourcePlugin') - ->will($this->returnValue($plugin)); - $migrateExecutable = $this->getMockBuilder('Drupal\migrate\MigrateExecutable') - ->disableOriginalConstructor() - ->getMock(); - $this->source = new TestSource($migration, $migrateExecutable); - - $cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); - $this->source->setCache($cache); - } - - public function testRetrieval() { - $this->queryResultTest($this->source, $this->expectedResults); - } - - /** - * @param \Drupal\migrate\Row $row - * @param string $key - * @return mixed - */ - protected function getValue($row, $key) { - return $row->getSourceProperty($key); - } - - /** - * {@inheritdoc} - */ - public static function getInfo() { - return array( - 'name' => 'SQL source test', - 'description' => 'Tests for SQL source plugin.', - 'group' => 'Migrate', - ); - } - -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateTestCase.php b/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateTestCase.php deleted file mode 100644 index 7ca0ae6..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/MigrateTestCase.php +++ /dev/null @@ -1,141 +0,0 @@ -getMock('Drupal\migrate\Plugin\MigrateIdMapInterface'); - if ($this->mapJoinable) { - $idmap->expects($this->once()) - ->method('getQualifiedMapTable') - ->will($this->returnValue('test_map')); - } - - $migration = $this->getMock('Drupal\migrate\Entity\MigrationInterface'); - $migration->expects($this->any()) - ->method('getIdMap') - ->will($this->returnValue($idmap)); - $configuration = $this->migrationConfiguration; - $migration->expects($this->any())->method('get')->will($this->returnCallback(function ($argument) use ($configuration) { - return isset($configuration[$argument]) ? $configuration[$argument] : ''; - })); - $migration->expects($this->any()) - ->method('id') - ->will($this->returnValue($configuration['id'])); - return $migration; - } - - /** - * @return \Drupal\Core\Database\Connection - */ - protected function getDatabase($database_contents) { - $database = $this->getMockBuilder('Drupal\Core\Database\Connection') - ->disableOriginalConstructor() - ->getMock(); - $database->databaseContents = &$database_contents; - $database->expects($this->any()) - ->method('select')->will($this->returnCallback(function ($base_table, $base_alias) use ($database_contents) { - return new FakeSelect($base_table, $base_alias, $database_contents); - })); - $database->expects($this->any()) - ->method('schema') - ->will($this->returnCallback(function () use (&$database_contents) { - return new FakeDatabaseSchema($database_contents); - })); - $database->expects($this->any()) - ->method('insert') - ->will($this->returnCallback(function ($table) use (&$database_contents) { - return new FakeInsert($database_contents, $table); - })); - $database->expects($this->any()) - ->method('update') - ->will($this->returnCallback(function ($table) use (&$database_contents) { - return new FakeUpdate($database_contents, $table); - })); - $database->expects($this->any()) - ->method('merge') - ->will($this->returnCallback(function ($table) use (&$database_contents) { - return new FakeMerge($database_contents, $table); - })); - $database->expects($this->any()) - ->method('query') - ->will($this->throwException(new \Exception('Query is not supported'))); - return $database; - } - - /** - * Tests a query - * - * @param array|\Traversable - * The countable. foreach-able actual results if a query is being run. - */ - public function queryResultTest($iter, $expected_results) { - $this->assertSame(count($expected_results), count($iter), 'Number of results match'); - $count = 0; - foreach ($iter as $data_row) { - $expected_row = $expected_results[$count]; - $count++; - foreach ($expected_row as $key => $expected_value) { - $this->retrievalAssertHelper($expected_value, $this->getValue($data_row, $key), sprintf('Value matches for key "%s"', $key)); - } - } - $this->assertSame(count($expected_results), $count); - } - - /** - * @param array $row - * @param string $key - * @return mixed - */ - protected function getValue($row, $key) { - return $row[$key]; - } - - /** - * Asserts tested values during test retrieval. - * - * @param mixed $expected_value - * The incoming expected value to test. - * @param mixed $actual_value - * The incoming value itself. - * @param string $message - * The tested result as a formatted string. - */ - protected function retrievalAssertHelper($expected_value, $actual_value, $message) { - if (is_array($expected_value)) { - foreach ($expected_value as $k => $v) { - $this->retrievalAssertHelper($v, $actual_value[$k], $message . '['. $k . ']'); - } - } - else { - $this->assertSame((string) $expected_value, (string) $actual_value, $message); - } - } - -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/TestSource.php b/core/modules/migrate/tests/Drupal/migrate/Tests/TestSource.php deleted file mode 100644 index 99988d6..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/TestSource.php +++ /dev/null @@ -1,18 +0,0 @@ -cache = $cache; - } -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/process/GetTest.php b/core/modules/migrate/tests/Drupal/migrate/Tests/process/GetTest.php deleted file mode 100644 index e49e1f2..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/process/GetTest.php +++ /dev/null @@ -1,90 +0,0 @@ - 'Get process plugin', - 'description' => 'Tests the get process plugin.', - 'group' => 'Migrate', - ); - } - - function setUp() { - $this->plugin = new TestGet(); - parent::setUp(); - } - - function testTransformSourceString() { - $this->row->expects($this->once()) - ->method('getSourceProperty') - ->with('test') - ->will($this->returnValue('source_value')); - $this->plugin->setSource('test'); - $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty'); - $this->assertSame($value, 'source_value'); - } - - function testTransformSourceArray() { - $map = array( - 'test1' => 'source_value1', - 'test2' => 'source_value2', - ); - $this->plugin->setSource(array('test1', 'test2')); - $this->row->expects($this->exactly(2)) - ->method('getSourceProperty') - ->will($this->returnCallback(function ($argument) use ($map) { return $map[$argument]; } )); - $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty'); - $this->assertSame($value, array('source_value1', 'source_value2')); - } - - function testTransformSourceStringAt() { - $this->row->expects($this->once()) - ->method('getSourceProperty') - ->with('@test') - ->will($this->returnValue('source_value')); - $this->plugin->setSource('@@test'); - $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty'); - $this->assertSame($value, 'source_value'); - } - - function testTransformSourceArrayAt() { - $map = array( - 'test1' => 'source_value1', - '@test2' => 'source_value2', - '@test3' => 'source_value3', - 'test4' => 'source_value4', - ); - $this->plugin->setSource(array('test1', '@@test2', '@@test3', 'test4')); - $this->row->expects($this->exactly(4)) - ->method('getSourceProperty') - ->will($this->returnCallback(function ($argument) use ($map) { return $map[$argument]; } )); - $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty'); - $this->assertSame($value, array('source_value1', 'source_value2', 'source_value3', 'source_value4')); - } -} - -namespace Drupal\migrate\Plugin\migrate\process; - -class TestGet extends Get { - function __construct() { - } - function setSource($source) { - $this->configuration['source'] = $source; - } -} diff --git a/core/modules/migrate/tests/Drupal/migrate/Tests/process/MigrateProcessTestCase.php b/core/modules/migrate/tests/Drupal/migrate/Tests/process/MigrateProcessTestCase.php deleted file mode 100644 index d99a865..0000000 --- a/core/modules/migrate/tests/Drupal/migrate/Tests/process/MigrateProcessTestCase.php +++ /dev/null @@ -1,39 +0,0 @@ -row = $this->getMockBuilder('Drupal\migrate\Row') - ->disableOriginalConstructor() - ->getMock(); - $this->migrateExecutable = $this->getMockBuilder('Drupal\migrate\MigrateExecutable') - ->disableOriginalConstructor() - ->getMock(); - parent::setUp(); - } - -} diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 0dbd1ac..da32b99 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -14,7 +14,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Language\Language; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Session\AccountInterface; @@ -68,7 +68,7 @@ class NodeSearch extends SearchPluginBase implements AccessibleInterface, Search /** * The Drupal state object used to set 'node.cron_last'. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -111,7 +111,7 @@ static public function create(ContainerInterface $container, array $configuratio $container->get('plugin.manager.entity'), $container->get('module_handler'), $container->get('config.factory')->get('search.settings'), - $container->get('keyvalue')->get('state'), + $container->get('state'), $container->get('current_user') ); } @@ -133,12 +133,12 @@ static public function create(ContainerInterface $container, array $configuratio * A module manager object. * @param \Drupal\Core\Config\Config $search_settings * A config object for 'search.settings'. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The Drupal state object used to set 'node.cron_last'. * @param \Drupal\Core\Session\AccountInterface $account * The $account object to use for checking for access to advanced search. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, Connection $database, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, KeyValueStoreInterface $state, AccountInterface $account = NULL) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, Connection $database, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, StateInterface $state, AccountInterface $account = NULL) { $this->database = $database; $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php index 66ea769..f07f3e1 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php @@ -55,6 +55,7 @@ function testNodeTypeCustomizationPersistence() { $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall')); $this->drupalPostForm(NULL, array(), t('Uninstall')); $forum = entity_load('node_type', 'forum'); + \Drupal::state()->resetCache(); $this->assertFalse($forum->isLocked(), 'Forum node type is not locked'); $this->drupalGet('node/add'); $this->assertNoText('forum', 'forum type is no longer found on node/add'); diff --git a/core/modules/node/node.views.inc b/core/modules/node/node.views.inc index cdeb8a0..6c82604 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for node.module. + * Provide views data and handlers for node.module. + * + * @ingroup views_module_handlers */ use Drupal\views\Analyzer; diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php index 19bc077..cef8953 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php @@ -8,7 +8,7 @@ namespace Drupal\rest\Plugin\views\display; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\views\Annotation\ViewsDisplay; use Drupal\Core\Annotation\Translation; @@ -99,14 +99,14 @@ class RestExport extends PathPluginBase { * The plugin implementation definition. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. * @param \Drupal\Core\ContentNegotiation $content_negotiation * The content negotiation library. * @param \Symfony\Component\HttpFoundation\Request $request * The request object. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, RouteProviderInterface $route_provider, KeyValueStoreInterface $state, ContentNegotiation $content_negotiation, Request $request) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, RouteProviderInterface $route_provider, StateInterface $state, ContentNegotiation $content_negotiation, Request $request) { parent::__construct($configuration, $plugin_id, $plugin_definition, $route_provider, $state); $this->contentNegotiation = $content_negotiation; $this->request = $request; diff --git a/core/modules/rest/tests/Drupal/rest/Tests/CollectRoutesTest.php b/core/modules/rest/tests/Drupal/rest/Tests/CollectRoutesTest.php index ae4bb43..05c6d5d 100644 --- a/core/modules/rest/tests/Drupal/rest/Tests/CollectRoutesTest.php +++ b/core/modules/rest/tests/Drupal/rest/Tests/CollectRoutesTest.php @@ -82,7 +82,7 @@ protected function setUp() { ->getMock(); $container->set('router.route_provider', $route_provider); - $state = $this->getMock('\Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $state = $this->getMock('\Drupal\Core\KeyValueStore\StateInterface'); $container->set('state', $state); $style_manager = $this->getMockBuilder('\Drupal\views\Plugin\ViewsPluginManager') diff --git a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php index 0bf795a..5e280ee 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\search\SearchPluginManager; use Drupal\Core\Form\ConfigFormBase; @@ -44,7 +44,7 @@ class SearchSettingsForm extends ConfigFormBase { /** * The Drupal state storage service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -59,10 +59,10 @@ class SearchSettingsForm extends ConfigFormBase { * The manager for search plugins. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key/value store interface, gives access to state based config settings. */ - public function __construct(ConfigFactory $config_factory, ContextInterface $context, SearchPluginManager $manager, ModuleHandlerInterface $module_handler, KeyValueStoreInterface $state) { + public function __construct(ConfigFactory $config_factory, ContextInterface $context, SearchPluginManager $manager, ModuleHandlerInterface $module_handler, StateInterface $state) { parent::__construct($config_factory, $context); $this->searchSettings = $config_factory->get('search.settings'); $this->searchPluginManager = $manager; diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 5eb5b26..dee1760 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -175,10 +175,8 @@ public function containerBuild(ContainerBuilder $container) { ->addArgument(new Reference('service_container')) ->addArgument(new Reference('settings')); - $container->register('state', 'Drupal\Core\KeyValueStore\KeyValueStoreInterface') - ->setFactoryService(new Reference('keyvalue')) - ->setFactoryMethod('get') - ->addArgument('state'); + $container->register('state', 'Drupal\Core\KeyValueStore\State') + ->addArgument(new Reference('keyvalue')); } if ($container->hasDefinition('path_processor_alias')) { diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 284df1d..e26b53b 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -2445,6 +2445,7 @@ protected function drupalGetSettings() { * An array containing e-mail messages captured during the current test. */ protected function drupalGetMails($filter = array()) { + \Drupal::state()->resetCache(); $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $filtered_emails = array(); @@ -3442,6 +3443,7 @@ protected function assertNoResponse($code, $message = '', $group = 'Browser') { * TRUE on pass, FALSE on fail. */ protected function assertMail($name, $value = '', $message = '', $group = 'E-mail') { + \Drupal::state()->resetCache(); $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $email = end($captured_emails); return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, $group); diff --git a/core/modules/statistics/statistics.views.inc b/core/modules/statistics/statistics.views.inc index fe9a9e6..3814692 100644 --- a/core/modules/statistics/statistics.views.inc +++ b/core/modules/statistics/statistics.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for statistics.module. + * Provide views data and handlers for statistics.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/system/lib/Drupal/system/Form/CronForm.php b/core/modules/system/lib/Drupal/system/Form/CronForm.php index 84dddb1..5d94762 100644 --- a/core/modules/system/lib/Drupal/system/Form/CronForm.php +++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -22,7 +22,7 @@ class CronForm extends ConfigFormBase { /** * Stores the state storage service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -33,10 +33,10 @@ class CronForm extends ConfigFormBase { * The factory for configuration objects. * @param \Drupal\Core\Config\Context\ContextInterface $context * The configuration context used for this configuration object. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(ConfigFactory $config_factory, ContextInterface $context, KeyValueStoreInterface $state) { + public function __construct(ConfigFactory $config_factory, ContextInterface $context, StateInterface $state) { parent::__construct($config_factory, $context); $this->state = $state; } diff --git a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php index fa10960..693dc28 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,7 +21,7 @@ class SiteMaintenanceModeForm extends ConfigFormBase { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -32,10 +32,10 @@ class SiteMaintenanceModeForm extends ConfigFormBase { * The factory for configuration objects. * @param \Drupal\Core\Config\Context\ContextInterface $context * The configuration context to use. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state keyvalue collection to use. */ - public function __construct(ConfigFactory $config_factory, ContextInterface $context, KeyValueStoreInterface $state) { + public function __construct(ConfigFactory $config_factory, ContextInterface $context, StateInterface $state) { parent::__construct($config_factory, $context); $this->state = $state; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php index de63b73..0008e5f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php @@ -54,6 +54,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_1'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch with simple operations performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -61,6 +62,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_2'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch with multistep operation performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_2'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -68,6 +70,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_3'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_3'), 'Batch with simple and multistep operations performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_3'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -75,6 +78,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_4'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_4'), 'Nested batch performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_4'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); } @@ -95,6 +99,7 @@ function testBatchFormMultistep() { // Second step triggers batch 2. $this->drupalPostForm(NULL, array(), 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch for step 2 performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_2'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 78326e9..18dc465 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -113,6 +113,7 @@ function testEntityFormLanguage() { $node->getTranslation($langcode2)->body->value = $this->randomName(16); $node->save(); $this->drupalGet($langcode2 . '/node/' . $node->id() . '/edit'); + \Drupal::state()->resetCache(); $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; $this->assertTrue($langcode2 == $form_langcode, "Node edit form language is $langcode2."); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php index 3391a14..ccf6070 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php @@ -32,7 +32,7 @@ /** * The state service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php index 409f3aa..ee61284 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php @@ -93,6 +93,7 @@ function testCustom403And404Pages() { // Check that the initial trail (during the Drupal bootstrap) matches // what we expect. + \Drupal::state()->resetCache(); $initial_trail = \Drupal::state()->get('menu_test.active_trail_initial') ?: array(); $this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), format_string('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array( '@status_code' => $status_code, diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php index 6fe28f2..996dea4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php @@ -68,6 +68,7 @@ function testAutomaticCron() { \Drupal::state()->set('system.cron_last', $cron_last); $this->drupalGet(''); sleep(1); + \Drupal::state()->resetCache(); $this->assertTrue($cron_last < \Drupal::state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.'); // Disable the cron threshold through the interface. diff --git a/core/modules/system/tests/modules/entity_test/entity_test.views.inc b/core/modules/system/tests/modules/entity_test/entity_test.views.inc index 389923a..32da74d 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.views.inc +++ b/core/modules/system/tests/modules/entity_test/entity_test.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for entity_test.module. + * Provide views data and handlers for entity_test.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/ActiveTrailSubscriber.php b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/ActiveTrailSubscriber.php index 4bb3595..5b63e55 100644 --- a/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/ActiveTrailSubscriber.php +++ b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/ActiveTrailSubscriber.php @@ -7,7 +7,7 @@ namespace Drupal\menu_test\EventSubscriber; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -27,17 +27,17 @@ class ActiveTrailSubscriber implements EventSubscriberInterface { /** * The state service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; /** * Constructs a new ActiveTrailSubscriber. * - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state service. */ - public function __construct(KeyValueStoreInterface $state) { + public function __construct(StateInterface $state) { $this->state = $state; } diff --git a/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php b/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php index 1c8ea06..9078493 100644 --- a/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php +++ b/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php @@ -7,7 +7,7 @@ namespace Drupal\service_provider_test; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\DestructableInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; @@ -18,17 +18,17 @@ class TestClass implements EventSubscriberInterface, DestructableInterface { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; /** * Constructor. * - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(KeyValueStoreInterface $state) { + public function __construct(StateInterface $state) { $this->state = $state; } diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index 96f84aa..fb88184 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -24,23 +24,11 @@ function taxonomy_term_page(Term $term) { foreach ($term->uriRelationships() as $rel) { $uri = $term->uri($rel); // Set the term path as the canonical URL to prevent duplicate content. - $build['#attached']['drupal_add_html_head_link'][] = array( - array( - 'rel' => $rel, - 'href' => url($uri['path'], $uri['options']), - ), - TRUE, - ); + drupal_add_html_head_link(array('rel' => $rel, 'href' => url($uri['path'], $uri['options'])), TRUE); if ($rel == 'canonical') { // Set the non-aliased canonical path as a default shortlink. - $build['#attached']['drupal_add_html_head_link'][] = array( - array( - 'rel' => 'shortlink', - 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE))), - ), - TRUE, - ); + drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE); } } diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index 3404b3a..001c125 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for taxonomy.module. + * Provide views data and handlers for taxonomy.module. + * + * @ingroup views_module_handlers */ use Drupal\Core\Entity\FieldableDatabaseStorageController; diff --git a/core/modules/tracker/tracker.views.inc b/core/modules/tracker/tracker.views.inc index 14c125e..1a5e1fb 100644 --- a/core/modules/tracker/tracker.views.inc +++ b/core/modules/tracker/tracker.views.inc @@ -3,6 +3,8 @@ /** * @file * Provide views data for tracker.module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/user/user.views.inc b/core/modules/user/user.views.inc index 52d28eb..f49e812 100644 --- a/core/modules/user/user.views.inc +++ b/core/modules/user/user.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data for user.module. + * Provide views data and handlers for user.module. + * + * @ingroup views_module_handlers */ use Drupal\views\ViewExecutable; diff --git a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php index 26108b9..c8b0437 100644 --- a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php +++ b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\MapArray; use Drupal\Core\DestructableInterface; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Routing\RouteSubscriberBase; use Drupal\views\Plugin\views\display\DisplayRouterInterface; use Drupal\views\ViewExecutable; @@ -44,7 +44,7 @@ class RouteSubscriber extends RouteSubscriberBase implements DestructableInterfa /** * The state key value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -60,10 +60,10 @@ class RouteSubscriber extends RouteSubscriberBase implements DestructableInterfa * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(EntityManagerInterface $entity_manager, KeyValueStoreInterface $state) { + public function __construct(EntityManagerInterface $entity_manager, StateInterface $state) { $this->viewStorageController = $entity_manager->getStorageController('view'); $this->state = $state; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php index 51c8308..0fa04f8 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php @@ -7,7 +7,7 @@ namespace Drupal\views\Plugin\views\display; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Routing\RouteCompiler; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\views\Views; @@ -35,7 +35,7 @@ /** * The state key value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -50,10 +50,10 @@ * The plugin implementation definition. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, RouteProviderInterface $route_provider, KeyValueStoreInterface $state) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, RouteProviderInterface $route_provider, StateInterface $state) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->routeProvider = $route_provider; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php b/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php index 136e5bb..7b1e0b1 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php @@ -57,13 +57,13 @@ public function attachTo($display_id, $path, $title) { '#url' => $url, '#title' => $title, ); - $feed_icon['#attached']['drupal_add_html_head_link'][][] = array( + $this->view->feed_icon .= drupal_render($feed_icon); + drupal_add_html_head_link(array( 'rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => $title, - 'href' => $url, - ); - $this->view->feed_icon .= drupal_render($feed_icon); + 'href' => $url + )); } } diff --git a/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php index 8a69bd3..6e4c644 100644 --- a/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php @@ -44,7 +44,7 @@ class RouteSubscriberTest extends UnitTestCase { /** * The mocked key value storage. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\KeyValueStore\StateInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $state; @@ -68,7 +68,7 @@ protected function setUp() { ->method('getStorageController') ->with('view') ->will($this->returnValue($this->viewStorageController)); - $this->state = $this->getMock('\Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $this->state = $this->getMock('\Drupal\Core\KeyValueStore\StateInterface'); $this->routeSubscriber = new TestRouteSubscriber($this->entityManager, $this->state); } diff --git a/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php index 2e2395e..748d3c3 100644 --- a/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php @@ -43,7 +43,7 @@ class PathPluginBaseTest extends UnitTestCase { /** * The mocked key value storage. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\KeyValueStore\StateInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $state; @@ -62,7 +62,7 @@ protected function setUp() { parent::setUp(); $this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface'); - $this->state = $this->getMock('\Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $this->state = $this->getMock('\Drupal\Core\KeyValueStore\StateInterface'); $this->pathPlugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase') ->setConstructorArgs(array(array(), 'path_base', array(), $this->routeProvider, $this->state)) ->setMethods(NULL) diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index a1fa531..ea2c97c 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -839,3 +839,11 @@ function hook_views_plugins_wizard_alter(array &$plugins) { /** * @} */ + +/** + * @defgroup views_module_handlers Views module handlers + * @{ + * Handlers exposed by various modules to Views. + * @} + */ + diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index edf844a..b3af1d4 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -2,7 +2,9 @@ /** * @file - * Provide views data that isn't tied to any other module. + * Provide views data and handlers that aren't tied to any other module. + * + * @ingroup views_module_handlers */ /** diff --git a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php index b30bb34..12a0984 100644 --- a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php +++ b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php @@ -77,7 +77,7 @@ public function testBuildRowEntityList() { array(array(), 'default', $display_manager->getDefinition('default')) ); $route_provider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface'); - $state = $this->getMock('\Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $state = $this->getMock('\Drupal\Core\KeyValueStore\StateInterface'); $page_display = $this->getMock('Drupal\views\Plugin\views\display\Page', array('initDisplay', 'getPath'), array(array(), 'default', $display_manager->getDefinition('page'), $route_provider, $state) diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php index bfbe65c..fecb135 100644 --- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php @@ -66,7 +66,7 @@ class CssCollectionRendererUnitTest extends UnitTestCase { /** * The state mock class. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\KeyValueStore\StateInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $state; @@ -81,7 +81,7 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->state = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $this->state = $this->getMock('Drupal\Core\KeyValueStore\StateInterface'); $this->renderer = new CssCollectionRenderer($this->state); $this->file_css_group = array( diff --git a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php index a77a939..9f864f8 100644 --- a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php +++ b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php @@ -19,7 +19,7 @@ class PrivateKeyTest extends UnitTestCase { /** * The state mock class. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\KeyValueStore\StateInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $state; @@ -52,7 +52,7 @@ public function setUp() { parent::setUp(); $this->key = Crypt::randomStringHashed(55); - $this->state = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $this->state = $this->getMock('Drupal\Core\KeyValueStore\StateInterface'); $this->privateKey = new PrivateKey($this->state); } diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css index 6314e93..5dad110 100644 --- a/core/themes/bartik/css/style.css +++ b/core/themes/bartik/css/style.css @@ -953,17 +953,17 @@ ul.links { /* ------------------ Footer ------------------ */ -#footer-wrapper .block .content { +#footer-wrapper { color: #c0c0c0; color: rgba(255, 255, 255, 0.65); font-size: 0.857em; } -#footer-wrapper .block .content a { +#footer-wrapper a { color: #fcfcfc; color: rgba(255, 255, 255, 0.8); } -#footer-wrapper .block .content a:hover, -#footer-wrapper .block .content a:focus { +#footer-wrapper a:hover, +#footer-wrapper a:focus { color: #fefefe; color: rgba(255, 255, 255, 0.95); text-decoration: underline;