$wgMaxArticleSize is defined as "maximum article size in kilobytes",
however the way it was being used in WikiImporter and EditPage was
actually allowing 1023 bytes more than the limit. Other code using the
variable was limiting it to the specified value.
Change-Id: I85e4d2146643c5ac65f27cf464a51b28d68440b0
/** @var bool */
public $tooBig = false;
/** @var bool */
public $tooBig = false;
- /** @var bool */
- public $kblength = false;
-
/** @var bool */
public $missingComment = false;
/** @var bool */
public $missingComment = false;
/** @var bool */
protected $edit;
/** @var bool */
protected $edit;
+ /** @var bool|int */
+ protected $contentLength = false;
+
/**
* @var bool Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing
*/
/**
* @var bool Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing
*/
- $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
- if ( $this->kblength > $wgMaxArticleSize ) {
+ $this->contentLength = strlen( $this->textbox1 );
+ if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
// Error will be displayed by showEditForm()
$this->tooBig = true;
$status->setResult( false, self::AS_CONTENT_TOO_BIG );
// Error will be displayed by showEditForm()
$this->tooBig = true;
$status->setResult( false, self::AS_CONTENT_TOO_BIG );
}
// Check for length errors again now that the section is merged in
}
// Check for length errors again now that the section is merged in
- $this->kblength = (int)( strlen( $this->toEditText( $content ) ) / 1024 );
- if ( $this->kblength > $wgMaxArticleSize ) {
+ $this->contentLength = strlen( $this->toEditText( $content ) );
+ if ( $this->contentLength > $wgMaxArticleSize * 1024 ) {
$this->tooBig = true;
$status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
return $status;
$this->tooBig = true;
$status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
return $status;
'wrap' => "<div class=\"mw-titleprotectedwarning\">\n$1</div>" ] );
}
'wrap' => "<div class=\"mw-titleprotectedwarning\">\n$1</div>" ] );
}
- if ( $this->kblength === false ) {
- $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 );
+ if ( $this->contentLength === false ) {
+ $this->contentLength = strlen( $this->textbox1 );
- if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
+ if ( $this->tooBig || $this->contentLength > $wgMaxArticleSize * 1024 ) {
$wgOut->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
[
'longpageerror',
$wgOut->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
[
'longpageerror',
- $wgLang->formatNum( $this->kblength ),
+ $wgLang->formatNum( round( $this->contentLength / 1024, 3 ) ),
$wgLang->formatNum( $wgMaxArticleSize )
]
);
$wgLang->formatNum( $wgMaxArticleSize )
]
);
- (int)( strlen( $revisionInfo['text'] ) / 1024 ) > $wgMaxArticleSize
+ strlen( $revisionInfo['text'] ) > $wgMaxArticleSize * 1024
) {
throw new MWException( 'The text of ' .
( isset( $revisionInfo['id'] ) ?
) {
throw new MWException( 'The text of ' .
( isset( $revisionInfo['id'] ) ?