#42776 closed defect (bug) (invalid)
WP(v.4.9.1) error in wp-db.php
Reported by: | adminkov | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9.1 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Working on my plugin, I found that when I send a request to
a database where there is one field empty - then WP (v.4.9.1) gives an
error and stop.
Example:
- my request:
$sql = "INSERT INTO {$wpdb->prefix}watchman_site_cross_table (`date_country`, `tbl_country`, `tbl_result`) SELECT DATE_FORMAT(`time_visit`,'%Y %m') as `date_country`, LEFT(`country`,4) as `tbl_country`, COUNT(`user_ip`) as `tbl_result` FROM {$wpdb->prefix}watchman_site GROUP BY `date_country`, `tbl_country` ORDER BY `tbl_country` "; $wpdb->query($sql);
- The message in the admin panel:
Fatal error: Cannot access empty property in D:OpenServerdomainsadminkov.localwp-includes wp-db.php on line 1901
3.The reason for WP break is that the 'country' field is empty. Maybe this
will help you improve WP(v.4.9.1). Good luck.
Change History (4)
#2
in reply to:
↑ 1
@
7 years ago
Replying to dd32:
Hi @dd32,
I want to help WP developers.
Now on the merits of the case:
When I received this error, I manually filled in the blank field "country" and the error was gone.
I attached to my answer a small file from my plugin that gave an error
Thanks!
https://www.adminkov.bcr.by/wordpress/error-plugin-wordpress/
Note: See
TracTickets for help on using
tickets.
Hi @adminkov,
Can you please verify the code needed to reproduce this?
With the code provided, being a
INSERT
it shouldn't have been running on line 1901 as that's for select-based queries. Was it indeed aSELECT
query which you were running?The code in question (The first large block deals with INSERT's, the second highlight is the line which triggered the fatal)
https://core.trac.wordpress.org/browser/tags/4.9.1/src/wp-includes/wp-db.php?marks=1877-1892,1901#L1874
Thanks!