Skip to content
Snippets Groups Projects
Commit 643bea89 authored by Jess's avatar Jess
Browse files

Issue #3118087 by dww, JoshaHubbers, jungle, tedbow, RajabNatshah, Kingdutch,...

Issue #3118087 by dww, JoshaHubbers, jungle, tedbow, RajabNatshah, Kingdutch, JonMcL, xjm, Nick Hope, wroehrig, wxman, broeker, mlozano7, kazajhodo, suit4, xmacinfo, BrightBold: If any extension has a missing or invalid version, Update manager throws errors and is confused about site update status
parent 9fe181ae
No related branches found
No related tags found
No related merge requests found
......@@ -2,5 +2,4 @@ name: 'AAA Update test'
type: module
description: 'Support module for update module testing.'
package: Testing
version: VERSION
core: 8.x
......@@ -793,6 +793,43 @@ public function testUnsupportedRelease() {
$this->confirmUnsupportedStatus('8.x-1.1', '8.x-2.0', 'Recommended version:');
}
/**
* Tests messages for invalid, empty and missing version strings.
*/
public function testNonStandardVersionStrings() {
$version_infos = [
'invalid' => [
'version' => 'llama',
'expected' => 'Invalid version: llama',
],
'empty' => [
'version' => '',
'expected' => 'Empty version',
],
'null' => [
'expected' => 'Invalid version: Unknown',
],
];
foreach ($version_infos as $version_info) {
$system_info = [
'aaa_update_test' => [
'project' => 'aaa_update_test',
'hidden' => FALSE,
],
];
if (isset($version_info['version'])) {
$system_info['aaa_update_test']['version'] = $version_info['version'];
}
$this->config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus([
'drupal' => '0.0',
$this->updateProject => '1_0-supported',
]);
$this->standardTests();
$this->assertSession()->elementTextContains('css', $this->updateTableLocator, $version_info['expected']);
}
}
/**
* Asserts that a core compatibility message is correct for an update.
*
......
......@@ -194,6 +194,9 @@ function update_calculate_project_data($available) {
* version (e.g., 5.x-1.5-beta1, 5.x-1.5-beta2, and 5.x-1.5). Development
* snapshots for a given major version are always listed last.
*
* NOTE: This function *must* set a value for $project_data['status'] before
* returning, or the rest of the Update Manager will break in unexpected ways.
*
* @param $project_data
* An array containing information about a specific project.
* @param $available
......@@ -261,11 +264,19 @@ function update_calculate_project_update_status(&$project_data, $available) {
}
// Figure out the target major version.
// Off Drupal.org, '0' could be a valid version string, so don't use empty().
if (!isset($project_data['existing_version']) || $project_data['existing_version'] === '') {
$project_data['status'] = UPDATE_UNKNOWN;
$project_data['reason'] = t('Empty version');
return;
}
try {
$existing_major = ModuleVersion::createFromVersionString($project_data['existing_version'])->getMajorVersion();
}
catch (UnexpectedValueException $exception) {
// If the version has an unexpected value we can't determine updates.
$project_data['status'] = UPDATE_UNKNOWN;
$project_data['reason'] = t('Invalid version: @existing_version', ['@existing_version' => $project_data['existing_version']]);
return;
}
$supported_branches = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment