| @@ -129,9 +129,9 @@ | ||
| 129 | 129 | && $wp_filesystem->is_writable($baseDir) |
| 130 | 130 | && $wp_filesystem->move($src, $dest, true) |
| 131 | 131 | ) { |
| 132 | 132 | // Short circuit to prevent file permission errors |
| 133 | - if ($wp_filesystem->chmod($dest, FS_CHMOD_FILE)) { | |
| 133 | + if (acym_chmod($dest, FS_CHMOD_FILE)) { | |
| 134 | 134 | return true; |
| 135 | 135 | } else { |
| 136 | 136 | acym_enqueueMessage(acym_translation('ACYM_FILE_REJECTED_SAFETY_REASON'), 'error'); |
| 137 | 137 | } |
| @@ -188,9 +188,19 @@ | ||
| 188 | 188 | require_once ABSPATH.'wp-admin/includes/file.php'; |
| 189 | 189 | WP_Filesystem(); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return $wp_filesystem->chmod($path, $mode); | |
| 192 | + $applied = $wp_filesystem instanceof \WP_Filesystem_Base && $wp_filesystem->chmod($path, $mode); | |
| 193 | + | |
| 194 | + clearstatcache(true, $path); | |
| 195 | + $currentMode = @fileperms($path); | |
| 196 | + | |
| 197 | + if ($applied && $currentMode !== false && ($currentMode & 0777) === $mode) { | |
| 198 | + return true; | |
| 199 | + } | |
| 200 | + | |
| 201 | + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_chmod -- Fallback | |
| 202 | + return @chmod($path, $mode); | |
| 193 | 203 | } |
| 194 | 204 | |
| 195 | 205 | function acym_deleteFile(string $file): bool |
| 196 | 206 | { |
| @@ -197,9 +207,11 @@ | ||
| 197 | 207 | if (!file_exists($file)) { |
| 198 | 208 | return true; |
| 199 | 209 | } |
| 200 | 210 | |
| 201 | - return wp_delete_file($file); | |
| 211 | + $deleted = wp_delete_file($file); | |
| 212 | + | |
| 213 | + return ($deleted || is_null($deleted)); | |
| 202 | 214 | } |
| 203 | 215 | |
| 204 | 216 | |
| 205 | 217 | function acym_getInternalFileContents(string $path) |