$this->mTrans = $trans;
}
+ /**
+ * Check whether an interwiki prefix exists
+ *
+ * @return bool Whether it exists
+ * @param $prefix string Interwiki prefix to use
+ */
+ static public function isValidInterwiki( $prefix ){
+ global $wgContLang;
+ $prefix = $wgContLang->lc( $prefix );
+ if( isset( self::$smCache[$prefix] ) ){
+ return true;
+ }
+ global $wgInterwikiCache;
+ if ($wgInterwikiCache) {
+ return Interwiki::isValidInterwikiCached( $key );
+ }
+ $iw = new Interwiki;
+ if( !$iw->load( $prefix ) ){
+ return false;
+ }
+ if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){
+ array_shift( self::$smCache );
+ }
+ self::$smCache[$prefix] = &$iw;
+ return true;
+ }
+
/**
* Fetch an Interwiki object
*
* @param $prefix string Interwiki prefix to use
*/
static public function fetch( $prefix ) {
+ global $wgContLang;
+ $prefix = $wgContLang->lc( $prefix );
if( isset( self::$smCache[$prefix] ) ){
return self::$smCache[$prefix];
}
return Interwiki::getInterwikiCached( $key );
}
$iw = new Interwiki;
- $iw->load( $prefix );
+ if( !$iw->load( $prefix ) ){
+ return false;
+ }
if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){
array_shift( self::$smCache );
}
* @note More logic is explained in DefaultSettings.
*
* @param $key \type{\string} Database key
- * @return \type{\string} URL of interwiki site
+ * @return \type{\Interwiki} An interwiki object
*/
protected static function getInterwikiCached( $key ) {
global $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
self::$smCache[$prefix] = &$s;
return $s;
}
+
+ /**
+ * Check whether an interwiki is in the cache
+ *
+ * @note More logic is explained in DefaultSettings.
+ *
+ * @param $key \type{\string} Database key
+ * @return \type{\bool} Whether it exists
+ */
+ protected static function isValidInterwikiCached( $key ) {
+ global $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
+ static $db, $site;
+
+ if (!$db)
+ $db=dba_open($wgInterwikiCache,'r','cdb');
+ /* Resolve site name */
+ if ($wgInterwikiScopes>=3 and !$site) {
+ $site = dba_fetch('__sites:' . wfWikiID(), $db);
+ if ($site=="")
+ $site = $wgInterwikiFallbackSite;
+ }
+ $value = dba_fetch( wfMemcKey( $key ), $db);
+ if ($value=='' and $wgInterwikiScopes>=3) {
+ /* try site-level */
+ $value = dba_fetch("_{$site}:{$key}", $db);
+ }
+ if ($value=='' and $wgInterwikiScopes>=2) {
+ /* try globals */
+ $value = dba_fetch("__global:{$key}", $db);
+ }
+ if ($value=='undef')
+ $value='';
+ if ( $value != '' ) {
+ return true;
+ }else{
+ return false;
+ }
+ }
/**
* Clear all member variables in the current object. Does not clear
# Ordinary namespace
$dbkey = $m[2];
$this->mNamespace = $ns;
- } elseif( new Interwiki( $p ) ) {
+ } elseif( Interwiki::isValidInterwiki( $p ) ) {
if( !$firstPass ) {
# Can't make a local interwiki link to an interwiki link.
# That's just crazy!
* @return \type{\mixed} True on success, getUserPermissionsErrors()-like array on failure
*/
public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) {
- global $wgUser;
-
$errors = array();
if( !$nt ) {
// Normally we'd add this to $errors, but we'll get
}
if ( $auth ) {
+ global $wgUser;
$errors = wfArrayMerge($errors,
$this->getUserPermissionsErrors('move', $wgUser),
$this->getUserPermissionsErrors('edit', $wgUser),
$nt->getUserPermissionsErrors('move', $wgUser),
$nt->getUserPermissionsErrors('edit', $wgUser));
-
- # Root userpage ?
- if ( $nt->getNamespace() == NS_USER && !$nt->isSubpage() && !$wgUser->isAllowed('move-rootuserpages') ) {
- $errors[] = array('moverootuserpagesnotallowed');
- }
}
$match = EditPage::matchSpamRegex( $reason );
$errors[] = array('spamprotectiontext');
}
+ global $wgUser;
$err = null;
if( !wfRunHooks( 'AbortMove', array( $this, $nt, $wgUser, &$err, $reason ) ) ) {
$errors[] = array('hookaborted', $err);