X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FRevision.php;h=bcfbe638b4b1c408f0057849fd9cebeaa95b6873;hb=712cd1481e0a28e519e9178f458039d520458554;hp=ff4a28438608bb21f5723aba2f55db1bd1ef27d8;hpb=34487054ed508a1924832625d9c71dd3960825fc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Revision.php b/includes/Revision.php index ff4a284386..bcfbe638b4 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -362,7 +362,7 @@ class Revision implements IDBAccessObject { $row = self::fetchFromConds( $db, $conditions, $flags ); if ( $row ) { $rev = new Revision( $row ); - $rev->mWiki = $db->getWikiID(); + $rev->mWiki = $db->getDomainID(); return $rev; } @@ -1401,7 +1401,7 @@ class Revision implements IDBAccessObject { * * @param IDatabase $dbw (master connection) * @throws MWException - * @return int + * @return int The revision ID */ public function insertOn( $dbw ) { global $wgDefaultExternalStore, $wgContentHandlerUseDB; @@ -1442,10 +1442,8 @@ class Revision implements IDBAccessObject { # Record the text (or external storage URL) to the text table if ( $this->mTextId === null ) { - $old_id = $dbw->nextSequenceValue( 'text_old_id_seq' ); $dbw->insert( 'text', [ - 'old_id' => $old_id, 'old_text' => $data, 'old_flags' => $flags, ], __METHOD__ @@ -1458,11 +1456,7 @@ class Revision implements IDBAccessObject { } # Record the edit in revisions - $rev_id = $this->mId !== null - ? $this->mId - : $dbw->nextSequenceValue( 'revision_rev_id_seq' ); $row = [ - 'rev_id' => $rev_id, 'rev_page' => $this->mPage, 'rev_text_id' => $this->mTextId, 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0, @@ -1478,6 +1472,9 @@ class Revision implements IDBAccessObject { ? self::base36Sha1( $this->mText ) : $this->mSha1, ]; + if ( $this->mId !== null ) { + $row['rev_id'] = $this->mId; + } list( $commentFields, $commentCallback ) = CommentStore::newKey( 'rev_comment' )->insertWithTempTable( $dbw, $this->mComment ); @@ -1508,7 +1505,7 @@ class Revision implements IDBAccessObject { $dbw->insert( 'revision', $row, __METHOD__ ); if ( $this->mId === null ) { - // Only if nextSequenceValue() was called + // Only if auto-increment was used $this->mId = $dbw->insertId(); } $commentCallback( $this->mId ); @@ -1521,6 +1518,16 @@ class Revision implements IDBAccessObject { ); } + // Insert IP revision into ip_changes for use when querying for a range. + if ( $this->mUser === 0 && IP::isValid( $this->mUserText ) ) { + $ipcRow = [ + 'ipc_rev_id' => $this->mId, + 'ipc_rev_timestamp' => $row['rev_timestamp'], + 'ipc_hex' => IP::toHex( $row['rev_user_text'] ), + ]; + $dbw->insert( 'ip_changes', $ipcRow, __METHOD__ ); + } + // Avoid PHP 7.1 warning of passing $this by reference $revision = $this; Hooks::run( 'RevisionInsertComplete', [ &$revision, $data, $flags ] ); @@ -1706,7 +1713,7 @@ class Revision implements IDBAccessObject { * @return Revision|null Revision or null on error */ public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) { - global $wgContentHandlerUseDB, $wgContLang; + global $wgContentHandlerUseDB; $fields = [ 'page_latest', 'page_namespace', 'page_title', 'rev_text_id', 'rev_len', 'rev_sha1' ]; @@ -1733,9 +1740,6 @@ class Revision implements IDBAccessObject { $user = $wgUser; } - // Truncate for whole multibyte characters - $summary = $wgContLang->truncate( $summary, 255 ); - $row = [ 'page' => $pageId, 'user_text' => $user->getName(), @@ -1937,7 +1941,7 @@ class Revision implements IDBAccessObject { $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); return $cache->getWithSetCallback( // Page/rev IDs passed in from DB to reflect history merges - $cache->makeGlobalKey( 'revision', $db->getWikiID(), $pageId, $revId ), + $cache->makeGlobalKey( 'revision', $db->getDomainID(), $pageId, $revId ), $cache::TTL_WEEK, function ( $curValue, &$ttl, array &$setOpts ) use ( $db, $pageId, $revId ) { $setOpts += Database::getCacheSetOptions( $db );