Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#42776 closed defect (bug) (invalid)

WP(v.4.9.1) error in wp-db.php

Reported by: adminkov's profile adminkov Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.1
Component: Query Keywords:
Focuses: Cc:

Description (last modified by dd32)

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.

  1. 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` ";
  2. 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)

#1 follow-up: @dd32
6 years ago

  • Description modified (diff)
  • Keywords reporter-feedback added

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 a SELECT 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),1901#L1874


#2 in reply to: ↑ 1 @adminkov
6 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


#3 @adminkov
6 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#4 @netweb
6 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.