Page MenuHomePhabricator

Edit conflict detection for claims still having some issues
Closed, ResolvedPublic

Description

There are issues when edit conflicts are occurring for claims:

  1. User A edits a claim, User B edits the same claim without refreshing the page before, an error is shown saying "Exception Caught: Can only add \Wikibase\Claim implementing objects to Wikibase\Claims." but it should report an edit conflict instead.
  1. User A edits a claim, User B edits the same claim but clicks on save without actually changing the claim. In that case the claim will be overwritten by User B without notice but an edit conflict should be detected instead.

Version: unspecified
Severity: normal

Details

Reference
bz44101

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:23 AM
bzimport set Reference to bz44101.
bzimport added a subscriber: Unknown Object (MLST).

When bailing on assert violations, you'll see the issue occurs before that point:

Warning: assert(): Assertion failed in /home/j/www/phase3/extensions/Wikibase/lib/includes/claim/Claims.php on line 223

This means

$claims->getByElementHash( $diffOp->getNewValue() );

is returning false (I have verified this) while the list should contain the claim. This makes me suspect there is a bug in HashArray, the class on which Claims is build. Not been able to track it down further so far.

Doing a dump of state causing the error:

added under $claim = $claims->getByElementHash( $diffOp->getNewValue() );

if(!($claim instanceof Claim)) {
q($this, $claims, $sourceHashes, $targetHashes, $claim);
}

<pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>Wikibase\Claims</i>)[<i>108</i>]

<b>object</b>(<i>Wikibase\Statement</i>)[<i>66</i>]
  <i>protected</i> 'references' <font color='#888a85'>=&gt;</font> 
    <b>object</b>(<i>Wikibase\ReferenceList</i>)[<i>109</i>]
  <i>protected</i> 'rank' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>1</font>
  <i>protected</i> 'mainSnak' <font color='#888a85'>=&gt;</font> 
    <b>object</b>(<i>Wikibase\PropertyValueSnak</i>)[<i>67</i>]
      <i>protected</i> 'dataValue' <font color='#888a85'>=&gt;</font> 
        <b>object</b>(<i>Wikibase\EntityId</i>)[<i>68</i>]
          <i>protected</i> 'entityType' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'item'</font> <i>(length=4)</i>
          <i>protected</i> 'numericId' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>28</font>
      <i>protected</i> 'propertyId' <font color='#888a85'>=&gt;</font> 
        <b>object</b>(<i>Wikibase\EntityId</i>)[<i>69</i>]
          <i>protected</i> 'entityType' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'property'</font> <i>(length=8)</i>
          <i>protected</i> 'numericId' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>14</font>
  <i>protected</i> 'qualifiers' <font color='#888a85'>=&gt;</font> 
    <b>object</b>(<i>Wikibase\SnakList</i>)[<i>65</i>]
  <i>protected</i> 'guid' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'q35$9191D62B-EC8A-45AD-8068-BEE0B60308E6'</font> <i>(length=40)</i>

</pre>
<pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>Wikibase\Claims</i>)[<i>110</i>]

<b>object</b>(<i>Wikibase\Statement</i>)[<i>101</i>]
  <i>protected</i> 'references' <font color='#888a85'>=&gt;</font> 
    <b>object</b>(<i>Wikibase\ReferenceList</i>)[<i>96</i>]
  <i>protected</i> 'rank' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>1</font>
  <i>protected</i> 'mainSnak' <font color='#888a85'>=&gt;</font> 
    <b>object</b>(<i>Wikibase\PropertyValueSnak</i>)[<i>88</i>]
      <i>protected</i> 'dataValue' <font color='#888a85'>=&gt;</font> 
        <b>object</b>(<i>Wikibase\EntityId</i>)[<i>95</i>]
          <i>protected</i> 'entityType' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'item'</font> <i>(length=4)</i>
          <i>protected</i> 'numericId' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>22</font>
      <i>protected</i> 'propertyId' <font color='#888a85'>=&gt;</font> 
        <b>object</b>(<i>Wikibase\EntityId</i>)[<i>104</i>]
          <i>protected</i> 'entityType' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'property'</font> <i>(length=8)</i>
          <i>protected</i> 'numericId' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>14</font>
  <i>protected</i> 'qualifiers' <font color='#888a85'>=&gt;</font> 
    <b>object</b>(<i>Wikibase\SnakList</i>)[<i>94</i>]
  <i>protected</i> 'guid' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'q35$9191D62B-EC8A-45AD-8068-BEE0B60308E6'</font> <i>(length=40)</i>

</pre>
<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b> <i>(size=1)</i>

0 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'7efc8e1c8696d2a639dee79bb6d76ab190898aa3'</font> <i>(length=40)</i>

</pre>
<pre class='xdebug-var-dump' dir='ltr'>
<b>array</b> <i>(size=1)</i>

0 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'3cefed471aa6a8cb29eed34f006181d257d9ef6d'</font> <i>(length=40)</i>

</pre>
<pre class='xdebug-var-dump' dir='ltr'><small>boolean</small> <font color='#75507b'>false</font>
</pre>

(In reply to comment #3)

https://gerrit.wikimedia.org/r/#/c/46814/

Update Issue 1:
After that change got merged the error message changed from "Exception Caught: Can only add \Wikibase\Claim implementing objects to Wikibase\Claims." to "Failed to save the change" but it should be "Edit not allowed: Edit conflict." in that case.

Update Issue 2:
This issue is still there.

Issue II should be solved by merit of unchanged values not being possible to save.