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


PHP LocalRepo::getFileProps方法代码示例

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


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

示例1: getFile

 /**
  * Get a file and its metadata from the stash.
  * The noAuth param is a bit janky but is required for automated scripts which clean out the stash.
  *
  * @param $key String: key under which file information is stored
  * @param $noAuth Boolean (optional) Don't check authentication. Used by maintenance scripts.
  * @throws UploadStashFileNotFoundException
  * @throws UploadStashNotLoggedInException
  * @throws UploadStashWrongOwnerException
  * @throws UploadStashBadPathException
  * @return UploadStashFile
  */
 public function getFile($key, $noAuth = false)
 {
     if (!preg_match(self::KEY_FORMAT_REGEX, $key)) {
         throw new UploadStashBadPathException("key '{$key}' is not in a proper format");
     }
     if (!$noAuth) {
         if (!$this->isLoggedIn) {
             throw new UploadStashNotLoggedInException(__METHOD__ . ' No user is logged in, files must belong to users');
         }
     }
     if (!isset($this->fileMetadata[$key])) {
         if (!$this->fetchFileMetadata($key)) {
             // If nothing was received, it's likely due to replication lag.  Check the master to see if the record is there.
             $this->fetchFileMetadata($key, DB_MASTER);
         }
         if (!isset($this->fileMetadata[$key])) {
             throw new UploadStashFileNotFoundException("key '{$key}' not found in stash");
         }
         // create $this->files[$key]
         $this->initFile($key);
         // fetch fileprops
         $path = $this->fileMetadata[$key]['us_path'];
         $this->fileProps[$key] = $this->repo->getFileProps($path);
     }
     if (!$this->files[$key]->exists()) {
         wfDebug(__METHOD__ . " tried to get file at {$key}, but it doesn't exist\n");
         throw new UploadStashBadPathException("path doesn't exist");
     }
     if (!$noAuth) {
         if ($this->fileMetadata[$key]['us_user'] != $this->userId) {
             throw new UploadStashWrongOwnerException("This file ({$key}) doesn't belong to the current user.");
         }
     }
     return $this->files[$key];
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:47,代码来源:UploadStash.php

示例2: wfProfileIn

 /**
  * Record a file upload in the upload log and the image table
  * @param $oldver
  * @param $comment string
  * @param $pageText string
  * @param $props bool|array
  * @param $timestamp bool|string
  * @param $user null|User
  * @return bool
  */
 function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
 {
     wfProfileIn(__METHOD__);
     if (is_null($user)) {
         global $wgUser;
         $user = $wgUser;
     }
     $dbw = $this->repo->getMasterDB();
     $dbw->begin(__METHOD__);
     if (!$props) {
         wfProfileIn(__METHOD__ . '-getProps');
         $props = $this->repo->getFileProps($this->getVirtualUrl());
         wfProfileOut(__METHOD__ . '-getProps');
     }
     if ($timestamp === false) {
         $timestamp = $dbw->timestamp();
     }
     $props['description'] = $comment;
     $props['user'] = $user->getId();
     $props['user_text'] = $user->getName();
     $props['timestamp'] = wfTimestamp(TS_MW, $timestamp);
     // DB -> TS_MW
     $this->setProps($props);
     # Fail now if the file isn't there
     if (!$this->fileExists) {
         wfDebug(__METHOD__ . ": File " . $this->getRel() . " went missing!\n");
         wfProfileOut(__METHOD__);
         return false;
     }
     $reupload = false;
     # Test to see if the row exists using INSERT IGNORE
     # This avoids race conditions by locking the row until the commit, and also
     # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
     $dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
     if ($dbw->affectedRows() == 0) {
         # (bug 34993) Note: $oldver can be empty here, if the previous
         # version of the file was broken. Allow registration of the new
         # version to continue anyway, because that's better than having
         # an image that's not fixable by user operations.
         $reupload = true;
         # Collision, this is an update of a file
         # Insert previous contents into oldimage
         $dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
         # Update the current image row
         $dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
     } else {
         # This is a new file, so update the image count
         DeferredUpdates::addUpdate(SiteStatsUpdate::factory(array('images' => 1)));
     }
     $descTitle = $this->getTitle();
     $wikiPage = new WikiFilePage($descTitle);
     $wikiPage->setFile($this);
     # Add the log entry
     $log = new LogPage('upload');
     $action = $reupload ? 'overwrite' : 'upload';
     $logId = $log->addEntry($action, $descTitle, $comment, array(), $user);
     wfProfileIn(__METHOD__ . '-edit');
     $exists = $descTitle->exists();
     if ($exists) {
         # Create a null revision
         $latest = $descTitle->getLatestRevID();
         $nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleID(), $log->getRcComment(), false);
         if (!is_null($nullRevision)) {
             $nullRevision->insertOn($dbw);
             wfRunHooks('NewRevisionFromEditComplete', array($wikiPage, $nullRevision, $latest, $user));
             $wikiPage->updateRevisionOn($dbw, $nullRevision);
         }
     }
     # Commit the transaction now, in case something goes wrong later
     # The most important thing is that files don't get lost, especially archives
     # NOTE: once we have support for nested transactions, the commit may be moved
     #       to after $wikiPage->doEdit has been called.
     $dbw->commit(__METHOD__);
     if ($exists) {
         # Invalidate the cache for the description page
         $descTitle->invalidateCache();
         $descTitle->purgeSquid();
     } else {
         # New file; create the description page.
         # There's already a log entry, so don't make a second RC entry
         # Squid and file cache for the description page are purged by doEditContent.
         $content = ContentHandler::makeContent($pageText, $descTitle);
         $status = $wikiPage->doEditContent($content, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user);
         if (isset($status->value['revision'])) {
             // XXX; doEdit() uses a transaction
             $dbw->begin(__METHOD__);
             $dbw->update('logging', array('log_page' => $status->value['revision']->getPage()), array('log_id' => $logId), __METHOD__);
             $dbw->commit(__METHOD__);
             // commit before anything bad can happen
         }
//.........这里部分代码省略.........
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:101,代码来源:LocalFile.php


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