r25026 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25025‎ | r25026 | r25027 >
Date:01:25, 22 August 2007
Author:kim
Status:old
Tags:
Comment:
CopyTo now working again, though not without an additional gnarly
dc global hack.

(You may point and laugh at me now)

Hopefully I can pull all these hacks sometime soon.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php
@@ -471,6 +471,12 @@
472472
473473 function translatedTextExists($textId, $languageId) {
474474 $dc=wdGetDataSetContext();
 475+
 476+ if (is_null($textId))
 477+ throw new Exception("textId is null");
 478+ if (is_null($languageId))
 479+ throw new Exception("languageId is null");
 480+
475481 $dbr = &wfGetDB(DB_SLAVE);
476482 $queryResult = $dbr->query(
477483 "SELECT translated_content_id" .
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php
@@ -629,17 +629,18 @@
630630
631631 $o=OmegaWikiAttributes::getInstance();
632632
633 - if ($viewInformation->filterLanguageId == 0)
 633+ if ($viewInformation->filterLanguageId == 0) {
634634 return getTranslatedContentRecordSet($translatedContentId, $viewInformation);
635 - else {
 635+
 636+ } else {
636637 $recordSet = getFilteredTranslatedContentRecordSet($translatedContentId, $viewInformation);
637638
638639 if (count($viewInformation->queryTransactionInformation->versioningAttributes()) > 0)
639640 return $recordSet;
640641 else {
641 - if ($recordSet->getRecordCount() > 0)
 642+ if ($recordSet->getRecordCount() > 0) {
642643 return $recordSet->getRecord(0)->text;
643 - else
 644+ } else
644645 return "";
645646 }
646647 }
@@ -651,6 +652,7 @@
652653 global
653654 $translatedContentTable;
654655
 656+
655657 $o=OmegaWikiAttributes::getInstance();
656658
657659 $recordSet = queryRecordSet(
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -155,12 +155,10 @@
156156 $record->possiblySynonymous = getPossiblySynonymousRecordSet($id, $view);
157157 $filterRelationTypes[] = $view->possiblySynonymousRelationTypeId;
158158 }
159 -
160159 $record->relations = getDefinedMeaningRelationsRecordSet($id, $filterRelationTypes, $view);
161160 $record->reciprocalRelations = getDefinedMeaningReciprocalRelationsRecordSet($id, $view);
162161 $record->classMembership = getDefinedMeaningClassMembershipRecordSet($id, $view);
163162 $record->collectionMembership= getDefinedMeaningCollectionMembershipRecordSet($id, $view);
164 -
165163 $objectAttributesRecord = getObjectAttributesRecord($id, $view);
166164 $record->definedMeaningAttributes = $objectAttributesRecord;
167165 applyPropertyToColumnFiltersToRecord($record, $objectAttributesRecord, $view);
@@ -189,6 +187,7 @@
190188 # more here?
191189 $expression->createNewInDatabase();
192190
 191+
193192 # shouldn't this stuff be protected?
194193 $expressionId=$expression->id;
195194 $languageId=$expression->languageId;
@@ -203,6 +202,7 @@
204203 echo "id: $expressionId lang: $languageId";
205204 $definedMeaningId=createNewDefinedMeaning($expressionId, $languageId, $text);
206205
 206+
207207 getDefinedMeaningEditor($this->viewInformation)->save(
208208 $this->getIdStack($definedMeaningId),
209209 $this->getRecord()
@@ -256,7 +256,10 @@
257257 */
258258 public function getRecord() {
259259 if(!$this->recordIsLoaded) {
 260+
 261+ $this->hackDC($this->dataset); // XXX don't do this at home
260262 $this->loadRecord();
 263+ $this->unhackDC(); // XXX very evil
261264 }
262265 if(!$this->recordIsLoaded) {
263266 return null;
@@ -279,7 +282,6 @@
280283
281284 $record=$this->getRecord();
282285 $expression=$record->expression;
283 - echo var_dump($expression);
284286 $spelling=$expression->definedMeaningDefiningExpression;
285287 $language=$expression->language;
286288 return findOrCreateExpression($spelling, $language);
@@ -308,6 +310,31 @@
309311 # use proper OO for this.
310312 }
311313
 314+ /* XXX
 315+ * 2 very dirty functions, as a placeholder to make things work
 316+ * this very instant.
 317+ * Take the already evil global context, and twist it to our
 318+ * own nefarious ends, then we put it back ASAP and hope nobody
 319+ * notices.
 320+ * Of course, one day they will.
 321+ * Before then, this should be refactored out.
 322+ * Probably by next week friday
 323+ * XXX */
 324+ protected $_saved_dc=null;
 325+ public function hackDC($to_dataset) {
 326+ global
 327+ $wdCurrentContext;
 328+
 329+ $this->_saved_dc=$wdCurrentContext;
 330+ $wdCurrentContext=$to_dc;
 331+ }
 332+
 333+ public function unhackDC() {
 334+ global
 335+ $wdCurrentContext;
 336+ $wdCurrentContext=$this->_saved_dc;
 337+ }
 338+
312339 /**
313340 * Return one of the syntrans entries of this defined meaning,
314341 * specified by language code. Caches the syntrans records

Status & tagging log