PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
media-cloud-sync / includes / base / stream-wrappers / readonly-trait.php

readonly-trait.php in Media Cloud Sync 1.4.2, at includes/base/stream-wrappers/readonly-trait.php

52 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Dudlewebs\WPMCS;
3
4 defined('ABSPATH') || exit;
5
6 /**
7 * Removes write/enumeration capability from a vendor stream wrapper class —
8 * `use`d by ReadOnlyS3StreamWrapper and ReadOnlyGcsStreamWrapper, each still
9 * extending its own real vendor parent for read support.
10 *
11 * @since 1.4.3
12 */
13 trait ReadOnlyStreamWrapperTrait {
14 public function stream_open($path, $mode, $options, &$opened_path) {
15 if (!in_array($mode, ['r', 'rb'], true)) {
16 return false;
17 }
18 // parent:: resolves to whichever vendor class the using class actually extends.
19 return parent::stream_open($path, $mode, $options, $opened_path);
20 }
21
22 public function unlink($path) {
23 return false;
24 }
25
26 public function rename($path_from, $path_to) {
27 return false;
28 }
29
30 public function mkdir($path, $mode, $options) {
31 return false;
32 }
33
34 public function rmdir($path, $options) {
35 return false;
36 }
37
38 public function stream_metadata($path, $option, $value) {
39 return false;
40 }
41
42 /** dir_readdir()/dir_closedir()/dir_rewinddir() need no override — PHP never reaches them once opendir() itself fails. */
43 public function dir_opendir($path, $options) {
44 return false;
45 }
46
47 /** Defense in depth — stream_open()'s mode check should already make this unreachable. */
48 public function stream_write($data) {
49 return 0;
50 }
51 }
52