Skip to content

Commit

Permalink
Coding Standards: Use strict comparison in `wp_xmlrpc_server::pingbac…
Browse files Browse the repository at this point in the history
…k_ping()`.

Follow-up to [2983], [55365].

Props aristath, poena, afercia, SergeyBiryukov.
See #62279.

git-svn-id: https://develop.svn.wordpress.org/trunk@59663 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Jan 18, 2025
1 parent 2f65488 commit f33ee44
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/wp-includes/class-wp-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6885,6 +6885,7 @@ public function pingback_ping( $args ) {
*/
$urltest = parse_url( $pagelinkedto );
$post_id = url_to_postid( $pagelinkedto );

if ( $post_id ) {
// $way
} elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) {
Expand Down Expand Up @@ -6917,15 +6918,15 @@ public function pingback_ping( $args ) {
// TODO: Attempt to extract a post ID from the given URL.
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
}
$post_id = (int) $post_id;

$post = get_post( $post_id );
$post_id = (int) $post_id;
$post = get_post( $post_id );

if ( ! $post ) { // Post not found.
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
}

if ( url_to_postid( $pagelinkedfrom ) == $post_id ) {
if ( url_to_postid( $pagelinkedfrom ) === $post_id ) {
return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
}

Expand Down

0 comments on commit f33ee44

Please sign in to comment.