/** * Move file to the new title * * Move current, old version and all thumbnails * to the new filename. Old file is deleted. * * Cache purging is done; checks for validity * and logging are caller's responsibility * * @param Title $target New file name * @return FileRepoStatus */ function move($target) { if ($this->getRepo()->getReadOnlyReason() !== false) { return $this->readOnlyFatalStatus(); } wfDebugLog('imagemove', "Got request to move {$this->name} to " . $target->getText()); $batch = new LocalFileMoveBatch($this, $target); $this->lock(); // begin $batch->addCurrent(); $archiveNames = $batch->addOlds(); $status = $batch->execute(); $this->unlock(); // done wfDebugLog('imagemove', "Finished moving {$this->name}"); // Purge the source and target files... $oldTitleFile = wfLocalFile($this->title); $newTitleFile = wfLocalFile($target); // Hack: the lock()/unlock() pair is nested in a transaction so the locking is not // tied to BEGIN/COMMIT. To avoid slow purges in the transaction, move them outside. $this->getRepo()->getMasterDB()->onTransactionIdle(function () use($oldTitleFile, $newTitleFile, $archiveNames) { $oldTitleFile->purgeEverything(); foreach ($archiveNames as $archiveName) { $oldTitleFile->purgeOldThumbnails($archiveName); } $newTitleFile->purgeEverything(); }); if ($status->isOK()) { // Now switch the object $this->title = $target; // Force regeneration of the name and hashpath unset($this->name); unset($this->hashPath); } return $status; }
/** * Move file to the new title * * Move current, old version and all thumbnails * to the new filename. Old file is deleted. * * Cache purging is done; checks for validity * and logging are caller's responsibility * * @param $target Title New file name * @return FileRepoStatus object. */ function move($target) { wfDebugLog('imagemove', "Got request to move {$this->name} to " . $target->getText()); $this->lock(); $batch = new LocalFileMoveBatch($this, $target); $batch->addCurrent(); $batch->addOlds(); $status = $batch->execute(); wfDebugLog('imagemove', "Finished moving {$this->name}"); $this->purgeEverything(); $this->unlock(); if ($status->isOk()) { // Now switch the object $this->title = $target; // Force regeneration of the name and hashpath unset($this->name); unset($this->hashPath); // Purge the new image $this->purgeEverything(); } return $status; }
/** * Move file to the new title * * Move current, old version and all thumbnails * to the new filename. Old file is deleted. * * Cache purging is done; checks for validity * and logging are caller's responsibility * * @param Title $target New file name * @return Status */ function move($target) { if ($this->getRepo()->getReadOnlyReason() !== false) { return $this->readOnlyFatalStatus(); } wfDebugLog('imagemove', "Got request to move {$this->name} to " . $target->getText()); $batch = new LocalFileMoveBatch($this, $target); $this->lock(); // begin $batch->addCurrent(); $archiveNames = $batch->addOlds(); $status = $batch->execute(); $this->unlock(); // done wfDebugLog('imagemove', "Finished moving {$this->name}"); // Purge the source and target files... $oldTitleFile = wfLocalFile($this->title); $newTitleFile = wfLocalFile($target); // To avoid slow purges in the transaction, move them outside... DeferredUpdates::addUpdate(new AutoCommitUpdate($this->getRepo()->getMasterDB(), __METHOD__, function () use($oldTitleFile, $newTitleFile, $archiveNames) { $oldTitleFile->purgeEverything(); foreach ($archiveNames as $archiveName) { $oldTitleFile->purgeOldThumbnails($archiveName); } $newTitleFile->purgeEverything(); }), DeferredUpdates::PRESEND); if ($status->isOK()) { // Now switch the object $this->title = $target; // Force regeneration of the name and hashpath unset($this->name); unset($this->hashPath); } return $status; }
/** * Move file to the new title * * Move current, old version and all thumbnails * to the new filename. Old file is deleted. * * Cache purging is done; checks for validity * and logging are caller's responsibility * * @param $target Title New file name * @return FileRepoStatus object. */ function move($target) { if ($this->getRepo()->getReadOnlyReason() !== false) { return $this->readOnlyFatalStatus(); } wfDebugLog('imagemove', "Got request to move {$this->name} to " . $target->getText()); $batch = new LocalFileMoveBatch($this, $target); $this->lock(); // begin $batch->addCurrent(); $archiveNames = $batch->addOlds(); $status = $batch->execute(); $this->unlock(); // done wfDebugLog('imagemove', "Finished moving {$this->name}"); $this->purgeEverything(); foreach ($archiveNames as $archiveName) { $this->purgeOldThumbnails($archiveName); } if ($status->isOK()) { // Now switch the object $this->title = $target; // Force regeneration of the name and hashpath unset($this->name); unset($this->hashPath); // Purge the new image $this->purgeEverything(); } return $status; }
/** * Move file to the new title * * Move current, old version and all thumbnails * to the new filename. Old file is deleted. * * Cache purging is done; checks for validity * and logging are caller's responsibility * * @param $target Title New file name * @return FileRepoStatus object. */ function move($target) { wfDebugLog('imagemove', "Got request to move {$this->name} to " . $target->getText()); // Wikia change - begin // @author macbre global $wgUploadMaintenance; if (!empty($wgUploadMaintenance)) { return Status::newFatal('filedelete-maintenance'); } // Wikia change - end $this->lock(); // begin $batch = new LocalFileMoveBatch($this, $target); $batch->addCurrent(); $archiveNames = $batch->addOlds(); $status = $batch->execute(); $this->unlock(); // done wfDebugLog('imagemove', "Finished moving {$this->name}"); $this->purgeEverything(); foreach ($archiveNames as $archiveName) { $this->purgeOldThumbnails($archiveName); } if ($status->isOk()) { // Now switch the object $this->title = $target; // Force regeneration of the name and hashpath unset($this->name); unset($this->hashPath); // Wikia change - begin // @author macbre unset($this->url); // Wikia change - end // Purge the new image $this->purgeEverything(); } return $status; }