本文整理汇总了PHP中LocalFile::getRepo方法的典型用法代码示例。如果您正苦于以下问题:PHP LocalFile::getRepo方法的具体用法?PHP LocalFile::getRepo怎么用?PHP LocalFile::getRepo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalFile
的用法示例。
在下文中一共展示了LocalFile::getRepo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purgeFromArchiveTable
protected function purgeFromArchiveTable(LocalFile $file)
{
$db = $file->getRepo()->getSlaveDB();
$res = $db->select('filearchive', array('fa_archive_name'), array('fa_name' => $file->getName()), __METHOD__);
foreach ($res as $row) {
$file->purgeOldThumbnails($row->fa_archive_name);
}
}
示例2: execute
/**
* Run the transaction, except the cleanup batch.
* The cleanup batch should be run in a separate transaction, because it locks different
* rows and there's no need to keep the image row locked while it's acquiring those locks
* The caller may have its own transaction open.
* So we save the batch and let the caller call cleanup()
* @return FileRepoStatus
*/
public function execute()
{
global $wgLang;
$repo = $this->file->getRepo();
if (!$this->all && !$this->ids) {
// Do nothing
return $repo->newGood();
}
$lockOwnsTrx = $this->file->lock();
$dbw = $this->file->repo->getMasterDB();
$status = $this->file->repo->newGood();
$exists = (bool) $dbw->selectField('image', '1', array('img_name' => $this->file->getName()), __METHOD__, $lockOwnsTrx ? array() : array('LOCK IN SHARE MODE'));
// Fetch all or selected archived revisions for the file,
// sorted from the most recent to the oldest.
$conditions = array('fa_name' => $this->file->getName());
if (!$this->all) {
$conditions['fa_id'] = $this->ids;
}
$result = $dbw->select('filearchive', ArchivedFile::selectFields(), $conditions, __METHOD__, array('ORDER BY' => 'fa_timestamp DESC'));
$idsPresent = array();
$storeBatch = array();
$insertBatch = array();
$insertCurrent = false;
$deleteIds = array();
$first = true;
$archiveNames = array();
foreach ($result as $row) {
$idsPresent[] = $row->fa_id;
if ($row->fa_name != $this->file->getName()) {
$status->error('undelete-filename-mismatch', $wgLang->timeanddate($row->fa_timestamp));
$status->failCount++;
continue;
}
if ($row->fa_storage_key == '') {
// Revision was missing pre-deletion
$status->error('undelete-bad-store-key', $wgLang->timeanddate($row->fa_timestamp));
$status->failCount++;
continue;
}
$deletedRel = $repo->getDeletedHashPath($row->fa_storage_key) . $row->fa_storage_key;
$deletedUrl = $repo->getVirtualUrl() . '/deleted/' . $deletedRel;
if (isset($row->fa_sha1)) {
$sha1 = $row->fa_sha1;
} else {
// old row, populate from key
$sha1 = LocalRepo::getHashFromKey($row->fa_storage_key);
}
# Fix leading zero
if (strlen($sha1) == 32 && $sha1[0] == '0') {
$sha1 = substr($sha1, 1);
}
if (is_null($row->fa_major_mime) || $row->fa_major_mime == 'unknown' || is_null($row->fa_minor_mime) || $row->fa_minor_mime == 'unknown' || is_null($row->fa_media_type) || $row->fa_media_type == 'UNKNOWN' || is_null($row->fa_metadata)) {
// Refresh our metadata
// Required for a new current revision; nice for older ones too. :)
$props = RepoGroup::singleton()->getFileProps($deletedUrl);
} else {
$props = array('minor_mime' => $row->fa_minor_mime, 'major_mime' => $row->fa_major_mime, 'media_type' => $row->fa_media_type, 'metadata' => $row->fa_metadata);
}
if ($first && !$exists) {
// This revision will be published as the new current version
$destRel = $this->file->getRel();
$insertCurrent = array('img_name' => $row->fa_name, 'img_size' => $row->fa_size, 'img_width' => $row->fa_width, 'img_height' => $row->fa_height, 'img_metadata' => $props['metadata'], 'img_bits' => $row->fa_bits, 'img_media_type' => $props['media_type'], 'img_major_mime' => $props['major_mime'], 'img_minor_mime' => $props['minor_mime'], 'img_description' => $row->fa_description, 'img_user' => $row->fa_user, 'img_user_text' => $row->fa_user_text, 'img_timestamp' => $row->fa_timestamp, 'img_sha1' => $sha1);
// The live (current) version cannot be hidden!
if (!$this->unsuppress && $row->fa_deleted) {
$storeBatch[] = array($deletedUrl, 'public', $destRel);
$this->cleanupBatch[] = $row->fa_storage_key;
}
} else {
$archiveName = $row->fa_archive_name;
if ($archiveName == '') {
// This was originally a current version; we
// have to devise a new archive name for it.
// Format is <timestamp of archiving>!<name>
$timestamp = wfTimestamp(TS_UNIX, $row->fa_deleted_timestamp);
do {
$archiveName = wfTimestamp(TS_MW, $timestamp) . '!' . $row->fa_name;
$timestamp++;
} while (isset($archiveNames[$archiveName]));
}
$archiveNames[$archiveName] = true;
$destRel = $this->file->getArchiveRel($archiveName);
$insertBatch[] = array('oi_name' => $row->fa_name, 'oi_archive_name' => $archiveName, 'oi_size' => $row->fa_size, 'oi_width' => $row->fa_width, 'oi_height' => $row->fa_height, 'oi_bits' => $row->fa_bits, 'oi_description' => $row->fa_description, 'oi_user' => $row->fa_user, 'oi_user_text' => $row->fa_user_text, 'oi_timestamp' => $row->fa_timestamp, 'oi_metadata' => $props['metadata'], 'oi_media_type' => $props['media_type'], 'oi_major_mime' => $props['major_mime'], 'oi_minor_mime' => $props['minor_mime'], 'oi_deleted' => $this->unsuppress ? 0 : $row->fa_deleted, 'oi_sha1' => $sha1);
}
$deleteIds[] = $row->fa_id;
if (!$this->unsuppress && $row->fa_deleted & File::DELETED_FILE) {
// private files can stay where they are
$status->successCount++;
} else {
$storeBatch[] = array($deletedUrl, 'public', $destRel);
$this->cleanupBatch[] = $row->fa_storage_key;
}
$first = false;
//.........这里部分代码省略.........