cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[Critical BUG] [Phalcon 1.3.4] [PHP 5.4+] unreliable assignment in modelmanager's createBuilder

Open samuraee opened this issue 12 years ago • 0 comments

I have 2 tables 1 for "Services" and another for "Inbounds" that Inbonuds table has a foreign key to the Services table. Now I want to show Inbounds rows in a in my view. Everything seems OK but there is a not reliable condition with Builder. let to describe:

        $builder = $this->modelsManager->createBuilder()
            ->columns('*')
            ->from('App\Model\Inbounds')
            ->join('App\Model\Services')
            ->orderBy('App\Model\Inbounds.id DESC')
            ->where("1=1");

the output of $builder->getQuery()->getSingleResult() is a Phalcon\Mvc\Model\Row object that contains to properties like below:

object(Phalcon\Mvc\Model\Row)[159]
  public 'autocharge' =>  <-----PROBLEM IS HERE ******************************
    object(App\Model\Inbounds)[160]
      public 'id' => string '12' (length=2)
      public 'msisdn' => string '09121234567' (length=11)
      public 'fk_services_id' => string '1' (length=1)
      public 'created_at' => string '2014-11-29 15:17:00' (length=19)
      public 'autocharge' => string '0' (length=1)
      //
      // blah blah blah ...
      //
  public 'slogan' =>    <-----PROBLEM IS HERE ******************************
    object(App\Model\Services)[161]
      public 'id' => string '1' (length=1)
      public 'mci_service_id' => string '677' (length=3)
      public 'name' => string '...' (length=38)
      public 'status' => string '1' (length=1)
      public 'slogan' => string '...' (length=76)
      // 
      // blah blah blah ...
      //

As you can see in the output's dump, The builder has used the last table's field name (autocharge, slogan) as assign property and this is completely unreliable. I unified the last field's name is both tables and it caused overwriting the assign property.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

samuraee avatar Nov 29 '14 16:11 samuraee