当前位置: 首页>>代码示例>>PHP>>正文


PHP LocalRepo类代码示例

本文整理汇总了PHP中LocalRepo的典型用法代码示例。如果您正苦于以下问题:PHP LocalRepo类的具体用法?PHP LocalRepo怎么用?PHP LocalRepo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LocalRepo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkFiles

 protected function checkFiles(LocalRepo $repo, array $paths, $verbose)
 {
     if (!count($paths)) {
         return;
     }
     $dbr = $repo->getSlaveDB();
     $curNames = [];
     $oldNames = [];
     $imgIN = [];
     $oiWheres = [];
     foreach ($paths as $path) {
         $name = basename($path);
         if (preg_match('#^archive/#', $path)) {
             if ($verbose) {
                 $this->output("Checking old file {$name}\n");
             }
             $oldNames[] = $name;
             list(, $base) = explode('!', $name, 2);
             // <TS_MW>!<img_name>
             $oiWheres[] = $dbr->makeList(['oi_name' => $base, 'oi_archive_name' => $name], LIST_AND);
         } else {
             if ($verbose) {
                 $this->output("Checking current file {$name}\n");
             }
             $curNames[] = $name;
             $imgIN[] = $name;
         }
     }
     $res = $dbr->query($dbr->unionQueries([$dbr->selectSQLText('image', ['name' => 'img_name', 'old' => 0], $imgIN ? ['img_name' => $imgIN] : '1=0'), $dbr->selectSQLText('oldimage', ['name' => 'oi_archive_name', 'old' => 1], $oiWheres ? $dbr->makeList($oiWheres, LIST_OR) : '1=0')], true), __METHOD__);
     $curNamesFound = [];
     $oldNamesFound = [];
     foreach ($res as $row) {
         if ($row->old) {
             $oldNamesFound[] = $row->name;
         } else {
             $curNamesFound[] = $row->name;
         }
     }
     foreach (array_diff($curNames, $curNamesFound) as $name) {
         $file = $repo->newFile($name);
         // Print name and public URL to ease recovery
         if ($file) {
             $this->output($name . "\n" . $file->getCanonicalUrl() . "\n\n");
         } else {
             $this->error("Cannot get URL for bad file title '{$name}'");
         }
     }
     foreach (array_diff($oldNames, $oldNamesFound) as $name) {
         list(, $base) = explode('!', $name, 2);
         // <TS_MW>!<img_name>
         $file = $repo->newFromArchiveName(Title::makeTitle(NS_FILE, $base), $name);
         // Print name and public URL to ease recovery
         $this->output($name . "\n" . $file->getCanonicalUrl() . "\n\n");
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:55,代码来源:findOrphanedFiles.php

示例2: newFromKey

 /**
  * Create a OldLocalFile from a SHA-1 key
  * Do not call this except from inside a repo class.
  *
  * @param string $sha1 Base-36 SHA-1
  * @param LocalRepo $repo
  * @param string|bool $timestamp MW_timestamp (optional)
  *
  * @return bool|OldLocalFile
  */
 static function newFromKey($sha1, $repo, $timestamp = false)
 {
     $dbr = $repo->getSlaveDB();
     $conds = array('oi_sha1' => $sha1);
     if ($timestamp) {
         $conds['oi_timestamp'] = $dbr->timestamp($timestamp);
     }
     $row = $dbr->selectRow('oldimage', self::selectFields(), $conds, __METHOD__);
     if ($row) {
         return self::newFromRow($row, $repo);
     } else {
         return false;
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:24,代码来源:OldLocalFile.php

示例3: execute

 public function execute()
 {
     if (!$this->hasOption('delete')) {
         $this->output("Use --delete to actually confirm this script\n");
         return;
     }
     # Data should come off the master, wrapped in a transaction
     $dbw = $this->getDB(DB_MASTER);
     $dbw->begin(__METHOD__);
     $repo = RepoGroup::singleton()->getLocalRepo();
     # Get "active" revisions from the filearchive table
     $this->output("Searching for and deleting archived files...\n");
     $res = $dbw->select('filearchive', array('fa_id', 'fa_storage_group', 'fa_storage_key', 'fa_sha1'), '', __METHOD__);
     $count = 0;
     foreach ($res as $row) {
         $key = $row->fa_storage_key;
         if (!strlen($key)) {
             $this->output("Entry with ID {$row->fa_id} has empty key, skipping\n");
             continue;
         }
         $group = $row->fa_storage_group;
         $id = $row->fa_id;
         $path = $repo->getZonePath('deleted') . '/' . $repo->getDeletedHashPath($key) . $key;
         if (isset($row->fa_sha1)) {
             $sha1 = $row->fa_sha1;
         } else {
             // old row, populate from key
             $sha1 = LocalRepo::getHashFromKey($key);
         }
         // Check if the file is used anywhere...
         $inuse = $dbw->selectField('oldimage', '1', array('oi_sha1' => $sha1, $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE), __METHOD__, array('FOR UPDATE'));
         $needForce = true;
         if (!$repo->fileExists($path)) {
             $this->output("Notice - file '{$key}' not found in group '{$group}'\n");
         } elseif ($inuse) {
             $this->output("Notice - file '{$key}' is still in use\n");
         } elseif (!$repo->quickPurge($path)) {
             $this->output("Unable to remove file {$path}, skipping\n");
             continue;
             // don't delete even with --force
         } else {
             $needForce = false;
         }
         if ($needForce) {
             if ($this->hasOption('force')) {
                 $this->output("Got --force, deleting DB entry\n");
             } else {
                 continue;
             }
         }
         $count++;
         $dbw->delete('filearchive', array('fa_id' => $id), __METHOD__);
     }
     $dbw->commit(__METHOD__);
     $this->output("Done! [{$count} file(s)]\n");
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:56,代码来源:deleteArchivedFiles.php

示例4: checkFiles

 protected function checkFiles(LocalRepo $repo, array $names, $verbose)
 {
     if (!count($names)) {
         return;
     }
     $dbr = $repo->getSlaveDB();
     $imgIN = array();
     $oiWheres = array();
     foreach ($names as $name) {
         if (strpos($name, '!') !== false) {
             if ($verbose) {
                 $this->output("Checking old file {$name}\n");
             }
             list(, $base) = explode('!', $name);
             // <TS_MW>!<img_name>
             $oiWheres[] = $dbr->makeList(array('oi_name' => $base, 'oi_archive_name' => $name), LIST_AND);
         } else {
             if ($verbose) {
                 $this->output("Checking current file {$name}\n");
             }
             $imgIN[] = $name;
         }
     }
     $res = $dbr->query($dbr->unionQueries(array($dbr->selectSQLText('image', array('name' => 'img_name'), array('img_name' => $imgIN)), $dbr->selectSQLText('oldimage', array('name' => 'oi_archive_name'), $dbr->makeList($oiWheres, LIST_OR))), true), __METHOD__);
     $namesFound = array();
     foreach ($res as $row) {
         $namesFound[] = $row->name;
     }
     $namesOrphans = array_diff($names, $namesFound);
     foreach ($namesOrphans as $name) {
         // Print name and public URL to ease recovery
         if (strpos($name, '!') !== false) {
             list(, $base) = explode('!', $name);
             // <TS_MW>!<img_name>
             $file = $repo->newFromArchiveName(Title::makeTitle(NS_FILE, $base), $name);
         } else {
             $file = $repo->newFile($name);
         }
         $this->output($name . "\n" . $file->getUrl() . "\n\n");
     }
 }
开发者ID:pirater,项目名称:mediawiki,代码行数:41,代码来源:findOrphanedFiles.php

示例5: doDBUpdates

 public function doDBUpdates()
 {
     $startTime = microtime(true);
     $dbw = wfGetDB(DB_MASTER);
     $table = 'filearchive';
     $conds = array('fa_sha1' => '', 'fa_storage_key IS NOT NULL');
     if (!$dbw->fieldExists($table, 'fa_sha1', __METHOD__)) {
         $this->output("fa_sha1 column does not exist\n\n", true);
         return false;
     }
     $this->output("Populating fa_sha1 field from fa_storage_key\n");
     $endId = $dbw->selectField($table, 'MAX(fa_id)', false, __METHOD__);
     $batchSize = $this->mBatchSize;
     $done = 0;
     do {
         $res = $dbw->select($table, array('fa_id', 'fa_storage_key'), $conds, __METHOD__, array('LIMIT' => $batchSize));
         $i = 0;
         foreach ($res as $row) {
             if ($row->fa_storage_key == '') {
                 // Revision was missing pre-deletion
                 continue;
             }
             $sha1 = LocalRepo::getHashFromKey($row->fa_storage_key);
             $dbw->update($table, array('fa_sha1' => $sha1), array('fa_id' => $row->fa_id), __METHOD__);
             $lastId = $row->fa_id;
             $i++;
         }
         $done += $i;
         if ($i !== $batchSize) {
             break;
         }
         // print status and let slaves catch up
         $this->output(sprintf("id %d done (up to %d), %5.3f%%  \r", $lastId, $endId, $lastId / $endId * 100));
         wfWaitForSlaves();
     } while (true);
     $processingTime = microtime(true) - $startTime;
     $this->output(sprintf("\nDone %d files in %.1f seconds\n", $done, $processingTime));
     return true;
     // we only updated *some* files, don't log
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:40,代码来源:populateFilearchiveSha1.php

示例6: loadFromRow

 /**
  * Load ArchivedFile object fields from a DB row.
  *
  * @param stdClass $row Object database row
  * @since 1.21
  */
 public function loadFromRow($row)
 {
     $this->id = intval($row->fa_id);
     $this->name = $row->fa_name;
     $this->archive_name = $row->fa_archive_name;
     $this->group = $row->fa_storage_group;
     $this->key = $row->fa_storage_key;
     $this->size = $row->fa_size;
     $this->bits = $row->fa_bits;
     $this->width = $row->fa_width;
     $this->height = $row->fa_height;
     $this->metadata = $row->fa_metadata;
     $this->mime = "{$row->fa_major_mime}/{$row->fa_minor_mime}";
     $this->media_type = $row->fa_media_type;
     $this->description = $row->fa_description;
     $this->user = $row->fa_user;
     $this->user_text = $row->fa_user_text;
     $this->timestamp = $row->fa_timestamp;
     $this->deleted = $row->fa_deleted;
     if (isset($row->fa_sha1)) {
         $this->sha1 = $row->fa_sha1;
     } else {
         // old row, populate from key
         $this->sha1 = LocalRepo::getHashFromKey($this->key);
     }
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:32,代码来源:ArchivedFile.php

示例7: list

 /**
  * @param $info array|null
  */
 function __construct($info)
 {
     parent::__construct($info);
     $this->wiki = $info['wiki'];
     list($this->dbName, $this->tablePrefix) = wfSplitWikiID($this->wiki);
     $this->hasSharedCache = $info['hasSharedCache'];
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:10,代码来源:ForeignDBViaLBRepo.php

示例8: fetchFileMetadata

	/**
	 * Helper function: do the actual database query to fetch file metadata.
	 *
	 * @param string $key key
	 * @param $readFromDB: constant (default: DB_SLAVE)
	 * @return boolean
	 */
	protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) {
		// populate $fileMetadata[$key]
		$dbr = null;
		if ( $readFromDB === DB_MASTER ) {
			// sometimes reading from the master is necessary, if there's replication lag.
			$dbr = $this->repo->getMasterDb();
		} else {
			$dbr = $this->repo->getSlaveDb();
		}

		$row = $dbr->selectRow(
			'uploadstash',
			'*',
			array( 'us_key' => $key ),
			__METHOD__
		);

		if ( !is_object( $row ) ) {
			// key wasn't present in the database. this will happen sometimes.
			return false;
		}

		$this->fileMetadata[$key] = (array)$row;

		return true;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:33,代码来源:UploadStash.php

示例9: getDescriptionText

 /**
  * Get the HTML text of the description page, if available
  *
  * @return string
  */
 function getDescriptionText()
 {
     global $wgMemc, $wgLang;
     if (!$this->repo->fetchDescription) {
         return false;
     }
     $renderUrl = $this->repo->getDescriptionRenderUrl($this->getName(), $wgLang->getCode());
     if ($renderUrl) {
         if ($this->repo->descriptionCacheExpiry > 0) {
             wfDebug("Attempting to get the description from cache...");
             $key = $this->repo->getLocalCacheKey('RemoteFileDescription', 'url', $wgLang->getCode(), $this->getName());
             $obj = $wgMemc->get($key);
             if ($obj) {
                 wfDebug("success!\n");
                 return $obj;
             }
             wfDebug("miss\n");
         }
         wfDebug("Fetching shared description from {$renderUrl}\n");
         $res = Http::get($renderUrl);
         if ($res && $this->repo->descriptionCacheExpiry > 0) {
             $wgMemc->set($key, $res, $this->repo->descriptionCacheExpiry);
         }
         return $res;
     } else {
         return false;
     }
 }
开发者ID:namrenni,项目名称:mediawiki,代码行数:33,代码来源:File.php

示例10: getHashPathForLevel

 static function getHashPathForLevel($name, $levels)
 {
     global $wgContLang;
     $bits = explode(':', $name);
     $filename = $bits[count($bits) - 1];
     $path = parent::getHashPathForLevel($filename, $levels);
     return count($bits) > 1 ? $wgContLang->getNsIndex($bits[0]) . '/' . $path : $path;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:8,代码来源:NSFileRepo_body.php

示例11: foreach

 /**
  * Find all instances of files with this key
  *
  * @param $hash String base 36 SHA-1 hash
  * @return Array of File objects
  */
 function findBySha1($hash)
 {
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $result = $this->localRepo->findBySha1($hash);
     foreach ($this->foreignRepos as $repo) {
         $result = array_merge($result, $repo->findBySha1($hash));
     }
     return $result;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:17,代码来源:RepoGroup.php

示例12:

	/**
	 * @param $info array|null
	 */
	function __construct( $info ) {
		parent::__construct( $info );
		$this->dbType = $info['dbType'];
		$this->dbServer = $info['dbServer'];
		$this->dbUser = $info['dbUser'];
		$this->dbPassword = $info['dbPassword'];
		$this->dbName = $info['dbName'];
		$this->dbFlags = $info['dbFlags'];
		$this->tablePrefix = $info['tablePrefix'];
		$this->hasSharedCache = $info['hasSharedCache'];
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:14,代码来源:ForeignDBRepo.php

示例13: getcwd

 function __construct($info)
 {
     parent::__construct($info);
     // Required settings
     $this->directory = $info['directory'];
     $this->url = $info['url'];
     $this->hashLevels = $info['hashLevels'];
     if (isset($info['cache'])) {
         $this->cache = getcwd() . '/images/' . $info['cache'];
     }
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:11,代码来源:ICRepo.php

示例14: fetchFileMetadata

 /**
  * Helper function: do the actual database query to fetch file metadata.
  *
  * @param $key String: key
  * @return boolean
  */
 protected function fetchFileMetadata($key)
 {
     // populate $fileMetadata[$key]
     $dbr = $this->repo->getSlaveDb();
     $row = $dbr->selectRow('uploadstash', '*', array('us_key' => $key), __METHOD__);
     if (!is_object($row)) {
         // key wasn't present in the database. this will happen sometimes.
         return false;
     }
     $this->fileMetadata[$key] = array('us_user' => $row->us_user, 'us_key' => $row->us_key, 'us_orig_path' => $row->us_orig_path, 'us_path' => $row->us_path, 'us_size' => $row->us_size, 'us_sha1' => $row->us_sha1, 'us_mime' => $row->us_mime, 'us_media_type' => $row->us_media_type, 'us_image_width' => $row->us_image_width, 'us_image_height' => $row->us_image_height, 'us_image_bits' => $row->us_image_bits, 'us_source_type' => $row->us_source_type, 'us_timestamp' => $row->us_timestamp, 'us_status' => $row->us_status);
     return true;
 }
开发者ID:natalieschauser,项目名称:csp_media_wiki,代码行数:18,代码来源:UploadStash.php

示例15: foreach

 /**
  * Find all instances of files with this keys
  *
  * @param array $hashes base 36 SHA-1 hashes
  * @return array of array of File objects
  */
 function findBySha1s(array $hashes)
 {
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $result = $this->localRepo->findBySha1s($hashes);
     foreach ($this->foreignRepos as $repo) {
         $result = array_merge_recursive($result, $repo->findBySha1s($hashes));
     }
     //sort the merged (and presorted) sublist of each hash
     foreach ($result as $hash => $files) {
         usort($result[$hash], 'File::compare');
     }
     return $result;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:21,代码来源:RepoGroup.php


注:本文中的LocalRepo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。