Special:PagesWithProp: Do not show very long or binary values
authorMatmaRex <matma.rex@gmail.com>
Tue, 23 Jul 2013 15:40:28 +0000 (17:40 +0200)
committerMatmaRex <matma.rex@gmail.com>
Tue, 23 Jul 2013 16:26:28 +0000 (18:26 +0200)
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: <propvalue-or-message>"
instead of "Page (<propvalue-or-message>)", because the helpful
messages themselves include parentheses.

[1] https://en.wikipedia.org/wiki/Special:PagesWithProp?propname=templatedata

Bug: 51888
Change-Id: Ib2db241a117b06faee2426c8ea9ae18eab499e08

includes/specials/SpecialPagesWithProp.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index 72a3476..27331e5 100644 (file)
@@ -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;
index c68de09..bb4763b 100644 (file)
@@ -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.<br />
 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
index 276ac15..91f418c 100644 (file)
@@ -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]]',
index e09de8e..43d05d0 100644 (file)
@@ -1709,6 +1709,8 @@ $wgMessageStructure = array(
                'pageswithprop-text',
                'pageswithprop-prop',
                'pageswithprop-submit',
+               'pageswithprop-prophidden-long',
+               'pageswithprop-prophidden-binary',
        ),
        'doubleredirects' => array(
                'doubleredirects',