Skip to content
Snippets Groups Projects
Commit 5df20ac4 authored by catch's avatar catch
Browse files

Issue #2338167 by alexpott, rbmboogie: Update ProjectInfo class to reflect...

Issue #2338167 by alexpott, rbmboogie: Update ProjectInfo class to reflect changes to extension system
parent 8ce356a3
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -19,9 +19,8 @@ class ProjectInfo { ...@@ -19,9 +19,8 @@ class ProjectInfo {
/** /**
* Populates an array of project data. * Populates an array of project data.
* *
* @todo https://www.drupal.org/node/2338167 update class since extensions can * @todo https://www.drupal.org/node/2553909 update class since extensions can
* no longer be hidden, enabled or disabled. Additionally, base themes have * no longer be disabled.
* to be installed for sub themes to work.
* *
* This iterates over a list of the installed modules or themes and groups * This iterates over a list of the installed modules or themes and groups
* them by project and status. A few parts of this function assume that * them by project and status. A few parts of this function assume that
...@@ -29,10 +28,12 @@ class ProjectInfo { ...@@ -29,10 +28,12 @@ class ProjectInfo {
* modules or themes are being processed (there is a setting to control if * modules or themes are being processed (there is a setting to control if
* disabled code should be included in the Available updates report or not), * disabled code should be included in the Available updates report or not),
* those are only processed after $projects has been populated with * those are only processed after $projects has been populated with
* information about the enabled code. 'Hidden' modules are always ignored. * information about the enabled code. 'Hidden' modules and themes are
* 'Hidden' themes are ignored only if they have no enabled sub-themes. * ignored if they are not installed. 'Hidden' Modules and themes in the
* This function also records the latest change time on the .info.yml * "Testing" package are ignored regardless of installation status.
* files for each module or theme, which is important data which is used when *
* This function also records the latest change time on the .info.yml files
* for each module or theme, which is important data which is used when
* deciding if the available update data should be invalidated. * deciding if the available update data should be invalidated.
* *
* @param array $projects * @param array $projects
...@@ -50,25 +51,8 @@ class ProjectInfo { ...@@ -50,25 +51,8 @@ class ProjectInfo {
*/ */
function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_whitelist = array()) { function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_whitelist = array()) {
foreach ($list as $file) { foreach ($list as $file) {
// A disabled or hidden base theme of an enabled sub-theme still has all // Just projects with a matching status should be listed.
// of its code run by the sub-theme, so we include it in our "enabled" if ($file->status != $status) {
// projects list.
if ($status && !empty($file->sub_themes)) {
foreach ($file->sub_themes as $key => $name) {
// Build a list of installed sub-themes.
if ($list[$key]->status) {
$file->installed_sub_themes[$key] = $name;
}
}
// If the theme is uninstalled and there are no installed subthemes, we
// should ignore this base theme for the installed case. If the site is
// trying to display uninstalled themes, we'll catch it then.
if (!$file->status && empty($file->installed_sub_themes)) {
continue;
}
}
// Otherwise, just add projects of the proper status to our list.
elseif ($file->status != $status) {
continue; continue;
} }
...@@ -77,9 +61,15 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -77,9 +61,15 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
continue; continue;
} }
// Skip if it's a hidden module or hidden theme without installed // Skip if it's a hidden project and the project is not installed.
// sub-themes. if (!empty($file->info['hidden']) && empty($status)) {
if (!empty($file->info['hidden']) && empty($file->installed_sub_themes)) { continue;
}
// Skip if it's a hidden project and the project is a test project. Tests
// should use hook_system_info_alter() to test ProjectInfo's
// functionality.
if (!empty($file->info['hidden']) && isset($file->info['package']) && $file->info['package'] == 'Testing') {
continue; continue;
} }
...@@ -120,25 +110,10 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -120,25 +110,10 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
else { else {
$project_display_type = $project_type; $project_display_type = $project_type;
} }
if (empty($status) && empty($file->installed_sub_themes)) { if (empty($status)) {
// If we're processing disabled modules or themes, append a suffix. // If we're processing disabled modules or themes, append a suffix.
// However, we don't do this to a base theme with installed
// subthemes, since we treat that case as if it is installed.
$project_display_type .= '-disabled'; $project_display_type .= '-disabled';
} }
// Add a list of sub-themes that "depend on" the project and a list of base
// themes that are "required by" the project.
if ($project_name == 'drupal') {
// Drupal core is always required, so this extra info would be noise.
$sub_themes = array();
$base_themes = array();
}
else {
// Add list of installed sub-themes.
$sub_themes = !empty($file->installed_sub_themes) ? $file->installed_sub_themes : array();
// Add list of base themes.
$base_themes = !empty($file->base_themes) ? $file->base_themes : array();
}
if (!isset($projects[$project_name])) { if (!isset($projects[$project_name])) {
// Only process this if we haven't done this project, since a single // Only process this if we haven't done this project, since a single
// project can have multiple modules or themes. // project can have multiple modules or themes.
...@@ -151,8 +126,6 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -151,8 +126,6 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
'includes' => array($file->getName() => $file->info['name']), 'includes' => array($file->getName() => $file->info['name']),
'project_type' => $project_display_type, 'project_type' => $project_display_type,
'project_status' => $status, 'project_status' => $status,
'sub_themes' => $sub_themes,
'base_themes' => $base_themes,
); );
} }
elseif ($projects[$project_name]['project_type'] == $project_display_type) { elseif ($projects[$project_name]['project_type'] == $project_display_type) {
...@@ -164,12 +137,6 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -164,12 +137,6 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
$projects[$project_name]['includes'][$file->getName()] = $file->info['name']; $projects[$project_name]['includes'][$file->getName()] = $file->info['name'];
$projects[$project_name]['info']['_info_file_ctime'] = max($projects[$project_name]['info']['_info_file_ctime'], $file->info['_info_file_ctime']); $projects[$project_name]['info']['_info_file_ctime'] = max($projects[$project_name]['info']['_info_file_ctime'], $file->info['_info_file_ctime']);
$projects[$project_name]['datestamp'] = max($projects[$project_name]['datestamp'], $file->info['datestamp']); $projects[$project_name]['datestamp'] = max($projects[$project_name]['datestamp'], $file->info['datestamp']);
if (!empty($sub_themes)) {
$projects[$project_name]['sub_themes'] += $sub_themes;
}
if (!empty($base_themes)) {
$projects[$project_name]['base_themes'] += $base_themes;
}
} }
elseif (empty($status)) { elseif (empty($status)) {
// If we have a project_name that matches, but the project_display_type // If we have a project_name that matches, but the project_display_type
......
...@@ -66,6 +66,7 @@ function testNoReleasesAvailable() { ...@@ -66,6 +66,7 @@ function testNoReleasesAvailable() {
* Tests the basic functionality of a contrib module on the status report. * Tests the basic functionality of a contrib module on the status report.
*/ */
function testUpdateContribBasic() { function testUpdateContribBasic() {
$project_link = \Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'));
$system_info = array( $system_info = array(
'#all' => array( '#all' => array(
'version' => '8.0.0', 'version' => '8.0.0',
...@@ -87,7 +88,30 @@ function testUpdateContribBasic() { ...@@ -87,7 +88,30 @@ function testUpdateContribBasic() {
$this->assertText(t('Up to date')); $this->assertText(t('Up to date'));
$this->assertRaw('<h3>' . t('Modules') . '</h3>'); $this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertNoText(t('Update available')); $this->assertNoText(t('Update available'));
$this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.'); $this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
// Since aaa_update_test is installed the fact it is hidden and in the
// Testing package means it should not appear.
$system_info['aaa_update_test']['hidden'] = TRUE;
$this->config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(
array(
'drupal' => '0.0',
'aaa_update_test' => '1_0',
)
);
$this->assertNoRaw($project_link, 'Link to aaa_update_test project does not appear.');
// A hidden and installed project not in the Testing package should appear.
$system_info['aaa_update_test']['package'] = 'aaa_update_test';
$this->config('update_test.settings')->set('system_info', $system_info)->save();
$this->refreshUpdateStatus(
array(
'drupal' => '0.0',
'aaa_update_test' => '1_0',
)
);
$this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
} }
/** /**
......
...@@ -51,10 +51,6 @@ interface UpdateManagerInterface { ...@@ -51,10 +51,6 @@ interface UpdateManagerInterface {
* 'theme'. * 'theme'.
* - project_status: This indicates if the project is enabled and will * - project_status: This indicates if the project is enabled and will
* always be TRUE, as the function only returns enabled projects. * 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_process_project_info()
* @see update_calculate_project_data() * @see update_calculate_project_data()
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
* - data: The data about an extra item. * - data: The data about an extra item.
* - includes: The projects within the project. * - includes: The projects within the project.
* - disabled: The currently disabled projects in the project. * - disabled: The currently disabled projects in the project.
* - base_themes: The base themes supplied by the project.
* - sub_themes: The subthemes supplied by the project.
* *
* @see template_preprocess_update_project_status() * @see template_preprocess_update_project_status()
* *
...@@ -105,18 +103,4 @@ ...@@ -105,18 +103,4 @@
Includes: {{ includes|placeholder }} Includes: {{ includes|placeholder }}
{% endtrans %} {% endtrans %}
{% endif %} {% endif %}
{% if base_themes %}
{% set basethemes = base_themes|join(', ') %}
{% trans %}
Depends on: {{ basethemes }}
{% endtrans %}
{% endif %}
{% if sub_themes %}
{% set subthemes = sub_themes|join(', ') %}
{% trans %}
Required by: {{ subthemes|placeholder }}
{% endtrans %}
{% endif %}
</div> </div>
...@@ -183,7 +183,7 @@ function update_theme() { ...@@ -183,7 +183,7 @@ function update_theme() {
'file' => 'update.report.inc', 'file' => 'update.report.inc',
), ),
'update_project_status' => array( 'update_project_status' => array(
'variables' => array('project' => array(), 'includes_status' => array()), 'variables' => array('project' => array()),
'file' => 'update.report.inc', 'file' => 'update.report.inc',
), ),
// We are using template instead of '#type' => 'table' here to keep markup // We are using template instead of '#type' => 'table' here to keep markup
......
...@@ -39,24 +39,12 @@ function template_preprocess_update_report(&$variables) { ...@@ -39,24 +39,12 @@ function template_preprocess_update_report(&$variables) {
$variables['no_updates_message'] = _update_no_data(); $variables['no_updates_message'] = _update_no_data();
} }
$status = array();
// Create an array of status values keyed by module or theme name, since
// we'll need this while generating the report if we have to cross reference
// anything (e.g. subthemes which have base themes missing an update).
foreach ($data as $project) {
foreach ($project['includes'] as $key => $name) {
$status[$key] = $project['status'];
}
}
$rows = array(); $rows = array();
foreach ($data as $project) { foreach ($data as $project) {
$project_status = array( $project_status = array(
'#theme' => 'update_project_status', '#theme' => 'update_project_status',
'#project' => $project, '#project' => $project,
'#includes_status' => $status,
); );
// Build project rows. // Build project rows.
...@@ -120,14 +108,10 @@ function template_preprocess_update_report(&$variables) { ...@@ -120,14 +108,10 @@ function template_preprocess_update_report(&$variables) {
* @param array $variables * @param array $variables
* An associative array containing: * An associative array containing:
* - project: An array of information about the project. * - project: An array of information about the project.
* - includes_status: An array of sub-project statuses where the keys are the
* shortnames of each project and the values are UPDATE_* integer constants
* as defined in update.module.
*/ */
function template_preprocess_update_project_status(&$variables) { function template_preprocess_update_project_status(&$variables) {
// Storing by reference because we are sorting the project values. // Storing by reference because we are sorting the project values.
$project = &$variables['project']; $project = &$variables['project'];
$includes_status = $variables['includes_status'];
// Set the project title and URL. // Set the project title and URL.
$variables['title'] = (isset($project['title'])) ? $project['title'] : $project['name']; $variables['title'] = (isset($project['title'])) ? $project['title'] : $project['name'];
...@@ -249,42 +233,6 @@ function template_preprocess_update_project_status(&$variables) { ...@@ -249,42 +233,6 @@ function template_preprocess_update_project_status(&$variables) {
} }
} }
if (!empty($project['base_themes'])) {
asort($project['base_themes']);
$base_themes = array();
foreach ($project['base_themes'] as $base_key => $base_theme) {
switch ($includes_status[$base_key]) {
case UPDATE_NOT_SECURE:
$base_status_label = t('Security update required!');
break;
case UPDATE_REVOKED:
$base_status_label = t('Revoked!');
break;
case UPDATE_NOT_SUPPORTED:
$base_status_label = t('Not supported!');
break;
default:
$base_status_label = '';
}
if ($base_status_label) {
$base_themes[] = t('%base_theme (!base_label)', array(
'%base_theme' => $base_theme,
'!base_label' => $base_status_label,
));
}
else {
$base_themes[] = drupal_placeholder($base_theme);
}
}
$variables['base_themes'] = $base_themes;
}
if (!empty($project['sub_themes'])) {
sort($project['sub_themes']);
$variables['sub_themes'] = $project['sub_themes'];
}
// Set the project status details. // Set the project status details.
$status_label = NULL; $status_label = NULL;
switch ($project['status']) { switch ($project['status']) {
......
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