private function save(array $data) { $bp = BotPassword::newUnsaved(['centralId' => $this->userId, 'appId' => $this->par, 'restrictions' => MWRestrictions::newFromJson($data['restrictions']), 'grants' => array_merge(MWGrants::getHiddenGrants(), preg_replace('/^grant-/', '', $data['grants']))]); if ($this->operation === 'insert' || !empty($data['resetPassword'])) { $this->password = PasswordFactory::generateRandomPasswordString(max(32, $this->getConfig()->get('MinimalPasswordLength'))); $passwordFactory = new PasswordFactory(); $passwordFactory->init(RequestContext::getMain()->getConfig()); $password = $passwordFactory->newFromPlaintext($this->password); } else { $password = null; } if ($bp->save($this->operation, $password)) { return Status::newGood(); } else { // Messages: botpasswords-insert-failed, botpasswords-update-failed return Status::newFatal("botpasswords-{$this->operation}-failed", $this->par); } }
/** * @covers MWGrants::getHiddenGrants */ public function testGetHiddenGrants() { $this->assertSame(['hidden1', 'hidden2'], MWGrants::getHiddenGrants()); }