Skip to content

Conversation

Eriknag
Copy link
Contributor

@Eriknag Eriknag commented Jun 26, 2025

I also came across the issue described in #16362

The error happens when you contain a table that was joined earlier on.
In my case the join was added in the findAll method and performed a check on deleted items.
E.g. When an article is set to deleted I want to prevent it's comments from being loaded as well.
And later on, when I used loadInto, it gave the exception.

It also happens when you add a join in the contain options, so that's how I decided to test it.

@othercorey othercorey added this to the 5.2.6 milestone Jun 26, 2025
Comment on lines +6382 to +6383
$expected = $table->get(2, contain: ['Articles.Authors']);
$this->assertEquals($expected, $entity);
Copy link
Member

Choose a reason for hiding this comment

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

Should we also have an assertion on the contained associations being present in both results?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@LordSimal
Copy link
Contributor

shoudln't this go into 4.x and get merged upstream or will this be backported to 4.x?

@dereuromark
Copy link
Member

If it exists in main, we usually always fix first there, and then backport where needed.

@markstory markstory merged commit 4fd9c16 into cakephp:5.x Jul 4, 2025
13 checks passed
markstory pushed a commit that referenced this pull request Jul 4, 2025
* Fixes InvalidArgumentException when joining and containing the same table in a loadInto call
* Fix phpcs Errors
* Add assertions on article and author in TableTest::testloadBelongsToDoubleJoin

---------

Co-authored-by: Erik Nagelkerke <erik.nagelkerke@centerdata.nl>
markstory added a commit that referenced this pull request Jul 7, 2025
* Fixes InvalidArgumentException (#16362) (#18763)

* Fixes InvalidArgumentException when joining and containing the same table in a loadInto call
* Fix phpcs Errors
* Add assertions on article and author in TableTest::testloadBelongsToDoubleJoin

---------

Co-authored-by: Erik Nagelkerke <erik.nagelkerke@centerdata.nl>

* Fix finder syntax

---------

Co-authored-by: Eriknag <inirva@gmail.com>
Co-authored-by: Erik Nagelkerke <erik.nagelkerke@centerdata.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants