PluginProbe
WPIDE – File Manager & Code Editor / trunk
WPIDE – File Manager & Code Editor vtrunk
3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 3.4 All 54 releases
← All changes | wp-content/fatal-error-handler.php +22 -7 3.1trunk View file →
@@ -13,11 +13,15 @@
13 13 protected static $backupDir = '/wpide/backups/';
14 14
15 15 public static function boot()
16 16 {
17 - register_shutdown_function([__CLASS__, 'shutdownHandler']);
18 - set_exception_handler([__CLASS__, 'exceptionHandler']);
19 - set_error_handler([__CLASS__, 'errorHandler']);
17 +
18 + if (version_compare(PHP_VERSION, '7.4.0', '>=')) {
19 +
20 + register_shutdown_function([__CLASS__, 'shutdownHandler']);
21 + set_exception_handler([__CLASS__, 'exceptionHandler']);
22 + set_error_handler([__CLASS__, 'errorHandler']);
23 + }
20 24 }
21 25
22 26 public static function isPluginScreen(): bool
23 27 {
@@ -47,9 +51,8 @@
47 51 }
48 52
49 53 public static function exceptionHandler(Throwable $exception)
50 54 {
51 -
52 55 self::errorHandler(-1, $exception->getMessage(), $exception->getFile(), $exception->getLine());
53 56 }
54 57
55 58 public static function errorHandler($error_type, $error_message, $error_file, $error_line)
@@ -58,8 +61,14 @@
58 61 if (!$error_type) {
59 62 return;
60 63 }
61 64
65 + // Respect the active error_reporting mask so @-suppressed warnings
66 + // and globally filtered notices do not get re-logged by this handler.
67 + if (-1 !== $error_type && 0 === (error_reporting() & $error_type)) {
68 + return false;
69 + }
70 +
62 71 $fatal = false;
63 72
64 73 switch ($error_type) {
65 74
@@ -138,9 +147,9 @@
138 147 $lockfile = self::backupDir().'.lock';
139 148 $backup_file = self::findBackupFile($error_file);
140 149
141 150 // If backup exists
142 - if (file_exists($backup_file)) {
151 + if (!empty($backup_file) && file_exists($backup_file)) {
143 152
144 153 if (ob_get_length()) ob_end_clean();
145 154
146 155 // If on admin side, show file recovery wizard
@@ -209,10 +218,16 @@
209 218
210 219 public static function findBackupFile($error_file): ?string
211 220 {
212 221
222 + $backupFolders = scandir(self::backupDir());
223 +
224 + if(empty($backupFolders)) {
225 + return null;
226 + }
227 +
213 228 // Get backup folders
214 - $backupFolders = array_filter(scandir(self::backupDir()), function ($folder) {
229 + $backupFolders = array_filter($backupFolders, function ($folder) {
215 230
216 231 if ($folder === '.' || $folder === '..') {
217 232 return false;
218 233 }
@@ -868,5 +883,5 @@
868 883 }
869 884 }
870 885
871 886 WPIDE_Error_Handler::boot();
872 -}
887 +}