Skip to content

Commit 9956c86

Browse files
Filesystem API: Check for the correct result in some WP_Filesystem_FTPext methods.
This avoids a PHP warning when `::dirlist()` returns `false` under certain conditions: > `Warning: Trying to access array offset on value of type bool in wp-admin/includes/class-wp-filesystem-ftpsockets.php on line 326` Follow-up to [6779], [30678], [45226]. Props apermo, malt3, SergeyBiryukov. Fixes #63474. git-svn-id: https://develop.svn.wordpress.org/trunk@61311 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 76a8f03 commit 9956c86

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/wp-admin/includes/class-wp-filesystem-ftpext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function chmod( $file, $mode = false, $recursive = false ) {
299299
public function owner( $file ) {
300300
$dir = $this->dirlist( $file );
301301

302-
return $dir[ $file ]['owner'];
302+
return $dir[ $file ]['owner'] ?? '';
303303
}
304304

305305
/**
@@ -313,7 +313,7 @@ public function owner( $file ) {
313313
public function getchmod( $file ) {
314314
$dir = $this->dirlist( $file );
315315

316-
return $dir[ $file ]['permsn'];
316+
return $dir[ $file ]['permsn'] ?? '';
317317
}
318318

319319
/**
@@ -327,7 +327,7 @@ public function getchmod( $file ) {
327327
public function group( $file ) {
328328
$dir = $this->dirlist( $file );
329329

330-
return $dir[ $file ]['group'];
330+
return $dir[ $file ]['group'] ?? '';
331331
}
332332

333333
/**

src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function chmod( $file, $mode = false, $recursive = false ) {
309309
public function owner( $file ) {
310310
$dir = $this->dirlist( $file );
311311

312-
return $dir[ $file ]['owner'];
312+
return $dir[ $file ]['owner'] ?? '';
313313
}
314314

315315
/**
@@ -323,7 +323,7 @@ public function owner( $file ) {
323323
public function getchmod( $file ) {
324324
$dir = $this->dirlist( $file );
325325

326-
return $dir[ $file ]['permsn'];
326+
return $dir[ $file ]['permsn'] ?? '';
327327
}
328328

329329
/**
@@ -337,7 +337,7 @@ public function getchmod( $file ) {
337337
public function group( $file ) {
338338
$dir = $this->dirlist( $file );
339339

340-
return $dir[ $file ]['group'];
340+
return $dir[ $file ]['group'] ?? '';
341341
}
342342

343343
/**

0 commit comments

Comments
 (0)