Issue #3132426 by alexpott, dww, GuyPaddock, catch, VladimirAus: Notice: Undefined index: title in Drupal\update\ProjectSecurityRequirement

merge-requests/25/head
catch 2020-10-29 10:46:22 +00:00
parent 79f9e9dc97
commit d7758d6565
4 changed files with 51 additions and 0 deletions

View File

@ -82,8 +82,14 @@ interface UpdateManagerInterface {
/**
* Processes a step in batch for fetching available update data.
*
* Before calling this method, call
* UpdateManagerInterface::refreshUpdateData() to clear existing update data
* and initiate re-fetching.
*
* @param array $context
* Reference to an array used for Batch API storage.
*
* @see \Drupal\update\UpdateManagerInterface::refreshUpdateData()
*/
public function fetchDataBatch(&$context);

View File

@ -127,6 +127,11 @@ class UpdateProcessor implements UpdateProcessorInterface {
*/
public function fetchData() {
$end = time() + $this->updateSettings->get('fetch.timeout');
if ($this->fetchQueue->numberOfItems()) {
// Delete any stored project data as that needs refreshing when
// update_calculate_project_data() is called.
$this->tempStore->delete('update_project_data');
}
while (time() < $end && ($item = $this->fetchQueue->claimItem())) {
$this->processFetchTask($item->data);
$this->fetchQueue->deleteItem($item);

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns:dc="http://purl.org/dc/elements/1.1/">
</project>

View File

@ -862,6 +862,43 @@ class UpdateCoreTest extends UpdateTestBase {
}
}
/**
* Checks that Drupal recovers after problems connecting to update server.
*/
public function testBrokenThenFixedUpdates() {
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
'access administration pages',
]));
$this->setSystemInfo('8.0.0');
// Instead of using refreshUpdateStatus(), set these manually.
$this->config('update.settings')
->set('fetch.url', Url::fromRoute('update_test.update_test')->setAbsolute()->toString())
->save();
// Use update XML that has no information to simulate a broken response from
// the update server.
$this->config('update_test.settings')
->set('xml_map', ['drupal' => 'broken'])
->save();
// This will retrieve broken updates.
$this->cronRun();
$this->drupalGet('admin/reports/status');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('There was a problem checking available updates for Drupal.');
$this->config('update_test.settings')
->set('xml_map', ['drupal' => 'sec.0.2'])
->save();
// Simulate the update_available_releases state expiring before cron is run
// and the state is used by \Drupal\update\UpdateManager::getProjects().
\Drupal::keyValueExpirable('update_available_releases')->deleteAll();
// This cron run should retrieve fixed updates.
$this->cronRun();
$this->drupalGet('admin/structure');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('There is a security update available for your version of Drupal.');
}
/**
* Tests messages when a project release is marked unsupported.
*