← All changes
|
jetpack_vendor/automattic/jetpack-sync/src/modules/class-constants.php
+23
-6
13.6.2
→
16.3-beta
View file →
| @@ -8,8 +8,12 @@ | ||
| 8 | 8 | namespace Automattic\Jetpack\Sync\Modules; |
| 9 | 9 | |
| 10 | 10 | use Automattic\Jetpack\Sync\Defaults; |
| 11 | 11 | |
| 12 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 13 | + exit( 0 ); | |
| 14 | +} | |
| 15 | + | |
| 12 | 16 | /** |
| 13 | 17 | * Class to handle sync for constants. |
| 14 | 18 | */ |
| 15 | 19 | class Constants extends Module { |
| @@ -27,8 +31,15 @@ | ||
| 27 | 31 | */ |
| 28 | 32 | const CONSTANTS_AWAIT_TRANSIENT_NAME = 'jetpack_sync_constants_await'; |
| 29 | 33 | |
| 30 | 34 | /** |
| 35 | + * Constants whitelist array. | |
| 36 | + * | |
| 37 | + * @var array | |
| 38 | + */ | |
| 39 | + public $constants_whitelist; | |
| 40 | + | |
| 41 | + /** | |
| 31 | 42 | * Sync module name. |
| 32 | 43 | * |
| 33 | 44 | * @access public |
| 34 | 45 | * |
| @@ -138,19 +149,25 @@ | ||
| 138 | 149 | * |
| 139 | 150 | * @access public |
| 140 | 151 | * |
| 141 | 152 | * @param array $config Full sync configuration for this sync module. |
| 153 | + * @param array $status This module Full Sync status. | |
| 142 | 154 | * @param int $send_until The timestamp until the current request can send. |
| 143 | - * @param array $state This module Full Sync status. | |
| 155 | + * @param int $started The timestamp when the full sync started. | |
| 144 | 156 | * |
| 145 | 157 | * @return array This module Full Sync status. |
| 146 | 158 | */ |
| 147 | - public function send_full_sync_actions( $config, $send_until, $state ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 159 | + public function send_full_sync_actions( $config, $status, $send_until, $started ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 148 | 160 | // we call this instead of do_action when sending immediately. |
| 149 | - $this->send_action( 'jetpack_full_sync_constants', array( true ) ); | |
| 161 | + $result = $this->send_action( 'jetpack_full_sync_constants', array( true ) ); | |
| 150 | 162 | |
| 151 | - // The number of actions enqueued, and next module state (true == done). | |
| 152 | - return array( 'finished' => true ); | |
| 163 | + if ( is_wp_error( $result ) ) { | |
| 164 | + $status['error'] = true; | |
| 165 | + return $status; | |
| 166 | + } | |
| 167 | + $status['finished'] = true; | |
| 168 | + $status['sent'] = $status['total']; | |
| 169 | + return $status; | |
| 153 | 170 | } |
| 154 | 171 | |
| 155 | 172 | /** |
| 156 | 173 | * Retrieve an estimated number of actions that will be enqueued. |
| @@ -158,9 +175,9 @@ | ||
| 158 | 175 | * @access public |
| 159 | 176 | * |
| 160 | 177 | * @param array $config Full sync configuration for this sync module. |
| 161 | 178 | * |
| 162 | - * @return array Number of items yet to be enqueued. | |
| 179 | + * @return int Number of items yet to be enqueued. | |
| 163 | 180 | */ |
| 164 | 181 | public function estimate_full_sync_actions( $config ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 165 | 182 | return 1; |
| 166 | 183 | } |