Doctrine 1
  1. Doctrine 1
  2. DC-307

Oracle adapter statement is not behavin correctly when error mode is Doctrine_Core::ERRMODE_SILENT or Doctrine_Core::ERRMODE_WARNING

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.2.1
    • Component/s: None
    • Labels:
      None

      Description

      Fetch column method looks like this:

      public function fetchColumn($columnIndex = 0)
      {
      if ( ! is_integer($columnIndex)) {
      $this->handleError(array('message'=>"columnIndex parameter should be numeric"));
      }
      $row = $this->fetch(Doctrine_Core::FETCH_NUM);
      return $row[$columnIndex];
      }

      Method handleError() not always throws an exception, and by passing it a string or any other variable type than integer will result in warning.

      Fix (depending on what is considered to be required by interface):

      if ( ! is_integer($columnIndex)) {
      $this->handleError(array('message'=>"columnIndex parameter should be numeric"));
      return false;
      }

      or

      if ( ! is_integer($columnIndex)) {
      throw new Doctrine_Adapter_Exception("columnIndex parameter should be numeric");
      }

        Activity

        Hide
        Juozas Kaziukenas added a comment -

        Fixed code comments

        Show
        Juozas Kaziukenas added a comment - Fixed code comments
        Hide
        Jonathan H. Wage added a comment -

        I don't quite understand what you are wanting me to change here. can you explain?

        Show
        Jonathan H. Wage added a comment - I don't quite understand what you are wanting me to change here. can you explain?
        Hide
        Jonathan H. Wage added a comment -

        Nevermind, I understand. I think returning false is probably the right choice, don';t you think?

        Show
        Jonathan H. Wage added a comment - Nevermind, I understand. I think returning false is probably the right choice, don';t you think?
        Hide
        Juozas Kaziukenas added a comment -

        If I pass:

        fetchColumn('test')

        and the error level is set like above, this code will generate php notice, because you will be trying:

        return $row['test'];

        So the problem is - when handleError() is not throwing exception, check is_integer() is almost ignored.

        Show
        Juozas Kaziukenas added a comment - If I pass: fetchColumn('test') and the error level is set like above, this code will generate php notice, because you will be trying: return $row ['test'] ; So the problem is - when handleError() is not throwing exception, check is_integer() is almost ignored.
        Hide
        Juozas Kaziukenas added a comment -

        I would say false is correct. Although it depends on what interface is expecting.

        I don't know about Oracle, but some RDBMS support boolean types and false can be a value too, so when you are returning false here, in user code it would be hard to detect a problem. (although it's hardly plausible)

        Show
        Juozas Kaziukenas added a comment - I would say false is correct. Although it depends on what interface is expecting. I don't know about Oracle, but some RDBMS support boolean types and false can be a value too, so when you are returning false here, in user code it would be hard to detect a problem. (although it's hardly plausible)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Juozas Kaziukenas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: