There are certain scenarios when moving a statement in the UI results in an "specified index is out of bounds" error.
Version: master
Severity: major
Whiteboard: backlog
There are certain scenarios when moving a statement in the UI results in an "specified index is out of bounds" error.
Version: master
Severity: major
Whiteboard: backlog
This occurs, for example, when adding three statements with a property not yet featured by the item.
The UI sends the correct information, although the baseRevId sent along with the request is, of course, the one received when the item was loaded since that one is not updated by the "add statement" operation.
When the entity content is loaded in the SetClaim module, the initial set of claims/statements as to the baseRevId is loaded and passed to ChangeOpClaim. Consequently, the statements just added are missing and the index where to place the statements within the flat list of statements is wrong because the statements previously added are not detected being in the list of statements.
I've seen this happen plenty (10+) times. How to reproduce:
Exception Caught: Specified index is out of bounds"
#0 extensions\Wikibase\vendor\wikibase\data-model\src\Wikibase\DataModel\ByPropertyIdArray.php(432): Wikibase\DataModel\ByPropertyIdArray->moveObjectToIndex(Object(Wikibase\DataModel\Claim\Statement), 3)
#1 extensions\Wikibase\repo\includes\ChangeOp\ChangeOpClaim.php(100): Wikibase\DataModel\ByPropertyIdArray->addObjectAtIndex(Object(Wikibase\DataModel\Claim\Statement), 3)
#2 extensions\Wikibase\repo\includes\api\SetClaim.php(64): Wikibase\ChangeOp\ChangeOpClaim->apply(Object(Wikibase\DataModel\Entity\Item))
#3 includes\api\ApiMain.php(861): Wikibase\Api\SetClaim->execute()
#4 includes\api\ApiMain.php(362): ApiMain->executeAction()
#5 includes\api\ApiMain.php(333): ApiMain->executeActionWithErrorHandling()
#6 api.php(76): ApiMain->execute()
#7 {main}~
Occours whenever the index submitted to wbsetclaim is 2 above the number of claims currently in the item for the baserevid that has been submitted.
i.e. 1 claim on item for baserevid 888 >> submit a new claim with index 3 >> Exception
Change 108503 had a related patch set uploaded by Addshore:
Clean up error for claim index out of bounds
Change 108527 had a related patch set uploaded by Addshore:
Implement hack to avoid UI throwing this error
Change 108672 had a related patch set uploaded by Addshore:
Clean up error for claim index out of bounds