#48960 closed defect (bug) (fixed)
failed to open dir: No such file or directory in WIndows
Reported by: | eden159 | Owned by: | azaozz |
---|---|---|---|
Milestone: | 5.3.2 | Priority: | normal |
Severity: | major | Version: | 5.3.1 |
Component: | Media | Keywords: | has-patch fixed-major |
Focuses: | Cc: |
Description (last modified by )
After updating to version 5.3.1 on my Window server I got the following error:
Warning: scandir(C:\Windows\TEMP/,C:\Windows\TEMP/): Zugriff verweigert (code: 5) in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479 Warning: scandir(C:\Windows\TEMP/): failed to open dir: No such file or directory in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479 Warning: scandir(): (errno 2): No such file or directory in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479 Warning: array_diff(): Argument #1 is not an array in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479 Warning: scandir(C:\Windows\TEMP/,C:\Windows\TEMP/): Zugriff verweigert (code: 5) in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479 Warning: scandir(C:\Windows\TEMP/): failed to open dir: No such file or directory in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479 Warning: scandir(): (errno 2): No such file or directory in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479 Warning: array_diff(): Argument #1 is not an array in D:\Data\_iis\intercycle.dev.mxm.ch\wp-includes\functions.php on line 2479
It is trying to access a folder which it does not have access to and it is producing this error.
Attachments (2)
Change History (28)
#4
in reply to:
↑ 1
@
5 years ago
wp_includes has the functions.php with the right permissions. I cannot disable all the plugins since it is a dev server and other people are working on it as well.
Replying to pikamander2:
Does the bug still happen when you disable all of your plugins? (Be sure to make a backup beforehand)
Does your wp-includes folder contain a functions.php file? If so, is it set to the right permissions?
#5
follow-up:
↓ 7
@
5 years ago
Sounds like this is caused by wp_unique_filename()
checking for existing files in the wrong directory: https://core.trac.wordpress.org/browser/tags/5.3.1/src/wp-includes/functions.php#L2473. The warnings can be silenced, but that will "hide" the underlying problem making it harder to find and debug (basically that function doesn't do anything when the directory is not readable).
@eden159 could you give some more details please: when does this happen (during upload, etc.), and if it makes the performed action fail (i.e. an upload would fail).
#7
in reply to:
↑ 5
@
5 years ago
Hi This happens on EVERY page in the ADMIN panel. In the frontend there are no warnings - only in the admin panel and every page.
Replying to azaozz:
Sounds like this is caused by
wp_unique_filename()
checking for existing files in the wrong directory: https://core.trac.wordpress.org/browser/tags/5.3.1/src/wp-includes/functions.php#L2473. The warnings can be silenced, but that will "hide" the underlying problem making it harder to find and debug (basically that function doesn't do anything when the directory is not readable).
@eden159 could you give some more details please: when does this happen (during upload, etc.), and if it makes the performed action fail (i.e. an upload would fail).
#8
@
5 years ago
Looking at this further, it seems caused by unreadable temp directory when using wp_tempnam()
.
In addition wp_tempnam()
seem to be called from a plugin that is (perhaps) writing couple of files to the disk on every wp-admin page load. Not sure why this is needed but it's a pretty bad performance.
To fix this and similar cases perhaps the last filename check in wp_unique_filename()
should be done only when the file is going to be in the uploads dir. In addition, perhaps scandir()
should be silenced as there might be cases where it will fail regardless.
#9
@
5 years ago
- Keywords has-patch needs-testing added; reporter-feedback removed
- Milestone changed from Awaiting Review to 5.3.2
In 48960.diff:
- Only check for "image sub-size like" filenames when the file will be in the uploads dir.
- Silence errors in
scandir()
. - Fix the unit tests to match.
#10
@
5 years ago
- Severity changed from normal to major
Same problem with Linux, see
https://wordpress.org/support/topic/wordpress-5-3-1-error/
This ticket was mentioned in Slack in #forums by clorith. View the logs.
5 years ago
#12
@
5 years ago
48960.diff
looks good to me.
48960.1.diff
just refreshes the patch to use proper Yoda condition.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
5 years ago
#14
@
5 years ago
Same here. Happens when updating themes, plugins or translations. Tested with ALL plugins disabled and Twenty Nineteen theme. A friend of mine and other users have the same problem: https://wordpress.org/support/topic/wordpress-5-3-1-error/
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
5 years ago
#16
@
5 years ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from new to closed
In 46965:
#17
@
5 years ago
- Keywords fixed-major added; needs-testing removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopen for 5.3.2.
#19
follow-up:
↓ 20
@
5 years ago
Hi guys do a great job, I have a suggestion to improve scandir, the code is well commented .. I'm not sure for php 7.4 in doubt I have inserted a comment.
Best wishes for happy holidays and good work.
currently your patch can pass false in array_diff in my example is correct.
<?php // Compatibily with open_basedir $dir_trim = dirname( '/' . preg_replace( '#^((?:[^:]+:)?(?:\\\\|/))?(.*)$#', '$2', rtrim( $dir, '\\/' ) ) . '/' ) !== '/' ? $dir_default = array( '.', '..' ) : $dir_default = array( '.' ); $dir_arr = @scandir( $dir ); if( !$dir_arr ) { //compatibility php 7.4 see https://wiki.php.net/rfc/notice-for-non-valid-array-container unset( $dir_arr ); $dir_arr = $dir_default; } // restore key with start 0 or now array_diff work , previous // scandir without variable not remove dot. $files = array_values( array_diff( $dir_arr, array( '.', '..' ) ) ); unset( $dir_default, $dir_arr, $dir_trim );
#20
in reply to:
↑ 19
@
5 years ago
Replying to autotutorial:
Thanks for the suggestion but not sure the 7.4/E_WARNING for invalid container read array-access is needed here. According to the PHP docs scandir()
returns an array, or false
on error. We are only interested if it is an array (i.e. not false) and if there are any actual file names in it.
It is also limited to only look at the upload dir, which is generally always readable/writable, and scandir()
is silenced in case there are any other edge cases/errors.
#21
follow-up:
↓ 23
@
5 years ago
Thanks for your answer, the problem remains that when it is false it must be converted to an empty array for array_diff otherwise there is a warning for the invalid argument .. expect an array, further array_value recreates the keys starting from 0 otherwise the array starts at 2.
#23
in reply to:
↑ 21
;
follow-up:
↓ 25
@
5 years ago
Replying to autotutorial:
the problem remains that when it is false it must be converted to an empty array...
Right. The if ( ! empty( $files ) )
checks that.
#24
@
5 years ago
Everybody having this problem, please test https://wordpress.org/wordpress-5.3.2-RC1.zip asap if possible. Scheduled for release tomorrow.
#25
in reply to:
↑ 23
;
follow-up:
↓ 26
@
5 years ago
Replying to azaozz:
Replying to autotutorial:
the problem remains that when it is false it must be converted to an empty array...
Right. The
if ( ! empty( $files ) )
checks that.
I got carried away by the enthusiasm I didn't see the change in the patch and I looked at it ten times I realized it when you closed the topic .. sorry.
#26
in reply to:
↑ 25
@
5 years ago
Replying to autotutorial:
NP, thanks for looking at this! Always nice to have more people checking things :)
Does the bug still happen when you disable all of your plugins? (Be sure to make a backup beforehand)
Does your wp-includes folder contain a functions.php file? If so, is it set to the right permissions?