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
20 changes: 7 additions & 13 deletions php/class-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,22 +356,16 @@ public function maybe_file_exist_in_url( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return false;
}
// phpcs:disable WordPress.WP.AlternativeFunctions
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_NOBODY, true );
curl_exec( $ch );
$code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );

if ( 200 === $code ) {
$status = true;
} else {
$status = false;

$head = wp_safe_remote_head( $url );

if ( is_wp_error( $head ) ) {
return false;
}

curl_close( $ch );
// phpcs:enable
$code = wp_remote_retrieve_response_code( $head );

return $status;
return 200 === $code;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion php/relate/class-relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,17 @@ public function flush_cache() {
* @param array $post_ids The post ids.
*/
public static function preload( $post_ids ) {
// Check if the post_ids are objects.
$maybe_ids = array_column( $post_ids, 'ID' );
if ( ! empty( $maybe_ids ) ) {
// If so, make sure to just use the IDs.
$post_ids = $maybe_ids;
}
global $wpdb;
$table_name = Utils::get_relationship_table();
// Do the public_ids.
$list = implode( ', ', array_fill( 0, count( $post_ids ), '%d' ) );
$where = "post_id IN( {$list} )";
$where = "post_id IN ( {$list} )";

$sql = $wpdb->prepare( "SELECT * FROM {$table_name} WHERE {$where}", $post_ids ); // phpcs:ignore WordPress.DB
$posts = $wpdb->get_results( $sql, ARRAY_A ); // phpcs:ignore WordPress.DB
Expand Down