Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"cakephp/cakephp": "^5.0"
},
"require": {
"php": ">=8.1",
"cakephp/orm": "^5.0"
"php": ">=8.4",
"cakephp/orm": "^5.3.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be necessary to increase the requirements. I'd still expect 5.0 users to be able to use this version. If it's required I'll have to publish a new major version of this package.

},
"autoload": {
"psr-4": {
Expand Down
10 changes: 10 additions & 0 deletions src/ORM/LazyLoadEntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ trait LazyLoadEntityTrait
*/
protected $_unsetProperties = [];

/**
* Override __get, because in Cake 5.3, __get has been overridden, so breaking functionality
* @param string $name
* @return void
*/
public function &__get(string $field): mixed
{
return $this->get($field);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cake has always had a __get() method on the EntityTrait, see:

4.x: https://github.com/cakephp/cakephp/blob/4.x/src/Datasource/EntityTrait.php#L139-L148
5.x: https://github.com/cakephp/cakephp/blob/5.x/src/Datasource/EntityTrait.php#L146-L155

It looks like what has changed is that it now calls getRequiredOrFail(). I'm struggling to understand how this fixed your issue!


/**
* Overrides get() to check for associated data to lazy load, if that
* property doesn't already exist
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/LazyLoadEntityTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LazyLoadEntityTrait test
* @property ArticlesTable $Articles
*/
#[\AllowDynamicProperties]
class LazyLoadEntityTraitTest extends TestCase
{
use LocatorAwareTrait;
Expand Down