Problem/Motivation
Remove unused variable $result from MoveTest. There are couple of instances
try {
$result = $this->fileRepository->move(clone $source, $source->getFileUri(), FileSystemInterface::EXISTS_ERROR);
$this->fail('expected FileExistsException');
}
try {
$result = $this->fileRepository->move(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_ERROR);
$this->fail('expected FileExistsException');
}
Steps to reproduce
Proposed resolution
Remaining tasks
Investigate the history of the variable. Why was it added and what happened that made it unused.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3331212-nr-bot.txt | 150 bytes | needs-review-queue-bot |
| #7 | MoveTest_Success_Execution.png | 14.84 KB | anup.sinha |
| #4 | 3331212-removed-unused-variable.patch | 1.28 KB | prabuela |
Issue fork drupal-3331212
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3331212-remove-unused-variable
changes, plain diff MR !3230
Comments
Comment #2
anmolgoyal74 commentedComment #3
prabuela commentedComment #4
prabuela commentedThe unused variable are removed from the file.
Comment #5
prabuela commentedComment #7
anup.sinha commentedHi All,
I have reviewed the changes and it looks good to me. I have executed the kernel "MoveTest" after applying the patch in my local setup and it ran successfully. PFA the screenshot(MoveTest_Success_Execution.png) of the test execution.
Thanks & Regards,
Anup
Comment #8
quietone commentedThe code change looks correct. However, when removing an unused variable we should look in to the history. The variable may have been used in the past and perhaps it still should be. Why was the usage removed? Have we lost some test coverage?
Setting needs works for investigation into the history of $result.
Comment #9
anup.sinha commentedHi @quietone,
Old code in 9.2.x branch:
// Copy the file over itself. Clone the object so we don't have to worry
// about the function changing our reference copy.
$result = file_move(clone $source, $source->uri, FILE_EXISTS_REPLACE);
$this->assertFalse($result, t('File move failed.'));
$this->assertEqual($contents, file_get_contents($source->uri), t('Contents of file were not altered.'));
The file was changed in 9.3.x release in this commit - https://git.drupalcode.org/project/drupal/-/commit/64074071d1c78274df253...
Issue link - https://www.drupal.org/project/drupal/issues/3223209
Here deprecated file_move() function was replaced with service method fileRepository->move(). Now earlier there was an assertFalse() as file_move() function returns TRUE/FALSE but the new service move() function either returns the File entity or throws exception in case of errors. So we cannot use the old assertFalse() check anymore.
So as per my analysis current patch is fine as no test coverage is removed. Request you to check the mentioned commit and let me know please if there is any observation.
Thanks & Regards,
Anup
Comment #10
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #11
anup.sinha commentedHi @Prabu,
The automated test bot actually tried to test your merge request instead of the patch. As a a result it failed as there are no changes in that merge request. So request you to close that merge request if you are not planning to use it and put the issue status to needs review.
Thanks & Regards,
Anup
Comment #13
prabuela commentedComment #14
longwaveThanks for the analysis in #9. We no longer need the variable now we have an exception, so this is change is correct and ready to commit.
Comment #16
catchCommitted/pushed to 10.1.x, thanks!