r113055 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113054‎ | r113055 | r113056 >
Date:18:11, 5 March 2012
Author:kipcool
Status:deferred
Tags:
Comment:
removed some php warnings
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Controller.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Record.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialImportTSV.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php
@@ -184,6 +184,9 @@
185185 }
186186
187187 public function add( IdStack $idPath, $record ) {
 188+ if ( ! $record->expression ) {
 189+ return;
 190+ }
188191 $definedMeaningId = $idPath->getKeyStack()->peek( 0 )->definedMeaningId;
189192 $expressionValue = $record->expression;
190193
@@ -308,6 +311,11 @@
309312 }
310313 }
311314
 315+/*
 316+ * Controller to add a new expression directly
 317+ * i.e. not by translating an existing DM,
 318+ * but by adding a new word + language + definition
 319+ */
312320 class ExpressionController extends DefaultUpdateController {
313321 protected $spelling;
314322 protected $filterLanguageId;
@@ -319,6 +327,9 @@
320328
321329 public function add( IdStack $idPath, $record ) {
322330 if ( $this->filterLanguageId == 0 ) {
 331+ if ( ! $record->expression ) {
 332+ return;
 333+ }
323334 $expressionLanguageId = $record->expression->language;
324335 } else {
325336 $expressionLanguageId = $this->filterLanguageId;
@@ -433,6 +444,9 @@
434445 }
435446
436447 public function add( IdStack $idPath, $record ) {
 448+ if ( ! $record->link ) {
 449+ return;
 450+ }
437451 $objectId = $this->objectIdFetcher->fetch( $idPath->getKeyStack() );
438452 $linkAttributeId = $this->determineAttributeId( $idPath, "URL", $record->linkAttribute );
439453 $linkValue = $record->link;
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialImportTSV.php
@@ -225,12 +225,5 @@
226226 }
227227
228228 }
229 -
230 -
231 - /* HELPER METHODS START HERE */
232 -
233 - function getLanguage( $columnName ) {
234 -
235 - }
236 -
 229+
237230 }
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php
@@ -88,8 +88,11 @@
8989 */
9090 public function setAttributeValuesByOrder( $values ) {
9191 $atts = $this->structure->getAttributes();
92 - for ( $i = 0; $i < count( $atts ); $i++ )
93 - $this->values[$atts[$i]->id] = $values[$i];
 92+ for ( $i = 0; $i < count( $atts ); $i++ ) {
 93+ if ( array_key_exists ( $i, $values ) ) {
 94+ $this->values[$atts[$i]->id] = $values[$i];
 95+ }
 96+ }
9497 }
9598
9699 /*

Status & tagging log