/**
  * Deletes the file from local disk, if it exists.
  * @task impl
  */
 public function deleteFile($handle)
 {
     $path = $this->getLocalDiskFileStorageFullPath($handle);
     if (Filesystem::pathExists($path)) {
         AphrontWriteGuard::willWrite();
         Filesystem::remove($path);
     }
 }
 /**
  * Delete a blob from Amazon S3.
  */
 public function deleteFile($handle)
 {
     AphrontWriteGuard::willWrite();
     $s3 = $this->newS3API();
     $profiler = PhutilServiceProfiler::getInstance();
     $call_id = $profiler->beginServiceCall(array('type' => 's3', 'method' => 'deleteObject'));
     $s3->deleteObject($this->getBucketName(), $handle);
     $profiler->endServiceCall($call_id, array());
 }
 /**
  * Delete a blob from Amazon S3.
  */
 public function deleteFile($handle)
 {
     $s3 = $this->newS3API();
     AphrontWriteGuard::willWrite();
     $profiler = PhutilServiceProfiler::getInstance();
     $call_id = $profiler->beginServiceCall(array('type' => 's3', 'method' => 'deleteObject'));
     $s3->setParametersForDeleteObject($handle)->resolve();
     $profiler->endServiceCall($call_id, array());
 }
 protected function checkWrite($raw_query)
 {
     // NOTE: The opening "(" allows queries in the form of:
     //
     //   (SELECT ...) UNION (SELECT ...)
     $is_write = !preg_match('/^[(]*(SELECT|SHOW|EXPLAIN)\\s/', $raw_query);
     if ($is_write) {
         AphrontWriteGuard::willWrite();
         return true;
     }
     return false;
 }
 public function executeRawQuery($raw_query)
 {
     $this->lastResult = null;
     $retries = max(1, PhabricatorEnv::getEnvConfig('mysql.connection-retries'));
     while ($retries--) {
         try {
             $this->requireConnection();
             // TODO: Do we need to include transactional statements here?
             $is_write = !preg_match('/^(SELECT|SHOW|EXPLAIN)\\s/', $raw_query);
             if ($is_write) {
                 AphrontWriteGuard::willWrite();
             }
             $start = microtime(true);
             $profiler = PhutilServiceProfiler::getInstance();
             $call_id = $profiler->beginServiceCall(array('type' => 'query', 'config' => $this->configuration, 'query' => $raw_query, 'write' => $is_write));
             $result = $this->rawQuery($raw_query);
             $profiler->endServiceCall($call_id, array());
             if ($this->nextError) {
                 $result = null;
             }
             if ($result) {
                 $this->lastResult = $result;
                 break;
             }
             $this->throwQueryException($this->connection);
         } catch (AphrontQueryConnectionLostException $ex) {
             if ($this->isInsideTransaction()) {
                 // Zero out the transaction state to prevent a second exception
                 // ("program exited with open transaction") from being thrown, since
                 // we're about to throw a more relevant/useful one instead.
                 $state = $this->getTransactionState();
                 while ($state->getDepth()) {
                     $state->decreaseDepth();
                 }
                 // We can't close the connection before this because
                 // isInsideTransaction() and getTransactionState() depend on the
                 // connection.
                 $this->closeConnection();
                 throw $ex;
             }
             $this->closeConnection();
             if (!$retries) {
                 throw $ex;
             }
             $class = get_class($ex);
             $message = $ex->getMessage();
             phlog("Retrying ({$retries}) after {$class}: {$message}");
         }
     }
 }
 public function deleteFile($handle)
 {
     AphrontWriteGuard::willWrite();
     unset(self::$storage[$handle]);
 }
 /**
  * Delete a blob from S3.
  * @task impl
  */
 public function deleteFile($handle)
 {
     AphrontWriteGuard::willWrite();
     $this->newS3API()->deleteObject($this->getBucketName(), $handle);
 }
 protected function checkWrite($raw_query)
 {
     // NOTE: The opening "(" allows queries in the form of:
     //
     //   (SELECT ...) UNION (SELECT ...)
     $is_write = !preg_match('/^[(]*(SELECT|SHOW|EXPLAIN)\\s/', $raw_query);
     if ($is_write) {
         if ($this->getReadOnly()) {
             throw new Exception(pht('Attempting to issue a write query on a read-only ' . 'connection (to database "%s")!', $this->getConfiguration('database')));
         }
         AphrontWriteGuard::willWrite();
         return true;
     }
     return false;
 }
 public function executeRawQuery($raw_query)
 {
     $this->lastResult = null;
     $retries = 3;
     while ($retries--) {
         try {
             $this->requireConnection();
             // TODO: Do we need to include transactional statements here?
             $is_write = !preg_match('/^(SELECT|SHOW|EXPLAIN)\\s/', $raw_query);
             if ($is_write) {
                 AphrontWriteGuard::willWrite();
             }
             $start = microtime(true);
             $profiler = PhutilServiceProfiler::getInstance();
             $call_id = $profiler->beginServiceCall(array('type' => 'query', 'config' => $this->configuration, 'query' => $raw_query, 'write' => $is_write));
             $result = @mysql_query($raw_query, $this->connection);
             $profiler->endServiceCall($call_id, array());
             if ($result) {
                 $this->lastResult = $result;
                 break;
             }
             $this->throwQueryException($this->connection);
         } catch (AphrontQueryConnectionLostException $ex) {
             if (!$retries) {
                 throw $ex;
             }
             if ($this->isInsideTransaction()) {
                 throw $ex;
             }
             $this->closeConnection();
         }
     }
 }
 protected function checkWrite($raw_query)
 {
     $is_write = !preg_match('/^(SELECT|SHOW|EXPLAIN)\\s/', $raw_query);
     if ($is_write) {
         AphrontWriteGuard::willWrite();
         return true;
     }
     return false;
 }