Example #1
0
 /**
  * Override handling of action=purge
  */
 public function doPurge()
 {
     $this->loadFile();
     if ($this->mFile->exists()) {
         wfDebug('ImagePage::doPurge purging ' . $this->mFile->getName() . "\n");
         $update = new HTMLCacheUpdate($this->mTitle, 'imagelinks');
         $update->doUpdate();
         $this->mFile->upgradeRow();
         $this->mFile->purgeCache(array('forThumbRefresh' => true));
     } else {
         wfDebug('ImagePage::doPurge no image for ' . $this->mFile->getName() . "; limiting purge to cache only\n");
         // even if the file supposedly doesn't exist, force any cached information
         // to be updated (in case the cached information is wrong)
         $this->mFile->purgeCache(array('forThumbRefresh' => true));
     }
     return parent::doPurge();
 }
Example #2
0
 /**
  * Override handling of action=purge
  */
 public function doPurge()
 {
     global $wgCityId;
     $this->loadFile();
     if ($this->mFile->exists()) {
         wfDebug('ImagePage::doPurge purging ' . $this->mFile->getName() . "\n");
         // Wikia Change Start @author Scott Rabin (srabin@wikia-inc.com)
         $task = (new \Wikia\Tasks\Tasks\HTMLCacheUpdateTask())->wikiId($wgCityId)->title($this->mTitle);
         $task->call('purge', 'imagelinks');
         $task->queue();
         // Wikia Change End
         $this->mFile->upgradeRow();
         $this->mFile->purgeCache(array('forThumbRefresh' => true));
     } else {
         wfDebug('ImagePage::doPurge no image for ' . $this->mFile->getName() . "; limiting purge to cache only\n");
         // even if the file supposedly doesn't exist, force any cached information
         // to be updated (in case the cached information is wrong)
         $this->mFile->purgeCache(array('forThumbRefresh' => true));
     }
     return parent::doPurge();
 }
Example #3
0
 /**
  * Moves an image to a safe private location
  * Caller is responsible for clearing caches
  * @param File $oimage
  * @returns mixed, timestamp string on success, false on failure
  */
 function makeOldImagePrivate($oimage)
 {
     $transaction = new FSTransaction();
     if (!FileStore::lock()) {
         wfDebug(__METHOD__ . ": failed to acquire file store lock, aborting\n");
         return false;
     }
     $oldpath = $oimage->getArchivePath() . DIRECTORY_SEPARATOR . $oimage->archive_name;
     // Dupe the file into the file store
     if (file_exists($oldpath)) {
         // Is our directory configured?
         if ($store = FileStore::get('deleted')) {
             if (!$oimage->sha1) {
                 $oimage->upgradeRow();
                 // sha1 may be missing
             }
             $key = $oimage->sha1 . '.' . $oimage->getExtension();
             $transaction->add($store->insert($key, $oldpath, FileStore::DELETE_ORIGINAL));
         } else {
             $group = null;
             $key = null;
             $transaction = false;
             // Return an error and do nothing
         }
     } else {
         wfDebug(__METHOD__ . " deleting already-missing '{$oldpath}'; moving on to database\n");
         $group = null;
         $key = '';
         $transaction = new FSTransaction();
         // empty
     }
     if ($transaction === false) {
         // Fail to restore?
         wfDebug(__METHOD__ . ": import to file store failed, aborting\n");
         throw new MWException("Could not archive and delete file {$oldpath}");
         return false;
     }
     wfDebug(__METHOD__ . ": set db items, applying file transactions\n");
     $transaction->commit();
     FileStore::unlock();
     $m = explode('!', $oimage->archive_name, 2);
     $timestamp = $m[0];
     return $timestamp;
 }