Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.6.1, 0.7, 0.8, 0.9, 1.0, 1.1
    • Fix Version/s: 0.9
    • Component/s: PHP - Library
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      There are two double function calls in the transport classes to strlen, which can easily prevented. See the attached patch file.

        Activity

        Jake Farrell made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Jake Farrell [ jfarrell ]
        Fix Version/s 0.9 [ 12316294 ]
        Resolution Fixed [ 1 ]
        D. Edler made changes -
        Description There are two double Function calls to strlen, which can easily prevented.


        Index: trunk/lib/php/src/transport/TTransport.php
        ===================================================================
        --- trunk/lib/php/src/transport/TTransport.php (revision 1292723)
        +++ trunk/lib/php/src/transport/TTransport.php (working copy)
        @@ -81,7 +81,7 @@
           public function readAll($len) {
             // return $this->read($len);
         
        - $data = '';
        + $data = $this->read($len - $got);
             $got = 0;
             while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
               $data .= $this->read($len - $got);
        Index: trunk/lib/php/src/transport/TMemoryBuffer.php
        ===================================================================
        --- trunk/lib/php/src/transport/TMemoryBuffer.php (revision 1292723)
        +++ trunk/lib/php/src/transport/TMemoryBuffer.php (working copy)
        @@ -54,13 +54,15 @@
           }
         
           public function read($len) {
        - if (TStringFuncFactory::create()->strlen($this->buf_) === 0) {
        + $bufLength = TStringFuncFactory::create()->strlen($this->buf_);
        +
        + if ($bufLength === 0) {
               throw new TTransportException('TMemoryBuffer: Could not read ' .
                                             $len . ' bytes from buffer.',
                                             TTransportException::UNKNOWN);
             }
         
        - if (TStringFuncFactory::create()->strlen($this->buf_) <= $len) {
        + if ($bufLength <= $len) {
               $ret = $this->buf_;
               $this->buf_ = '';
               return $ret;
        There are two double function calls in the transport classes to strlen, which can easily prevented. See the attached patch file.
        D. Edler made changes -
        Field Original Value New Value
        Attachment patch.diff [ 12515736 ]
        D. Edler created issue -

          People

          • Assignee:
            Jake Farrell
            Reporter:
            D. Edler
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 10m
              10m
              Remaining:
              Remaining Estimate - 10m
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development