From d1f1ee8d5c225f512388b646384c42ad5a7f164e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 19 Sep 2005 06:10:58 +0000 Subject: [PATCH] * (bug 2570) Add 'watch this page' checkbox on uploads, watch uploads by default when 'watchdefault' option is on --- RELEASE-NOTES | 2 ++ includes/Image.php | 29 ++++++++++++++++++----------- includes/SpecialUpload.php | 17 +++++++++++++++-- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6537359588..bf454ca162 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -114,6 +114,8 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 2792) Update rebuildrecentchanges.inc for new schema * Special:Import/importDump fixes: report XML parse errors, accept * (bug 3489) PHP 5.1 compat problem with captioned images +* (bug 2570) Add 'watch this page' checkbox on uploads, watch uploads + by default when 'watchdefault' option is on === Caveats === diff --git a/includes/Image.php b/includes/Image.php index a8ff72709a..6622fd10fa 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1266,7 +1266,7 @@ class Image /** * Record an image upload in the upload log and the image table */ - function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '' ) { + function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false ) { global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList; global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList; @@ -1336,15 +1336,7 @@ class Image $descTitle = $this->getTitle(); $purgeURLs = array(); - if ( $dbw->affectedRows() ) { - # Successfully inserted, this is a new image - $id = $descTitle->getArticleID(); - - if ( $id == 0 ) { - $article = new Article( $descTitle ); - $article->insertNewArticle( $textdesc, $desc, false, false, true ); - } - } else { + if( $dbw->affectedRows() == 0 ) { # Collision, this is an update of an image # Insert previous contents into oldimage $dbw->insertSelect( 'oldimage', 'image', @@ -1381,12 +1373,27 @@ class Image 'img_name' => $this->name ), $fname ); + } + + $article = new Article( $descTitle ); + $minor = false; + $watch = $watch || $wgUser->isWatched( $descTitle ); + $suppressRC = true; // There's already a log entry, so don't double the RC load + + if( $descTitle->exists() ) { + // TODO: insert a null revision into the page history for this update. + if( $watch ) { + $wgUser->addWatch( $descTitle ); + } # Invalidate the cache for the description page $descTitle->invalidateCache(); $purgeURLs[] = $descTitle->getInternalURL(); + } else { + // New image; create the description page. + $article->insertNewArticle( $textdesc, $desc, $minor, $watch, $suppressRC ); } - + # Invalidate cache for all pages using this image $linksTo = $this->getLinksTo(); diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index ec6d4c3708..8273924eec 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -55,7 +55,9 @@ class UploadForm { $this->mUploadDescription = $request->getText( 'wpUploadDescription' ); $this->mLicense = $request->getText( 'wpLicense' ); $this->mUploadCopyStatus = $request->getText( 'wpUploadCopyStatus' ); - $this->mUploadSource = $request->getText( 'wpUploadSource'); + $this->mUploadSource = $request->getText( 'wpUploadSource' ); + $this->mWatchthis = $request->getBool( 'wpWatchthis' ); + wfDebug( "UploadForm: watchthis is: '$this->mWatchthis'\n" ); $this->mAction = $request->getVal( 'action' ); @@ -306,7 +308,8 @@ class UploadForm { $this->mUploadDescription, $this->mLicense, $this->mUploadCopyStatus, - $this->mUploadSource ); + $this->mUploadSource, + $this->mWatchthis ); if ( $success ) { $this->showSuccess(); @@ -516,6 +519,7 @@ class UploadForm { mUploadDescription ) . "\" /> mLicense ) . "\" /> mDestFile ) . "\" /> + mWatchthis ) ) . "\" /> {$copyright} @@ -591,6 +595,10 @@ class UploadForm { " ; } + $watchChecked = $wgUser->getOption( 'watchdefault' ) + ? 'checked="checked"' + : ''; + $wgOut->addHTML( "
@@ -607,6 +615,11 @@ class UploadForm { + + + " ); if ( $licenseshtml != '' ) { -- 2.20.1
+ +