section = $section; $this->userSummary = $userSummary; $this->autoSummary = $autoSummary; $this->allowBlankSummary = $allowBlankSummary; $this->newContent = $newContent; $this->originalContent = $originalContent; } public function checkConstraint(): string { if ( $this->section === 'new' ) { // Constraint is not applicable $this->result = self::CONSTRAINT_PASSED; return self::CONSTRAINT_PASSED; } if ( $this->originalContent === null ) { // T301947: User loses access to revision after loading $this->result = self::CONSTRAINT_FAILED; return self::CONSTRAINT_FAILED; } if ( !$this->allowBlankSummary && !$this->newContent->equals( $this->originalContent ) && !$this->newContent->isRedirect() && md5( $this->userSummary ) === $this->autoSummary ) { $this->result = self::CONSTRAINT_FAILED; } else { $this->result = self::CONSTRAINT_PASSED; } return $this->result; } public function getLegacyStatus(): StatusValue { $statusValue = StatusValue::newGood(); if ( $this->result === self::CONSTRAINT_FAILED ) { if ( $this->originalContent === null ) { // T301947: User loses access to revision after loading // The error message, rev-deleted-text-permission, is not // really in use currently. It's added for completeness and in // case any code path wants to know the error. $statusValue->fatal( 'rev-deleted-text-permission' ); $statusValue->value = self::AS_REVISION_WAS_DELETED; } else { $statusValue->fatal( 'missingsummary' ); $statusValue->value = self::AS_SUMMARY_NEEDED; } } return $statusValue; } }