X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fchangetags%2FChangeTags.php;h=7e4dd006ac42e3e3f9518a7b392f2ae6047c9bea;hp=95848ea0850eda0d9eebec0b1b40c9c48cad4530;hb=faf7cc4a09848c538320bd2b9067b1a77c0a0183;hpb=a18476eab39dc201384c68cbd27228c5af32f7fc diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 95848ea085..7e4dd006ac 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -408,19 +408,24 @@ class ChangeTags { sort( $prevTags ); sort( $newTags ); if ( $prevTags == $newTags ) { - // No change. return false; } if ( !$newTags ) { - // no tags left, so delete the row altogether + // No tags left, so delete the row altogether $dbw->delete( 'tag_summary', $tsConds, __METHOD__ ); } else { - $dbw->replace( 'tag_summary', - [ 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ], - array_filter( array_merge( $tsConds, [ 'ts_tags' => implode( ',', $newTags ) ] ) ), - __METHOD__ - ); + // Specify the non-DEFAULT value columns in the INSERT/REPLACE clause + $row = array_filter( [ 'ts_tags' => implode( ',', $newTags ) ] + $tsConds ); + // Check the unique keys for conflicts, ignoring any NULL *_id values + $uniqueKeys = []; + foreach ( [ 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ] as $uniqueColumn ) { + if ( isset( $row[$uniqueColumn] ) ) { + $uniqueKeys[] = [ $uniqueColumn ]; + } + } + + $dbw->replace( 'tag_summary', $uniqueKeys, $row, __METHOD__ ); } return true;