Addshore has uploaded a new change for review.

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


Change subject: Fix Undefined Index and array_merge warning in Lib
......................................................................

Fix Undefined Index and array_merge warning in Lib

Found while running update.php

Change-Id: I5c1b88f1fe2c0227f4751a4b25794c61b07a99e8
---
M lib/WikibaseLib.php
M repo/includes/api/EditEntity.php
2 files changed, 24 insertions(+), 0 deletions(-)


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

diff --git a/lib/WikibaseLib.php b/lib/WikibaseLib.php
index 65a7120..f4d7311 100644
--- a/lib/WikibaseLib.php
+++ b/lib/WikibaseLib.php
@@ -49,6 +49,10 @@
        include_once( __DIR__ . '/../vendor/autoload.php' );
 }
 
+if( !array_key_exists( 'evilDataValueMap', $GLOBALS ) ) {
+       $GLOBALS['evilDataValueMap'] = array();
+}
+
 $GLOBALS['evilDataValueMap'] = array_merge(
        $GLOBALS['evilDataValueMap'],
        array(
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 72ba60d..7eaa365 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -23,6 +23,7 @@
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\Entity;
 use Wikibase\EntityContent;
+use Wikibase\EntityLookup;
 use Wikibase\Item;
 use Wikibase\Lib\ClaimGuidGenerator;
 use Wikibase\Lib\Serializers\SerializerFactory;
@@ -55,12 +56,20 @@
        protected $validLanguageCodes;
 
        /**
+        * @since 0.5
+        *
+        * @var EntityLookup
+        */
+       protected $entityLookup;
+
+       /**
         * @see ApiBase::_construct()
         */
        public function __construct( $mainModule, $moduleName ) {
                parent::__construct( $mainModule, $moduleName );
 
                $this->validLanguageCodes = array_flip( 
Utils::getLanguageCodes() );
+               $this->entityLookup = 
WikibaseRepo::getDefaultInstance()->getEntityLookup();
        }
 
        /**
@@ -127,13 +136,24 @@
                $data = json_decode( $params['data'], true );
                $this->validateDataProperties( $data, $entityContent );
 
+               $currentEntity = $this->entityLookup->getEntity( 
$entity->getId() );
                if ( $params['clear'] ) {
+                       // If we are not clearing the current revision then die!
+                       if( 
!$entityContent->getEntityRevision()->getEntity()->equals( $currentEntity ) ) {
+                               wfProfileOut( __METHOD__ );
+                               $this->dieUsage(
+                                       'Tried to clear entity using baserevid 
of entity with content not equal to that of latest
+                                       revision',
+                                       'editconflict'
+                               );
+                       }
                        $entity->clear();
                }
 
                // if we create a new property, make sure we set the datatype
                if( !$entityContent->getTitle()->exists() && $entity instanceof 
Property ){
                        if ( !isset( $data['datatype'] ) ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'No datatype given', 
'param-illegal' );
                        } else {
                                $entity->setDataTypeId( $data['datatype'] );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c1b88f1fe2c0227f4751a4b25794c61b07a99e8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

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

Reply via email to