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

findByPropertyWithJoin in SingleDatabaseRespository should check primary keys #120

Open
birgerstoeckelmann opened this issue Sep 4, 2024 · 2 comments
Assignees

Comments

@birgerstoeckelmann
Copy link

Dear in2code team,

We had a problem with relations that were to be updated in the database on the foreign system, but a ‘Duplicate Key’ exception occurred during publishing.

After analysing, we were able to determine that MM relations in the ‘sys_category_record_mm’ table should be updated, although they were different relations via the ‘tablenames’ and ‘fieldname’ columns.

Our starting point was a field that simply saves categories as CSV values, but the problem can presumably also be found in other MM relations.

In the SingleDatabaseRepository class (vendor/in2code/in2publish_core/Classes/Component/Core/Repository/SingleDatabaseRepository. php) there is the method ‘findByPropertyWithJoin’ - here an identifier hash is generated based on the array entries ‘$splitRow[’mmtbl‘][’uid_local‘]’ and ‘$splitRow[’mmtbl‘][’uid_foreign‘]’.
If there are now entries with the same uid_local and uid_foreign but different values in ‘tablenames’ and/or ‘fieldname’, these are given the same identifier (see screenshot).

Bildschirmfoto 2024-09-02 um 15 32 18

At this point, the primary key of the table ‘$splitRow[’table‘]’ would have to be analysed in order to create a correct hash across all fields of the key.

We have solved it on the clamp at this point:

$mmIdentityProperties = [ $splitRow['mmtbl']['uid_local'], $splitRow['mmtbl']['uid_foreign'], ]; if(isset($splitRow['mmtbl']['tablenames'])) { $mmIdentityProperties[] = $splitRow['mmtbl']['tablenames']; } if(isset($splitRow['mmtbl']['fieldname'])) { $mmIdentityProperties[] = $splitRow['mmtbl']['fieldname']; }

Publisher version: 12.5.3

@tinzog
Copy link
Contributor

tinzog commented Sep 4, 2024

Thanks for opening this issue.
We will investigate this as soon as possible .

@sbusemann
Copy link
Contributor

sbusemann commented Sep 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants