当前位置: 首页>>代码示例>>PHP>>正文


PHP Status::newFatal方法代码示例

本文整理汇总了PHP中Status::newFatal方法的典型用法代码示例。如果您正苦于以下问题:PHP Status::newFatal方法的具体用法?PHP Status::newFatal怎么用?PHP Status::newFatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Status的用法示例。


在下文中一共展示了Status::newFatal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * Perform validation on the user submitted data
  * and check that we can perform the rename
  * @param array $data
  *
  * @return Status
  */
 function validate(array $data)
 {
     if (!class_exists('RenameuserSQL')) {
         return Status::newFatal('centralauth-rename-notinstalled');
     }
     $oldUser = User::newFromName($data['oldname']);
     if (!$oldUser) {
         return Status::newFatal('centralauth-rename-doesnotexist');
     }
     if ($oldUser->getName() === $this->getUser()->getName()) {
         return Status::newFatal('centralauth-rename-cannotself');
     }
     $newUser = User::newFromName($data['newname']);
     if (!$newUser) {
         return Status::newFatal('centralauth-rename-badusername');
     }
     if (!$this->overrideAntiSpoof && class_exists('CentralAuthSpoofUser')) {
         $spoofUser = new CentralAuthSpoofUser($newUser->getName());
         $conflicts = $this->processAntiSpoofConflicts($oldUser->getName(), $spoofUser->getConflicts());
         if ($conflicts) {
             return Status::newFatal('centralauth-rename-antispoofconflicts2', $this->getLanguage()->commaList($conflicts));
         }
     }
     $validator = new GlobalRenameUserValidator();
     $status = $validator->validate($oldUser, $newUser);
     return $status;
 }
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:34,代码来源:SpecialGlobalRenameUser.php

