WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#36403 closed defect (bug) (fixed)

Incorrect use of E_USER_NOTICE in wpdb::_real_escape()

Reported by: SergeyBiryukov Owned by: andizer
Milestone: 4.6 Priority: normal
Severity: normal Version: 3.6
Component: Database Keywords: good-first-bug has-patch
Focuses: Cc:
PR Number:

Description

in wpdb::_real_escape(), the last parameter for _doing_it_wrong() calls is E_USER_NOTICE, which leads to the following message:

wpdb must set a database connection for use with escaping. This message was added in version 1024.

It was apparently influenced by trigger_error(). For _doing_it_wrong(), however, the last parameter should be the version of WordPress where the message was added, i.e. '3.6'.

Introduced in [24758].

Attachments (2)

36403.diff (1.3 KB) - added by andizer 4 years ago.
36403-revision.diff (1.2 KB) - added by andizer 3 years ago.
Update patch

Download all attachments as: .zip

Change History (8)

@andizer
4 years ago

#1 @andizer
4 years ago

  • Keywords has-patch added; needs-patch removed

Just added a patch for this.

#2 @pento
3 years ago

  • Keywords needs-refresh added

Thanks for the patch, @andizer! It shouldn't be $wp_version, we need to pass the WordPress version where this error message was introduced - in this case, version 3.6.

#3 @andizer
3 years ago

Thank you for your comment. I was too quick in writing the patch, should have read the issue better. I've updated the patch.

Last edited 3 years ago by andizer (previous) (diff)

@andizer
3 years ago

Update patch

#4 @DrewAPicture
3 years ago

  • Owner set to andizer
  • Status changed from new to assigned

Assigning to mark the good-first-bug as "claimed".

#5 @SergeyBiryukov
3 years ago

  • Keywords needs-refresh removed
  • Milestone changed from Awaiting Review to 4.6

#6 @SergeyBiryukov
3 years ago

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

In 38133:

Database: Replace incorrect use of E_USER_NOTICE in wpdb::_real_escape() with the version number where the message was added.

Props andizer.
Fixes #36403.

Note: See TracTickets for help on using tickets.