Skip to content
Snippets Groups Projects
Commit 889b5c93 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Merge branch '3450284-defaultargumentskipurl-views-setting' into '4.x'

Add a config schema deprecation analyzer with dedicated implementation for the...

See merge request !83
parents a4918a74 b455aec4
No related branches found
No related tags found
No related merge requests found
Pipeline #185905 passed with warnings
<?php
declare(strict_types=1);
namespace Drupal\upgrade_status;
use Drupal\Core\Extension\Extension;
/**
* Config schema deprecation analyzer.
*/
final class ConfigSchemaDeprecationAnalyzer {
/**
* Analyzes usages of deprecated config schema elements in an extension.
*
* @param \Drupal\Core\Extension\Extension $extension
* The extension to be analyzed.
*
* @return \Drupal\upgrade_status\DeprecationMessage[]
* A list of deprecation messages.
*
* @throws \Exception
*/
public function analyze(Extension $extension): array {
$deprecations = [];
$project_dir = DRUPAL_ROOT . '/' . $extension->getPath();
$config_files = $this->getViewsConfigFiles($project_dir);
foreach ($config_files as $config_file) {
$error_path = str_replace(DRUPAL_ROOT . '/', '', $config_file);
$file_contents = file_get_contents($config_file);
if (($line = $this->findKeyLine('default_argument_skip_url:', $file_contents)) !== 1) {
$deprecations[] = new DeprecationMessage("Support from all Views contextual filter settings for the default_argument_skip_url setting is removed from drupal:11.0.0. No replacement is provided. See https://www.drupal.org/node/3382316.", $error_path, $line, 'ConfigSchemaDeprecationAnalyzer');
}
}
return $deprecations;
}
/**
* Finds all views config files for extensions under a path.
*
* @param string $path
* Base path to find all views config files in.
*
* @return array
* A list of paths to views config files found under the base path.
*/
private function getViewsConfigFiles(string $path) {
$files = [];
foreach(glob($path . '/views.view.*.yml') as $file) {
$files[] = $file;
}
foreach (glob($path . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge($files, $this->getViewsConfigFiles($dir));
}
return $files;
}
/**
* Finds the line that contiains the substring.
*
* @param string $substring
* The string to find.
* @param string $file_contents
* String contents of a file.
* @return
* Line number if found, 1 otherwise.
*/
private function findKeyLine($substring, $file_contents) {
$lines = explode("\n", $file_contents);
foreach ($lines as $num => $line) {
if (strpos($line, $substring) !== FALSE) {
return $num + 1;
}
}
return 1;
}
}
......@@ -112,6 +112,13 @@ final class DeprecationAnalyzer {
*/
protected $extensionMetadataDeprecationAnalyzer;
/**
* The config schema deprecation analyzer.
*
* @var \Drupal\upgrade_status\ConfigSchemaDeprecationAnalyzer
*/
protected $configSchemaDeprecationAnalyzer;
/**
* The CSS deprecation analyzer.
*
......@@ -161,6 +168,8 @@ final class DeprecationAnalyzer {
* The route deprecation analyzer.
* @param \Drupal\upgrade_status\ExtensionMetadataDeprecationAnalyzer $extension_metadata_analyzer
* The extension metadata analyzer.
* @param \Drupal\upgrade_status\ConfigSchemaDeprecationAnalyzer $config_schema_analyzer
* The config schema analyzer.
* @param \Drupal\upgrade_status\CSSDeprecationAnalyzer $css_deprecation_analyzer
* The CSS deprecation analyzer.
* @param \Drupal\Component\Datetime\TimeInterface $time
......@@ -176,6 +185,7 @@ final class DeprecationAnalyzer {
ThemeFunctionDeprecationAnalyzer $theme_function_deprecation_analyzer,
RouteDeprecationAnalyzer $route_deprecation_analyzer,
ExtensionMetadataDeprecationAnalyzer $extension_metadata_analyzer,
ConfigSchemaDeprecationAnalyzer $config_schema_analyzer,
CSSDeprecationAnalyzer $css_deprecation_analyzer,
TimeInterface $time
) {
......@@ -188,6 +198,7 @@ final class DeprecationAnalyzer {
$this->themeFunctionDeprecationAnalyzer = $theme_function_deprecation_analyzer;
$this->routeDeprecationAnalyzer = $route_deprecation_analyzer;
$this->extensionMetadataDeprecationAnalyzer = $extension_metadata_analyzer;
$this->configSchemaDeprecationAnalyzer = $config_schema_analyzer;
$this->CSSDeprecationAnalyzer = $css_deprecation_analyzer;
$this->time = $time;
}
......@@ -423,6 +434,7 @@ final class DeprecationAnalyzer {
$this->libraryDeprecationAnalyzer->analyze($extension),
$this->routeDeprecationAnalyzer->analyze($extension),
$this->CSSDeprecationAnalyzer->analyze($extension),
$this->configSchemaDeprecationAnalyzer->analyze($extension),
$metadataDeprecations,
);
if (projectCollector::getDrupalCoreMajorVersion() < 10) {
......
uuid: 6a7eb126-7ba9-493f-a209-e3aa0672b8f5
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
module:
- node
- taxonomy
- user
id: remove_default_argument_skip_url
label: 'Taxonomy term'
module: taxonomy
description: 'Content belonging to a certain taxonomy term.'
tag: default
base_table: node_field_data
base_field: nid
display:
default:
id: default
display_title: Default
display_plugin: default
position: 0
display_options:
fields: { }
pager:
type: mini
options:
offset: 0
items_per_page: 10
total_pages: 0
id: 0
tags:
next: ››
previous: ‹‹
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
empty: { }
sorts:
sticky:
id: sticky
table: taxonomy_index
field: sticky
relationship: none
group_type: group
admin_label: ''
plugin_id: standard
order: DESC
expose:
label: ''
field_identifier: sticky
exposed: false
created:
id: created
table: taxonomy_index
field: created
relationship: none
group_type: group
admin_label: ''
plugin_id: date
order: DESC
expose:
label: ''
field_identifier: created
exposed: false
granularity: second
arguments:
tid:
id: tid
table: taxonomy_index
field: tid
relationship: none
group_type: group
admin_label: ''
plugin_id: taxonomy_index_tid
default_action: 'not found'
exception:
value: ''
title_enable: false
title: All
title_enable: true
title: '{{ arguments.tid }}'
default_argument_type: fixed
default_argument_options:
argument: ''
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
override: false
items_per_page: 25
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: true
validate:
type: 'entity:taxonomy_term'
fail: 'not found'
validate_options:
bundles: { }
access: true
operation: view
multiple: 0
break_phrase: false
add_table: false
require_value: false
reduce_duplicates: false
filters:
langcode:
id: langcode
table: node_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: langcode
plugin_id: language
operator: in
value:
'***LANGUAGE_language_content***': '***LANGUAGE_language_content***'
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
status:
id: status
table: taxonomy_index
field: status
relationship: none
group_type: group
admin_label: ''
plugin_id: boolean
operator: '='
value: '1'
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: 'entity:node'
options:
view_mode: teaser
query:
type: views_query
options:
query_comment: ''
disable_sql_rewrite: false
distinct: false
replica: false
query_tags: { }
relationships: { }
link_display: page_1
link_url: ''
header:
entity_taxonomy_term:
id: entity_taxonomy_term
table: views
field: entity_taxonomy_term
relationship: none
group_type: group
admin_label: ''
plugin_id: entity
empty: true
target: '{{ raw_arguments.tid }}'
view_mode: full
tokenize: true
bypass_access: false
footer: { }
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags: { }
feed_1:
id: feed_1
display_title: Feed
display_plugin: feed
position: 2
display_options:
pager:
type: some
options:
offset: 0
items_per_page: 10
style:
type: rss
options:
grouping: { }
uses_fields: false
description: ''
row:
type: node_rss
options:
relationship: none
view_mode: default
query:
type: views_query
options: { }
display_extenders: { }
path: taxonomy/term/%/feed
displays:
page_1: page_1
default: '0'
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- url
- 'user.node_grants:view'
- user.permissions
tags: { }
page_1:
id: page_1
display_title: Page
display_plugin: page
position: 1
display_options:
query:
type: views_query
options: { }
display_extenders: { }
path: taxonomy/term/%
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- url
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags: { }
\ No newline at end of file
......@@ -36,8 +36,8 @@ class UpgradeStatusAnalyzeTest extends UpgradeStatusTestBase {
$report = $key_value->get('upgrade_status_test_error');
$this->assertNotEmpty($report);
$this->assertEquals(7, $report['data']['totals']['file_errors']);
$this->assertCount(7, $report['data']['files']);
$this->assertEquals(8, $report['data']['totals']['file_errors']);
$this->assertCount(8, $report['data']['files']);
$file = reset($report['data']['files']);
$message = $file['messages'][0];
$this->assertEquals('fatal.php', basename(key($report['data']['files'])));
......@@ -69,6 +69,11 @@ class UpgradeStatusAnalyzeTest extends UpgradeStatusTestBase {
$this->assertEquals("The #drupal-off-canvas selector is deprecated in drupal:9.5.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3305664.", $message['message']);
$this->assertEquals(0, $message['line']);
$file = next($report['data']['files']);
$this->assertEquals('views.view.remove_default_argument_skip_url.yml', basename(key($report['data']['files'])));
$message = $file['messages'][0];
$this->assertEquals("Support from all Views contextual filter settings for the default_argument_skip_url setting is removed from drupal:11.0.0. No replacement is provided. See https://www.drupal.org/node/3382316.", $message['message']);
$this->assertEquals(109, $message['line']);
$file = next($report['data']['files']);
$this->assertEquals('upgrade_status_test_error.info.yml', basename(key($report['data']['files'])));
$message = $file['messages'][0];
$this->assertEquals("Add core_version_requirement to designate which Drupal versions is the extension compatible with. See https://drupal.org/node/3070687.", $message['message']);
......
......@@ -51,7 +51,7 @@ class UpgradeStatusUiTest extends UpgradeStatusTestBase {
$assert_session->buttonExists('Export selected as HTML');
// Error and no-error test module results should show.
$this->assertSame('7 problems', strip_tags($page->find('css', 'tr.project-upgrade_status_test_error td.scan-result')->getHtml()));
$this->assertSame('8 problems', strip_tags($page->find('css', 'tr.project-upgrade_status_test_error td.scan-result')->getHtml()));
$this->assertSame($this->getDrupalCoreMajorVersion() < 10 ? 'No problems found' : '1 problem', strip_tags($page->find('css', 'tr.project-upgrade_status_test_10_compatible td.scan-result')->getHtml()));
$this->assertSame('No problems found', strip_tags($page->find('css', 'tr.project-upgrade_status_test_11_compatible td.scan-result')->getHtml()));
......@@ -69,7 +69,7 @@ class UpgradeStatusUiTest extends UpgradeStatusTestBase {
// Check UI of results for the custom project.
$this->drupalGet('/admin/reports/upgrade-status/project/upgrade_status_test_error');
$this->assertSession()->pageTextContains('Upgrade status test error');
$this->assertSession()->pageTextContains('2 errors found. 5 warnings found.');
$this->assertSession()->pageTextContains('2 errors found. ' . ($this->getDrupalCoreMajorVersion() < 10 ? '5' : '6') . ' warnings found.');
$this->assertSession()->pageTextContains('Syntax error, unexpected T_STRING on line 5');
// Go forward to the export page and assert that still contains the results
......@@ -79,7 +79,7 @@ class UpgradeStatusUiTest extends UpgradeStatusTestBase {
$this->assertSession()->pageTextContains('Upgrade status test error');
$this->assertSession()->pageTextContains('Custom projects');
$this->assertSession()->pageTextNotContains('Contributed projects');
$this->assertSession()->pageTextContains('2 errors found. 5 warnings found.');
$this->assertSession()->pageTextContains('2 errors found. ' . ($this->getDrupalCoreMajorVersion() < 10 ? '5' : '6') . ' warnings found.');
$this->assertSession()->pageTextContains('Syntax error, unexpected T_STRING on line 5');
// Go back to the results page and click over to exporting in single ASCII.
......@@ -88,7 +88,7 @@ class UpgradeStatusUiTest extends UpgradeStatusTestBase {
$this->assertSession()->pageTextContains('Upgrade status test error');
$this->assertSession()->pageTextContains('CUSTOM PROJECTS');
$this->assertSession()->pageTextNotContains('CONTRIBUTED PROJECTS');
$this->assertSession()->pageTextContains('2 errors found. 5 warnings found.');
$this->assertSession()->pageTextContains('2 errors found. ' . ($this->getDrupalCoreMajorVersion() < 10 ? '5' : '6') . ' warnings found.');
$this->assertSession()->pageTextContains('Syntax error, unexpected T_STRING on line 5');
// Run partial export of multiple projects.
......@@ -111,7 +111,7 @@ class UpgradeStatusUiTest extends UpgradeStatusTestBase {
$this->assertSession()->pageTextContains('Upgrade status test error');
$this->assertSession()->pageTextNotContains('Upgrade status test root module');
$this->assertSession()->pageTextNotContains('Upgrade status test contrib 9 compatbile');
$this->assertSession()->pageTextContains('2 errors found. 5 warnings found.');
$this->assertSession()->pageTextContains('2 errors found. ' . ($this->getDrupalCoreMajorVersion() < 10 ? '5' : '6') . ' warnings found.');
$this->assertSession()->pageTextContains('Syntax error, unexpected T_STRING on line 5');
}
}
......
......@@ -11,6 +11,7 @@ services:
- '@upgrade_status.theme_function_deprecation_analyzer'
- '@upgrade_status.route_deprecation_analyzer'
- '@upgrade_status.extension_metadata_deprecation_analyzer'
- '@upgrade_status.config_schema_deprecation_analyzer'
- '@upgrade_status.css_deprecation_analyzer'
- '@datetime.time'
upgrade_status.library_deprecation_analyzer:
......@@ -33,6 +34,8 @@ services:
class: Drupal\upgrade_status\CSSDeprecationAnalyzer
upgrade_status.extension_metadata_deprecation_analyzer:
class: Drupal\upgrade_status\ExtensionMetadataDeprecationAnalyzer
upgrade_status.config_schema_deprecation_analyzer:
class: Drupal\upgrade_status\ConfigSchemaDeprecationAnalyzer
upgrade_status.project_collector:
class: Drupal\upgrade_status\ProjectCollector
arguments:
......
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