X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fimport%2FWikiImporter.php;h=00bb61f7b284552906a94f61fdefdf5f3ac4e412;hb=0af17b526fffa06af403163c4b758d1da2e9441e;hp=41ec673a185b5c53c876fa4482338d274ae00819;hpb=09ee5d2505f99cc146f871307be7ac00b7368d76;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php index 41ec673a18..00bb61f7b2 100644 --- a/includes/import/WikiImporter.php +++ b/includes/import/WikiImporter.php @@ -120,10 +120,7 @@ class WikiImporter { wfDebug( "IMPORT: $data\n" ); } - public function notice( $msg /*, $param, ...*/ ) { - $params = func_get_args(); - array_shift( $params ); - + public function notice( $msg, ...$params ) { if ( is_callable( $this->mNoticeCallback ) ) { call_user_func( $this->mNoticeCallback, $msg, $params ); } else { # No ImportReporter -> CLI @@ -260,7 +257,7 @@ class WikiImporter { return true; } elseif ( $namespace >= 0 && - MWNamespace::exists( intval( $namespace ) ) + MediaWikiServices::getInstance()->getNamespaceInfo()->exists( intval( $namespace ) ) ) { $namespace = intval( $namespace ); $this->setImportTitleFactory( new NamespaceImportTitleFactory( $namespace ) ); @@ -286,7 +283,10 @@ class WikiImporter { if ( !$title || $title->isExternal() ) { $status->fatal( 'import-rootpage-invalid' ); - } elseif ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) { + } elseif ( + !MediaWikiServices::getInstance()->getNamespaceInfo()-> + hasSubpages( $title->getNamespace() ) + ) { $displayNSText = $title->getNamespace() == NS_MAIN ? wfMessage( 'blanknamespace' )->text() : MediaWikiServices::getInstance()->getContentLanguage()-> @@ -430,8 +430,7 @@ class WikiImporter { } } - $args = func_get_args(); - return Hooks::run( 'AfterImportPage', $args ); + return Hooks::run( 'AfterImportPage', func_get_args() ); } /** @@ -486,8 +485,7 @@ class WikiImporter { private function pageOutCallback( $title, $foreignTitle, $revCount, $sucCount, $pageInfo ) { if ( isset( $this->mPageOutCallback ) ) { - $args = func_get_args(); - call_user_func_array( $this->mPageOutCallback, $args ); + call_user_func_array( $this->mPageOutCallback, func_get_args() ); } } @@ -1101,14 +1099,23 @@ class WikiImporter { } elseif ( !$title->canExist() ) { $this->notice( 'import-error-special', $title->getPrefixedText() ); return false; - } elseif ( !$title->userCan( 'edit' ) && !$commandLineMode ) { - # Do not import if the importing wiki user cannot edit this page - $this->notice( 'import-error-edit', $title->getPrefixedText() ); - return false; - } elseif ( !$title->exists() && !$title->userCan( 'create' ) && !$commandLineMode ) { - # Do not import if the importing wiki user cannot create this page - $this->notice( 'import-error-create', $title->getPrefixedText() ); - return false; + } elseif ( !$commandLineMode ) { + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); + $user = RequestContext::getMain()->getUser(); + + if ( !$permissionManager->userCan( 'edit', $user, $title ) ) { + # Do not import if the importing wiki user cannot edit this page + $this->notice( 'import-error-edit', $title->getPrefixedText() ); + + return false; + } + + if ( !$title->exists() && !$permissionManager->userCan( 'create', $user, $title ) ) { + # Do not import if the importing wiki user cannot create this page + $this->notice( 'import-error-create', $title->getPrefixedText() ); + + return false; + } } return [ $title, $foreignTitle ];