#59406 closed defect (bug) (fixed)
Undefined and unused variable in WP_Test_Stream::mkdir
| Reported by: | david.binda | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.5 |
| Component: | Build/Test Tools | Version: | 5.6 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
The $file variable is undefined in https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/class-wp-test-stream.php?rev=55017#L206
Further, the $plainfile is not being used: https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/class-wp-test-stream.php?rev=55017#L204
Since I haven't been able to find a test which would be using the mkdir method of the stream wrapper, I'm unable to tell what would be the best approach to fix the method, since replacing the $file by $this->file nor by $plaifile does not seem to prevent repeated directory creations.
I'm attaching a patch which, IMHO, makes the method to work, but I'm not sure if it's the best approach.
Attachments (1)
Change History (12)
This ticket was mentioned in PR #5300 on WordPress/wordpress-develop by @sadizaman.
3 years ago
#2
- Keywords has-patch has-unit-tests added
#3
in reply to: ↑ description
@
3 years ago
- Version → 5.6
Thanks for the ticket! Introduced in [49230] / #42663.
Replying to david.binda:
Since I haven't been able to find a test which would be using the mkdir method of the stream wrapper, I'm unable to tell what would be the best approach to fix the method, since replacing the
$fileby$this->filenor by$plaifiledoes not seem to prevent repeated directory creations.
At a glance, it seems like the intention was to prevent directory creation if there is already a file with the same name. However, repeated directory creations should probably be prevented too, that would be consistent with the PHP mkdir() implementation.
So I think the patch may need some adjustment to do both.
This ticket was mentioned in PR #5557 on WordPress/wordpress-develop by @rajinsharwar.
3 years ago
#5
Preventing the creation of duplicate directories of the mkdir() function
Trac ticket: https://core.trac.wordpress.org/ticket/59406
#6
@
3 years ago
- Keywords changes-requested removed
Added the check for duplicate directories as well @SergeyBiryukov in the current patch.
#9
@
3 years ago
- Milestone 6.4 → 6.5
Since it's not a regression in 6.4, I think this ticket can be moved to 6.5 and does not need a backport.
@SergeyBiryukov commented on PR #5300:
3 years ago
#10
Thanks for the PR! Merged in r56998.
@SergeyBiryukov commented on PR #5557:
3 years ago
#11
Thanks for the PR! Merged in r56998.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Trac ticket: 59406
---
This ticket already has a patch. I have just updated the current patch. Looking for suggestion.