Warning: stripos() [function.stripos]: needle is not a string or an integer
WordPressを3.5から3.5.1 に変更したら、以下のような現象が発生するようになりました。
寄稿者で記事を投稿し、編集者(editor)または管理者(administrator)で『公開』しようとすると、警告が表示されます。
Warning: stripos() [function.stripos]: needle is not a string or an integer in /host/wordpress/wp-includes/functions.php on line 658 Warning: stripos() [function.stripos]: needle is not a string or an integer in /host/wordpress/wp-includes/functions.php on line 661 Warning: Cannot modify header information - headers already sent by (output started at /host/wordpress/wp-includes/functions.php:658) in /host/wordpress/wp-includes/pluggable.php on line 876
PHPはPHP 5.2.17を使用。WordPressは3.5.1。
検索してみたら、ここの人も困っているようで解決策まで至っていない状況でした。
こちらのもう1つのフォーラムでは、php.iniの『mbstring.func_overload = 0』オプションがどうたらこうたらと記載されていました。
mbstring.func_overloadについて
mbstring.func_overload は、php.iniにしか設定できない属性でhtaccessでは設定不可らしいです。
デバッグトレースもせずに、さっそくmbstring.func_overloadの値を変更して試してみましたが、結果、Warningメッセージは解消されませんでした。
軽くトレース、最初の警告「wp-includes/functions.php on line 658」のソースがここです。ついでに、WordPress3.4.2の同じ個所のソースも貼っておきます。
wordpress3.5.1-jaの該当箇所
function add_query_arg() {
$ret = '';
$args = func_get_args();
if ( is_array( $args[0] ) ) {
if ( count( $args ) < 2 || false === $args[1] )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = $args[1];
} else {
if ( count( $args ) < 3 || false === $args[2] )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = $args[2];
}
if ( $frag = strstr( $uri, '#' ) )
$uri = substr( $uri, 0, -strlen( $frag ) );
else
$frag = '';
if ( 0 === stripos( 'http://', $uri ) ) { // ★★★
$protocol = 'http://';
$uri = substr( $uri, 7 );
} elseif ( 0 === stripos( 'https://', $uri ) ) {
$protocol = 'https://';
$uri = substr( $uri, 8 );
} else {
$protocol = '';
}
wordpress3.4.2-jaの該当箇所
function add_query_arg() {
$ret = '';
if ( is_array( func_get_arg(0) ) ) {
if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = @func_get_arg( 1 );
} else {
if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = @func_get_arg( 2 );
}
if ( $frag = strstr( $uri, '#' ) ) // ★★★
$uri = substr( $uri, 0, -strlen( $frag ) );
else
$frag = '';
if ( preg_match( '|^https?://|i', $uri, $matches ) ) {
$protocol = $matches[0];
$uri = substr( $uri, strlen( $protocol ) );
} else {
$protocol = '';
}
警告内容からすると★★★マークのところでstriposの第2パラメータ「$uri」がおかしいということらしいです。値が入っていなかったり、文字列ではない可能性が高いです。3.4と3.5では処理自体もちょっと違いますね。
根本的な解決は分かりませんでしたが、WordPressを3.5.1から3.4.2にバージョンダウンさせたら警告はでなくなりました。
もしかしたら3.5.1に対応していない『プラグインの問題』という可能性もありますね。
環境設定で、警告表示だけなくす方法
あまりお勧めしませんが、警告はApacheログに出させるのみにして、画面に出力しないようにするならhtaccessに以下追記すればよさそうです。
php_value display_errors Off