mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Correct the WP_Test_Stream::mkdir() method.
The method attempted to check if there is already a file with the same name, however the conditional used an undefined variable. This commit prevents directory creation if a file or directory with the same name already exists, bringing consistency with the PHP `mkdir()` implementation. Includes adding missing documentation for the method. Reference: [https://www.php.net/manual/en/streamwrapper.mkdir.php PHP Manual: streamWrapper::mkdir()]. Follow-up to [49230]. Props david.binda, sadizaman, rajinsharwar, SergeyBiryukov. Fixes #59406. git-svn-id: https://develop.svn.wordpress.org/trunk@56998 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
88ab0a2c57
commit
c438bebad1
@ -198,16 +198,27 @@ class WP_Test_Stream {
|
||||
* Creates a directory.
|
||||
*
|
||||
* @see streamWrapper::mkdir
|
||||
*
|
||||
* @param string $path Directory which should be created.
|
||||
* @param int $mode The value passed to mkdir().
|
||||
* @param int $options A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function mkdir( $path, $mode, $options ) {
|
||||
$this->open( $path );
|
||||
|
||||
$plainfile = rtrim( $this->file, '/' );
|
||||
|
||||
if ( isset( WP_Test_Stream::$data[ $this->bucket ][ $file ] ) ) {
|
||||
// Check if a file or directory with the same name already exists.
|
||||
if ( isset( WP_Test_Stream::$data[ $this->bucket ][ $plainfile ] )
|
||||
|| isset( WP_Test_Stream::$data[ $this->bucket ][ $plainfile . '/' ] )
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dir_ref = & $this->get_directory_ref();
|
||||
$dir_ref = 'DIRECTORY';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user