X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=ee0699383ff5a3988769189e4b5beaa6686acc37;hb=dcd211106c88fcb3b9565045c6b2264dba6be13c;hp=362f905fd4a255f21f156e1d67d980c809b58d2d;hpb=71e4493c864e4f14f1c850c710be017a7198fd2b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index 362f905fd4..ee0699383f 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -260,9 +260,6 @@ class EditPage { /** @var bool */ public $tooBig = false; - /** @var bool */ - public $kblength = false; - /** @var bool */ public $missingComment = false; @@ -396,6 +393,9 @@ class EditPage { /** @var bool */ protected $edit; + /** @var bool|int */ + protected $contentLength = false; + /** * @var bool Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing */ @@ -1774,8 +1774,8 @@ class EditPage { return $status; } - $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 ); @@ -2062,8 +2062,8 @@ class EditPage { } // 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; @@ -2714,8 +2714,9 @@ class EditPage { $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'hiddencats' ], Linker::formatHiddenCategories( $this->page->getHiddenCategories() ) ) ); - $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'limitreport' ], - self::getPreviewLimitReport( $this->mParserOutput ) ) ); + if ( $this->mParserOutput ) { + $wgOut->setLimitReportData( $this->mParserOutput->getLimitReportData() ); + } $wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' ); @@ -2968,15 +2969,15 @@ class EditPage { 'wrap' => "
\n$1
" ] ); } - 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( "
\n$1\n
", [ 'longpageerror', - $wgLang->formatNum( $this->kblength ), + $wgLang->formatNum( round( $this->contentLength / 1024, 3 ) ), $wgLang->formatNum( $wgMaxArticleSize ) ] ); @@ -3442,41 +3443,12 @@ HTML return ''; } - $limitReport = Html::rawElement( 'div', [ 'class' => 'mw-limitReportExplanation' ], - wfMessage( 'limitreport-title' )->parseAsBlock() + return ResourceLoader::makeInlineScript( + ResourceLoader::makeConfigSetScript( + [ 'wgPageParseReport' => $output->getLimitReportData() ], + true + ) ); - - // Show/hide animation doesn't work correctly on a table, so wrap it in a div. - $limitReport .= Html::openElement( 'div', [ 'class' => 'preview-limit-report-wrapper' ] ); - - $limitReport .= Html::openElement( 'table', [ - 'class' => 'preview-limit-report wikitable' - ] ) . - Html::openElement( 'tbody' ); - - foreach ( $output->getLimitReportData() as $key => $value ) { - if ( Hooks::run( 'ParserLimitReportFormat', - [ $key, &$value, &$limitReport, true, true ] - ) ) { - $keyMsg = wfMessage( $key ); - $valueMsg = wfMessage( [ "$key-value-html", "$key-value" ] ); - if ( !$valueMsg->exists() ) { - $valueMsg = new RawMessage( '$1' ); - } - if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) { - $limitReport .= Html::openElement( 'tr' ) . - Html::rawElement( 'th', null, $keyMsg->parse() ) . - Html::rawElement( 'td', null, $valueMsg->params( $value )->parse() ) . - Html::closeElement( 'tr' ); - } - } - } - - $limitReport .= Html::closeElement( 'tbody' ) . - Html::closeElement( 'table' ) . - Html::closeElement( 'div' ); - - return $limitReport; } protected function showStandardInputs( &$tabindex = 2 ) { @@ -3536,13 +3508,12 @@ HTML if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$this, &$wgOut ] ) ) { $stats = $wgOut->getContext()->getStats(); $stats->increment( 'edit.failures.conflict' ); - if ( $this->mTitle->isTalkPage() ) { - $stats->increment( 'edit.failures.conflict.byType.talk' ); - } else { - $stats->increment( 'edit.failures.conflict.byType.subject' ); - } - if ( $this->mTitle->getNamespace() === NS_PROJECT ) { - $stats->increment( 'edit.failures.conflict.byNamespace.project' ); + // Only include 'standard' namespaces to avoid creating unknown numbers of statsd metrics + if ( + $this->mTitle->getNamespace() >= NS_MAIN && + $this->mTitle->getNamespace() <= NS_CATEGORY_TALK + ) { + $stats->increment( 'edit.failures.conflict.byNamespaceId.' . $this->mTitle->getNamespace() ); } $wgOut->wrapWikiMsg( '

$1

', "yourdiff" );