/** * Find a translation with any status for the given language pair and title. */ public function find($sourceTitle, $sourceLanguage, $targetLanguage) { $result = $this->getResult(); $translation = ContentTranslation\Translation::find($sourceLanguage, $targetLanguage, $sourceTitle); if ($translation !== null) { $translator = $translation->translation['lastUpdatedTranslator']; $translation->translation['translatorName'] = ContentTranslation\GlobalUser::newFromId($translator)->getName(); $result->addValue(array('query', 'contenttranslation'), 'translation', $translation->translation); } $this->getResult()->addValue(null, $this->getModuleName(), $result); }
protected function checkTargetUrl($row) { if ($row->translation_status === 'deleted') { return; } $url = $row->translation_target_url; if (trim($url) === '') { return; } // ALERT: assumes certain URL pattern $cutoff = strpos($url, '/wiki/') + 6; $name = rawurldecode(substr($url, $cutoff)); $title = Title::newFromText($name); if (!$title) { if ($row->translation_status === 'published') { $this->output("\\- E10 Translation published, but target is not valid title :(\n"); } else { $this->output("\\- E11 Invalid title, page cannot exist\n"); $this->resets[] = $row->translation_id; } return; } if ($title->exists()) { if ($this->hasCxTag($title, $row)) { if ($row->translation_status === 'draft') { $this->output("\\- E20 Page exists but status is draft\n"); } else { // status=published and page created with CX, the ideal case } } elseif ($title->isRedirect()) { $this->output("\\- E22 Page is a redirect\n"); } else { $user = ContentTranslation\GlobalUser::newFromId($row->translation_started_by); $userName = $user->getName(); $revId = $this->findRevisionToTag($title, $userName, $row->translation_last_updated_timestamp); if ($revId !== false) { $this->output("\\- E25 Page exists but no tag. Can tag rev {$revId} by {$userName}.\n"); $this->tags[] = array($row, $revId); } else { $this->output("\\- E24 Page exists but no tag.\n"); } } return; } $dbr = wfGetDB(DB_SLAVE); $conds = array(); # Assuming timestamps are in the correct format already $conds[] = 'log_timestamp > ' . $dbr->addQuotes($row->translation_start_timestamp); $conds['log_namespace'] = $title->getNamespace(); $conds['log_title'] = $title->getDbKey(); $field = $dbr->selectField('logging', 'log_type', $conds, __METHOD__); if ($field) { $this->output("\\- E30 Page doesn't exist but has log entry: {$field}\n"); return; } if ($row->translation_status === 'published') { $this->output("\\- E40 Translation published, but no sign of target page :(\n"); } else { $this->output("\\- E41 Page doesn't exist and never had log entry\n"); $this->resets[] = $row->translation_id; } return; }