示例2: testBeginSecondaryAccountCreation

 public function testBeginSecondaryAccountCreation()
 {
     $authManager = new AuthManager(new \FauxRequest(), new \HashConfig());
     $creator = $this->getMock('User');
     $userWithoutEmail = $this->getMock('User');
     $userWithoutEmail->expects($this->any())->method('getEmail')->willReturn('');
     $userWithoutEmail->expects($this->never())->method('sendConfirmationMail');
     $userWithEmailError = $this->getMock('User');
     $userWithEmailError->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $userWithEmailError->expects($this->any())->method('sendConfirmationMail')->willReturn(\Status::newFatal('fail'));
     $userExpectsConfirmation = $this->getMock('User');
     $userExpectsConfirmation->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $userExpectsConfirmation->expects($this->once())->method('sendConfirmationMail')->willReturn(\Status::newGood());
     $userNotExpectsConfirmation = $this->getMock('User');
     $userNotExpectsConfirmation->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $userNotExpectsConfirmation->expects($this->never())->method('sendConfirmationMail');
     $provider = new EmailNotificationSecondaryAuthenticationProvider(['sendConfirmationEmail' => false]);
     $provider->setManager($authManager);
     $provider->beginSecondaryAccountCreation($userNotExpectsConfirmation, $creator, []);
     $provider = new EmailNotificationSecondaryAuthenticationProvider(['sendConfirmationEmail' => true]);
     $provider->setManager($authManager);
     $provider->beginSecondaryAccountCreation($userWithoutEmail, $creator, []);
     $provider->beginSecondaryAccountCreation($userExpectsConfirmation, $creator, []);
     // test logging of email errors
     $logger = $this->getMockForAbstractClass(LoggerInterface::class);
     $logger->expects($this->once())->method('warning');
     $provider->setLogger($logger);
     $provider->beginSecondaryAccountCreation($userWithEmailError, $creator, []);
     // test disable flag used by other providers
     $authManager->setAuthenticationSessionData('no-email', true);
     $provider->setManager($authManager);
     $provider->beginSecondaryAccountCreation($userNotExpectsConfirmation, $creator, []);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:EmailNotificationSecondaryAuthenticationProviderTest.php

示例3: execute

 public function execute($subPage)
 {
     $this->setHeaders();
     $this->outputHeader();
     $this->loadAuth($subPage);
     if (!$subPage) {
         $this->showSubpageList();
         return;
     }
     if (!$this->authRequests) {
         // messages used: changecredentials-invalidsubpage, removecredentials-invalidsubpage
         $this->showSubpageList($this->msg(static::$messagePrefix . '-invalidsubpage', $subPage));
         return;
     }
     $status = $this->trySubmit();
     if ($status === false || !$status->isOK()) {
         $this->displayForm($status);
         return;
     }
     $response = $status->getValue();
     switch ($response->status) {
         case AuthenticationResponse::PASS:
             $this->success();
             break;
         case AuthenticationResponse::FAIL:
             $this->displayForm(Status::newFatal($response->message));
             break;
         default:
             throw new LogicException('invalid AuthenticationResponse');
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:SpecialChangeCredentials.php

示例4: onSubmit

 public function onSubmit(array $data, \HTMLForm $form = null)
 {
     // Get uploaded file
     $upload =& $_FILES['wpjsonimport'];
     // Check to make sure there is a file uploaded
     if ($upload === null || !$upload['name']) {
         return \Status::newFatal('importnofile');
     }
     // Messages borrowed from Special:Import
     if (!empty($upload['error'])) {
         switch ($upload['error']) {
             case 1:
             case 2:
                 return \Status::newFatal('importuploaderrorsize');
             case 3:
                 return \Status::newFatal('importuploaderrorpartial');
             case 4:
                 return \Status::newFatal('importuploaderrortemp');
             default:
                 return \Status::newFatal('importnofile');
         }
     }
     // Read file
     $fname = $upload['tmp_name'];
     if (!is_uploaded_file($fname)) {
         return \Status::newFatal('importnofile');
     }
     $data = \FormatJSON::parse(file_get_contents($fname));
     // If there is an error during JSON parsing, abort
     if (!$data->isOK()) {
         return $data;
     }
     $this->doImport($data->getValue());
 }
开发者ID:nbdd0121,项目名称:MW-FlowThread,代码行数:34,代码来源:Import.php

示例5: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         if (count($_SESSION) === 0) {
             // Empty session probably indicates that we didn't associate
             // with the session correctly. Note that being able to load
             // the user does not necessarily mean the session was loaded.
             // Most likely cause by suhosin.session.encrypt = On.
             $this->setLastError("Error associating with user session. " . "Try setting suhosin.session.encrypt = Off");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()));
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = array('verification' => $verification);
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:59,代码来源:PublishStashedFileJob.php

示例6: testOkAndErrors

 /**
  *
  */
 public function testOkAndErrors()
 {
     $status = Status::newGood('foo');
     $this->assertTrue($status->ok);
     $status = Status::newFatal('foo', 1, 2);
     $this->assertFalse($status->ok);
     $this->assertArrayEquals(array(array('type' => 'error', 'message' => 'foo', 'params' => array(1, 2))), $status->errors);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:11,代码来源:StatusTest.php

示例7: testNewFatalWithString

 /**
  * @covers Status::newFatal
  */
 public function testNewFatalWithString()
 {
     $message = 'foo';
     $status = Status::newFatal($message);
     $this->assertFalse($status->isGood());
     $this->assertFalse($status->isOK());
     $this->assertEquals($message, $status->getMessage()->getKey());
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:11,代码来源:StatusTest.php

示例8: execute

 /**
  * Main entry point.
  */
 public function execute()
 {
     $vars = Installer::getExistingLocalSettings();
     if ($vars) {
         $this->showStatusMessage(Status::newFatal("config-localsettings-cli-upgrade"));
     }
     $this->performInstallation(array($this, 'startStage'), array($this, 'endStage'));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:CliInstaller.php

示例9: testTrack

 /**
  * @dataProvider trackDataProvider
  * @param $amgId
  * @param $trackResult
  * @param $responseCode
  */
 public function testTrack($amgId, $trackResult, $responseCode)
 {
     $controller = new LyricFindController();
     $controller->setRequest(new WikiaRequest(['amgid' => $amgId]));
     $controller->setResponse(new WikiaResponse('json'));
     $this->mockClassWithMethods('LyricFindTrackingService', ['track' => $trackResult ? Status::newGood() : Status::newFatal('foo')]);
     $controller->track();
     $this->assertEquals($responseCode, $controller->getResponse()->getCode(), 'HTTP response code should match the expected value');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:LyricFindControllerTest.php

示例10: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $this->addTeardownCallback(function () use(&$scope) {
         ScopedCallback::consume($scope);
         // T126450
     });
     $context = RequestContext::getMain();
     $user = $context->getUser();
     try {
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()]);
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = ['verification' => $verification];
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user, isset($this->params['tags']) ? $this->params['tags'] : []);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError($status->getWikiText(false, false, 'en'));
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()]);
     } catch (Exception $e) {
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')]);
         $this->setLastError(get_class($e) . ": " . $e->getMessage());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:55,代码来源:PublishStashedFileJob.php

示例11: fetchUser

 /**
  * @param $username
  * @return Status
  */
 function fetchUser($username)
 {
     $knownwiki = $this->getRequest()->getVal('wpKnownWiki');
     $user = CentralAuthGroupMembershipProxy::newFromName($username);
     if (!$user) {
         return Status::newFatal('nosuchusershort', $username);
     } elseif (!$this->getRequest()->getCheck('saveusergroups') && !$user->attachedOn($knownwiki)) {
         return Status::newFatal('centralauth-globalgroupmembership-badknownwiki', $username, $knownwiki);
     }
     return Status::newGood($user);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:SpecialGlobalGroupMembership.php

示例12: fetchFile

 /**
  * Do the real fetching stuff
  */
 function fetchFile()
 {
     if (!self::isValidUrl($this->mUrl)) {
         return Status::newFatal('upload-proto-error');
     }
     $res = $this->curlCopy();
     if ($res !== true) {
         return Status::newFatal($res);
     }
     return Status::newGood();
 }
开发者ID:hala54,项目名称:DSMW,代码行数:14,代码来源:UploadFromUrl.php

示例13: open

	/**
	 * Open a /dev/urandom file handle
	 * Returns a Status object
	 */
	function open() {
		if ( $this->urandom ) {
			return Status::newGood();
		}

		if ( wfIsWindows() ) {
			return Status::newFatal( 'securepoll-urandom-not-supported' );
		}
		$this->urandom = fopen( '/dev/urandom', 'rb' );
		if ( !$this->urandom ) {
			return Status::newFatal( 'securepoll-dump-no-urandom' );
		}
		return Status::newGood();
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:18,代码来源:Random.php

示例14: submit

 /**
  * @return Status
  */
 public function submit()
 {
     $r = $this->parent->request;
     $type = $r->getVal('DBType');
     if (!$type) {
         return Status::newFatal('config-invalid-db-type');
     }
     $this->setVar('wgDBtype', $type);
     $installer = $this->parent->getDBInstaller($type);
     if (!$installer) {
         return Status::newFatal('config-invalid-db-type');
     }
     return $installer->submitConnectForm();
 }
开发者ID:Kaph-Noir,项目名称:mediawiki,代码行数:17,代码来源:WebInstallerDBConnect.php

示例15: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         if (count($_SESSION) === 0) {
             // Empty session probably indicates that we didn't associate
             // with the session correctly. Note that being able to load
             // the user does not necessarily mean the session was loaded.
             // Most likely cause by suhosin.session.encrypt = On.
             $this->setLastError("Error associating with user session. " . "Try setting suhosin.session.encrypt = Off");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood()));
         $upload = new UploadFromChunks($user);
         $upload->continueChunks($this->params['filename'], $this->params['filekey'], $context->getRequest());
         // Combine all of the chunks into a local file and upload that to a new stash file
         $status = $upload->concatenateChunks();
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // We have a new filekey for the fully concatenated file
         $newFileKey = $upload->getLocalFile()->getFileKey();
         // Remove the old stash file row and first chunk file
         $upload->stash->removeFileNoAuth($this->params['filekey']);
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'assembling', 'filekey' => $newFileKey, 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => Status::newFatal('api-error-stashfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         // To be extra robust.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:49,代码来源:AssembleUploadChunksJob.php


注:本文中的Status::newFatal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。