Skip to content

Commit c78c296

Browse files
committed
Revert and whitelist breaking changes
1 parent 498a831 commit c78c296

5 files changed

+16
-16
lines changed

functions.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22

3-
use WP_CLI\Utils;
4-
5-
function wpcli_export( $args = array() ) {
3+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Renaming breaks Phar compat.
4+
function wp_export( $args = array() ) {
65
$defaults = array(
76
'filters' => array(),
87
'format' => 'WP_Export_WXR_Formatter',
@@ -20,14 +19,14 @@ function wpcli_export( $args = array() ) {
2019
}
2120
}
2221

23-
function wpcli_export_build_in_condition( $column_name, $values, $format = '%s' ) {
22+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound,WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- Renaming breaks Phar compat.
23+
function _wp_export_build_IN_condition( $column_name, $values, $format = '%s' ) {
2424
global $wpdb;
2525

2626
if ( ! is_array( $values ) || empty( $values ) ) {
2727
return '';
2828
}
29-
$formats = implode( ', ', array_fill( 0, count( $values ), $format ) );
30-
$column_name_sql = Utils\esc_sql_ident( $column_name );
29+
$formats = implode( ', ', array_fill( 0, count( $values ), $format ) );
3130
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- $column_name_sql escaped as ident, $formats hardcoded value.
32-
return $wpdb->prepare( "{$column_name_sql} IN ({$formats})", $values );
31+
return $wpdb->prepare( "{$column_name} IN ({$formats})", $values );
3332
}

src/Export_Command.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
use WP_CLI\Utils;
44

5-
define( 'WPCLI_EXPORT_COMMAND_NO_SPLIT', '-1' );
5+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Changing breaks Phar compat.
6+
define( 'WP_CLI_EXPORT_COMMAND_NO_SPLIT', '-1' );
67

78
/**
89
* Exports WordPress content to a WXR file.
@@ -175,15 +176,15 @@ function( $file_path ) {
175176

176177
try {
177178
if ( $this->stdout ) {
178-
wpcli_export(
179+
wp_export(
179180
[
180181
'filters' => $this->export_args,
181182
'writer' => 'WP_Export_Stdout_Writer',
182183
'writer_args' => null,
183184
]
184185
);
185186
} else {
186-
wpcli_export(
187+
wp_export(
187188
[
188189
'filters' => $this->export_args,
189190
'writer' => 'WP_Export_Split_Files_Writer',

src/WP_Export_Query.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function post_type_where() {
211211
unset( $post_types['attachment'] );
212212
}
213213

214-
$this->wheres[] = wpcli_export_build_in_condition( 'p.post_type', $post_types );
214+
$this->wheres[] = _wp_export_build_IN_condition( 'p.post_type', $post_types );
215215
}
216216

217217
private function status_where() {
@@ -299,7 +299,7 @@ private function include_attachment_ids( $post_ids ) {
299299
$attachment_ids = [];
300300
$batch_of_post_ids = array_splice( $post_ids, 0, self::QUERY_CHUNK );
301301
while ( $batch_of_post_ids ) {
302-
$post_parent_condition = wpcli_export_build_in_condition( 'post_parent', $batch_of_post_ids );
302+
$post_parent_condition = _wp_export_build_IN_condition( 'post_parent', $batch_of_post_ids );
303303
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Escaped in wpcli_export_build_in_condition() function.
304304
$attachment_ids = array_merge( $attachment_ids, (array) $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND {$post_parent_condition}" ) );
305305
}

src/WP_Export_Split_Files_Writer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function __construct( $formatter, $writer_args = [] ) {
2323
//TODO: check if args are not missing
2424
if ( is_null( $writer_args['max_file_size'] ) ) {
2525
$this->max_file_size = 15 * MB_IN_BYTES;
26-
} elseif ( WPCLI_EXPORT_COMMAND_NO_SPLIT === $writer_args['max_file_size'] ) {
27-
$this->max_file_size = WPCLI_EXPORT_COMMAND_NO_SPLIT;
26+
} elseif ( WP_CLI_EXPORT_COMMAND_NO_SPLIT === $writer_args['max_file_size'] ) {
27+
$this->max_file_size = WP_CLI_EXPORT_COMMAND_NO_SPLIT;
2828
} else {
2929
$this->max_file_size = $writer_args['max_file_size'] * MB_IN_BYTES;
3030
}
@@ -38,7 +38,7 @@ public function __construct( $formatter, $writer_args = [] ) {
3838
public function export() {
3939
$this->start_new_file();
4040
foreach ( $this->formatter->posts() as $post_xml ) {
41-
if ( WPCLI_EXPORT_COMMAND_NO_SPLIT !== $this->max_file_size && $this->current_file_size + strlen( $post_xml ) > $this->max_file_size ) {
41+
if ( WP_CLI_EXPORT_COMMAND_NO_SPLIT !== $this->max_file_size && $this->current_file_size + strlen( $post_xml ) > $this->max_file_size ) {
4242
$this->start_new_file();
4343
}
4444
$this->write( $post_xml );

src/WP_Post_IDs_Iterator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function valid() {
5252

5353
private function load_next_posts_from_db() {
5454
$next_batch_post_ids = array_splice( $this->ids_left, 0, $this->limit );
55-
$in_post_ids_sql = wpcli_export_build_in_condition( 'ID', $next_batch_post_ids );
55+
$in_post_ids_sql = _wp_export_build_IN_condition( 'ID', $next_batch_post_ids );
5656
$this->results = $this->db->get_results( "SELECT * FROM {$this->db->posts} WHERE $in_post_ids_sql" );
5757
if ( ! $this->results ) {
5858
if ( $this->db->last_error ) {

0 commit comments

Comments
 (0)