Skip to content

Commit 9cc5f4e

Browse files
authored
Merge pull request #128 from wp-cli/fix/compat
2 parents e5c8555 + 1bc6e9c commit 9cc5f4e

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

src/WP_Export_Oxymel.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ public function optional_cdata( $tag_name, $contents ) {
1616
}
1717

1818
public function cdata( $text ) {
19-
if ( is_string( $text ) && ! seems_utf8( $text ) ) {
20-
$text = mb_convert_encoding( $text, 'UTF-8' );
19+
if ( is_string( $text ) ) {
20+
if ( function_exists( 'wp_is_valid_utf8' ) ) {
21+
if ( ! wp_is_valid_utf8( $text ) ) {
22+
$text = mb_convert_encoding( $text, 'UTF-8' );
23+
}
24+
} elseif ( ! seems_utf8( $text ) ) { // phpcs:ignore WordPress.WP.DeprecatedFunctions.seems_utf8Found
25+
$text = mb_convert_encoding( $text, 'UTF-8' );
26+
27+
}
2128
}
2229
return parent::cdata( $text );
2330
}

src/WP_Export_Query.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private function author_where() {
245245

246246
private function start_date_where() {
247247
global $wpdb;
248-
$timestamp = strtotime( $this->filters['start_date'] );
248+
$timestamp = $this->filters['start_date'] ? strtotime( $this->filters['start_date'] ) : null;
249249
if ( ! $timestamp ) {
250250
return;
251251
}
@@ -254,6 +254,9 @@ private function start_date_where() {
254254

255255
private function end_date_where() {
256256
global $wpdb;
257+
if ( ! $this->filters['end_date'] ) {
258+
return;
259+
}
257260
if ( preg_match( '/^\d{4}-\d{2}$/', $this->filters['end_date'] ) ) {
258261
$timestamp = $this->get_timestamp_for_the_last_day_of_a_month( $this->filters['end_date'] );
259262
} else {

src/WP_Export_WXR_Formatter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
* Responsible for formatting the data in WP_Export_Query to WXR
1313
*/
1414
class WP_Export_WXR_Formatter {
15+
private $export;
16+
private $wxr_version;
17+
1518
public function __construct( $export ) {
1619
$this->export = $export;
1720
$this->wxr_version = WXR_VERSION;
@@ -51,7 +54,7 @@ public function after_posts() {
5154
public function header() {
5255
$oxymel = new Oxymel();
5356
$wp_generator_tag = $this->export->wp_generator_tag();
54-
$comment = <<<COMMENT
57+
$comment = <<<'COMMENT'
5558
5659
This is a WordPress eXtended RSS file generated by WordPress as an export of your site.
5760
It contains information about your site's posts, pages, comments, categories, and other content.

src/WP_Map_Iterator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

33
class WP_Map_Iterator extends IteratorIterator {
4+
private $callback;
5+
46
public function __construct( $iterator, $callback ) {
57
$this->callback = $callback;
68
parent::__construct( $iterator );

src/WP_Post_IDs_Iterator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ class WP_Post_IDs_Iterator implements Iterator {
44
private $limit = 100;
55
private $post_ids;
66
private $ids_left;
7-
private $results = array();
7+
private $results = array();
8+
private $global_index = 0;
9+
private $index_in_results = 0;
10+
private $db;
811

912
public function __construct( $post_ids, $limit = null ) {
1013
$this->db = $GLOBALS['wpdb'];
@@ -15,26 +18,31 @@ public function __construct( $post_ids, $limit = null ) {
1518
}
1619
}
1720

21+
#[\ReturnTypeWillChange]
1822
public function current() {
1923
return $this->results[ $this->index_in_results ];
2024
}
2125

26+
#[\ReturnTypeWillChange]
2227
public function key() {
2328
return $this->global_index;
2429
}
2530

31+
#[\ReturnTypeWillChange]
2632
public function next() {
2733
++$this->index_in_results;
2834
++$this->global_index;
2935
}
3036

37+
#[\ReturnTypeWillChange]
3138
public function rewind() {
3239
$this->results = array();
3340
$this->global_index = 0;
3441
$this->index_in_results = 0;
3542
$this->ids_left = $this->post_ids;
3643
}
3744

45+
#[\ReturnTypeWillChange]
3846
public function valid() {
3947
if ( isset( $this->results[ $this->index_in_results ] ) ) {
4048
return true;

0 commit comments

Comments
 (0)