r24782 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24781‎ | r24782 | r24783 >
Date:09:59, 14 August 2007
Author:proes
Status:old
Tags:
Comment:
Turned on feature of an ArrayRecord to check whether used Attributes exist. This resulted only in errors in ObjectIdFetcher so I have added a check over there. The check will be removed later after refactoring ObjectIdFetcher.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Attribute.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Fetcher.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/Fetcher.php
@@ -13,8 +13,14 @@
1414 $this->attributeLevel = $attributeLevel;
1515 $this->attribute = $attribute;
1616 }
 17+
1718 public function fetch($keyPath) {
18 - return $keyPath->peek($this->attributeLevel)->getAttributeValue($this->attribute);
 19+ $key = $keyPath->peek($this->attributeLevel);
 20+
 21+ if ($key->getStructure()->supportsAttribute($this->attribute))
 22+ return $key->getAttributeValue($this->attribute);
 23+ else
 24+ return null;
1925 }
2026 }
2127
Index: trunk/extensions/Wikidata/OmegaWiki/Attribute.php
@@ -34,11 +34,11 @@
3535 if(is_null($this->id) && ($this->type instanceof Structure)) {
3636 $this->id = $this->type->getStructureType();
3737 // Override structure label with a more specific one
38 - } elseif(!is_null($this->id) && ($this->type instanceof Structure)) {
 38+ }
 39+ elseif(!is_null($this->id) && ($this->type instanceof Structure)) {
3940 $this->type->setStructureType($this->id);
4041 }
4142 }
42 -
4343 }
4444
4545 class Structure {
@@ -122,9 +122,12 @@
123123 return "Structure(" . implode(", ", $this->attributeIds) . ")";
124124 }
125125
 126+ public function supportsAttribute(Attribute $attribute) {
 127+ return $this->supportsAttributeId($attribute->id);
 128+ }
 129+
126130 public function supportsAttributeId($attributeId) {
127 - return true;
128 -// return in_array($attributeId, $this->attributeIds);
 131+ return in_array($attributeId, $this->attributeIds);
129132 }
130133 }
131134

Status & tagging log