Zend Framework

quoteInto won't accept valid SQL if question mark is in first position.

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.2
  • Fix Version/s: 1.9.6
  • Component/s: Zend_Db
  • Labels:
    None

Description

In Zend_Db_Adapter_Abstract

public function quoteInto($text, $value, $type = null, $count = null) {
if ($count === null) { return str_replace('?', $this->quote($value, $type), $text); } else {
while ($count > 0) {
if (strpos($text, '?') != false) { $text = substr_replace($text, $this->quote($value), strpos($text, '?'), 1); }
--$count;
}
return $text;
}
}

In the line "if (strpos($text, '?') != false) {", it should be !== and not !=, since position returned can be 0.
Else,
$table->select()->where('? = id', 123); //sample taken from forum in which I first wrote about this
which is valid, won't work.

Nothing fancy, but I think it could affect some people =)

  1. Abstract.patch
    19/Nov/09 12:32 PM
    0.5 kB
    Steve Hollis
  2. TestCommon.patch
    19/Nov/09 12:32 PM
    0.5 kB
    Steve Hollis

Activity

Hide
Steve Hollis added a comment -

Patch for Zend_Db_Abstract and test case attached.

Show
Steve Hollis added a comment - Patch for Zend_Db_Abstract and test case attached.
Hide
Matthew Weier O'Phinney added a comment -

Patch applied to trunk and 1.9 release branch. In the future, please create your patches from the root of your ZF installation to ensure we patch the correct files. (There are many "Abstract.php" and "TestCommon.php" files!)

Show
Matthew Weier O'Phinney added a comment - Patch applied to trunk and 1.9 release branch. In the future, please create your patches from the root of your ZF installation to ensure we patch the correct files. (There are many "Abstract.php" and "TestCommon.php" files!)

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: