WMDE-leszek has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/328488 )

Change subject: Skip invalid entity ids in 
PrefetchingWikiPageEntityMetaDataAccessor
......................................................................

Skip invalid entity ids in PrefetchingWikiPageEntityMetaDataAccessor

When looking up the entity id results in an exception,
the entity id should not be stored in prefetcher's internal cache.
Otherwise the invalid entity id might be looked up again in the
next prefetch call, resulting in the exception not related to the
actual input from caller.

Bug: T153076
Change-Id: I2ffedf6df5dc6e07be19cd2de4a0e70aab6c07fa
---
M lib/includes/Store/Sql/PrefetchingWikiPageEntityMetaDataAccessor.php
1 file changed, 13 insertions(+), 1 deletion(-)


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

diff --git 
a/lib/includes/Store/Sql/PrefetchingWikiPageEntityMetaDataAccessor.php 
b/lib/includes/Store/Sql/PrefetchingWikiPageEntityMetaDataAccessor.php
index 77fd538..6777a65 100644
--- a/lib/includes/Store/Sql/PrefetchingWikiPageEntityMetaDataAccessor.php
+++ b/lib/includes/Store/Sql/PrefetchingWikiPageEntityMetaDataAccessor.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Lib\Store\Sql;
 
+use InvalidArgumentException;
 use MapCacheLRU;
 use stdClass;
 use Wikibase\DataModel\Entity\EntityId;
@@ -196,7 +197,18 @@
                        return;
                }
 
-               $data = $this->lookup->loadRevisionInformation( $this->toFetch, 
$mode );
+               try {
+                       $data = $this->lookup->loadRevisionInformation( 
$this->toFetch, $mode );
+               } catch ( InvalidArgumentException $exception ) {
+                       // Do not store invalid entity ids (causing exceptions 
in lookup).
+
+                       // TODO: if the $exception was of more specific type 
and provided the relevant entity id,
+                       // it would possible to only remove the relevant key 
from toFetch.
+                       $this->toFetch = [];
+
+                       // Re-throw the exception to be handled by caller.
+                       throw $exception;
+               }
 
                // Store the data, including cache misses
                $this->store( $data );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ffedf6df5dc6e07be19cd2de4a0e70aab6c07fa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to