Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -11,7 +11,7 @@
}
],
"require": {
"wp-cli/wp-cli": "^2.12"
"wp-cli/wp-cli": "^2.13"
},
"require-dev": {
"wp-cli/entity-command": "^1.3 || ^2",
Expand Down
38 changes: 1 addition & 37 deletions src/Fetch_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function ( $ret, $data, $url ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunc
if ( ! class_exists( 'SimpleXMLElement' ) ) {
WP_CLI::error( "The PHP extension 'SimpleXMLElement' is not available but is required for XML-formatted output." );
}
WP_CLI::log( (string) $this->oembed_create_xml( (array) $data ) );
WP_CLI::log( (string) _oembed_create_xml( (array) $data ) );
} else {
Comment on lines 168 to 172
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling _oembed_create_xml() here will fatally error on WordPress versions prior to 4.4 (this command’s removed oembed_create_xml() method explicitly existed as a polyfill for older WP). Consider restoring the polyfill, or guarding with function_exists('_oembed_create_xml') and falling back to the local implementation / emitting a clear error if unavailable.

Copilot uses AI. Check for mistakes.
WP_CLI::log( (string) json_encode( $data ) );
}
Expand Down Expand Up @@ -211,40 +211,4 @@ function ( $ret, $data, $url ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunc

WP_CLI::log( $html );
}

/**
* Creates an XML string from a given array.
*
* Same as `\_oembed_create_xml()` in "wp-includes\embed.php" introduced in WP 4.4.0. Polyfilled as marked private (and also to cater for older WP versions).
*
* @see _oembed_create_xml()
*
* @param array $data The original oEmbed response data.
* @param \SimpleXMLElement $node Optional. XML node to append the result to recursively.
* @return string|false XML string on success, false on error.
*/
protected function oembed_create_xml( $data, $node = null ) {
if ( ! is_array( $data ) || empty( $data ) ) {
return false;
}

if ( null === $node ) {
$node = new \SimpleXMLElement( '<oembed></oembed>' );
}

foreach ( $data as $key => $value ) {
if ( is_numeric( $key ) ) {
$key = 'oembed';
}

if ( is_array( $value ) ) {
$item = $node->addChild( $key );
$this->oembed_create_xml( $value, $item );
} else {
$node->addChild( $key, esc_html( $value ) );
}
}

return $node->asXML();
}
}
2 changes: 2 additions & 0 deletions src/Provider_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ public function match_provider( $args, $assoc_args ) {
$link_type = Utils\get_flag_value( $assoc_args, 'link-type' );

if ( ! $discover && ( null !== $response_size_limit || null !== $link_type ) ) {
// @phpstan-ignore notIdentical.alwaysTrue
if ( null !== $response_size_limit && null !== $link_type ) {
$msg = "The 'limit-response-size' and 'link-type' options can only be used with discovery.";
// @phpstan-ignore notIdentical.alwaysTrue
} elseif ( null !== $response_size_limit ) {
$msg = "The 'limit-response-size' option can only be used with discovery.";
} else {
Expand Down