Problem/Motivation

admin/reports/upgrade doesn't correctly redirect. If views is enabled, it should use URL arguments instead of setting the session. See #2904549: Remove routing.yml for admin/reports/upgrade for why we are keeping both.

Proposed resolution

Let's keep the menu item, and fix it to use url query parameters if views is around and loosen up the security.

Remaining tasks

Code it.

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#72 2904546-70.patch4.13 KBalexpott
#72 67-70-interdiff.txt655 bytesalexpott
#67 interdiff_62-67.txt1.49 KBsarvjeetsingh
#67 2904546-67.patch4.13 KBsarvjeetsingh
#62 interdiff-2904546-58-62.txt4.29 KBmsuthars
#62 2904546-62.patch4.1 KBmsuthars
#58 interdiff.2904546.56-58.txt528 bytesabhisekmazumdar
#58 2904546-58.patch4.2 KBabhisekmazumdar
#56 2904546-56.patch4.39 KBquietone
#56 interdiff-51-56.txt2.04 KBquietone
#51 2904546-51.patch4.66 KBquietone
#51 interdiff-49-51.txt774 bytesquietone
#49 2904546-49.patch4.67 KBquietone
#49 interdiff-46-49.txt5.21 KBquietone
#47 interdiff_43-46.txt3.7 KBvsujeetkumar
#46 interdiff_43-46.patch3.7 KBvsujeetkumar
#46 2904546_46.patch5.18 KBvsujeetkumar
#43 interdiff_41-43.txt2.95 KBvsujeetkumar
#43 2904546_43.patch4.73 KBvsujeetkumar
#41 interdiff_35-41.txt2.42 KBvsujeetkumar
#41 2904546_41.patch4.43 KBvsujeetkumar
#35 adding-custom-access-2904546-35.patch2.84 KBvacho
#33 adding-custom-access-2904546-33.patch2.98 KBmrweiner
#32 adding-custom-access-2904546-32.patch2.95 KBmrweiner
#31 adding-custom-access-2904546-30.patch2.97 KBmrweiner
#29 adding-custom-access-2904546-29.patch2.98 KBmrweiner
#29 interdiff_24-29.txt3.5 KBmrweiner
#24 interdiff_15-24.txt1.75 KBmrweiner
#24 adding-custom-access-2904546-24.patch1.65 KBmrweiner
#15 adding-custom-access-2904546-15.patch1.44 KBdev.patrick
#13 adding-custom-access-2904546-13.patch1.44 KBdev.patrick
#10 adding-custom-access-2904546-10.patch1.44 KBdev.patrick
#6 migrate_drupal_ui-2904546-6-handle_upgrade_logs_arguments_w_or_wo_views.patch1.43 KBMaskOta
#4 migrate_drupal_ui-2904546-fix_upgrade_reports_redirection.patch1.37 KBMaskOta
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heddn created an issue. See original summary.

heddn’s picture

Title: admin/report/upgrade redirects to dblog, why? » admin/reports/upgrade redirects to dblog, why?
Issue summary: View changes
Issue tags: +Novice

This is tied to the upgrade log report. That seems a little restrictive. Perhaps we should use the same permission already in use for dblog, which is 'access site reports'?

return AccessResultAllowed::allowedIf((int) $account->id() === 1)->mergeCacheMaxAge(0);

Second issue:

    $_SESSION['dblog_overview_filter'] = [];
    $_SESSION['dblog_overview_filter']['type'] = ['migrate_drupal_ui' => 'migrate_drupal_ui'];
    return $this->redirect('dblog.overview');

This might have worked when dblog was still using the '/admin/reports/dblog' and \Drupal\dblog\Controller\DbLogController::overview menu item. But it got converted to a view and this no longer is functional. Instead of this session logic, we can use admin/reports/dblog?type%5B%5D=migrate_drupal_ui

heddn’s picture

Title: admin/reports/upgrade redirects to dblog, why? » admin/reports/upgrade redirect doesn't handle view arguments when enabled
Issue summary: View changes
MaskOta’s picture

heddn’s picture

This actually needs to handle with views and without views. So, let's add a module handler and check if the views is enabled and use one set of arguments. Or the previous arguments if views isn't enabled.

MaskOta’s picture

heddn’s picture

