Moodle

get_in_or_equal() should throw an exception if empty array is passed as $items

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

If empty array is passed to the $DB->get_in_or_equal(), the SQL containing "blahblah IN ()" is executed at the server, leading to dml_read_exception thrown (ERROR: syntax error). Of course, this is the caller's responsibility to check the passed value. However, I guess we should throw the exception sooner without actually querying the database.

Activity

Hide
David Mudrak added a comment -

The trivial fix committed into CVS HEAD. I used the same exception as we already throw at sql_substr(). Approved by skodak. Eloy, please double-check and close.

Show
David Mudrak added a comment - The trivial fix committed into CVS HEAD. I used the same exception as we already throw at sql_substr(). Approved by skodak. Eloy, please double-check and close.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: