r103362 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103361‎ | r103362 | r103363 >
Date:19:50, 16 November 2011
Author:bawolff
Status:ok
Tags:
Comment:
(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 (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -137,6 +137,7 @@
138138 files (like audio files)
139139 * (bug 32168) Add wfAssembleUrl for use in wfExpandUrl
140140 * (bug 32168) fixed - wfExpandUrl expands dot segments now
 141+* (bug 31535) Upload comments now truncated properly, and don't have brackets
141142
142143 === API changes in 1.19 ===
143144 * (bug 19838) siprop=interwikimap can now use the interwiki cache.
Index: trunk/phase3/includes/ImagePage.php
@@ -1058,7 +1058,7 @@
10591059 if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
10601060 $row .= '<td><span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span></td>';
10611061 } else {
1062 - $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::commentBlock( $description, $this->title ) . '</td>';
 1062+ $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment( $description, $this->title ) . '</td>';
10631063 }
10641064
10651065 $rowClass = null;
Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -893,6 +893,11 @@
894894 * archive name, or an empty string if it was a new file.
895895 */
896896 function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false, $user = null ) {
 897+ global $wgContLang;
 898+ // truncate nicely or the DB will do it for us
 899+ // non-nicely (dangling multi-byte chars, non-truncated
 900+ // version in cache).
 901+ $comment = $wgContLang->truncate( $comment, 255 );
897902 $this->lock();
898903 $status = $this->publish( $srcPath, $flags );
899904

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40837Fix for bug #332 - all UTF-8 output is now cleaned of invalid forms as define...krimpet00:42, 15 September 2008
r40840Release notes for bug #332krimpet01:37, 15 September 2008
r40861Revert r40837, r40839, r40840 (bug 332 - broken UTF-8)...brion17:51, 15 September 2008

Status & tagging log