$this->logger->notice('URL is invalid', ['url' => $data->url, 'error' => $exception]);
throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
}
- if (!empty($fetchResult) && $fetchResult->isSuccess()) {
- $this->logger->debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
- return $fetchResult->getBodyString();
- } else {
- if (empty($fetchResult)) {
- throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference));
- } else {
- throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $fetchResult->getReturnCode(), new Exception($fetchResult->getBodyString()));
- }
+
+ if (!$fetchResult->isSuccess()) {
+ throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $fetchResult->getReturnCode(), new Exception($fetchResult->getBodyString()));
}
+
+ $this->logger->debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
+ return $fetchResult->getBodyString();
}
/**
$is_new_table = false;
$sql3 = "";
if (!isset($database[$name])) {
- $sql = DbaDefinitionSqlWriter::createTable($name, $structure, $verbose, $action);
+ $sql = DbaDefinitionSqlWriter::createTable($name, $structure);
if ($verbose) {
echo $sql;
}
throw new ServiceUnavailableException('The Connection is empty, although connected is set true.');
}
+ $retval = false;
+
switch ($this->driver) {
case self::PDO:
// If there are no arguments we use "query"
*/
public function lastInsertId(): int
{
+ $id = 0;
+
switch ($this->driver) {
case self::PDO:
$id = $this->connection->lastInsertId();
return false;
}
+ $ret = false;
+
switch ($this->driver) {
case self::PDO:
$ret = $stmt->closeCursor();
} elseif ($stmt instanceof mysqli_result) {
$stmt->free();
$ret = true;
- } else {
- $ret = false;
}
break;
}
/**
* Acquire a lock to prevent a table optimization
*
- * @return bool
- * @throws LockPersistenceException
+ * @return bool
+ * @throws LockPersistenceException
*/
public function acquireOptimizeLock(): bool
{
/**
* Release the table optimization lock
*
- * @return bool
- * @throws LockPersistenceException
+ * @return bool
+ * @throws LockPersistenceException
*/
public function releaseOptimizeLock(): bool
{
}
while ($item = DBA::fetch($items)) {
- Tag::storeFromBody($item['uri-id'], $item['body'], '#!@', false);
+ Tag::storeFromBody($item['uri-id'], $item['body'], '#!@');
$id = $item['uri-id'];
++$rows;
if ($rows % 1000 == 0) {
while ($photo = DBA::fetch($photos)) {
$img = Photo::getImageForPhoto($photo);
- if (!empty($img)) {
- $md5 = md5($img->asString());
- } else {
- $md5 = '';
- }
+ $md5 = md5($img->asString());
+
DBA::update('photo', ['hash' => $md5], ['id' => $photo['id']]);
++$rows;
}
$parts = parse_url($contact['url']);
unset($parts['path']);
$server = (string)Uri::fromParts($parts);
-
+
DBA::update('contact',
['gsid' => GServer::getID($server, true), 'baseurl' => GServer::cleanURL($server)],
['id' => $contact['id']]);
foreach (['post-view', 'post-thread-view'] as $view) {
if (self::isView($view)) {
$sql = sprintf("DROP VIEW IF EXISTS `%s`", DBA::escape($view));
- if (!empty($sql) && $verbose) {
+ if ($verbose) {
echo $sql . ";\n";
}
- if (!empty($sql) && $action) {
+ if ($action) {
DBA::e($sql);
}
}
throw new HTTPException\NotFoundException('Direct message with ID ' . $mail . ' not found.');
}
+ $title = '';
+ $text = '';
+
if (!empty($text_mode)) {
$title = $mail['title'];
if ($text_mode == 'html') {
$text = HTML::toPlaintext(BBCode::convertForUriId($mail['uri-id'], $mail['body'], BBCode::TWITTER_API), 0);
}
} else {
- $title = '';
$text = $mail['title'] . "\n" . HTML::toPlaintext(BBCode::convertForUriId($mail['uri-id'], $mail['body'], BBCode::TWITTER_API), 0);
}