* @return CommentStoreComment
*/
public function createComment( IDatabase $dbw, $comment, array $data = null ) {
- global $wgContLang;
-
- if ( !$comment instanceof CommentStoreComment ) {
- if ( $data !== null ) {
- foreach ( $data as $k => $v ) {
- if ( substr( $k, 0, 1 ) === '_' ) {
- throw new InvalidArgumentException( 'Keys in $data beginning with "_" are reserved' );
- }
- }
- }
- if ( $comment instanceof Message ) {
- $message = clone $comment;
- $text = $message->inLanguage( $wgContLang ) // Avoid $wgForceUIMsgAsContentMsg
- ->setInterfaceMessageFlag( true )
- ->text();
- $comment = new CommentStoreComment( null, $text, $message, $data );
- } else {
- $comment = new CommentStoreComment( null, $comment, null, $data );
- }
- }
+ $comment = CommentStoreComment::newUnsavedComment( $comment, $data );
# Truncate comment in a Unicode-sensitive manner
$comment->text = $this->lang->truncate( $comment->text, self::MAX_COMMENT_LENGTH );
public $data;
/**
- * @private For use by CommentStore only
+ * @private For use by CommentStore only. Use self::newUnsavedComment() instead.
* @param int|null $id
* @param string $text
* @param Message|null $message
$this->message = $message ?: new RawMessage( '$1', [ $text ] );
$this->data = $data;
}
+
+ /**
+ * Create a new, unsaved CommentStoreComment
+ *
+ * @param string|Message|CommentStoreComment $comment Comment text or Message object.
+ * A CommentStoreComment is also accepted here, in which case it is returned unchanged.
+ * @param array|null $data Structured data to store. Keys beginning with '_' are reserved.
+ * Ignored if $comment is a CommentStoreComment.
+ * @return CommentStoreComment
+ */
+ public static function newUnsavedComment( $comment, array $data = null ) {
+ global $wgContLang;
+
+ if ( $comment instanceof CommentStoreComment ) {
+ return $comment;
+ }
+
+ if ( $data !== null ) {
+ foreach ( $data as $k => $v ) {
+ if ( substr( $k, 0, 1 ) === '_' ) {
+ throw new InvalidArgumentException( 'Keys in $data beginning with "_" are reserved' );
+ }
+ }
+ }
+
+ if ( $comment instanceof Message ) {
+ $message = clone $comment;
+ $text = $message->inLanguage( $wgContLang ) // Avoid $wgForceUIMsgAsContentMsg
+ ->setInterfaceMessageFlag( true )
+ ->text();
+ return new CommentStoreComment( null, $text, $message, $data );
+ } else {
+ return new CommentStoreComment( null, $comment, null, $data );
+ }
+ }
}
public function deletedLink( $id ) {
if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
$dbr = wfGetDB( DB_REPLICA );
- $row = $dbr->selectRow( 'archive', '*',
+ $row = $dbr->selectRow( 'archive',
+ Revision::selectArchiveFields(),
[ 'ar_rev_id' => $id ],
__METHOD__ );
if ( $row ) {
if ( $this->historyLine == 0 ) { // called for the first time, return line from cur
$this->historyRes = $dbr->select( 'image',
- [
- '*',
- "'' AS oi_archive_name",
- '0 as oi_deleted',
- 'img_sha1'
+ self::selectFields() + [
+ 'oi_archive_name' => $dbr->addQuotes( '' ),
+ 'oi_deleted' => 0,
],
[ 'img_name' => $this->title->getDBkey() ],
$fname
return false;
}
} elseif ( $this->historyLine == 1 ) {
- $this->historyRes = $dbr->select( 'oldimage', '*',
+ $this->historyRes = $dbr->select(
+ 'oldimage',
+ OldLocalFile::selectFields(),
[ 'oi_name' => $this->title->getDBkey() ],
$fname,
[ 'ORDER BY' => 'oi_timestamp DESC' ]
$wikiPage = $this;
// Trigger post-create hook
$params = [ &$wikiPage, &$user, $content, $summary,
- $flags & EDIT_MINOR, null, null, &$flags, $revision ];
+ $flags & EDIT_MINOR, null, null, &$flags, $revision ];
Hooks::run( 'PageContentInsertComplete', $params );
// Trigger post-save hook
- $params = array_merge( $params, [ &$status, $meta['baseRevId'] ] );
+ $params = array_merge( $params, [ &$status, $meta['baseRevId'], 0 ] );
Hooks::run( 'PageContentSaveComplete', $params );
}
),
'resources/src/mediawiki.rcfilters/mw.rcfilters.UriProcessor.js',
],
'dependencies' => [
+ 'jquery.byteLength',
'oojs',
'mediawiki.api',
'mediawiki.api.options',
* @static
* @inheritable
* @param {string} str
- * @return {string}
+ * @return {number}
*/
jQuery.byteLength = function ( str ) {
// This basically figures out how many bytes a UTF-16 string (which is what js sees)
// Stringify state
stringified = JSON.stringify( state );
- if ( stringified.length > 65535 ) {
+ if ( $.byteLength( stringified ) > 65535 ) {
// Sanity check, since the preference can only hold that.
return;
}