Hoo man has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/304711

Change subject: Only try to add a row in EntityPerPageTable if needed
......................................................................

Only try to add a row in EntityPerPageTable if needed

No need to (re-)insert a row there, if there's already one.

EntityPerPageTable::addEntityPage is called after any entity
edit, see EntityHandler::getEntityModificationUpdates.

Change-Id: I143f37949813e0849711bc808ce48a741c236d11
---
M repo/includes/Store/Sql/EntityPerPageTable.php
1 file changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/11/304711/1

diff --git a/repo/includes/Store/Sql/EntityPerPageTable.php 
b/repo/includes/Store/Sql/EntityPerPageTable.php
index 2aabf66..c05d2de 100644
--- a/repo/includes/Store/Sql/EntityPerPageTable.php
+++ b/repo/includes/Store/Sql/EntityPerPageTable.php
@@ -94,7 +94,9 @@
                        'epp_redirect_target' => $redirectTarget
                );
 
-               $this->addRowInternal( $values );
+               if ( !$this->rowExists( $values ) ) {
+                       $this->addRowInternal( $values );
+               }
        }
 
        /**
@@ -133,6 +135,15 @@
                );
        }
 
+       /**
+        * @param array $row
+        */
+       private function rowExists( array $row ) {
+               $dbw = wfGetDB( DB_MASTER );
+
+               $dbw->selectRow( 'wb_entity_per_page', '*', $row, __METHOD__ ) 
!== false;
+       }
+
        private function getConflictingRowConditions( array $values ) {
                $dbw = wfGetDB( DB_MASTER );
                $indexes = $this->getUniqueIndexes();

-- 
To view, visit https://gerrit.wikimedia.org/r/304711
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I143f37949813e0849711bc808ce48a741c236d11
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <h...@online.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to