/** * Find pages in mainspace that have a prefix of the new namespace * so we know titles that will need migrating * @param $ns int Namespace id (id for new namespace?) * @param $name String Prefix that is being made a namespace */ private function getConflicts( $ns, $name ) { $page = 'page'; $table = $this->db->tableName( $page ); $prefix = $this->db->strencode( $name ); $encNamespace = $this->db->addQuotes( $ns ); $titleSql = "TRIM(LEADING '$prefix:' FROM {$page}_title)"; if( $ns == 0 ) { // An interwiki; try an alternate encoding with '-' for ':' $titleSql = $this->db->buildConcat( array( "'$prefix-'", $titleSql ) ); } $sql = "SELECT {$page}_id AS id, {$page}_title AS oldtitle, $encNamespace + {$page}_namespace AS namespace, $titleSql AS title, {$page}_namespace AS oldnamespace FROM {$table} WHERE ( {$page}_namespace=0 OR {$page}_namespace=1 ) AND {$page}_title " . $this->db->buildLike( $name . ':', $this->db->anyString() ); $result = $this->db->query( $sql, __METHOD__ ); $set = array(); foreach( $result as $row ) { $set[] = $row; } return $set; }
/** * @param Array $options * @param DatabaseBase $db * @return array */ protected function getWamIndexConditions($options, $db) { $conds = array('fw1.time_id = FROM_UNIXTIME(' . $options['currentTimestamp'] . ')'); if ($options['wikiId']) { $conds['fw1.wiki_id'] = $options['wikiId']; } if (!is_null($options['wikiWord'])) { $conds[] = "dw.url like '%" . $db->strencode($options['wikiWord']) . "%' " . "OR dw.title like '%" . $db->strencode($options['wikiWord']) . "%'"; } if ($options['verticalId']) { $verticals = $options['verticalId']; } else { $verticals = $this->verticalIds; } $conds['fw1.vertical_id'] = $verticals; if (!is_null($options['wikiLang'])) { $conds['dw.lang'] = $db->strencode($options['wikiLang']); } if (!empty($options['excludeBlacklist']) || !empty($options['excludeNonCommercial'])) { $bannedIds = !empty($options['excludeBlacklist']) ? $this->getIdsBlacklistedWikis() : []; $nonCommercialIds = !empty($options['excludeNonCommercial']) ? $this->getNonCommercialWikis() : []; $blacklistIds = array_merge($bannedIds, $nonCommercialIds); if (!empty($blacklistIds)) { $conds[] = 'fw1.wiki_id NOT IN (' . $db->makeList($blacklistIds) . ')'; } } return $conds; }
protected function getConditionsForStaffTool($options, DatabaseBase $db) { $sqlOptions = array(); if (isset($options->lang)) { $sqlOptions[self::CITY_VISUALIZATION_TABLE_NAME . '.city_lang_code'] = $options->lang; } if (!empty($options->wikiHeadline)) { $sqlOptions[] = 'city_list.city_title like "%' . $db->strencode($options->wikiHeadline) . '%"'; } if (!empty($options->verticalId)) { $sqlOptions[self::CITY_VISUALIZATION_TABLE_NAME . '.city_vertical'] = $options->verticalId; } if (!empty($options->collectionId)) { $sqlOptions[WikiaCollectionsModel::COLLECTIONS_CV_TABLE . '.collection_id'] = $options->collectionId; } if (!empty($options->blockedFlag)) { $sqlOptions[] = self::CITY_VISUALIZATION_TABLE_NAME . '.city_flags & ' . WikisModel::FLAG_BLOCKED . ' > 0'; } if (!empty($options->officialFlag)) { $sqlOptions[] = self::CITY_VISUALIZATION_TABLE_NAME . '.city_flags & ' . WikisModel::FLAG_OFFICIAL . ' > 0'; } if (!empty($options->promotedFlag)) { $sqlOptions[] = self::CITY_VISUALIZATION_TABLE_NAME . '.city_flags & ' . WikisModel::FLAG_PROMOTED . ' > 0'; } return $sqlOptions; }