Skip to content

Conversation

BrianHenryIE
Copy link
Member

@lipemat opened PR #5947 to address an issue with filenames of premium plugins.

Warning: copy(-.): Failed to open stream: Permission denied

The failure was occurring with:

FileCache::import( 'plugin/advanced-sidebar-menu-pro-9.5.7.', 'C:\Users\box\AppData\Local\Temp/664e5754330ad-TsJObX.tmp' )

Tests with those values passed on MacOS, but Microsoft's documentation says:

Do not end a file or directory name with a space or a period.

https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions

The primary fix for this is to rtrim() the . during FileCache::validate_key(): c38a371, confirmed working: #5947 (comment)

Before realising the root issue, I had added a fix for the error message, 32ba58d, to begin, I needed to add a test for the happy path: 6f0b0e9, and I also added some comments and typehints I needed to debug.

@swissspidy
Copy link
Member

Some of the failing unit tests are addressed by #5950

BrianHenryIE and others added 3 commits May 23, 2024 10:49
@BrianHenryIE
Copy link
Member Author

Hmm... the PHPUnit methods are static methods but the documentation's examples do use the instance $this->.

A regular user of PHPUnit should use $this-> instead of self::

sebastianbergmann/phpunit#1914 (comment)

https://phpunit.de/manual/6.5/en/appendixes.assertions.html#appendixes.assertions.static-vs-non-static-usage-of-assertion-methods

@swissspidy swissspidy changed the title Fix "Warning: copy(-.): Failed to open stream: Permission denied" on Windows where FileCache used filename ending in . Address warnings with filenames ending in fullstop on Windows May 23, 2024
@swissspidy swissspidy added the bug label May 23, 2024
@swissspidy swissspidy added this to the 2.11.0 milestone May 23, 2024
@swissspidy swissspidy merged commit f701f40 into wp-cli:main May 23, 2024
lipemat added a commit to lipemat/wp-cli-bundle that referenced this pull request Jun 6, 2024
The sister pull request was merged which resolved the issue.

wp-cli/wp-cli#5951
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants