User:Leucosticte/Junkyard

public function doEditContent( Content $content, $summary, $flags = 0, $baseRevId = false,		User $user = null, $serialisation_format = null, $timestamp = null	) { global $wgUser, $wgUseAutomaticEditSummaries, $wgUseRCPatrol, $wgUseNPPatrol;

// Low-level sanity check if ( $this->mTitle->getText === '' ) { throw new MWException( 'Something is trying to edit an article with an empty title' ); }

wfProfileIn( __METHOD__ );

if ( !$content->getContentHandler->canBeUsedOn( $this->getTitle ) ) { wfProfileOut( __METHOD__ ); return Status::newFatal( 'content-not-allowed-here',				ContentHandler::getLocalizedName( $content->getModel ),				$this->getTitle->getPrefixedText ); }

$user = is_null( $user ) ? $wgUser : $user; $status = Status::newGood( array );

// Load the data from the master database if needed. // The caller may already loaded it from the master or even loaded it using // SELECT FOR UPDATE, so do not override that using clear. $this->loadPageData( 'fromdbmaster' );

$flags = $this->checkFlags( $flags );

// handle hook $hook_args = array( &$this, &$user, &$content, &$summary,							$flags & EDIT_MINOR, null, null, &$flags, &$status );

if ( !wfRunHooks( 'PageContentSave', $hook_args )			|| !ContentHandler::runLegacyHooks( 'ArticleSave', $hook_args ) ) {

wfDebug( __METHOD__ . ": ArticleSave or ArticleSaveContent hook aborted save!\n" );

if ( $status->isOK ) { $status->fatal( 'edit-hook-aborted' ); }

wfProfileOut( __METHOD__ ); return $status; }

// Silently ignore EDIT_MINOR if not allowed $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' ); $bot = $flags & EDIT_FORCE_BOT;

$old_content = $this->getContent( Revision::RAW ); // current revision's content

$dbw = wfGetDB( DB_MASTER );

// See if the timestamp we're using is the latest timestamp; if not, pull the // revision that's slightly older than that one if ( $old_content) { $oldTimestamp = $this->getTimestamp; } else { $oldTimestamp = 0; // Page doesn't exist yet }               if ( $timestamp && $oldTimestamp && $timestamp < $oldTimestamp ) { $olderRevision = $dbw->selectRow (                       'revision',                        array( 'rev_id' ),                        array( 'rev_timestamp' => $timestamp ),                        __METHOD__,                        array( 'ORDER_BY' => 'rev_timestamp DESC' )                    ); $oldId = $olderRevision->rev_id; $this->mTimestamp = $timestamp; } else { $oldsize = $old_content ? $old_content->getSize : 0; $oldid = $this->getLatest; $oldIsRedirect = $this->isRedirect; $oldcountable = $this->isCountable; $now = wfTimestampNow; $this->mTimestamp = $now;

$handler = $content->getContentHandler;

// Provide autosummaries if one is not provided and autosummaries are enabled. if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) { if ( !$old_content ) { $old_content = null; }                           $summary = $handler->getAutosummary( $old_content, $content, $flags ); }               }

$editInfo = $this->prepareContentForEdit( $content, null, $user, $serialisation_format ); $serialized = $editInfo->pst;

/**		 * @var Content $content */		$content = $editInfo->pstContent; $newsize = $content->getSize;

if ( $flags & EDIT_UPDATE ) { // Update article, but only if changed. $status->value['new'] = false;

if ( !$oldid ) { // Article gone missing wfDebug( __METHOD__ . ": EDIT_UPDATE specified but article doesn't exist\n" ); $status->fatal( 'edit-gone-missing' );

wfProfileOut( __METHOD__ ); return $status; } elseif ( !$old_content ) { // Sanity check for bug 37225 wfProfileOut( __METHOD__ ); throw new MWException( "Could not find text for current revision {$oldid}." ); }

$revision = new Revision( array( 'page'      => $this->getId, 'title'     => $this->getTitle, // for determining the default content model 'comment'   => $summary, 'minor_edit' => $isminor, 'text'      => $serialized, 'len'       => $newsize, 'parent_id' => $oldid, 'user'      => $user->getId, 'user_text' => $user->getName, 'timestamp' => $timestamp, 'content_model' => $content->getModel, 'content_format' => $serialisation_format, ) ); // XXX: pass content object?!

$page = $revision->getPage; $title = $revision->getTitle; // What is all this shit? 'page'      => $newid, 'title'     => $this->getTitle, // for determining the default content model 'comment'   => $summary, 'minor_edit' => $isminor, 'text'      => $serialized, 'len'       => $newsize, 'user'      => $user->getId, 'user_text' => $user->getName, 'timestamp' => $now, 'content_model' => $content->getModel, 'content_format' => $serialisation_format,

public static function onAPIEditBeforeSave( $editPage, $text, &$resultArr, $params ) { global $wgMirrorEditParams; $wgMirrorEditParams = $params; return true; }

public static function onPageContentSaveRevision ( $wikiPage, $user, $content, $summary,               $isMinor, $flags, $revision, $status, $baseRevId ) { global $wgMirrorEditParams; }

// TODO: This should look at the user table for users who are linked to users on the remote // wiki; for now those will be 0 and the user name.

// NEXT TASK: // This is all other stuff you need to change in the array, like on the line above. // There should only be a few.