Status: Needs review » Needs work
+++ b/core/modules/migrate_drupal_ui/migrate_drupal_ui.routing.yml
@@ -13,6 +13,6 @@ migrate_drupal_ui.log:
-    _custom_access: '\Drupal\migrate_drupal_ui\MigrateAccessCheck::checkAccess'
+    _permission: 'access site reports'

I think you still need the custom access check. That route will get overwritten by views, so no need to do anything special with the permissions if views is enabled. Otherwise, this looks pretty good.

MaskOta’s picture

I didn't remove the custom access check. I just replaced the one on the reports route with the permission to access site reports. Which seems consistent with the other report routes to me.

migrate_drupal_ui.upgrade:
  path: '/upgrade'
  defaults:
    _form: '\Drupal\migrate_drupal_ui\Form\MigrateUpgradeForm'
    _title: 'Upgrade'
  requirements:
    _custom_access: '\Drupal\migrate_drupal_ui\MigrateAccessCheck::checkAccess'
  options:
    _admin_route: TRUE

migrate_drupal_ui.log:
  path: '/admin/reports/upgrade'
  defaults:
      _controller: '\Drupal\migrate_drupal_ui\Controller\MigrateController::showLog'
  requirements:
     _permission: 'access site reports'
  options:
    _admin_route: TRUE
heddn’s picture

Let's not change that permissions check though.

dev.patrick’s picture

Adding to patch#6 chaining permission and custom_access.

dev.patrick’s picture

Status: Needs work » Needs review
quietone’s picture

Status: Needs review » Needs work

@dev.patrick, thanks for making the patch.

