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


PHP LocalRepo::resolveVirtualUrl方法代码示例

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


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

示例1: getFile

 /**
  * Get a file and its metadata from 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');
         }
     }
     $dbr = $this->repo->getSlaveDb();
     if (!isset($this->fileMetadata[$key])) {
         // try this first.  if it fails to find the row, check for lag, wait, try again. if its still missing, throw an exception.
         // this more complex solution keeps things moving for page loads with many requests
         // (ie. validating image ownership) when replag is high
         if (!$this->fetchFileMetadata($key)) {
             $lag = $dbr->getLag();
             if ($lag > 0 && $lag <= self::MAX_LAG) {
                 // if there's not too much replication lag, just wait for the slave to catch up to our last insert.
                 sleep(ceil($lag));
             } elseif ($lag > self::MAX_LAG) {
                 // that's a lot of lag to introduce into the middle of the UI.
                 throw new UploadStashMaxLagExceededException('Couldn\'t load stashed file metadata, and replication lag is above threshold: (MAX_LAG=' . self::MAX_LAG . ')');
             }
             // now that the waiting has happened, try again
             $this->fetchFileMetadata($key);
         }
         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'];
         if ($this->repo->isVirtualUrl($path)) {
             $path = $this->repo->resolveVirtualUrl($path);
         }
         $this->fileProps[$key] = File::getPropsFromPath($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:natalieschauser,项目名称:csp_media_wiki,代码行数:61,代码来源:UploadStash.php

示例2: 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'];
         if ($this->repo->isVirtualUrl($path)) {
             $path = $this->repo->resolveVirtualUrl($path);
         }
         $this->fileProps[$key] = File::getPropsFromPath($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:eFFemeer,项目名称:seizamcore,代码行数:50,代码来源:UploadStash.php


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