PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.6.1
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.6.1
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
← All changes | classes/Base/Upgrade.php +33 -7 2.0.22.6.1 View file →
@@ -10,8 +10,11 @@
10 10 namespace ContentControl\Base;
11 11
12 12 defined( 'ABSPATH' ) || exit;
13 13
14 +use Closure;
15 +use stdClass;
16 +
14 17 /**
15 18 * Base Upgrade class.
16 19 */
17 20 abstract class Upgrade implements \ContentControl\Interfaces\Upgrade {
@@ -32,9 +35,9 @@
32 35
33 36 /**
34 37 * Stream.
35 38 *
36 - * @var \ContentControl\Services\UpgradeStream
39 + * @var \ContentControl\Services\UpgradeStream|null
37 40 */
38 41 public $stream;
39 42
40 43 /**
@@ -98,9 +101,9 @@
98 101
99 102 /**
100 103 * Run the upgrade.
101 104 *
102 - * @return void|WP_Error|false
105 + * @return void|\WP_Error|false
103 106 */
104 107 abstract public function run();
105 108
106 109 /**
@@ -107,9 +110,9 @@
107 110 * Run the upgrade.
108 111 *
109 112 * @param \ContentControl\Services\UpgradeStream $stream Stream.
110 113 *
111 - * @return void|WP_Error|false
114 + * @return bool|\WP_Error
112 115 */
113 116 public function stream_run( $stream ) {
114 117 $this->stream = $stream;
115 118
@@ -116,20 +119,43 @@
116 119 $return = $this->run();
117 120
118 121 unset( $this->stream );
119 122
120 - return $return;
123 + if ( is_bool( $return ) || is_wp_error( $return ) ) {
124 + return $return;
125 + }
126 +
127 + return true;
121 128 }
122 129
123 130 /**
124 131 * Return the stream.
125 132 *
126 - * @return \ContentControl\Services\UpgradeStream|Object $stream Stream.
133 + * If no stream is available it returns a mock object with no-op methods to prevent errors.
134 + *
135 + * @return \ContentControl\Services\UpgradeStream|(object{
136 + * send_event: Closure,
137 + * send_error: Closure,
138 + * send_data: Closure,
139 + * update_status: Closure,
140 + * update_task_status: Closure,
141 + * start_upgrades: Closure,
142 + * complete_upgrades: Closure,
143 + * start_task: Closure,
144 + * update_task_progress:Closure,
145 + * complete_task: Closure
146 + * }&\stdClass) Stream.
127 147 */
128 148 public function stream() {
129 - $noop = function () {};
149 + $noop =
150 + /**
151 + * No-op.
152 + *
153 + * @return void
154 + */
155 + function () {};
130 156
131 - return isset( $this->stream ) ? $this->stream : (object) [
157 + return is_a( $this->stream, '\ContentControl\Services\UpgradeStream' ) ? $this->stream : (object) [
132 158 'send_event' => $noop,
133 159 'send_error' => $noop,
134 160 'send_data' => $noop,
135 161 'update_status' => $noop,