Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#11372 closed defect (bug) (fixed)

wpdb::query returns FALSE on TRUNCATE

Reported by: marcis20's profile marcis20 Owned by: ryan's profile ryan
Milestone: 3.2 Priority: normal
Severity: normal Version: 2.8.5
Component: Database Keywords: has-patch
Focuses: Cc:

Description

When executing a "TRUNCATE" SQL query, wpdb returns FALSE (num_rows = 0) although it's succesfull.

Maybe it should be included in the "if" section of the method check:

if ( preg_match("/^\\s*(insert|delete|update|replace|alter) /i",$query) ) {

And returns the "$this->rows_affected" value (1).

Attachments (3)

11372.diff (658 bytes) - added by scribu 14 years ago.
11372.2.diff (714 bytes) - added by scribu 14 years ago.
Move 'alter' to the first if () as well
11372.3.diff (817 bytes) - added by scribu 14 years ago.
Use single quotes, for readability

Download all attachments as: .zip

Change History (12)

#1 @scribu
15 years ago

For insert|delete|update|replace statements, rows_affected is set correctly.

The problematic ones are DDL statements: CREATE, DROP, TRUNCATE, ALTER etc.

#2 @hakre
15 years ago

Current trunk still has preg_match("/^\\s*(insert|delete|update|replace|alter) /i",$query) in there.

Related: #11799

#3 @Denis-de-Bernardy
15 years ago

  • Keywords bug-hunt added
  • Milestone changed from Unassigned to Future Release

#4 @Denis-de-Bernardy
15 years ago

  • Keywords featured added; bug-hunt removed

#5 @solarissmoke
14 years ago

Related/duplicate: #16228

@scribu
14 years ago

#6 @scribu
14 years ago

  • Keywords has-patch added; featured database query truncate removed

11372.diff handles CREATE, TRUNCATE and DROP.

#7 @scribu
14 years ago

  • Keywords 3.2-early added

@scribu
14 years ago

Move 'alter' to the first if () as well

@scribu
14 years ago

Use single quotes, for readability

#8 @scribu
14 years ago

  • Keywords 3.2-early removed
  • Milestone changed from Future Release to 3.2

#9 @ryan
14 years ago

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

In [18063]:

Properly handle return value of DDL statements. Props scribu, marcis20. fixes #11372

Note: See TracTickets for help on using tickets.