+++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
@@ -16,6 +16,9 @@ class MigrateController extends ControllerBase {
+	if ($this->moduleHandler()->moduleExists('views')) {

Whitespace error. If not aligned.

dev.patrick’s picture

Status: Needs work » Needs review
FileSize
1.44 KB

Thanks @Quietone, corrected white space error.

quietone’s picture

@dev.patrick, your welcome. But...

+++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
@@ -16,6 +16,10 @@ class MigrateController extends ControllerBase {
+	

the pesky whitespace moved to here!

dev.patrick’s picture

My bad. Using windows and has some issue with IDE. Really appreciate if you give another chance.

maxocub’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This looks good. I tested it manually and it works. We should add automated testing, that shouldn't be too hard.

Ivan Berezhnov’s picture

Issue tags: +CSKyiv18

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Chi’s picture

+++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
@@ -16,6 +16,9 @@ class MigrateController extends ControllerBase {
+    if ($this->moduleHandler()->moduleExists('views')) {

This is rather tricky. Even if Views module exists it does not guarantee that the Watchdog view is in place. Users are free to remove/modify any views.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jfurnas’s picture

Would adding another conditional for checking if the view/display is available and enabled help?

heddn’s picture

Probably that would help.

mrweiner’s picture

Added checks to patch from #15 to make sure that:

  • Watchdog view exists
  • Its Page display exists and is active
mrweiner’s picture

Status: Needs work » Needs review

Setting to "Needs Review"

heddn’s picture

Status: Needs review » Needs work

This is looking really nice. Any chance for a functional test with and without that view enabled? NW for tests.

mrweiner’s picture

Do you have any tips on how to structure such a test? I haven't written any tests before.

heddn’s picture

https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial has some details. You can also look at other functional tests in core or google for other tutorials.

mrweiner’s picture

Alright, new patch includes tests, fixes a couple of minor errors, and removes the redundant permission check on the route since it's handled by \Drupal\migrate_drupal_ui\MigrateAccessCheck::checkAccess

mrweiner’s picture

Status: Needs work » Needs review
mrweiner’s picture

mrweiner’s picture

Alright one more try! Removing whitespace

mrweiner’s picture

Adding test group -- I think this should do it.

heddn’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

Thanks for your contribution. Wonderful to see you figured out testing. A few small points to consider below...

  1. +++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
    @@ -16,6 +17,15 @@ class MigrateController extends ControllerBase {
    +          if (isset($page_display['display_options']['enabled']) && $page_display['display_options']['enabled']) {
    

    This could be combined into a !empty check.

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,57 @@
    +  public static $modules = [
    

    This should be protected I think.

  3. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,57 @@
    +  public function testRedirectDestination() {
    ...
    +  public function testRedirectDestinationWithoutView() {
    

    I don't see any asserts in these 2 tests that we are actually seeing filtered results. Which is sorta the intent of this issue.

  4. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,57 @@
    +    $this->testRedirectDestination();
    

    Let's duplicate the code from the test above here. Less coupling in tests is usually better.

vacho’s picture

Some refactor over #33 patch that solve points 1, 2, 4 about #34.

I don't understand well this point please more details:
"3. I don't see any asserts in these 2 tests that we are actually seeing filtered results. Which is sorta the intent of this issue. "

vacho’s picture

FileSize
2.53 KB
heddn’s picture

  1. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,51 @@
    +    // @see MigrateAccessCheck.php
    

    Let's use the class path for the file.

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,51 @@
    +    $this->drupalGet('admin/reports/upgrade');
    +    $this->assertUrl('admin/reports/dblog?type%5B%5D=migrate_drupal_ui');
    

    Here we're testing that we redirect to the view if it is enabled. But we don't have test a for if the view isn't enabled. Could we add a test of the url if the view is disabled too?

mrweiner’s picture

I think we are getting a bit jumbled up, here. Don't have my machine atm but here are some notes.

Here we're testing that we redirect to the view if it is enabled. But we don't have test a for if the view isn't enabled. Could we add a test of the url if the view is disabled too?

You're referencing the assertion in testRedirectDestinationWithoutView() which is the test without the view enabled -- it's being deleted prior to asserting the url. Did you mean to say that we need to add a test with the view enabled?

@vacho, why'd you remove testRedirectDestination()? It could be renamed to testRedirectDestinationWithView(), I suppose, but we need two separate tests in here.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

vsujeetkumar’s picture

Status: Needs work » Needs review
FileSize
4.43 KB
2.42 KB

Changes done according to #37.
@heddn Please review.

quietone’s picture

Status: Needs review » Needs work

Just looking at the documentation.

  1. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,102 @@
    +   * Disable the Watchdog view and then tests whether or not
    +   * the user is redirected when navigating to admin/reports/upgrades
    

    Sentence doesn't span 80 columns correctly and is missing a full stop.

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,102 @@
    +  public function testRedirectDestinationWithDisableView() {
    

    Method needs a summary line.

  3. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,102 @@
    +  public function testRedirectDestinationWithoutView() {
    

    Missing summary line

  4. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,102 @@
    +   * Click a disable link to perform a disable operation on a view.
    

    s/Click/Clicks/

  5. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,102 @@
    +   * @return
    

    Missing return type

  6. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,102 @@
    +   *   The views page content that results from clicking on the disable link, or FALSE on
    

    Line > 80 characters.

  7. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,102 @@
    +   * @param $label
    ...
    +   * @param $href_part
    

    Needs a datatype

vsujeetkumar’s picture

Status: Needs work » Needs review
FileSize
4.73 KB
2.95 KB

Done changes according to #42,
@quietone, Please review.

quietone’s picture

Assigned: Unassigned » quietone

Assigning to myself for review and testing

quietone’s picture

Assigned: quietone » Unassigned
Status: Needs review » Needs work

@vsujeetkumar, thanks for continuing with this.

I think this is missing a test. There are currently two tests, one with the view disabled and one with the view deleted. There needs to be a test with the view enabled.

  1. +++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
    @@ -16,6 +17,15 @@ class MigrateController extends ControllerBase {
    +          if (!empty($page_display['display_options']['enabled'])) {
    +            return $this->redirect('dblog.overview', ['type[]' => 'migrate_drupal_ui']);
    +          }
    

    During manual testing and running MigrateControllerTest the return statement was never reached. Perhaps my testing was not thorough but the tests certainly should be.

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,111 @@
    + * Provides a base class for testing the Migrate Controller.
    

    This is testing the Migrate Controller but it isn't a base class.

  3. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,111 @@
    +    $this->assertResponse(200);
    ...
    +    $this->assertUrl('admin/reports/dblog?type%5B%5D=migrate_drupal_ui');
    

    assertResponse() and assertUrl() are deprecated, Lets use whatever the recommended replacements are.

  4. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,111 @@
    +  public function clickViewsDisableLink($label, $href_part) {
    

    This method is used once which makes we wonder if it is really needed. Plus the return value is not used.

vsujeetkumar’s picture

Status: Needs work » Needs review
FileSize
5.18 KB
3.7 KB

Done the changes advised in #45,

1: Added the test for enable view.
2: updated the class summery.
3: Fixed the deprecated assertResponse() and assertUrl() issues.
4: Rename the method "clickViewsDisableLink" to clickViewsOperationsLink and now it is used in multiple places, Also it is required for disable and enable the view.

@quietone Please review.

vsujeetkumar’s picture

FileSize
3.7 KB

Please ignore the previous interdiff(interdiff_43-46.patch), I have added correct interdiff.

quietone’s picture

Status: Needs review » Needs work

Thanks for the fixes.

This time I looked closer at comments.

  1. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +   * Disable the watchdog view and redirect to the dblog from upgrade path.
    +   *
    +   * Disable the Watchdog view and then tests whether or not the user is
    +   * redirected when navigating to admin/reports/upgrades.
    

    The summary line and the summary are virtually identical. This is a simple test I think a summary line is sufficient. Maybe 'Tests the upgrade path with the watchdog view disabled and enabled.' The summary line should follow the coding standards, Drupal API documentation standards for functions

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +    $this->clickViewsOperationsLink($this->t('Disable'), '/watchdog/');
    

    clickViewsOperationsLink returns a value, why is that not used?

  3. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +    $this->assertSession()->addressEquals('admin/reports/dblog?type%5B%5D=migrate_drupal_ui');
    

    Can the address be a constant?

  4. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +    $this->clickViewsOperationsLink($this->t('Enable'), '/watchdog/');
    

    The last page navigated to was 'admin/reports/upgrade' which does not have an 'Enable' button. Am I missing something?

  5. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +    // Tests whether or not the user is redirected with the enable view when.
    +    // Navigating to admin/reports/upgrades.
    

    It looks like this is supposed to be one sentence, not two. It can be simpler, 'Tests redirection to report page when the watchdog view is enabled.'

  6. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +   * Delete the watchdog view and redirect to the dblog from upgrade path.
    +   *
    +   * Deletes the Watchdog view and then tests whether or not the user is
    +   * redirected when navigating to admin/reports/upgrades.
    

    Same here the summary line and summary are virtually the same.

  7. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +    $this->assertSession()->statusCodeEquals(200);
    

    Is this a sufficient test? Wouldn't it be better to test for ' The view Watchdog has been deleted.'

  8. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +    // Tests whether or not the user is redirected when.
    +    // Navigating to admin/reports/upgrades.
    

    Should be one sentence and wrapped correctly.

  9. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +   * Click a view link to perform an operation.
    

    s/Click/Clicks/

  10. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +   *   Text between the anchor tags of the disable link.
    

    The summary says that this method will 'perform an operation' yet here it specifically says it is a disable link. Which is correct?
    I've reread your comment and I see you changed the name of this method. Why is a name change needed here?

  11. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +   * @return
    

    Needs a return type.

  12. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,119 @@
    +   *   The views page content that results from clicking on the link or,
    +   *   FALSE onfailure.
    

    Not wrapped correctly and change 'onFailure' to 'on failure'. Would be good to add what causes a failure. I don't see that this returns page content, either. Oh, I see, it used to return a boolean TRUE or FALSE. What is the reason for changing that?

quietone’s picture

Status: Needs work » Needs review
FileSize
5.21 KB
4.67 KB

Here is a patch for the points in #48.

Status: Needs review » Needs work

The last submitted patch, 49: 2904546-49.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
FileSize
774 bytes
4.66 KB

Oops, forgot to uncomment a line in the test.

Status: Needs review » Needs work

The last submitted patch, 51: 2904546-51.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review

Random test failure, Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest. Setting back to NR.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now. Thanks for plugging away at this.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 51: 2904546-51.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
2.04 KB
4.39 KB

The failure occurs since #3164686: WebAssert::addressEquals() and AssertLegacyTrait::assertUrl() fail to check the querystring was committed. I have updated the test to reflect that. Tested manually as well.

+++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
@@ -16,6 +17,15 @@ class MigrateController extends ControllerBase {
+    if ($this->moduleHandler()->moduleExists('views')) {
+      if ($view = Views::getView('watchdog')) {
+        if ($page_display = $view->storage->getDisplay('page')) {
+          if (!empty($page_display['display_options']['enabled'])) {

I'm thinking that this can be replaced with

    if ($this->config('views.view.watchdog')->get('status')) {
      return $this->redirect('dblog.overview', ['type[]' => 'migrate_drupal_ui']);
    }

If views is not installed, $this->config('views.view.watchdog')->get('status') returns NULL. This seems a much simpler way to determine if the watchdog view is available.

heddn’s picture

Status: Needs review » Needs work

I agree w/ the change in #56 for status. Did a quick check if we need to worry about a non-existent views config, but it seems that is handled already by config factory, so we're good. This is ready to go back to RTBC, except for a quick nit.

+++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
@@ -3,6 +3,7 @@
+use Drupal\views\Views;

Unused import.

abhisekmazumdar’s picture

Status: Needs work » Needs review
FileSize
4.2 KB
528 bytes

Thank you @quietone for the patch. I have updated the #56 patch as suggested by @heddn.

heddn’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
    @@ -16,6 +16,9 @@ class MigrateController extends ControllerBase {
    +    if ($this->config('views.view.watchdog')->get('status')) {
    +      return $this->redirect('dblog.overview', ['type[]' => 'migrate_drupal_ui']);
    +    }
         $_SESSION['dblog_overview_filter'] = [];
         $_SESSION['dblog_overview_filter']['type'] = ['migrate_drupal_ui' => 'migrate_drupal_ui'];
         return $this->redirect('dblog.overview');
    

    I don't think hardcoding config IDs here is correct. I don't think we should do the if at all. We can do something like:

        // Set both session and a query parameter so both with the watchdog view and
        // the fallback.
        $_SESSION['dblog_overview_filter'] = [];
        $_SESSION['dblog_overview_filter']['type'] = ['migrate_drupal_ui' => 'migrate_drupal_ui'];
        return $this->redirect('dblog.overview', [], ['query' => ['type' => ['migrate_drupal_ui']]]);
    
  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,104 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  protected function setUp(): void {
    +    parent::setUp();
    +
    +    // Log in as user 1. Migrations in the UI can only be performed as user 1.
    +    $this->drupalLogin($this->rootUser);
    +  }
    

    I think we should be creating a message for testing purposes here so we can test that the type is selected - something like:

        // Create a migrate message for testing purposes.
        \Drupal::logger('migrate_drupal_ui')->notice('A test message');
    
  3. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,104 @@
    +  /**
    +   * Tests the upgrade path with the watchdog view disabled and enabled.
    +   */
    +  public function testRedirectDestination() {
    +    // Disable the watchdog view.
    +    $this->drupalGet('admin/structure/views');
    +    $this->assertTrue($this->clickViewsOperationsLink('Disable', '/watchdog/'));
    +    $session = $this->assertSession();
    +    $session->statusCodeEquals(200);
    +
    +    // Tests redirection to report page when the watchdog view is disabled.
    +    $this->drupalGet('admin/reports/upgrade');
    +    $session->addressEquals('admin/reports/dblog');
    +
    +    // Enable the watchdog view.
    +    $this->drupalGet('admin/structure/views');
    +    $this->assertTrue($this->clickViewsOperationsLink('Enable', '/watchdog/'));
    +    $session->statusCodeEquals(200);
    +
    +    // Tests redirection to report page when the watchdog view is enabled.
    +    $this->drupalGet('admin/reports/upgrade');
    +    $session->addressEquals('admin/reports/dblog?type%5B%5D=migrate_drupal_ui');
    +  }
    +
    +  /**
    +   * Tests the upgrade path with the watchdog view deleted.
    +   */
    +  public function testRedirectDestinationWithoutView() {
    +    // Delete the watchdog view.
    +    $this->drupalGet('admin/structure/views/view/watchdog/delete');
    +    $session = $this->assertSession();
    +    $session->statusCodeEquals(200);
    +
    +    $this->submitForm([], 'Delete');
    +    $session->statusCodeEquals(200);
    +    $session->pageTextContains('The view Watchdog has been deleted.');
    +
    +    // Tests whether or not the user is redirected with the view is deleted.
    +    $this->drupalGet('admin/reports/upgrade');
    +    $session->addressEquals('admin/reports/dblog');
    +  }
    

    I don't think we should have 2 tests here. It's not necessary. We should also be testing the whether or not the correct type is selected rather than the URL. I.e. we should be testing what the user wants to see - they don';t care whether it is session or a query parameter is what makes it work.

    So something like:

      /**
       * Tests the upgrade reports with the view enabled, disabled and uninstalled.
       */
      public function testUpgradeReport() {
        $session = $this->assertSession();
    
        $this->assertTrue(View::load('watchdog')->status(), 'Watchdog view is enabled');
        // Tests redirection to report page when the watchdog view is enabled.
        $this->drupalGet('admin/reports/upgrade');
        $session->optionExists('type[]', 'migrate_drupal_ui')->isSelected();
        $session->pageTextContainsOnce('A test message');
    
        // Disable the watchdog view.
        $this->drupalGet('admin/structure/views');
        $this->assertTrue($this->clickViewsOperationsLink('Disable', '/watchdog/'));
        $session->statusCodeEquals(200);
    
        // Tests redirection to report page when the watchdog view is disabled.
        $this->drupalGet('admin/reports/upgrade');
        $session->optionExists('type[]', 'migrate_drupal_ui')->isSelected();
        $session->pageTextContainsOnce('A test message');
    
        \Drupal::service('module_installer')->uninstall(['views_ui', 'views']);
        // Tests redirection to report page when views is uninstalled.
        $this->drupalGet('admin/reports/upgrade');
        $session->optionExists('type[]', 'migrate_drupal_ui')->isSelected();
        $session->pageTextContainsOnce('A test message');
      }
    
msuthars’s picture

Assigned: Unassigned » msuthars

Working on it.

msuthars’s picture

Assigned: msuthars » Unassigned
Status: Needs work » Needs review
FileSize
4.1 KB
4.29 KB

I have updated the #58 patch as suggested by @alexpott.

Status: Needs review » Needs work

The last submitted patch, 62: 2904546-62.patch, failed testing. View results

msuthars’s picture

Status: Needs work » Needs review
quietone’s picture

Status: Needs review » Needs work

I reviewed the patch and the changes suggested in #60 have been made. There are no coding standard errors. So, I though this was ready but then I noticed two problems with the comments.

  1. +++ b/core/modules/migrate_drupal_ui/src/Controller/MigrateController.php
    @@ -16,9 +16,11 @@ class MigrateController extends ControllerBase {
    +    // Set both session and a query parameter so both with the watchdog view and
    +    // the fallback.
    

    This sentence doesn't make sense. Maybe something like 'Set both the session and query parameter so both the watchdog view and the fallback work correctly.' I am not sure

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php
    @@ -0,0 +1,96 @@
    +   * Tests the upgrade reports with the view enabled, disabled and uninstalled.
    

    I think reports should be singular here, or am I wrong? s/reports/report/.

sarvjeetsingh’s picture

Assigned: Unassigned » sarvjeetsingh
sarvjeetsingh’s picture

Assigned: sarvjeetsingh » Unassigned
Status: Needs work » Needs review
FileSize
4.13 KB
1.49 KB

Made changes as per the above suggestions. please review.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now.

alexpott’s picture

Title: admin/reports/upgrade redirect doesn't handle view arguments when enabled » [backport] admin/reports/upgrade redirect doesn't handle view arguments when enabled
Version: 9.1.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed and pushed 0a8bf19ac6 to 9.1.x and 4190ccb3d8 to 9.0.x. Thanks!

I think this worth backporting to 8.9.x as it helps people with migrations.

  • alexpott committed 0a8bf19 on 9.1.x
    Issue #2904546 by mrweiner, vsujeetkumar, quietone, dev.patrick, MaskOta...

  • alexpott committed 4190ccb on 9.0.x
    Issue #2904546 by mrweiner, vsujeetkumar, quietone, dev.patrick, MaskOta...
alexpott’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
FileSize
655 bytes
4.13 KB

Removing the void.

alexpott’s picture

Title: [backport] admin/reports/upgrade redirect doesn't handle view arguments when enabled » admin/reports/upgrade redirect doesn't handle view arguments when enabled
Status: Reviewed & tested by the community » Fixed

Committed 606eae5 and pushed to 8.9.x. Thanks!

  • alexpott committed 606eae5 on 8.9.x
    Issue #2904546 by mrweiner, vsujeetkumar, quietone, dev.patrick, MaskOta...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.