https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103362

Revision: 103362
Author:   bawolff
Date:     2011-11-16 19:50:59 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
(bug 31535; bug 332) Properly truncate upload summaries (img_description) on 
the php side.

Before it would get truncated when inserted into the 255 byte db field. This is 
bad as it can leave dangling multi-byte unicode sequences, additionally, since 
directly after upload we appearently cache the file object, this can result in 
the comment in the file history table being super-huge.

This also removes the parenthesis in the comment field in the table. Its a 
table, we don't need to use () to visually separate it from the rest of the 
page content.

This commit also causes '...' (or the i18n'ed equivalent) to be appended when 
truncated a comment. Previously that didn't happen. Also I changed it to use a 
method that doesn't check for '*' as a special value to mean no description. I 
looked at the toolserver db, and even uploads to enwikipedia from 2002 don't 
use '*' as special no-description marker.

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES-1.19
    trunk/phase3/includes/ImagePage.php
    trunk/phase3/includes/filerepo/LocalFile.php

Modified: trunk/phase3/RELEASE-NOTES-1.19
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.19     2011-11-16 19:46:29 UTC (rev 103361)
+++ trunk/phase3/RELEASE-NOTES-1.19     2011-11-16 19:50:59 UTC (rev 103362)
@@ -137,6 +137,7 @@
   files (like audio files)
 * (bug 32168) Add wfAssembleUrl for use in wfExpandUrl
 * (bug 32168) fixed - wfExpandUrl expands dot segments now
+* (bug 31535) Upload comments now truncated properly, and don't have brackets
 
 === API changes in 1.19 ===
 * (bug 19838) siprop=interwikimap can now use the interwiki cache.

Modified: trunk/phase3/includes/ImagePage.php
===================================================================
--- trunk/phase3/includes/ImagePage.php 2011-11-16 19:46:29 UTC (rev 103361)
+++ trunk/phase3/includes/ImagePage.php 2011-11-16 19:50:59 UTC (rev 103362)
@@ -1058,7 +1058,7 @@
                if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
                        $row .= '<td><span class="history-deleted">' . 
wfMsgHtml( 'rev-deleted-comment' ) . '</span></td>';
                } else {
-                       $row .= '<td dir="' . $wgContLang->getDir() . '">' . 
Linker::commentBlock( $description, $this->title ) . '</td>';
+                       $row .= '<td dir="' . $wgContLang->getDir() . '">' . 
Linker::formatComment( $description, $this->title ) . '</td>';
                }
 
                $rowClass = null;

Modified: trunk/phase3/includes/filerepo/LocalFile.php
===================================================================
--- trunk/phase3/includes/filerepo/LocalFile.php        2011-11-16 19:46:29 UTC 
(rev 103361)
+++ trunk/phase3/includes/filerepo/LocalFile.php        2011-11-16 19:50:59 UTC 
(rev 103362)
@@ -893,6 +893,11 @@
         *     archive name, or an empty string if it was a new file.
         */
        function upload( $srcPath, $comment, $pageText, $flags = 0, $props = 
false, $timestamp = false, $user = null ) {
+               global $wgContLang;
+               // truncate nicely or the DB will do it for us
+               // non-nicely (dangling multi-byte chars, non-truncated
+               // version in cache).
+               $comment = $wgContLang->truncate( $comment, 255 );
                $this->lock();
                $status = $this->publish( $srcPath, $flags );
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to