【WordPress】プラグインSearch Everything その2

最近(1か月前あたりから?)プラグインSearch Everything を有効化しているサイトで新規投稿すると、HTTP ERROR 500 となるようです。

プラグインのサポートページをよく見ると、2017年8月からサポート終了ということでした。
https://wordpress.org/support/topic/search-everything-support-update/
※WordPress公式プラグインからは削除せず残すようです。

「公開」ボタンをクリックすると画面がエラーになる原因について
※予約ではなく、「公開」ステータスになるタイミング

デバッグでログを見ると、PHP Fatal error になっています。

codePHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /...../wp-content/plugins/search-everything/search-everything.php:927

こちらと同様に、PHP Errorがでないように対応してもよし。
変更内容↓

search-everything.php 914行目~//変更前
function se_post_publish_ping($post_id) {
//should happen only on first publish
$status = false;
if( !empty( $_POST['post_status'] ) && ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {
$permalink = get_permalink($post_id);
$zemanta_response = se_api(array(
'method' => 'zemanta.post_published_ping',
'current_url' => $permalink,
'post_url' => $permalink,
'post_rid' => '',
'interface' => 'wordpress-se',
'deployment' => 'search-everything',
'format' => 'json'
));
$response = json_decode($zemanta_response["body"]);
if (isset($response->status) && !is_wp_error($zemanta_response)) {
$status = $response->status;
}
}
return $status;
}

//変更後
function se_post_publish_ping($post_id) {
//should happen only on first publish
$status = false;
if( !empty( $_POST['post_status'] ) && ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {
$permalink = get_permalink($post_id);
$zemanta_response = se_api(array(
'method' => 'zemanta.post_published_ping',
'current_url' => $permalink,
'post_url' => $permalink,
'post_rid' => '',
'interface' => 'wordpress-se',
'deployment' => 'search-everything',
'format' => 'json'
));
if ( !is_wp_error( $zemanta_response) )://@@@追加
$response = json_decode($zemanta_response["body"]);
if (isset($response->status) && !is_wp_error($zemanta_response)) {
$status = $response->status;
}
endif;//@@@追加
}
return $status;
}

この部分の処理をみると、新規投稿時に、http://api.zemanta.com/services/rest/0.0/ へ POSTしにいくのですが、サブドメインapi.zemanta.com がなくなっていて(ネームサーバーにない)エラーとなった様子。

PINGサーバーかな?ま、何するのか分からないところにPOSTしにいかなくていいので、search-everything.php の最後にある、publist_post フック自体を削除(コメントアウト)としました。

search-everything.php 最後尾//変更前
add_action( 'publish_post', 'se_post_publish_ping' );

//変更後
//add_action( 'publish_post', 'se_post_publish_ping' );

♪♪♪

ちなみに、いつも使っているカスタムフィールドを検索対象に含めるコードはこちら
posts_search , posts_join にフックするので、検索関連のプラグインを使用していたり、テーマで検索カスタマイズしている場合には、おそらくかち合うためご注意を!

こちらもどうぞ

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です