-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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]: Property source is overwritten in models #16514
Comments
Related to this: There is also a test in the database that checks for this in particular. Have a look here: https://github.com/phalcon/cphalcon/blob/master/tests/database/Mvc/Model/SaveCest.php#L585 I checked the code once more and there is no Can you test this again or provide a script that we can run against the testing suite? |
Just created a new Phalcon empty app, to reproduce the problem. It happens not during model save but already on model creation from database. Here is a simple code: <?php
use Phalcon\Http\Response;
class TestController extends \Phalcon\Mvc\Controller
{
public function indexAction()
{
$result = Test::find();
$response = new Response();
$response->setJsonContent(
$result
);
return $response;
}
} Model <?php
use Phalcon\Mvc\Model;
class Test extends Model
{
public $id;
public $name;
public $source;
public $description;
} SQL Table CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`source` varchar(50) DEFAULT NULL,
`description` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `test` (`id`, `name`, `source`, `description`) VALUES
(1, 'one', 'internet', '234'),
(2, 'two', 'github', '123'),
(3, 'three', 'google', '553453'); Script output with Phalcon 5.6: Script output with Phalcon 5.4: |
@KirDE Thank you for this. I was able to reproduce it. The issue is in the The recent change of #16491 is related, since it takes into account getters to populate the array. As a result, it finds the I am going to put a conditional there to ignore the Fix incoming. |
Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord
Describe the bug
If filed in database called
source
, content of it is overwritten with table name.May be related to #11253
Could have something with method setSource() in a Model?.
To Reproduce
Get data from any table with field called
source
- content will be replaced with table name.It doesn't matter, if
$this->setSource('tablename')
is called in initialize or table name is detected automatically from model name.Expected behavior
source
should contain data from database.Screenshots
If applicable, add screenshots to help explain your problem.
Details
Additional information
Checked other keywords, they are not affected (
transaction
,group
).Workaround for those who facing the bug - use version 5.4 or replace
source
with another field name.The text was updated successfully, but these errors were encountered: