Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Model::find() protected/private property access public #14766

Closed
tidytrax opened this issue Jan 23, 2020 · 15 comments
Closed

[BUG]: Model::find() protected/private property access public #14766

tidytrax opened this issue Jan 23, 2020 · 15 comments
Labels
bug external dependency status: medium

Comments

@tidytrax
Copy link
Contributor

@tidytrax tidytrax commented Jan 23, 2020

Using get-set and protected property

class Model extends \Phalcon\Mvc\Model
{
    protected $prop;

    public function getProp()
    {
        return $this->prop;
    }

    public function setProp($prop)
    {
        $this->prop = $prop;
        return $this;
    }
}
$model = new Model();
**_Protected, Can't access._**
echo $model->prop;
$model->prop = 1;

**_Work can access_**
$model->setProp() OR $model->getProp(); 
$resultset = Model::find();
foreach ( $resultset as $row ) {
   echo $row->prop; //Works
   $row->prop = 1;
}

Config
Phalcon 4.0.2 / PHP 7.4.2 / Postgresql 12.1/Nginx 1.16.1

@tidytrax tidytrax added bug status: unverified labels Jan 23, 2020
@tidytrax tidytrax changed the title [BUG]: Model::find() protected proprerty public [BUG]: Model::find() protected property access public Jan 23, 2020
@ruudboon ruudboon added the 4.0.3 label Jan 24, 2020
@ruudboon
Copy link
Sponsor Member

@ruudboon ruudboon commented Jan 24, 2020

@tidytrax Is this occurring with properties as private as well?

@ruudboon ruudboon added this to Backlog in Phalcon Roadmap Jan 24, 2020
@tidytrax
Copy link
Contributor Author

@tidytrax tidytrax commented Jan 24, 2020

@tidytrax Is this occurring with properties as private as well?

Yes I tested now and private work also, same code above, but with private prop

foreach ( Model::find() as $row ) {
   echo $row->prop;
}

@ruudboon
Copy link
Sponsor Member

@ruudboon ruudboon commented Jan 24, 2020

@tidytrax thnx. We will have a look at it

@tidytrax
Copy link
Contributor Author

@tidytrax tidytrax commented Jan 24, 2020

@tidytrax thnx. We will have a look at it

Thanks, it's not a big problem, but the postgres boolean(14722) is killing my app.

Could you provide me with some turn around ? like someway to bring all fields as string.

@tidytrax tidytrax changed the title [BUG]: Model::find() protected property access public [BUG]: Model::find() protected/private property access public Jan 24, 2020
@tidytrax
Copy link
Contributor Author

@tidytrax tidytrax commented Jan 24, 2020

The bug occurs on Model::findFirst() also

@ruudboon ruudboon moved this from Backlog to Working on it in Phalcon Roadmap Jan 25, 2020
@ruudboon ruudboon added documentation and removed status: unverified labels Jan 25, 2020
@ruudboon ruudboon self-assigned this Jan 25, 2020
@ruudboon ruudboon added status: unverified and removed documentation labels Jan 25, 2020
@ruudboon
Copy link
Sponsor Member

@ruudboon ruudboon commented Jan 25, 2020

I wasn't able to reproduce this. Can you check the type of object you get from the result set?
Maybe the hydrate mode is incorrect?

$resultset->setHydrateMode(
            Resultset::HYDRATE_RECORDS
);

@tidytrax
Copy link
Contributor Author

@tidytrax tidytrax commented Jan 25, 2020

$model = UserSession::findFirst(['hydration' => Resultset::HYDRATE_RECORDS]);
$model->url = '/';
$model->save();

Work's even with hydrate.

@tidytrax
Copy link
Contributor Author

@tidytrax tidytrax commented Jan 25, 2020

Just a info, The Model extends an AbstractModel
The Abstract Model has the proprerties
And the public get-set

@ruudboon
Copy link
Sponsor Member

@ruudboon ruudboon commented Jan 25, 2020

Just a info, The Model extends an AbstractModel

Like this?

class AbstractModel extends \Phalcon\Mvc\Model
{
    protected $prop;

    public function getProp()
    {
        return $this->prop;
    }

    public function setProp($prop)
    {
        $this->prop = $prop;
        return $this;
    }
}

class MyModel extends AbstractModel {

}

$model = MyModel::findFirst();
$model->prop = 'secret';
$model->save();

@ruudboon ruudboon added 4.0.4 and removed 4.0.3 labels Jan 25, 2020
@tidytrax
Copy link
Contributor Author

@tidytrax tidytrax commented Jan 25, 2020

Yes exactly .
works on both way $model->prop or $model->setProp()

@ruudboon
Copy link
Sponsor Member

@ruudboon ruudboon commented Jan 25, 2020

Will write some extra tests for this to see if we can reproduce this. Are you on Linux?

@tidytrax
Copy link
Contributor Author

@tidytrax tidytrax commented Jan 25, 2020

Will write some extra tests for this to see if we can reproduce this. Are you on Linux?

Vagrant 2.2.6 VirtualBox 6.0.14 Ubuntu 19.10
Host Windows 10.

@Jurigag
Copy link
Contributor

@Jurigag Jurigag commented Feb 4, 2020

Related zephir-lang/zephir#2056, zephir-lang/zephir#2078, zephir-lang/zephir#2057

@ruudboon ruudboon removed their assignment Feb 7, 2020
@ruudboon ruudboon moved this from Working on it to Current Sprint (Ends February 7th) in Phalcon Roadmap Feb 7, 2020
@ruudboon ruudboon added status: medium external dependency and removed status: unverified labels Feb 7, 2020
@Jeckerson Jeckerson added 4.0.5 and removed 4.0.4 labels Feb 15, 2020
@niden niden added 4.0.6 and removed 4.0.5 labels Mar 8, 2020
@sergeyklay sergeyklay self-assigned this Mar 13, 2020
@sergeyklay sergeyklay removed their assignment Mar 26, 2020
@sergeyklay
Copy link
Member

@sergeyklay sergeyklay commented Apr 23, 2020

Zephir issue has been fixed in #2078. I'll release new version ASAP

@sergeyklay
Copy link
Member

@sergeyklay sergeyklay commented Apr 24, 2020

Zephir 0.12.18 released: https://github.com/phalcon/zephir/releases/tag/0.12.18

@niden niden added 4.1.0 and removed 4.0.6 labels May 18, 2020
@Jeckerson Jeckerson added 5.0 and removed 4.1.0 5.0 labels Sep 30, 2020
Phalcon Roadmap automation moved this from Active Sprint Tasks to Implemented Sep 30, 2020
@niden niden moved this from Implemented to Released in Phalcon Roadmap Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug external dependency status: medium
Projects
Phalcon Roadmap
  
Released
Development

No branches or pull requests

6 participants