* @param string|bool $timestamp Timestamp for img_timestamp, or false to use the
* current time
* @param User|null $user User object or null to use $wgUser
- *
+ * @param string[] $tags Change tags to add to the log entry and page revision.
* @return FileRepoStatus On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false,
- $timestamp = false, $user = null
+ $timestamp = false, $user = null, $tags = array()
) {
global $wgContLang;
// It is only *preferable* to avoid leaving such files orphaned.
// Once the second operation goes through, then the current version was
// updated and we must therefore update the DB too.
- if ( !$this->recordUpload2( $status->value, $comment, $pageText, $props, $timestamp, $user ) ) {
+ $oldver = $status->value;
+ if ( !$this->recordUpload2( $oldver, $comment, $pageText, $props, $timestamp, $user, $tags ) ) {
$status->fatal( 'filenotfound', $srcPath );
}
}
* @param bool|array $props
* @param string|bool $timestamp
* @param null|User $user
+ * @param string[] $tags
* @return bool
*/
function recordUpload2(
- $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null
+ $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = array()
) {
if ( is_null( $user ) ) {
global $wgUser;
# b) They won't cause rollback of the log publish/update above
$that = $this;
$dbw->onTransactionIdle( function () use (
- $that, $reupload, $wikiPage, $newPageContent, $comment, $user, $logEntry, $logId, $descId
+ $that, $reupload, $wikiPage, $newPageContent, $comment, $user, $logEntry, $logId, $descId, $tags
) {
# Update memcache after the commit
$that->invalidateCache();
);
# Now that the log entry is up-to-date, make an RC entry.
- $logEntry->publish( $logId );
+ $recentChange = $logEntry->publish( $logId );
+
+ if ( $tags ) {
+ ChangeTags::addTags(
+ $tags,
+ $recentChange ? $recentChange->getAttribute( 'rc_id' ) : null,
+ $logEntry->getAssociatedRevId(),
+ $logId
+ );
+ }
+
# Run hook for other updates (typically more cache purging)
Hooks::run( 'FileUpload', array( $that, $reupload, !$newPageContent ) );
*
* @param int $newId Id of the log entry.
* @param string $to One of: rcandudp (default), rc, udp
+ * @return RecentChange|null
*/
public function publish( $newId, $to = 'rcandudp' ) {
$log = new LogPage( $this->getType() );
if ( $log->isRestricted() ) {
- return;
+ return null;
}
$rc = $this->getRecentChange( $newId );
$rc->getAttribute( 'rc_patrolled' ) === 1 ) {
PatrolLog::record( $rc, true, $this->getPerformer() );
}
+
+ return $rc;
}
public function getType() {
* @param string $pageText
* @param bool $watch
* @param User $user
- *
+ * @param string[] $tags Change tags to add to the log entry and page revision.
* @return Status Indicating the whether the upload succeeded.
*/
- public function performUpload( $comment, $pageText, $watch, $user ) {
+ public function performUpload( $comment, $pageText, $watch, $user, $tags = array() ) {
$this->getLocalFile()->load( File::READ_LATEST );
$status = $this->getLocalFile()->upload(
File::DELETE_SOURCE,
$this->mFileProps,
false,
- $user
+ $user,
+ $tags
);
if ( $status->isGood() ) {