diff -u b/core/modules/locale/lib/Drupal/locale/LocaleProjectStorage.php b/core/modules/locale/lib/Drupal/locale/LocaleProjectStorage.php --- b/core/modules/locale/lib/Drupal/locale/LocaleProjectStorage.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleProjectStorage.php @@ -2,15 +2,17 @@ /** * @file - * Contains Drupal\locale\ProjectStorage. + * Contains Drupal\locale\LocaleProjectStorage. */ -namespace Drupal\Core\KeyValueStore; +namespace Drupal\locale; + +use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; /** * Provides the locale project storage system using a key value store. */ -class LocaleProjectStorage { +class LocaleProjectStorage implements LocaleProjectStorageInterface { /** * The key value store to use. @@ -121,10 +123,17 @@ $this->cache = array(); } + /** + * {@inheritdoc} + */ public function deleteAll() { + $this->resetCache(); $this->keyValueStore->deleteAll(); } + /** + * {@inheritdoc} + */ public function disableAll() { $projects = $this->keyValueStore->getAll(); array_walk($projects, function($project){ @@ -135,6 +144,15 @@ - public function count() { - return count($this->keyValueStore->getAll()); + /** + * {@inheritdoc} + */ + public function countProjects() { + return !empty($this->cache) ? count($this->cache) : count($this->keyValueStore->getAll()); } + /** + * {@inheritdoc} + */ + public function getAll() { + return !empty($this->cache) ? $this->cache : $this->keyValueStore->getAll(); + } } diff -u b/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc --- b/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -85,6 +85,7 @@ // 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 @@ -96,7 +97,6 @@ $projects[$name] = $project; // Create or update the project record. - $data['name'] = $name; \Drupal::service('locale.project')->set($project->name, $data); // Invalidate the cache of translatable projects. diff -u b/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc --- b/core/modules/locale/locale.translation.inc +++ b/core/modules/locale/locale.translation.inc @@ -54,8 +54,7 @@ if (empty($projects)) { // Get project data from the database. - $row_count = db_query_range('SELECT 1 FROM {locale_project}', 0, 1)->fetchField(); - + $row_count = \Drupal::service('locale.project')->countProjects(); // http://drupal.org/node/1777106 is a follow-up issue to make the check for // possible out-of-date project information more robust. if ($row_count == 0 && \Drupal::moduleHandler()->moduleExists('update')) { only in patch2: unchanged: --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1906,16 +1906,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: --- /dev/null +++ b/core/modules/locale/lib/Drupal/locale/LocalProjectStorageInterface.php @@ -0,0 +1,106 @@ +