Remove the fallback for create rights (covered in PM edit rights check).
Remove key to i18n message, no longer being used. Bug: T272079 Change-Id: Id6566e5241b06ba377c2eca083221ee02556365f
This commit is contained in:
parent
1f66af055d
commit
6ebaa5caf6
12 changed files with 7 additions and 57 deletions
|
|
@ -734,21 +734,6 @@ class EditPage implements IEditObject {
|
|||
$this->mTitle,
|
||||
$rigor
|
||||
);
|
||||
# Can this title be created?
|
||||
if ( !$this->mTitle->exists() ) {
|
||||
$permErrors = array_merge(
|
||||
$permErrors,
|
||||
wfArrayDiff2(
|
||||
$this->permManager->getPermissionErrors(
|
||||
'create',
|
||||
$user,
|
||||
$this->mTitle,
|
||||
$rigor
|
||||
),
|
||||
$permErrors
|
||||
)
|
||||
);
|
||||
}
|
||||
# Ignore some permissions errors when a user is just previewing/viewing diffs
|
||||
$remove = [];
|
||||
foreach ( $permErrors as $error ) {
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@
|
|||
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\PageIdentity;
|
||||
use MediaWiki\Page\PageRecord;
|
||||
use MediaWiki\Page\PageReference;
|
||||
use MediaWiki\Permissions\Authority;
|
||||
use MediaWiki\Permissions\PermissionStatus;
|
||||
use MediaWiki\Session\SessionManager;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
|
|
@ -3395,9 +3393,9 @@ class OutputPage extends ContextSource {
|
|||
$vars['wgUserVariant'] = $languageConverter->getPreferredVariant();
|
||||
}
|
||||
// Same test as SkinTemplate
|
||||
$vars['wgIsProbablyEditable'] = $this->performerCanEditOrCreate( $this->getAuthority(), $title );
|
||||
$vars['wgIsProbablyEditable'] = $this->getAuthority()->probablyCan( 'edit', $title );
|
||||
$vars['wgRelevantPageIsProbablyEditable'] = $relevantTitle &&
|
||||
$this->performerCanEditOrCreate( $this->getAuthority(), $relevantTitle );
|
||||
$this->getAuthority()->probablyCan( 'edit', $relevantTitle );
|
||||
foreach ( $title->getRestrictionTypes() as $type ) {
|
||||
// Following keys are set in $vars:
|
||||
// wgRestrictionCreate, wgRestrictionEdit, wgRestrictionMove, wgRestrictionUpload
|
||||
|
|
@ -3501,19 +3499,6 @@ class OutputPage extends ContextSource {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Authority $performer
|
||||
* @param PageIdentity $page
|
||||
* @return bool
|
||||
*/
|
||||
private function performerCanEditOrCreate(
|
||||
Authority $performer,
|
||||
PageIdentity $page
|
||||
) {
|
||||
return $performer->probablyCan( 'edit', $page )
|
||||
&& ( $page->exists() || $performer->probablyCan( 'create', $page ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Array in format "link name or number => 'link html'".
|
||||
*/
|
||||
|
|
@ -3576,7 +3561,7 @@ class OutputPage extends ContextSource {
|
|||
|
||||
# Universal edit button
|
||||
if ( $config->get( 'UniversalEditButton' ) && $this->isArticleRelated() ) {
|
||||
if ( $this->performerCanEditOrCreate( $this->getAuthority(), $this->getTitle() ) ) {
|
||||
if ( $this->getAuthority()->probablyCan( 'edit', $this->getTitle() ) ) {
|
||||
// Original UniversalEditButton
|
||||
$msg = $this->msg( 'edit' )->text();
|
||||
$tags['universal-edit-button'] = Html::element( 'link', [
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class ApiEditPage extends ApiBase {
|
|||
// Now let's check whether we're even allowed to do this
|
||||
$this->checkTitleUserPermissions(
|
||||
$titleObj,
|
||||
$titleObj->exists() ? 'edit' : [ 'edit', 'create' ],
|
||||
'edit',
|
||||
[ 'autoblock' => true ]
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -113,9 +113,6 @@ class ContentModelChange {
|
|||
$titleWithNewContentModel->setContentModel( $this->newModel );
|
||||
|
||||
$status = PermissionStatus::newEmpty();
|
||||
if ( !$current->exists() ) {
|
||||
$authorizer( 'create', $current, $status );
|
||||
}
|
||||
$authorizer( 'editcontentmodel', $current, $status );
|
||||
$authorizer( 'edit', $current, $status );
|
||||
$authorizer( 'editcontentmodel', $titleWithNewContentModel, $status );
|
||||
|
|
|
|||
|
|
@ -1327,13 +1327,6 @@ class WikiImporter {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !$title->exists() && !$this->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 ];
|
||||
|
|
|
|||
|
|
@ -1475,8 +1475,7 @@ class Article implements Page {
|
|||
$text = wfMessage( 'missing-revision', $oldid )->plain();
|
||||
}
|
||||
|
||||
} elseif ( $this->getContext()->getAuthority()->probablyCan( 'create', $title ) &&
|
||||
$this->getContext()->getAuthority()->probablyCan( 'edit', $title )
|
||||
} elseif ( $this->getContext()->getAuthority()->probablyCan( 'edit', $title )
|
||||
) {
|
||||
$message = $isRegistered ? 'noarticletext' : 'noarticletextanon';
|
||||
$text = wfMessage( $message )->plain();
|
||||
|
|
|
|||
|
|
@ -1058,10 +1058,7 @@ class SkinTemplate extends Skin {
|
|||
}
|
||||
|
||||
// Checks if user can edit the current page if it exists or create it otherwise
|
||||
if ( $this->getAuthority()->probablyCan( 'edit', $title ) &&
|
||||
( $title->exists() ||
|
||||
$this->getAuthority()->probablyCan( 'create', $title ) )
|
||||
) {
|
||||
if ( $this->getAuthority()->probablyCan( 'edit', $title ) ) {
|
||||
// Builds CSS class for talk page links
|
||||
$isTalkClass = $isTalk ? ' istalk' : '';
|
||||
// Whether the user is editing the page
|
||||
|
|
|
|||
|
|
@ -594,7 +594,6 @@ class SpecialSearch extends SpecialPage {
|
|||
} elseif (
|
||||
$this->contentHandlerFactory->getContentHandler( $title->getContentModel() )
|
||||
->supportsDirectEditing()
|
||||
&& $this->getAuthority()->probablyCan( 'create', $title )
|
||||
&& $this->getAuthority()->probablyCan( 'edit', $title )
|
||||
) {
|
||||
$messageName = 'searchmenu-new';
|
||||
|
|
|
|||
|
|
@ -660,9 +660,6 @@ abstract class UploadBase {
|
|||
$status = PermissionStatus::newEmpty();
|
||||
$performer->authorizeWrite( 'edit', $nt, $status );
|
||||
$performer->authorizeWrite( 'upload', $nt, $status );
|
||||
if ( !$nt->exists() ) {
|
||||
$performer->authorizeWrite( 'create', $nt, $status );
|
||||
}
|
||||
if ( !$status->isGood() ) {
|
||||
return $status->toLegacyErrorArray();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3033,7 +3033,6 @@
|
|||
"import-token-mismatch": "Loss of session data.\n\nYou might have been logged out. '''Please verify that you're still logged in and try again'''.\nIf it still does not work, try [[Special:UserLogout|logging out]] and logging back in, and check that your browser allows cookies from this site.",
|
||||
"import-invalid-interwiki": "Cannot import from the specified wiki.",
|
||||
"import-error-edit": "Page \"$1\" was not imported because you are not allowed to edit it.",
|
||||
"import-error-create": "Page \"$1\" was not imported because you are not allowed to create it.",
|
||||
"import-error-interwiki": "Page \"$1\" was not imported because its name is reserved for external linking (interwiki).",
|
||||
"import-error-special": "Page \"$1\" was not imported because it belongs to a special namespace that does not allow pages.",
|
||||
"import-error-invalid": "Page \"$1\" was not imported because the name to which it would be imported is invalid on this wiki.",
|
||||
|
|
|
|||
|
|
@ -3257,7 +3257,6 @@
|
|||
"import-token-mismatch": "Used as error message in [[Special:Import]].\n\nSee also:\n* {{msg-mw|import-invalid-interwiki}}\n* {{msg-mw|Importunknownsource}}\n\n{{Identical|Loss of session data}}",
|
||||
"import-invalid-interwiki": "Used as error message in [[Special:Import]].\n\nSee also:\n* {{msg-mw|import-token-mismatch}}\n* {{msg-mw|import-invalid-interwiki}}\n* {{msg-mw|Importunknownsource}}",
|
||||
"import-error-edit": "Import error message displayed when importing user has no edit rights for a page.\n\nParameters:\n* $1 - a page name\n{{Related|Import-error}}",
|
||||
"import-error-create": "Import error message displayed when importing user has no create rights for a page.\n\nParameters:\n* $1 - a page name\n{{Related|Import-error}}",
|
||||
"import-error-interwiki": "Used as error message when importing pages. Parameters:\n* $1 - page title\n{{Related|Import-error}}",
|
||||
"import-error-special": "Used as error message when importing pages. Parameters:\n* $1 - page title\n{{Related|Import-error}}",
|
||||
"import-error-invalid": "Used as error message when importing pages. Parameters:\n* $1 - page title\n{{Related|Import-error}}",
|
||||
|
|
|
|||
|
|
@ -3198,7 +3198,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider provideGetJsVarsEditable
|
||||
* @covers OutputPage::performerCanEditOrCreate
|
||||
* @covers OutputPage::getJSVars
|
||||
*/
|
||||
public function testGetJsVarsEditable( Authority $performer, array $expectedEditableConfig ) {
|
||||
$op = $this->newInstance( [], null, null, $performer );
|
||||
|
|
|
|||
Loading…
Reference in a new issue