Closed Patricio-Byte-Solution closed 2 years ago
Duplicate of #4360 ?
Maybe need to revive #4368? @najdanovicivan are you available/interested to complete that?
@MGatner Iβm willing to work on this one but Iβm currently on vacation. I wont be able to start working on this one before the September 5th
Not a problem! We're all volunteers doing what we can when we can π€ If this isn't feasible for you then please speak up so others will take it on - no judgement whatsoever (I haven't written code for CI4 in months).
Does this issue has been solved at current develop branch?
Because I can't reproduce the output by using the same Steps to Reproduce
code.
This is the output what I get, as this image shows that the type of sonEntity is array
without SonEntity Object
.
Does this issue has been solved at current develop branch?
Yes, I cannot reproduce the issue.
On develop
branch.
<?php
namespace App\Controllers;
use CodeIgniter\Entity\Entity;
class Home extends BaseController
{
public function index()
{
$entityFather = new Entity();
$entityFather->name = 'Patricio';
$entityFather->sonEntity = new Entity(['name' => 'Maximo', 'age' => 18]);
$rawArray = $entityFather->toRawArray(false, true);
dd($rawArray);
}
}
$ php public/index.php
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β $rawArray β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
array (2) [
'name' => string (8) "Patricio"
'sonEntity' => array (2) [
'name' => string (6) "Maximo"
'age' => integer 18
]
]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Called from .../app/Controllers/Home.php:18 [dd()]
The model fails to save entities when they have internal entities. This occurs because of an error in the code in
system\Model.php
. Specifically in the functionobjectToRawArray()
. When "parent::objectToRawArray($data, $onlyChanged);
" is called in that function, the parameter "$recursive
" is missing.
I don't know this is a bug or not.
I don't know this is a bug or not.
Looks like it to me!
PHP Version
8.0
CodeIgniter4 Version
4.2.1
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
MySQL
What happened?
The model fails to save entities when they have internal entities. This occurs because of an error in the code in
system\Model.php
. Specifically in the functionobjectToRawArray()
. When "parent::objectToRawArray($data, $onlyChanged);
" is called in that function, the parameter "$recursive
" is missing.Steps to Reproduce
Expected Output
Anything else?
Thank you very much for your work.