[wp-trac] [WordPress Trac] #34976: Plug ins fail to update after WP 4.4 installed
WordPress Trac
noreply at wordpress.org
Sat Dec 12 19:31:03 UTC 2015
#34976: Plug ins fail to update after WP 4.4 installed
----------------------------+--------------------
Reporter: patdundee | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.4.1
Component: Filesystem API | Version: 4.4
Severity: normal | Resolution:
Keywords: | Focuses:
----------------------------+--------------------
Comment (by mensmaximus):
As @Otto42 wrote you can't rely on RFCs. The root cause for the problem is
using dirname( $file ) instead of $file.
WP 4.3.1 is accessing the file or directory directly, e.g.
'/htdocs/.htaccess'. Even if the ftp server does not show hidden files
for ftp_nlist() command by default it returns the filename if you access
it directly.
WP 4.4 is accessing the directory where the file or directory lives. From
the example above '/htdocs' is accessed and ftp_nlist() returns the
content of the directory as exposed by the ftp server. If hidden files are
not shown by default '.htaccess' would be missing.
This is the reason why removing the -a option from 4.4 fails on the
.maintenance while it works in 4.3.1.
I don't know why $wp_filesystem->exists() has been changed in 4.4. If the
goal was to get rid of $wp_filesystem->is_dir() one could have simply used
ftp_size() to check whether $file is a directory as it will always return
-1.
If using dirname( $file ) is the way WP should work from now you need to
test whether you can see hidden files with ftp_nlist() or not by putting a
hidden file to the ftp server before you execute ftp_nlist() and remove it
afterwards. If you don't see the file you have to try it again with the -a
option set.
{{{#!php
<?php
public function exists( $file ) {
$path = dirname( $file );
$filename = basename( $file );
$ftp_file_name = ".tmp_ftp";
$ftp_file_content = "temporary file to evaluate whether the ftp
server returns hidden files by default";
$ftp_file_stream = fopen( 'data://text/plain,' .
$ftp_file_content,'r');
@ftp_fput( $conn, $path . '/' . $ftp_file_name, $ftp_file_stream,
FTP_BINARY);
$file_list = @ftp_nlist( $this->link, $path );
if( !in_array( $ftp_file_name, $file_list, true )) {
$file_list = @ftp_nlist( $this->link, '-a ' . $path );
}
ftp_delete( $conn, $path . '/' . $ftp_file_name );
if ( $file_list ) {
$file_list = array_map( 'basename', $file_list );
}
return $file_list && in_array( $filename, $file_list );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34976#comment:61>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list