in2code-de / in2publish_core

in2publish Community Version
https://www.in2code.de/produkte/content-publisher/
GNU General Public License v3.0
40 stars 23 forks source link

[FEATURE] Inline MM processing allowed #20

Closed birgerstoeckelmann closed 7 years ago

birgerstoeckelmann commented 7 years ago

Hello,

we discovered a problem with an additional page field configured as inline m:n relation. This is the relation configuration of the field:

'config' => [
            'type' => 'inline',
            'foreign_table' => 'tx_smssystems_domain_model_relation',
            'MM' => 'tx_smssystems_pages_relation_mm',

The MM table has two keys uid_local and uid_foreign as usual, no uid field.

Records related to this page field are published, but the relation itself is not transferred. The needed inserts in the mm tables are missing in the live system.

To solve this problem we first modified the InlineProcessor class to allow the 'MM' config property. If this config entry is set, the FOREIGN_FIELD config entry is not required anymore and is unset. This needs to be done because otherwise the inline field configuration is put into the incompatible TCA configuration (FOREIGN_FIELD is missing) and on the other hand the method fetchRelatedRecordsByInlineMm in the CommonRepository class would log an error (line 1434).

The second modification is in the fetchRelatedRecordsByInlineMm method itself when findPropertiesByProperty is called with a missing (better: with the wrong default value "uid") value for the parameter indexField. In the m:n-relations the indexField is a combination of uid_local and uid_foreign of the mm-table and therefore the value for the indexField parameter is "uid_local,uid_foreign" (line 1454, 1456).

Now the Publish Overview module correctly shows all relations to this field, the records and the mm-table entries (the model above even contains properties with other m:n-relations which all are shown correctly in the list). All records and relations are published successfully to the live system.

Could you please check this pull request and tell us if this works for you too? We absolutly need a way to publish inline m:n relations belonging to a custom page field.

Thanks again ;)

birgerstoeckelmann commented 7 years ago

Hi @vertexvaar, thank you for your quick answer and review! I changed the canPreProcess method to add reasons if a wrong configuration is given. Please let me now if you would implement the checking somewhere different ;)

birgerstoeckelmann commented 7 years ago

Line removed ;)