From: Alexander Ebert Date: Wed, 19 Jul 2017 15:23:22 +0000 (+0200) Subject: Only throw an exception for empty arrays while devtools are active X-Git-Tag: 3.1.0_Alpha_1~243 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3e2a85b7f5a7a2d8736af5211ec41b69b1080f7a;p=GitHub%2FWoltLab%2FWCF.git Only throw an exception for empty arrays while devtools are active See #2338 --- diff --git a/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php b/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php index d4273878ac..0a884cccf0 100644 --- a/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php +++ b/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php @@ -31,11 +31,18 @@ class PreparedStatementConditionBuilder extends ConditionBuilder { throw new SystemException("missing parameter for token number " . ($count + 1) . " in condition '".$condition."'"); } else if (is_array($parameters[$count]) && empty($parameters[$count])) { - throw new \RuntimeException("An empty array was passed for token number " . ($count + 1) . " in condition '".$condition."'"); + // Only throw an exception if the developer tools are active, preventing this + // from triggering an error for queries that are never actually executed. + // + // This is done to preserve backwards-compatibility with earlier releases that + // allowed this kind of issue, effectively relying on the database to bail out. + if (ENABLE_DEBUG_MODE && ENABLE_DEVELOPER_TOOLS) { + throw new \RuntimeException("An empty array was passed for token number " . ($count + 1) . " in condition '" . $condition . "'"); + } } $result = '?'; - if (is_array($parameters[$count])) { + if (is_array($parameters[$count]) && !empty($parameters[$count])) { $result .= str_repeat(',?', count($parameters[$count]) - 1); }