PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.9.4
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.9.4
4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / Traits / SafeFileInfoTrait.php
wp-staging / Framework / Traits Last commit date
ApplyFiltersTrait.php 2 months ago ArrayableTrait.php 7 months ago BatchSizeCalculateTrait.php 7 months ago BearerTokenTrait.php 5 months ago BenchmarkTrait.php 3 years ago BooleanTransientTrait.php 5 years ago DatabaseSearchReplaceTrait.php 1 month ago DbRowsGeneratorTrait.php 4 years ago DebugLogTrait.php 1 year ago DeveloperTimerTrait.php 9 months ago EndOfLinePlaceholderTrait.php 1 year ago EventLoggerTrait.php 2 months ago FileScanToCacheTrait.php 2 days ago FormatTrait.php 1 year ago HttpRequestTrait.php 9 months ago HydrateTrait.php 1 year ago I18nTrait.php 1 year ago IpResolverTrait.php 11 months ago MaintenanceTrait.php 6 months ago MemoryExhaustTrait.php 2 years ago MySQLRowsGeneratorTrait.php 7 months ago NoticesTrait.php 2 days ago PropertyConstructor.php 5 years ago RenameTmpDirectoryTrait.php 6 months ago ResourceTrait.php 5 months ago RestRequestTrait.php 4 months ago RestoreFileExclusionTrait.php 1 year ago SafeFileInfoTrait.php 2 days ago SerializeTrait.php 1 year ago SetTimeLimitTrait.php 2 months ago SlashTrait.php 1 year ago SqlCommentTrait.php 4 months ago TablePrefixValidator.php 4 months ago UrlTrait.php 1 year ago ValueGetterTrait.php 2 years ago WindowsOsTrait.php 1 year ago
SafeFileInfoTrait.php
82 lines
1 <?php
2
3 namespace WPStaging\Framework\Traits;
4
5 use RuntimeException;
6 use SplFileInfo;
7
8 use function WPStaging\functions\debug_log;
9
10 /**
11 * Wraps SplFileInfo stat calls that can throw a RuntimeException when
12 * open_basedir restrictions block access to the path being inspected.
13 */
14 trait SafeFileInfoTrait
15 {
16 /**
17 * @param SplFileInfo $item
18 * @return bool|null Null when open_basedir blocks the check.
19 */
20 protected function isLinkSafely(SplFileInfo $item)
21 {
22 try {
23 return $item->isLink();
24 } catch (RuntimeException $openBaseDirException) {
25 $this->logInaccessiblePath($item, $openBaseDirException);
26 return null;
27 }
28 }
29
30 /**
31 * @param SplFileInfo $item
32 * @return bool|null Null when open_basedir blocks the check.
33 */
34 protected function isFileSafely(SplFileInfo $item)
35 {
36 try {
37 return $item->isFile();
38 } catch (RuntimeException $openBaseDirException) {
39 $this->logInaccessiblePath($item, $openBaseDirException);
40 return null;
41 }
42 }
43
44 /**
45 * @param SplFileInfo $item
46 * @return bool|null Null when open_basedir blocks the check.
47 */
48 protected function isDirSafely(SplFileInfo $item)
49 {
50 try {
51 return $item->isDir();
52 } catch (RuntimeException $openBaseDirException) {
53 $this->logInaccessiblePath($item, $openBaseDirException);
54 return null;
55 }
56 }
57
58 /**
59 * @param SplFileInfo $item
60 * @return string|false False when open_basedir blocks the check or the target is unresolvable.
61 */
62 protected function getRealPathSafely(SplFileInfo $item)
63 {
64 try {
65 return $item->getRealPath();
66 } catch (RuntimeException $openBaseDirException) {
67 $this->logInaccessiblePath($item, $openBaseDirException);
68 return false;
69 }
70 }
71
72 /**
73 * @param SplFileInfo $item
74 * @param RuntimeException $exception
75 * @return void
76 */
77 protected function logInaccessiblePath(SplFileInfo $item, RuntimeException $exception)
78 {
79 debug_log('WP STAGING: Skipping inaccessible path during scan: ' . $item->getPathname() . ' - ' . $exception->getMessage());
80 }
81 }
82