X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=94919023294138e5fc84d8cbd5ac894e1d0c3a08;hb=f739a8f368ab64d63a2f21d15caf2caa766d6fc5;hp=d5a2f3fba3051c84ddf76ca6a41c203f107f2305;hpb=ca982ff27e8a3ddab918025a52bad298501cff27;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index d5a2f3fba3..9491902329 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -213,6 +213,7 @@ class WikiPage implements Page, IDBAccessObject { * @todo Move this UI stuff somewhere else * * @see ContentHandler::getActionOverrides + * @return array */ public function getActionOverrides() { return $this->getContentHandler()->getActionOverrides(); @@ -878,11 +879,10 @@ class WikiPage implements Page, IDBAccessObject { } // Update the DB post-send if the page has not cached since now - $that = $this; $latest = $this->getLatest(); DeferredUpdates::addCallableUpdate( - function () use ( $that, $retval, $latest ) { - $that->insertRedirectEntry( $retval, $latest ); + function () use ( $retval, $latest ) { + $this->insertRedirectEntry( $retval, $latest ); }, DeferredUpdates::POSTSEND, wfGetDB( DB_MASTER ) @@ -1166,11 +1166,10 @@ class WikiPage implements Page, IDBAccessObject { * page ID is already in use. */ public function insertOn( $dbw, $pageId = null ) { - $pageIdForInsert = $pageId ?: $dbw->nextSequenceValue( 'page_page_id_seq' ); + $pageIdForInsert = $pageId ? [ 'page_id' => $pageId ] : []; $dbw->insert( 'page', [ - 'page_id' => $pageIdForInsert, 'page_namespace' => $this->mTitle->getNamespace(), 'page_title' => $this->mTitle->getDBkey(), 'page_restrictions' => '', @@ -1180,7 +1179,7 @@ class WikiPage implements Page, IDBAccessObject { 'page_touched' => $dbw->timestamp(), 'page_latest' => 0, // Fill this in shortly... 'page_len' => 0, // Fill this in shortly... - ], + ] + $pageIdForInsert, __METHOD__, 'IGNORE' ); @@ -1659,7 +1658,7 @@ class WikiPage implements Page, IDBAccessObject { // Convenience variables $now = wfTimestampNow(); $oldid = $meta['oldId']; - /** @var $oldContent Content|null */ + /** @var Content|null $oldContent */ $oldContent = $meta['oldContent']; $newsize = $content->getSize(); @@ -2299,10 +2298,10 @@ class WikiPage implements Page, IDBAccessObject { public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user, $tags = null ) { - global $wgCascadingRestrictionLevels, $wgContLang; + global $wgCascadingRestrictionLevels; if ( wfReadOnly() ) { - return Status::newFatal( 'readonlytext', wfReadOnlyReason() ); + return Status::newFatal( wfMessage( 'readonlytext', wfReadOnlyReason() ) ); } $this->loadPageData( 'fromdbmaster' ); @@ -2372,9 +2371,6 @@ class WikiPage implements Page, IDBAccessObject { $logAction = 'protect'; } - // Truncate for whole multibyte characters - $reason = $wgContLang->truncate( $reason, 255 ); - $logRelationsValues = []; $logRelationsField = null; $logParamsDetails = []; @@ -2446,7 +2442,6 @@ class WikiPage implements Page, IDBAccessObject { $dbw->insert( 'page_restrictions', [ - 'pr_id' => $dbw->nextSequenceValue( 'page_restrictions_pr_id_seq' ), 'pr_page' => $id, 'pr_type' => $action, 'pr_level' => $restrictions, @@ -2484,6 +2479,7 @@ class WikiPage implements Page, IDBAccessObject { $cascade = false; if ( $limit['create'] != '' ) { + $commentFields = CommentStore::newKey( 'pt_reason' )->insert( $dbw, $reason ); $dbw->replace( 'protected_titles', [ [ 'pt_namespace', 'pt_title' ] ], [ @@ -2493,8 +2489,7 @@ class WikiPage implements Page, IDBAccessObject { 'pt_timestamp' => $dbw->timestamp(), 'pt_expiry' => $dbw->encodeExpiry( $expiry['create'] ), 'pt_user' => $user->getId(), - 'pt_reason' => $reason, - ], __METHOD__ + ] + $commentFields, __METHOD__ ); $logParamsDetails[] = [ 'type' => 'create', @@ -2738,6 +2733,7 @@ class WikiPage implements Page, IDBAccessObject { * @param array|string &$error Array of errors to append to * @param User $user The deleting user * @param array $tags Tags to apply to the deletion action + * @param string $logsubtype * @return Status Status object; if successful, $status->value is the log_id of the * deletion log entry. If the page couldn't be deleted because it wasn't * found, $status is a non-fatal 'cannotdelete' error @@ -2746,7 +2742,7 @@ class WikiPage implements Page, IDBAccessObject { $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $user = null, $tags = [], $logsubtype = 'delete' ) { - global $wgUser, $wgContentHandlerUseDB; + global $wgUser, $wgContentHandlerUseDB, $wgCommentTableSchemaMigrationStage; wfDebug( __METHOD__ . "\n" ); @@ -2810,6 +2806,9 @@ class WikiPage implements Page, IDBAccessObject { $content = null; } + $revCommentStore = new CommentStore( 'rev_comment' ); + $arCommentStore = new CommentStore( 'ar_comment' ); + $fields = Revision::selectFields(); $bitfield = false; @@ -2827,20 +2826,28 @@ class WikiPage implements Page, IDBAccessObject { // the rev_deleted field, which is reserved for this purpose. // Get all of the page revisions + $commentQuery = $revCommentStore->getJoin(); $res = $dbw->select( - 'revision', - $fields, + [ 'revision' ] + $commentQuery['tables'], + $fields + $commentQuery['fields'], [ 'rev_page' => $id ], __METHOD__, - 'FOR UPDATE' + 'FOR UPDATE', + $commentQuery['joins'] ); + // Build their equivalent archive rows $rowsInsert = []; + $revids = []; + + /** @var int[] Revision IDs of edits that were made by IPs */ + $ipRevIds = []; + foreach ( $res as $row ) { + $comment = $revCommentStore->getComment( $row ); $rowInsert = [ 'ar_namespace' => $namespace, 'ar_title' => $dbKey, - 'ar_comment' => $row->rev_comment, 'ar_user' => $row->rev_user, 'ar_user_text' => $row->rev_user_text, 'ar_timestamp' => $row->rev_timestamp, @@ -2854,12 +2861,19 @@ class WikiPage implements Page, IDBAccessObject { 'ar_page_id' => $id, 'ar_deleted' => $suppress ? $bitfield : $row->rev_deleted, 'ar_sha1' => $row->rev_sha1, - ]; + ] + $arCommentStore->insert( $dbw, $comment ); if ( $wgContentHandlerUseDB ) { $rowInsert['ar_content_model'] = $row->rev_content_model; $rowInsert['ar_content_format'] = $row->rev_content_format; } $rowsInsert[] = $rowInsert; + $revids[] = $row->rev_id; + + // Keep track of IP edits, so that the corresponding rows can + // be deleted in the ip_changes table. + if ( (int)$row->rev_user === 0 && IP::isValid( $row->rev_user_text ) ) { + $ipRevIds[] = $row->rev_id; + } } // Copy them into the archive table $dbw->insert( 'archive', $rowsInsert, __METHOD__ ); @@ -2874,6 +2888,14 @@ class WikiPage implements Page, IDBAccessObject { // Now that it's safely backed up, delete it $dbw->delete( 'page', [ 'page_id' => $id ], __METHOD__ ); $dbw->delete( 'revision', [ 'rev_page' => $id ], __METHOD__ ); + if ( $wgCommentTableSchemaMigrationStage > MIGRATION_OLD ) { + $dbw->delete( 'revision_comment_temp', [ 'revcomment_rev' => $revids ], __METHOD__ ); + } + + // Also delete records from ip_changes as applicable. + if ( count( $ipRevIds ) > 0 ) { + $dbw->delete( 'ip_changes', [ 'ipc_rev_id' => $ipRevIds ], __METHOD__ ); + } // Log the deletion, if the page was suppressed, put it in the suppression log instead $logtype = $suppress ? 'suppress' : 'delete'; @@ -3138,9 +3160,6 @@ class WikiPage implements Page, IDBAccessObject { // Trim spaces on user supplied text $summary = trim( $summary ); - // Truncate for whole multibyte characters. - $summary = $wgContLang->truncate( $summary, 255 ); - // Save $flags = EDIT_UPDATE | EDIT_INTERNAL;