Addshore has uploaded a new change for review.

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


Change subject: Implement hack to avoid UI throwing this error
......................................................................

Implement hack to avoid UI throwing this error

Bug: 58394
Change-Id: I5e5e39d443889ec586bff16f1604d238633a901e
---
M repo/includes/ChangeOp/ChangeOpClaim.php
M repo/tests/phpunit/includes/api/SetClaimTest.php
2 files changed, 21 insertions(+), 4 deletions(-)


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

diff --git a/repo/includes/ChangeOp/ChangeOpClaim.php 
b/repo/includes/ChangeOp/ChangeOpClaim.php
index 2a310bf..4f6c10b 100644
--- a/repo/includes/ChangeOp/ChangeOpClaim.php
+++ b/repo/includes/ChangeOp/ChangeOpClaim.php
@@ -101,8 +101,26 @@
                        try{
                                $indexedClaimList->addObjectAtIndex( 
$this->claim, $this->index );
                        }
-                       catch( OutOfBoundsException $e ){
-                               throw new ChangeOpException( "Can not add claim 
at given index : ". $this->index );
+                       catch( OutOfBoundsException $e ) {
+                               /**
+                                * XXX: The below is hacky due to bug 58394
+                                * If we fail with the user supplied index and 
the index is greater than 0
+                                * presume the user wants to have the index at 
the end of the list
+                                */
+                               if( $this->index < 0 ) {
+                                       throw new ChangeOpException( 'Can not 
add claim at given index : '. $this->index );
+                               } else {
+                                       $hackIndex = $indexedClaimList->count() 
+ 1;
+                                       try{
+                                               
$indexedClaimList->addObjectAtIndex( $this->claim, $hackIndex );
+                                       }
+                                       catch( OutOfBoundsException $e ) {
+                                               throw new ChangeOpException(
+                                                       'Can not add claim at 
given index : '. $this->index . ' ' .
+                                                       'Or at index : ' . 
$hackIndex
+                                               );
+                                       }
+                               }
                        }
 
                } else {
diff --git a/repo/tests/phpunit/includes/api/SetClaimTest.php 
b/repo/tests/phpunit/includes/api/SetClaimTest.php
index 897b81f..7372d60 100644
--- a/repo/tests/phpunit/includes/api/SetClaimTest.php
+++ b/repo/tests/phpunit/includes/api/SetClaimTest.php
@@ -265,8 +265,7 @@
 
        /**
         * @see Bug 58394 - "specified index out of bounds" issue when moving a 
statement
-        * @expectedException UsageException
-        * @expectedExceptionMessage Failed to apply changeOp: Can not create 
claim at given index
+        * @note A hack is  in place in ChangeOpClaim to allow this
         */
        public function testBug58394SpecifiedIndexOutOfBounds() {
                // Initialize item content with empty claims:

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

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

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

Reply via email to