Problem/Motivation

In core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php, $assert_session variable never used.

Comments

shetpooja04 created an issue. See original summary.

shetpooja04’s picture

Assigned: shetpooja04 » Unassigned
Status: Active » Needs review
StatusFileSize
new766 bytes
new649.9 KB

Commit ID: 5d95f2e1

Link: https://git.drupalcode.org/project/drupal/-/commit/5d95f2e177facb2895153ae68619e042f72b93a2

File: core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php Line: 417

For Issue: https://www.drupal.org/project/drupal/issues/3136668 the variable is added but not used

Please review

meena.bisht’s picture

Assigned: Unassigned » meena.bisht
meena.bisht’s picture

Status: Needs review » Needs work

As , unable to find use of $this->assertSession();. So putting it back to needs work.

meena.bisht’s picture

Assigned: meena.bisht » Unassigned
Status: Needs work » Needs review
StatusFileSize
new737 bytes

Uploading patch , removing $this->assertSession();.

ranjith_kumar_k_u’s picture

The above patch looks good,the variable "$assert_session" is not used anywhere in the testOrphanedSchemaEntries() function ,so there is no need of "$this->assertSession();" also.RTBC

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

sulfikar_s’s picture

The above patch applied cleanly on 9.2.x-dev. The variable "$assert_session" is not used under the function testOrphanedSchemaEntries(). So removing the line is the better option. Appreciate your research !.

Changing the status to RTBC.

sulfikar_s’s picture

Status: Needs review » Reviewed & tested by the community

  • xjm committed 9a6f2d1 on 9.2.x
    Issue #3173891 by shetpooja04, meena.bisht: Remove unused variable $...

  • xjm committed d8e5196 on 9.1.x
    Issue #3173891 by shetpooja04, meena.bisht: Remove unused variable $...

  • xjm committed ccf9f34 on 9.0.x
    Issue #3173891 by shetpooja04, meena.bisht: Remove unused variable $...
xjm’s picture

Version: 9.2.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks @shetpooja04 for documenting the issue that added the variable and showing that it was unused from the start. It's probable that the author planned to use it for assertions but the test did not end up requiring it. We definitely need that information when we commit these.

@meena.bisht's fix is also correct here. $this->assertSession() doesn't do anything on its own; it's just a getter for a new WebAssert session. Reference: https://api.drupal.org/api/drupal/vendor%21behat%21mink%21src%21Mink.php...

@sulfikar_s and @ranjith_kumar_k_u, in the future, you can provide additional help out by verifying the information about when the variable was added and how it ended up unused, like the info that @shetpooja04 provided and anything else you can discover. (It won't always be in a single issue). That's information we use to make sure these unused variables aren't hiding bugs. It's important not just that it's unused, but why.

As a removal of dead code and test fix, this issue is backportable to the production branch. So, committed to 9.2.x, and backported to 9.1.x and 9.0.x (to keep the branches closer together). I did not backport to 8.9.x at this time but will queue an 8.9.x test run to see if the patch can be backported there as well.

Thanks!

catch’s picture

Version: 8.9.x-dev » 9.0.x-dev
Status: Patch (to be ported) » Fixed

8.9.x is security only now, so moving this to fixed against 9.0.x

Status: Fixed » Closed (fixed)

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