Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4704
bug13721.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:05 PM
2014-11-21 22:05:03 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
bug13721.patch
View Options
Index: SqlWriter.java
===================================================================
--- SqlWriter.java (revision 64603)
+++ SqlWriter.java (working copy)
@@ -26,6 +26,7 @@
package org.mediawiki.importer;
import java.io.IOException;
+import java.nio.charset.Charset;
import java.text.MessageFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -36,6 +37,9 @@
public abstract class SqlWriter implements DumpWriter {
+
+ public static Charset ENCODING = Charset.forName("UTF-8");
+
public static abstract class Traits {
public abstract SqlLiteral getCurrentTime();
public abstract SqlLiteral getRandom();
@@ -323,6 +327,15 @@
return title.replace(' ', '_');
}
+ protected static String commentFormat( String comment ) {
+ if( comment == null || comment.isEmpty() ) return "";
+ //truncate comment to 255 Bytes - a tinyblob
+ while( comment.getBytes(ENCODING).length > 255 ) {
+ comment = comment.substring(0, comment.length() - 1 );
+ }
+ return comment;
+ }
+
protected String timestampFormat(Calendar time) {
return traits.getTimestampFormatter().format(new Object[] {
new Integer(time.get(Calendar.YEAR)),
Index: SqlWriter15.java
===================================================================
--- SqlWriter15.java (revision 64603)
+++ SqlWriter15.java (working copy)
@@ -79,7 +79,7 @@
{"rev_id", new Integer(revision.Id)},
{"rev_page", new Integer(currentPage.Id)},
{"rev_text_id", new Integer(revision.Id)},
- {"rev_comment", revision.Comment == null ? "" : revision.Comment},
+ {"rev_comment", commentFormat( revision.Comment ) },
{"rev_user", revision.Contributor.Username == null ? ZERO : new Integer(revision.Contributor.Id)},
{"rev_user_text", revision.Contributor.Username == null ? "" : revision.Contributor.Username},
{"rev_timestamp", timestampFormat(revision.Timestamp)},
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4269
Default Alt Text
bug13721.patch (1 KB)
Attached To
Mode
T15721: Data too long for column 'rev_comment'
Attached
Detach File
Event Timeline
Log In to Comment