| 1 |
<?php |
| 2 |
/** |
| 3 |
* WP-CLI deprecated commands for ElasticPress |
| 4 |
* |
| 5 |
* @since 4.4.0 |
| 6 |
* @package elasticpress |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace ElasticPress; |
| 10 |
|
| 11 |
use WP_CLI; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
// @codeCoverageIgnoreStart |
| 15 |
exit; // Exit if accessed directly. |
| 16 |
// @codeCoverageIgnoreEnd |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Deprecated CLI Commands for ElasticPress |
| 21 |
*/ |
| 22 |
trait DeprecatedCommand { |
| 23 |
|
| 24 |
/** |
| 25 |
* DEPRECATED. Return all index names as a JSON object. |
| 26 |
* |
| 27 |
* This command is deprecated. Please use `get-indices` instead. |
| 28 |
* |
| 29 |
* ## OPTIONS |
| 30 |
* |
| 31 |
* [--pretty] |
| 32 |
* : Use this flag to render a pretty-printed version of the JSON response. |
| 33 |
* |
| 34 |
* @subcommand get-indexes |
| 35 |
* @since 3.2, `--pretty` introduced in 4.1.0 |
| 36 |
* @param array $args Positional CLI args. |
| 37 |
* @param array $assoc_args Associative CLI args. |
| 38 |
* @deprecated 4.4.0 |
| 39 |
* @see Command\get_indices() |
| 40 |
*/ |
| 41 |
public function get_indexes( $args, $assoc_args ) { |
| 42 |
_deprecated_function( 'get-indexes', '4.4.0', 'get-indices' ); |
| 43 |
WP_CLI::warning( |
| 44 |
sprintf( |
| 45 |
/* translators: New command name */ |
| 46 |
esc_html__( 'This command is deprecated. Please use %s instead.', 'elasticpress' ), |
| 47 |
'get-indices' |
| 48 |
) |
| 49 |
); |
| 50 |
$this->get_indices( $args, $assoc_args ); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* DEPRECATED. Return all indexes from the cluster as a JSON object. |
| 55 |
* |
| 56 |
* This command is deprecated. Please use `get-cluster-indices` instead. |
| 57 |
* |
| 58 |
* ## OPTIONS |
| 59 |
* |
| 60 |
* [--pretty] |
| 61 |
* : Use this flag to render a pretty-printed version of the JSON response. |
| 62 |
* |
| 63 |
* @subcommand get-cluster-indexes |
| 64 |
* @since 3.2, `--pretty` introduced in 4.1.0 |
| 65 |
* @param array $args Positional CLI args. |
| 66 |
* @param array $assoc_args Associative CLI args. |
| 67 |
* @deprecated 4.4.0 |
| 68 |
* @see Command\get_cluster_indices() |
| 69 |
*/ |
| 70 |
public function get_cluster_indexes( $args, $assoc_args ) { |
| 71 |
_deprecated_function( 'get-cluster-indexes', '4.4.0', 'get-cluster-indices' ); |
| 72 |
WP_CLI::warning( |
| 73 |
sprintf( |
| 74 |
/* translators: New command name */ |
| 75 |
esc_html__( 'This command is deprecated. Please use %s instead.', 'elasticpress' ), |
| 76 |
'get-cluster-indices' |
| 77 |
) |
| 78 |
); |
| 79 |
$this->get_cluster_indices( $args, $assoc_args ); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* DEPRECATED. Index all posts for a site or network wide. |
| 84 |
* |
| 85 |
* This command is deprecated. Please use `sync` instead. |
| 86 |
* |
| 87 |
* ## OPTIONS |
| 88 |
* |
| 89 |
* [--network-wide] |
| 90 |
* : Force indexing on all the blogs in the network. `--network-wide` takes an optional argument to limit the number of blogs to be indexed across where 0 is no limit. For example, `--network-wide=5` would limit indexing to only 5 blogs on the network |
| 91 |
* |
| 92 |
* [--setup] |
| 93 |
* : Clear the index first and re-send the put mapping. Use `--yes` to skip the confirmation |
| 94 |
* |
| 95 |
* [--per-page=<per_page_number>] |
| 96 |
* : Determine the amount of posts to be indexed per bulk index (or cycle) |
| 97 |
* |
| 98 |
* [--nobulk] |
| 99 |
* : Disable bulk indexing |
| 100 |
* |
| 101 |
* [--static-bulk] |
| 102 |
* : Do not use dynamic bulk requests, i.e., send only one request per batch of documents. |
| 103 |
* |
| 104 |
* [--show-errors] |
| 105 |
* : Show all errors |
| 106 |
* |
| 107 |
* [--show-bulk-errors] |
| 108 |
* : Display the error message returned from Elasticsearch when a post fails to index using the /_bulk endpoint |
| 109 |
* |
| 110 |
* [--show-nobulk-errors] |
| 111 |
* : Display the error message returned from Elasticsearch when a post fails to index while not using the /_bulk endpoint |
| 112 |
* |
| 113 |
* [--offset=<offset_number>] |
| 114 |
* : Skip the first n posts (don't forget to remove the `--setup` flag when resuming or the index will be emptied before starting again). |
| 115 |
* |
| 116 |
* [--indexables=<indexables>] |
| 117 |
* : Specify the Indexable(s) which will be indexed |
| 118 |
* |
| 119 |
* [--post-type=<post_types>] |
| 120 |
* : Specify which post types will be indexed (by default: all indexable post types are indexed). For example, `--post-type="my_custom_post_type"` would limit indexing to only posts from the post type "my_custom_post_type". Accepts multiple post types separated by comma |
| 121 |
* |
| 122 |
* [--include=<IDs>] |
| 123 |
* : Choose which object IDs to include in the index |
| 124 |
* |
| 125 |
* [--post-ids=<IDs>] |
| 126 |
* : Choose which post_ids to include when indexing the Posts Indexable (deprecated) |
| 127 |
* |
| 128 |
* [--upper-limit-object-id=<ID>] |
| 129 |
* : Upper limit of a range of IDs to be indexed. If indexing IDs from 30 to 45, this should be 45 |
| 130 |
* |
| 131 |
* [--lower-limit-object-id=<ID>] |
| 132 |
* : Lower limit of a range of IDs to be indexed. If indexing IDs from 30 to 45, this should be 30 |
| 133 |
* |
| 134 |
* [--ep-host=<host>] |
| 135 |
* : Custom Elasticsearch host |
| 136 |
* |
| 137 |
* [--ep-prefix=<prefix>] |
| 138 |
* : Custom ElasticPress prefix |
| 139 |
* |
| 140 |
* [--yes] |
| 141 |
* : Skip confirmation needed by `--setup` |
| 142 |
* |
| 143 |
* @param array $args Positional CLI args. |
| 144 |
* @since 0.1.2 |
| 145 |
* @param array $assoc_args Associative CLI args. |
| 146 |
* @deprecated 4.4.0 |
| 147 |
* @see Command\sync() |
| 148 |
*/ |
| 149 |
public function index( $args, $assoc_args ) { |
| 150 |
_deprecated_function( 'index', '4.4.0', 'sync' ); |
| 151 |
WP_CLI::warning( |
| 152 |
sprintf( |
| 153 |
/* translators: New command name */ |
| 154 |
esc_html__( 'This command is deprecated. Please use %s instead.', 'elasticpress' ), |
| 155 |
'sync' |
| 156 |
) |
| 157 |
); |
| 158 |
$this->sync( $args, $assoc_args ); |
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* DEPRECATED. Clear a sync/index process. |
| 163 |
* |
| 164 |
* This command is deprecated. Please use `clear-sync` instead. |
| 165 |
* |
| 166 |
* If an index was stopped prematurely and won't start again, this will clear this cached data such that a new index can start. |
| 167 |
* |
| 168 |
* @subcommand clear-index |
| 169 |
* @param array $args Positional CLI args. |
| 170 |
* @param array $assoc_args Associative CLI args. |
| 171 |
* @since 3.4 |
| 172 |
* @deprecated 4.4.0 |
| 173 |
* @see Command\clear_sync() |
| 174 |
*/ |
| 175 |
public function clear_index( $args, $assoc_args ) { |
| 176 |
_deprecated_function( 'clear-index', '4.4.0', 'clear-sync' ); |
| 177 |
WP_CLI::warning( |
| 178 |
sprintf( |
| 179 |
/* translators: New command name */ |
| 180 |
esc_html__( 'This command is deprecated. Please use %s instead.', 'elasticpress' ), |
| 181 |
'clear-sync' |
| 182 |
) |
| 183 |
); |
| 184 |
$this->clear_sync( $args, $assoc_args ); |
| 185 |
} |
| 186 |
|
| 187 |
/** |
| 188 |
* DEPRECATED. Returns the status of an ongoing index operation in JSON array. |
| 189 |
* |
| 190 |
* This command is deprecated. Please use `get-ongoing-sync-status` instead. |
| 191 |
* |
| 192 |
* Returns the status of an ongoing index operation in JSON array with the following fields: |
| 193 |
* indexing | boolean | True if index operation is ongoing or false |
| 194 |
* method | string | 'cli', 'web' or 'none' |
| 195 |
* items_indexed | integer | Total number of items indexed |
| 196 |
* total_items | integer | Total number of items indexed or -1 if not yet determined |
| 197 |
* |
| 198 |
* ## OPTIONS |
| 199 |
* |
| 200 |
* [--pretty] |
| 201 |
* : Use this flag to render a pretty-printed version of the JSON response. |
| 202 |
* |
| 203 |
* @subcommand get-indexing-status |
| 204 |
* @since 3.5.1, `--pretty` introduced in 4.1.0 |
| 205 |
* @param array $args Positional CLI args. |
| 206 |
* @param array $assoc_args Associative CLI args. |
| 207 |
* @deprecated 4.4.0 |
| 208 |
* @see Command\get_ongoing_sync_status() |
| 209 |
*/ |
| 210 |
public function get_indexing_status( $args, $assoc_args ) { |
| 211 |
_deprecated_function( 'get-indexing-status', '4.4.0', 'get-ongoing-sync-status' ); |
| 212 |
WP_CLI::warning( |
| 213 |
sprintf( |
| 214 |
/* translators: New command name */ |
| 215 |
esc_html__( 'This command is deprecated. Please use %s instead.', 'elasticpress' ), |
| 216 |
'get-ongoing-sync-status' |
| 217 |
) |
| 218 |
); |
| 219 |
$this->get_ongoing_sync_status( $args, $assoc_args ); |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* DEPRECATED. Returns a JSON array with the results of the last CLI index (if present) or an empty array. |
| 224 |
* |
| 225 |
* This command is deprecated. Please use `get-last-cli-sync` instead. |
| 226 |
* |
| 227 |
* ## OPTIONS |
| 228 |
* |
| 229 |
* [--clear] |
| 230 |
* : Clear the `ep_last_cli_index` option. |
| 231 |
* |
| 232 |
* [--pretty] |
| 233 |
* : Use this flag to render a pretty-printed version of the JSON response. |
| 234 |
* |
| 235 |
* @subcommand get-last-cli-index |
| 236 |
* @since 3.5.1, `--pretty` introduced in 4.1.0 |
| 237 |
* @param array $args Positional CLI args. |
| 238 |
* @param array $assoc_args Associative CLI args. |
| 239 |
* @deprecated 4.4.0 |
| 240 |
* @see Command\get_last_cli_sync() |
| 241 |
*/ |
| 242 |
public function get_last_cli_index( $args, $assoc_args ) { |
| 243 |
_deprecated_function( 'get-last-cli-index', '4.4.0', 'get-last-cli-sync' ); |
| 244 |
WP_CLI::warning( |
| 245 |
sprintf( |
| 246 |
/* translators: New command name */ |
| 247 |
esc_html__( 'This command is deprecated. Please use %s instead.', 'elasticpress' ), |
| 248 |
'get-last-cli-sync' |
| 249 |
) |
| 250 |
); |
| 251 |
$this->get_last_cli_sync( $args, $assoc_args ); |
| 252 |
} |
| 253 |
|
| 254 |
/** |
| 255 |
* DEPRECATED. Stop the indexing operation started from the dashboard. |
| 256 |
* |
| 257 |
* This command is deprecated. Please use `stop-sync` instead. |
| 258 |
* |
| 259 |
* @subcommand stop-indexing |
| 260 |
* @since 3.5.2 |
| 261 |
* @param array $args Positional CLI args. |
| 262 |
* @param array $assoc_args Associative CLI args. |
| 263 |
* @deprecated 4.4.0 |
| 264 |
* @see Command\stop_sync() |
| 265 |
*/ |
| 266 |
public function stop_indexing( $args, $assoc_args ) { |
| 267 |
_deprecated_function( 'stop-indexing', '4.4.0', 'stop-sync' ); |
| 268 |
WP_CLI::warning( |
| 269 |
sprintf( |
| 270 |
/* translators: New command name */ |
| 271 |
esc_html__( 'This command is deprecated. Please use %s instead.', 'elasticpress' ), |
| 272 |
'stop-sync' |
| 273 |
) |
| 274 |
); |
| 275 |
$this->stop_sync( $args, $assoc_args ); |
| 276 |
} |
| 277 |
} |
| 278 |
|