protected function placeAbbrevsAdd($titleString, $xml) { $this->placeAbbrevsSeenPlaces = array(); $title = Title::newFromText($titleString, NS_PLACE); $titleString = $title->getDBkey(); list($prefName, $locatedIn) = Place::getPrefNameLocatedIn($titleString); list($alis, $altNames) = Place::placeAbbrevsGetData($xml); // get wlh $dbr =& wfGetDB(DB_SLAVE); $sql = 'select * from pagelinks' . ' where pl_namespace = 106 and pl_title = ' . $dbr->addQuotes($titleString) . ' and exists (select * from page where page_namespace = 106 and page_title = pl_title and page_is_redirect = 0)' . ' and exists (select * from page where page_id = pl_from and page_namespace = 108)' . ' limit 1'; $rows = $dbr->query($sql, 'placeAbbrevsCountPagelinks'); $errno = $dbr->lastErrno(); $wlh = 1; while ($row = $dbr->fetchObject($rows)) { $wlh = 0; } $dbr->freeResult($rows); // $priority includes $numSpaces from parent places, which it shouldn't $parents = Place::placeAbbrevsGetParents($locatedIn); foreach ($parents as $parentName => $priority) { $numSpaces = substr_count($prefName, ' '); Place::placeAbbrevsInsertAbbrevs($prefName, $prefName, $parentName, $titleString, $wlh + $numSpaces + $priority + 10); foreach ($altNames as $altName) { $numSpaces = substr_count($altName, ' '); Place::placeAbbrevsInsertAbbrevs($altName, $prefName, $parentName, $titleString, $wlh + $numSpaces + $priority + 24); } } foreach ($alis as $ali) { $parents = Place::placeAbbrevsGetParents($ali); foreach ($parents as $primaryName => $priority) { $numSpaces = substr_count($prefName, ' '); Place::placeAbbrevsInsertAbbrevs($prefName, $prefName, $primaryName, $titleString, $wlh + $numSpaces + $priority + 11); foreach ($altNames as $altName) { $numSpaces = substr_count($altName, ' '); Place::placeAbbrevsInsertAbbrevs($altName, $prefName, $primaryName, $titleString, $wlh + $numSpaces + $priority + 25); } } } }