reverted: --- b/core/modules/locale/lib/Drupal/locale/LocaleProjectStorage.php +++ /dev/null @@ -1,173 +0,0 @@ -keyValueStore = $key_value_factory->get('locale.project'); - } - - /** - * {@inheritdoc} - */ - public function get($key, $default = NULL) { - $values = $this->getMultiple(array($key)); - return isset($values[$key]) ? $values[$key] : $default; - } - - /** - * {@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])) { - $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->setMultiple(array($key => $value)); - } - - /** - * {@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 deleteMultiple(array $keys) { - foreach ($keys as $key) { - $this->cache[$key] = NULL; - } - $this->keyValueStore->deleteMultiple($keys); - } - - /** - * {@inheritdoc} - */ - public function resetCache() { - $this->cache = array(); - static::$all = FALSE; - } - - /** - * {@inheritdoc} - */ - public function deleteAll() { - $this->keyValueStore->deleteAll(); - $this->resetCache(); - } - - /** - * {@inheritdoc} - */ - public function disableAll() { - $projects = $this->keyValueStore->getAll(); - foreach (array_keys($projects) as $key) { - $projects[$key]['status'] = 0; - if (isset($cache[$key])) { - $cache[$key] = $projects[$key]; - } - } - $this->keyValueStore->setMultiple($projects); - - } - - /** - * {@inheritdoc} - */ - public function countProjects() { - return count($this->getAll()); - } - - /** - * {@inheritdoc} - */ - public function getAll() { - if (!static::$all) { - $this->cache = $this->keyValueStore->getAll(); - static::$all = TRUE; - } - return $this->cache; - } -} reverted: --- b/core/modules/locale/lib/Drupal/locale/LocaleProjectStorageInterface.php +++ /dev/null @@ -1,106 +0,0 @@ -condition('f.project', array_keys($projects)) ->condition('f.last_checked', $last, '<') ->fields('f', array('project', 'langcode')) - // Only currently installed / enabled components should be checked for. - ->condition('p.status', 1) ->execute()->fetchAll(); foreach ($files as $file) { $updates[$file->project][] = $file->langcode; only in patch2: unchanged: --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1607,16 +1607,15 @@ function _install_prepare_import($langcode) { // we check if at least the major version number is available. if ($info['major']) { $core = $info['major'] . '.x'; - db_insert('locale_project') - ->fields(array( - 'name' => 'drupal', - 'project_type' => 'module', - 'core' => $core, - 'version' => $version, - 'server_pattern' => $install_state['server_pattern'], - 'status' => 1, - )) - ->execute(); + $data = array( + 'name' => 'drupal', + 'project_type' => 'module', + 'core' => $core, + 'version' => $version, + 'server_pattern' => $install_state['server_pattern'], + 'status' => 1, + ); + \Drupal::service('locale.project')->set($data['name'], $data); module_load_include('compare.inc', 'locale'); locale_translation_check_projects_local(array('drupal'), array($install_state['parameters']['langcode'])); } only in patch2: unchanged: --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -19,9 +19,7 @@ * Clear the project data table. */ function locale_translation_flush_projects() { - // Followup issue: http://drupal.org/node/1842362 - // Replace {locale_project} table by \Drupal::state() variable(s). - db_truncate('locale_project')->execute(); + Drupal::service('locale.project')->deleteAll(); } /** @@ -55,11 +53,7 @@ function locale_translation_build_projects() { $projects = locale_translation_project_list(); // Mark all previous projects as disabled and store new project data. - db_update('locale_project') - ->fields(array( - 'status' => 0, - )) - ->execute(); + \Drupal::service('locale.project')->disableAll(); $default_server = locale_translation_default_translation_server(); @@ -91,6 +85,7 @@ function locale_translation_build_projects() { // For every project store information. $data += array( + 'name' => $name, 'version' => isset($data['info']['version']) ? $data['info']['version'] : '', 'core' => isset($data['info']['core']) ? $data['info']['core'] : \Drupal::CORE_COMPATIBILITY, // A project can provide the path and filename pattern to download the @@ -102,17 +97,7 @@ function locale_translation_build_projects() { $projects[$name] = $project; // Create or update the project record. - db_merge('locale_project') - ->key('name', $project->name) - ->fields(array( - 'name' => $project->name, - 'project_type' => $project->project_type, - 'core' => $project->core, - 'version' => $project->version, - 'server_pattern' => $project->server_pattern, - 'status' => $project->status, - )) - ->execute(); + \Drupal::service('locale.project')->set($project->name, $data); // Invalidate the cache of translatable projects. locale_translation_clear_cache_projects(); only in patch2: unchanged: --- /dev/null +++ b/core/modules/locale/src/LocaleProjectStorage.php @@ -0,0 +1,173 @@ +keyValueStore = $key_value_factory->get('locale.project'); + } + + /** + * {@inheritdoc} + */ + public function get($key, $default = NULL) { + $values = $this->getMultiple(array($key)); + return isset($values[$key]) ? $values[$key] : $default; + } + + /** + * {@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])) { + $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->setMultiple(array($key => $value)); + } + + /** + * {@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 deleteMultiple(array $keys) { + foreach ($keys as $key) { + $this->cache[$key] = NULL; + } + $this->keyValueStore->deleteMultiple($keys); + } + + /** + * {@inheritdoc} + */ + public function resetCache() { + $this->cache = array(); + static::$all = FALSE; + } + + /** + * {@inheritdoc} + */ + public function deleteAll() { + $this->keyValueStore->deleteAll(); + $this->resetCache(); + } + + /** + * {@inheritdoc} + */ + public function disableAll() { + $projects = $this->keyValueStore->getAll(); + foreach (array_keys($projects) as $key) { + $projects[$key]['status'] = 0; + if (isset($cache[$key])) { + $cache[$key] = $projects[$key]; + } + } + $this->keyValueStore->setMultiple($projects); + + } + + /** + * {@inheritdoc} + */ + public function countProjects() { + return count($this->getAll()); + } + + /** + * {@inheritdoc} + */ + public function getAll() { + if (!static::$all) { + $this->cache = $this->keyValueStore->getAll(); + static::$all = TRUE; + } + return $this->cache; + } +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/locale/src/LocaleProjectStorageInterface.php @@ -0,0 +1,106 @@ +