AnsweredAssumed Answered

Potential bug in M2MRelationship::compareRow causes duplicate relationships

Question asked by Francesca Shiekh on Dec 18, 2015

I believe that in the following function found in



should consider whether the definition also contains a primary_flag_column and ignore that too when comparing, as well as ignoring the id and date_modified.



     * Used to check for duplicate rows for this relationship. Compares all fields rather than just id's.


     * @param       $currentRow existing row

     * @param       $dataToInsert new row to be inserted

     * @param array $ignoreFields fields to ignore for duplicate comparison


     * @return bool true if rows are identical.


    protected function compareRow($currentRow, $dataToInsert, $ignoreFields = array('id', 'date_modified'))


        foreach($dataToInsert as $field => $value) {

            if (!in_array($field, $ignoreFields) && (!isset($currentRow[$field]) || $currentRow[$field] != $value)) {

                return false;




        return true;






Thank you Brett Zufelt for putting me on the right track.