maxSize = $maxSize * 1024; // Convert from kilobytes $this->contentSize = $contentSize; if ( $type === self::BEFORE_MERGE ) { $this->errorCode = self::AS_CONTENT_TOO_BIG; } elseif ( $type === self::AFTER_MERGE ) { $this->errorCode = self::AS_MAX_ARTICLE_SIZE_EXCEEDED; } else { throw new InvalidArgumentException( "Invalid type: $type" ); } $this->type = $type; } public function checkConstraint(): string { return $this->contentSize > $this->maxSize ? self::CONSTRAINT_FAILED : self::CONSTRAINT_PASSED; } public function getLegacyStatus(): StatusValue { $statusValue = StatusValue::newGood(); if ( $this->contentSize > $this->maxSize ) { // Either self::AS_CONTENT_TOO_BIG, if it was too big before merging, // or self::AS_MAX_ARTICLE_SIZE_EXCEEDED, if it was too big after merging $statusValue->setResult( false, $this->errorCode ); $statusValue->fatal( MessageValue::new( 'longpageerror' ) ->numParams( round( $this->contentSize / 1024, 3 ), $this->maxSize / 1024 ) ); } return $statusValue; } /** * Get the type, so that the two different uses of this constraint can be told * apart in debug logs. * @internal * @codeCoverageIgnore * @return string */ public function getType(): string { return $this->type; } }