本文整理汇总了PHP中AphrontWriteGuard::willWrite方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontWriteGuard::willWrite方法的具体用法?PHP AphrontWriteGuard::willWrite怎么用?PHP AphrontWriteGuard::willWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontWriteGuard
的用法示例。
在下文中一共展示了AphrontWriteGuard::willWrite方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteFile
/**
* 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);
}
}
示例2: deleteFile
/**
* 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());
}
示例3: deleteFile
/**
* 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());
}
示例4: checkWrite
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;
}
示例5: executeRawQuery
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}");
}
}
}
示例6: deleteFile
public function deleteFile($handle)
{
AphrontWriteGuard::willWrite();
unset(self::$storage[$handle]);
}
示例7: deleteFile
/**
* Delete a blob from S3.
* @task impl
*/
public function deleteFile($handle)
{
AphrontWriteGuard::willWrite();
$this->newS3API()->deleteObject($this->getBucketName(), $handle);
}
示例8: checkWrite
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;
}
示例9: executeRawQuery
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();
}
}
}
示例10: checkWrite
protected function checkWrite($raw_query)
{
$is_write = !preg_match('/^(SELECT|SHOW|EXPLAIN)\\s/', $raw_query);
if ($is_write) {
AphrontWriteGuard::willWrite();
return true;
}
return false;
}