diff --git a/core/modules/update/lib/Drupal/update/Controller/UpdateController.php b/core/modules/update/lib/Drupal/update/Controller/UpdateController.php index 6081361..37ab020 100644 --- a/core/modules/update/lib/Drupal/update/Controller/UpdateController.php +++ b/core/modules/update/lib/Drupal/update/Controller/UpdateController.php @@ -9,7 +9,7 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\update\UpdateManager; +use Drupal\update\UpdateManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -27,7 +27,7 @@ class UpdateController implements ContainerInjectionInterface { /** * Update manager service. * - * @var \Drupal\update\UpdateManager + * @var \Drupal\update\UpdateManagerInterface */ protected $updateManager; @@ -37,10 +37,10 @@ class UpdateController implements ContainerInjectionInterface { * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * Module Handler Service. * - * @param \Drupal\update\UpdateManager $update_manager + * @param \Drupal\update\UpdateManagerInterface $update_manager * Update Manager Service. */ - public function __construct(ModuleHandlerInterface $module_handler, UpdateManager $update_manager) { + public function __construct(ModuleHandlerInterface $module_handler, UpdateManagerInterface $update_manager) { $this->moduleHandler = $module_handler; $this->updateManager = $update_manager; } diff --git a/core/modules/update/lib/Drupal/update/UpdateManager.php b/core/modules/update/lib/Drupal/update/UpdateManager.php index f82a55c..fda2433 100644 --- a/core/modules/update/lib/Drupal/update/UpdateManager.php +++ b/core/modules/update/lib/Drupal/update/UpdateManager.php @@ -13,9 +13,9 @@ use Drupal\Core\Utility\ProjectInfo; /** - * Manages project update information. + * Default implementation of UpdateManagerInterface. */ -class UpdateManager { +class UpdateManager implements UpdateManagerInterface { /** * The update settings @@ -91,7 +91,7 @@ public function __construct(ConfigFactory $config_factory, ModuleHandlerInterfac } /** - * Clears out all the available update data and initiates re-fetching. + * {@inheritdoc} */ public function refreshUpdateData() { @@ -117,51 +117,7 @@ public function refreshUpdateData() { } /** - * Fetches an array of installed and enabled projects. - * - * This is only responsible for generating an array of projects (taking into - * account projects that include more than one module or theme). Other - * information like the specific version and install type (official release, - * dev snapshot, etc) is handled later in update_process_project_info() since - * that logic is only required when preparing the status report, not for - * fetching the available release data. - * - * This array is fairly expensive to construct, since it involves a lot of disk - * I/O, so we store the results. However, since this is not the data about - * available updates fetched from the network, it is acceptable to invalidate it - * somewhat quickly. If we keep this data for very long, site administrators are - * more likely to see incorrect results if they upgrade to a newer version of a - * module or theme but do not visit certain pages that automatically clear this - * data. - * - * @return - * An associative array of currently enabled projects keyed by the - * machine-readable project short name. Each project contains: - * - name: The machine-readable project short name. - * - info: An array with values from the main .info.yml file for this project. - * - name: The human-readable name of the project. - * - package: The package that the project is grouped under. - * - version: The version of the project. - * - project: The Drupal.org project name. - * - datestamp: The date stamp of the project's main .info.yml file. - * - _info_file_ctime: The maximum file change time for all of the .info.yml - * files included in this project. - * - datestamp: The date stamp when the project was released, if known. - * - includes: An associative array containing all projects included with this - * project, keyed by the machine-readable short name with the human-readable - * name as value. - * - project_type: The type of project. Allowed values are 'module' and - * 'theme'. - * - project_status: This indicates if the project is enabled and will always - * be TRUE, as the function only returns enabled projects. - * - sub_themes: If the project is a theme it contains an associative array of - * all sub-themes. - * - base_themes: If the project is a theme it contains an associative array - * of all base-themes. - * - * @see update_process_project_info() - * @see update_calculate_project_data() - * @see \Drupal\update\UpdateManager::projectStorage() + * {@inheritdoc} */ public function getProjects() { if (empty($this->projects)) { @@ -188,31 +144,7 @@ public function getProjects() { } /** - * Retrieves update storage data or empties it. - * - * Two very expensive arrays computed by this module are the list of all - * installed modules and themes (and .info.yml data, project associations, etc), and - * the current status of the site relative to the currently available releases. - * These two arrays are stored and used whenever possible. The data is cleared - * whenever the administrator visits the status report, available updates - * report, or the module or theme administration pages, since we should always - * recompute the most current values on any of those pages. - * - * Note: while both of these arrays are expensive to compute (in terms of disk - * I/O and some fairly heavy CPU processing), neither of these is the actual - * data about available updates that we have to fetch over the network from - * updates.drupal.org. That information is stored in the - * 'update_available_releases' collection -- it needs to persist longer than 1 - * hour and never get invalidated just by visiting a page on the site. - * - * @param $key - * The key of data to return. Valid options are 'update_project_data' and - * 'update_project_projects'. - * - * @return - * The stored value of the $projects array generated by - * update_calculate_project_data() or update_get_projects(), or an empty array - * when the storage is cleared. + * {@inheritdoc} */ public function projectStorage($key) { $projects = array(); @@ -240,10 +172,7 @@ public function projectStorage($key) { } /** - * Batch callback: Processes a step in batch for fetching available update data. - * - * @param $context - * Reference to an array used for Batch API storage. + * {@inheritdoc} */ public function fetchDataBatch(&$context) { if (empty($context['sandbox']['max'])) { diff --git a/core/modules/update/lib/Drupal/update/UpdateManagerInterface.php b/core/modules/update/lib/Drupal/update/UpdateManagerInterface.php new file mode 100644 index 0000000..8c1ab56 --- /dev/null +++ b/core/modules/update/lib/Drupal/update/UpdateManagerInterface.php @@ -0,0 +1,107 @@ +fetchTasks)) { @@ -141,7 +127,7 @@ public function createFetchTask($project) { } /** - * Attempts to drain the queue of tasks for release history data to fetch. + * {@inheritdoc} */ public function fetchData() { $end = time() + $this->updateSettings->get('fetch.timeout'); @@ -152,16 +138,7 @@ public function fetchData() { } /** - * Processes a task to fetch available update data for a single project. - * - * Once the release history XML data is downloaded, it is parsed and saved in - * an entry just for that project. - * - * @param array $project - * Associative array of information about the project to fetch data for. - * - * @return bool - * TRUE if we fetched parsable XML, otherwise FALSE. + * {@inheritdoc} */ public function processFetchTask($project) { global $base_url; @@ -272,37 +249,21 @@ protected function parseXml($raw_xml) { } /** - * Retrieves the number of items in the update fetch queue. - * - * @return int - * An integer estimate of the number of items in the queue. - * - * @see \Drupal\Core\Queue\QueueInterface::numberOfItems() + * {@inheritdoc} */ public function numberOfQueueItems() { return $this->fetchQueue->numberOfItems(); } /** - * Claims an item in the update fetch queue for processing. - * - * @return - * On success we return an item object. If the queue is unable to claim an - * item it returns false. - * - * @see \Drupal\Core\Queue\QueueInterface::claimItem() + * {@inheritdoc} */ public function claimQueueItem() { return $this->fetchQueue->claimItem(); } /** - * Deletes a finished item from the update fetch queue. - * - * @param $item - * The item returned by \Drupal\Core\Queue\QueueInterface::claimItem(). - * - * @see \Drupal\Core\Queue\QueueInterface::deleteItem() + * {@inheritdoc} */ public function deleteQueueItem($item) { return $this->fetchQueue->deleteItem($item);