Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#35892 closed defect (bug) (invalid)

Small issue in "get_calendar" function

Reported by: yetanotherdaniel's profile yetAnotherDaniel Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Widgets Keywords:
Focuses: Cc:

Description

In the "get_calendar" function (wp-includes/general-template.php) the following wpdb method with a SQL command is called:

'get_var("SELECT 1'

This will not work as "get_var" does not support that:
https://core.trac.wordpress.org/ticket/4090

The error is tiny. However, this seems to be a common mistake if you google for:
"get_var" "SELECT 1"

I either suggest to enable this functionality in the "get_var" method or fix it in get_calendar function as well as describe the issue in the codex (https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Variable).

Change History (3)

This ticket was mentioned in Slack in #core by dd32. View the logs.


9 years ago

#2 @pento
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 4.4.2 deleted

Thanks for the bug report!

The query in get_calendar() is written as SELECT 1 as test..., which does work correctly with mysqli_fetch_object().

It would require significant re-engineering and edge case handling in WPDB to handle the SELECT 1... case, which doesn't seem to have much payoff when there are simple workarounds available.

#3 @yetAnotherDaniel
9 years ago

You are right, I did saw the 'as test' as this is not a usual SQL syntax.

A hint in the codex would be perfect as this is a common error.

Thank you!

Note: See TracTickets for help on using tickets.