Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to WPCS v3 #110

Merged
merged 8 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/import-command": "^1 || ^2",
"wp-cli/media-command": "^1 || ^2",
"wp-cli/wp-cli-tests": "^3.1"
"wp-cli/wp-cli-tests": "^4"
},
"config": {
"process-timeout": 7200,
Expand Down
2 changes: 1 addition & 1 deletion export-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
return;
}

$wpcli_export_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
$wpcli_export_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $wpcli_export_autoloader ) ) {
require_once $wpcli_export_autoloader;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Export_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* # Export posts published by the user between given start and end date
* $ wp export --dir=/tmp/ --user=admin --post_type=post --start_date=2011-01-01 --end_date=2011-12-31
* Starting export process...
* Writing to file /tmp/staging.wordpress.2016-05-24.000.xml
* Writing to file /tmp/staging.WordPress.2016-05-24.000.xml
* Success: All done with export.
*
* @package wp-cli
Expand Down Expand Up @@ -58,7 +58,7 @@
* ---
*
* [--filename_format=<format>]
* : Use a custom format for export filenames. Defaults to '{site}.wordpress.{date}.{n}.xml'.
* : Use a custom format for export filenames. Defaults to '{site}.WordPress.{date}.{n}.xml'.
*
* [--include_once=<before_posts>]
* : Include specified export section only in the first export file. Valid options
Expand Down Expand Up @@ -111,19 +111,19 @@
* # Export posts published by the user between given start and end date
* $ wp export --dir=/tmp/ --user=admin --post_type=post --start_date=2011-01-01 --end_date=2011-12-31
* Starting export process...
* Writing to file /tmp/staging.wordpress.2016-05-24.000.xml
* Writing to file /tmp/staging.WordPress.2016-05-24.000.xml
* Success: All done with export.
*
* # Export posts by IDs
* $ wp export --dir=/tmp/ --post__in=123,124,125
* Starting export process...
* Writing to file /tmp/staging.wordpress.2016-05-24.000.xml
* Writing to file /tmp/staging.WordPress.2016-05-24.000.xml
* Success: All done with export.
*
* # Export a random subset of content
* $ wp export --post__in="$(wp post list --post_type=post --orderby=rand --posts_per_page=8 --format=ids)"
* Starting export process...
* Writing to file /var/www/example.com/public_html/staging.wordpress.2016-05-24.000.xml
* Writing to file /var/www/example.com/public_html/staging.WordPress.2016-05-24.000.xml
* Success: All done with export.
*/
public function __invoke( $_, $assoc_args ) {
Expand Down Expand Up @@ -252,7 +252,7 @@
$path = getcwd();
} elseif ( ! is_dir( $path ) ) {
WP_CLI::error( sprintf( "The directory '%s' does not exist.", $path ) );
} elseif ( ! is_writable( $path ) ) {

Check warning on line 255 in src/Export_Command.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: is_writable().
WP_CLI::error( sprintf( "The directory '%s' is not writable.", $path ) );
}

Expand Down Expand Up @@ -475,7 +475,7 @@
return true;
}

private function check_include_once( $include_once ) {

Check warning on line 478 in src/Export_Command.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

It is recommended not to use reserved keyword "include_once" as function parameter name. Found: $include_once
if ( null === $include_once ) {
return true;
}
Expand Down
1 change: 0 additions & 1 deletion src/WP_Export_Oxymel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ public function cdata( $text ) {
return parent::cdata( $text );
}
}

1 change: 0 additions & 1 deletion src/WP_Export_Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
return [];
}
$custom_taxonomies = get_taxonomies( [ '_builtin' => false ] );
$custom_terms = (array) get_terms( $custom_taxonomies, [ 'get' => 'all' ] );

Check failure on line 123 in src/WP_Export_Query.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

The parameter "[ 'get' => 'all' ]" at position #2 of get_terms() has been deprecated since WordPress version 4.5.0. Instead do not pass the parameter.
$this->check_for_orphaned_terms( $custom_terms );
$custom_terms = self::topologically_sort_terms( $custom_terms );
return $custom_terms;
Expand Down Expand Up @@ -306,7 +306,7 @@
}
$attachment_ids = [];
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition -- Assigment is part of the break condition.
while ( $batch_of_post_ids = array_splice( $post_ids, 0, self::QUERY_CHUNK ) ) {

Check warning on line 309 in src/WP_Export_Query.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

Variable assignment found within a condition. Did you mean to do a comparison ?
$post_parent_condition = _wp_export_build_IN_condition( 'post_parent', $batch_of_post_ids );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Escaped in wpcli_export_build_in_condition() function.
$attachment_ids = array_merge( $attachment_ids, (array) $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND {$post_parent_condition}" ) );
Expand Down Expand Up @@ -345,7 +345,7 @@
private static function topologically_sort_terms( $terms ) {
$sorted = [];
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition -- assignment is used as break condition.
while ( $term = array_shift( $terms ) ) {

Check warning on line 348 in src/WP_Export_Query.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

Variable assignment found within a condition. Did you mean to do a comparison ?
if ( 0 === (int) $term->parent || isset( $sorted[ $term->parent ] ) ) {
$sorted[ $term->term_id ] = $term;
} else {
Expand Down Expand Up @@ -413,4 +413,3 @@
return $comments;
}
}

3 changes: 1 addition & 2 deletions src/WP_Export_Split_Files_Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}

protected function write( $xml ) {
$res = fwrite( $this->f, $xml );

Check warning on line 66 in src/WP_Export_Split_Files_Writer.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

File operations should use WP_Filesystem methods instead of direct PHP filesystem calls. Found: fwrite().
if ( false === $res ) {
throw new WP_Export_Exception( 'WP Export: error writing to export file.' );
}
Expand Down Expand Up @@ -99,12 +99,11 @@

private function next_file_name() {
$next_file_name = sprintf( $this->filename_template, $this->next_file_number );
$this->next_file_number++;
++$this->next_file_number;
return $next_file_name;
}

private function next_file_path() {
return untrailingslashit( $this->destination_directory ) . DIRECTORY_SEPARATOR . $this->next_file_name();
}

}
1 change: 0 additions & 1 deletion src/WP_Export_WXR_Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function header() {
)
->open_channel
->to_string();

}

public function site_metadata() {
Expand Down
4 changes: 2 additions & 2 deletions src/WP_Post_IDs_Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function key() {
}

public function next() {
$this->index_in_results++;
$this->global_index++;
++$this->index_in_results;
++$this->global_index;
}

public function rewind() {
Expand Down
Loading