From: MatmaRex Date: Tue, 23 Jul 2013 15:40:28 +0000 (+0200) Subject: Special:PagesWithProp: Do not show very long or binary values X-Git-Tag: 1.31.0-rc.0~19140^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=9a829641b511e9987a2f01af3982c0ee52d38655;p=lhc%2Fweb%2Fwiklou.git Special:PagesWithProp: Do not show very long or binary values It already looks rather silly when querying for 'templatedata' prop from the TemplateData extension (e.g. [1]), it will start looking much worse once Ie66b0dd6 in TemplateData is merged (which makes it store the props gzip-compressed). Do not show very long (over 1 kB) or binary (containing a null byte) values; instead display a helpful message and size. Changing the display format slightly, it's now "Page: " instead of "Page ()", because the helpful messages themselves include parentheses. [1] https://en.wikipedia.org/wiki/Special:PagesWithProp?propname=templatedata Bug: 51888 Change-Id: Ib2db241a117b06faee2426c8ea9ae18eab499e08 --- diff --git a/includes/specials/SpecialPagesWithProp.php b/includes/specials/SpecialPagesWithProp.php index 72a3476363..27331e5d63 100644 --- a/includes/specials/SpecialPagesWithProp.php +++ b/includes/specials/SpecialPagesWithProp.php @@ -127,9 +127,22 @@ class SpecialPagesWithProp extends QueryPage { $title = Title::newFromRow( $result ); $ret = Linker::link( $title, null, array(), array(), array( 'known' ) ); if ( $result->pp_value !== '' ) { - $propValue = Html::element( 'span', array( 'class' => 'prop-value' ), $result->pp_value ); - $value = $this->msg( 'parentheses' )->rawParams( $propValue )->escaped(); - $ret .= " $value"; + // Do not show very long or binary values on the special page + $valueLength = strlen( $result->pp_value ); + $isBinary = strpos( $result->pp_value, "\0" ) !== false; + $isTooLong = $valueLength > 1024; + + if ( $isBinary || $isTooLong ) { + $message = $this + ->msg( $isBinary ? 'pageswithprop-prophidden-binary' : 'pageswithprop-prophidden-long' ) + ->numParams( round( $valueLength / 1024, 2 ) ); + + $propValue = Html::element( 'span', array( 'class' => 'prop-value-hidden' ), $message->text() ); + } else { + $propValue = Html::element( 'span', array( 'class' => 'prop-value' ), $result->pp_value ); + } + + $ret .= $this->msg( 'colon-separator' )->escaped() . $propValue; } return $ret; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index c68de09fb9..bb4763be13 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2641,12 +2641,14 @@ Remember to check for other links to the templates before deleting them.', They may have to link to a more appropriate page instead.
A page is treated as a disambiguation page if it uses a template that is linked from [[MediaWiki:Disambiguationspage]].", -'pageswithprop' => 'Pages with a page property', -'pageswithprop-summary' => '', # do not translate or duplicate this message to other languages -'pageswithprop-legend' => 'Pages with a page property', -'pageswithprop-text' => 'This page lists pages that use a particular page property.', -'pageswithprop-prop' => 'Property name:', -'pageswithprop-submit' => 'Go', +'pageswithprop' => 'Pages with a page property', +'pageswithprop-summary' => '', # do not translate or duplicate this message to other languages +'pageswithprop-legend' => 'Pages with a page property', +'pageswithprop-text' => 'This page lists pages that use a particular page property.', +'pageswithprop-prop' => 'Property name:', +'pageswithprop-submit' => 'Go', +'pageswithprop-prophidden-long' => 'long text property value hidden ($1 kilobytes)', +'pageswithprop-prophidden-binary' => 'binary property value hidden ($1 kilobytes)', 'doubleredirects' => 'Double redirects', 'doubleredirects-summary' => '', # do not translate or duplicate this message to other languages diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 276ac157d7..91f418c159 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -4115,6 +4115,14 @@ This block of text is shown on [[:Special:Disambiguations]]. {{Identical|Property name}}', 'pageswithprop-submit' => 'Label for the submit button on [[Special:PagesWithProp]]. {{Identical|Go}}', +'pageswithprop-prophidden-long' => 'Information shown on [[Special:PagesWithProp]] when property value is longer than 1 kilobyte. +See also {{msg-mw|pageswithprop-prophidden-binary}}. +Parameters: +* $1 - size of property value in kilobytes', +'pageswithprop-prophidden-binary' => 'Information shown on [[Special:PagesWithProp]] when property value contains binary data. +See also {{msg-mw|pageswithprop-prophidden-long}}. +Parameters: +* $1 - size of property value in kilobytes', 'doubleredirects' => '{{doc-special|DoubleRedirects}}', 'doubleredirectstext' => 'Shown on top of [[Special:Doubleredirects]]', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index e09de8ef2e..43d05d0b74 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1709,6 +1709,8 @@ $wgMessageStructure = array( 'pageswithprop-text', 'pageswithprop-prop', 'pageswithprop-submit', + 'pageswithprop-prophidden-long', + 'pageswithprop-prophidden-binary', ), 'doubleredirects' => array( 'doubleredirects',