Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

アクセスカウント用のプログラムでwpdb::prepareがnoticeを吐く #19

Closed
technote-space opened this issue Jan 8, 2019 · 2 comments

Comments

@technote-space
Copy link
Contributor

@technote-space technote-space commented Jan 8, 2019

[08-Jan-2019 13:34:59 UTC] PHP Notice:  wpdb::prepare が誤って呼び出されました。渡された引数の数 (3) に対する適正なプレースホルダー数 (2) がクエリーに含まれていません。 詳しくは WordPress のデバッグをご覧ください。 (このメッセージはバージョン 4.8.3 で追加されました) in /var/www/html/wordpress/wp-includes/functions.php on line 4204
[08-Jan-2019 13:34:59 UTC] PHP Stack trace:
[08-Jan-2019 13:34:59 UTC] PHP   1. {main}() /var/www/html/wordpress/wp-content/themes/cocoon-master/lib/analytics/access.php:0
[08-Jan-2019 13:34:59 UTC] PHP   2. logging_page_access() /var/www/html/wordpress/wp-content/themes/cocoon-master/lib/analytics/access.php:14
[08-Jan-2019 13:34:59 UTC] PHP   3. get_accesse_record_from() /var/www/html/wordpress/wp-content/themes/cocoon-master/lib/page-access/access-func.php:196
[08-Jan-2019 13:34:59 UTC] PHP   4. wpdb->prepare() /var/www/html/wordpress/wp-content/themes/cocoon-master/lib/page-access/access-func.php:234
[08-Jan-2019 13:34:59 UTC] PHP   5. _doing_it_wrong() /var/www/html/wordpress/wp-includes/wp-db.php:1297
[08-Jan-2019 13:34:59 UTC] PHP   6. trigger_error() /var/www/html/wordpress/wp-includes/functions.php:4204

該当箇所

  $query = $wpdb->prepare("SELECT * FROM {$table_name} USE INDEX({$index}) WHERE post_id = %d AND date = %s AND post_type = '$post_type'", $args);

正しいプログラム

  $query = $wpdb->prepare("SELECT * FROM {$table_name} USE INDEX({$index}) WHERE post_id = %d AND date = %s AND post_type = %s", $args);
technote-space added a commit to technote-fork/cocoon that referenced this issue Jan 8, 2019
technote-space added a commit to technote-fork/cocoon that referenced this issue Jan 8, 2019
technote-space added a commit to technote-fork/cocoon that referenced this issue Jan 8, 2019
@yhira

This comment has been minimized.

Copy link
Owner

@yhira yhira commented Jan 9, 2019

このnoticeには気づいていませんでした。
変なところに変数が入っていますね^^;
マージして修正したいと思います。

technote-space added a commit to technote-fork/cocoon that referenced this issue Jan 9, 2019
yhira added a commit that referenced this issue Jan 9, 2019
#19 SQLの修正
@technote-space

This comment has been minimized.

Copy link
Contributor Author

@technote-space technote-space commented Jan 9, 2019

マージありがとうございます。クローズします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.