protected $connection;
protected $driver = '';
protected $pdo_emulate_prepares = false;
- private $error = false;
+ private $error = '';
private $errorno = 0;
private $affected_rows = 0;
protected $in_transaction = false;
if (count($args) == 0) {
if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) {
$errorInfo = $this->connection->errorInfo();
- $this->error = $errorInfo[2];
- $this->errorno = (int) $errorInfo[1];
+ $this->error = (string)$errorInfo[2];
+ $this->errorno = (int)$errorInfo[1];
$retval = false;
$is_error = true;
break;
/** @var $stmt mysqli_stmt|PDOStatement */
if (!$stmt = $this->connection->prepare($sql)) {
$errorInfo = $this->connection->errorInfo();
- $this->error = $errorInfo[2];
- $this->errorno = (int) $errorInfo[1];
+ $this->error = (string)$errorInfo[2];
+ $this->errorno = (int)$errorInfo[1];
$retval = false;
$is_error = true;
break;
if (!$stmt->execute()) {
$errorInfo = $stmt->errorInfo();
- $this->error = $errorInfo[2];
- $this->errorno = (int) $errorInfo[1];
+ $this->error = (string)$errorInfo[2];
+ $this->errorno = (int)$errorInfo[1];
$retval = false;
$is_error = true;
} else {
if (!$can_be_prepared || (count($args) == 0)) {
$retval = $this->connection->query($this->replaceParameters($sql, $args));
if ($this->connection->errno) {
- $this->error = $this->connection->error;
- $this->errorno = $this->connection->errno;
+ $this->error = (string)$this->connection->error;
+ $this->errorno = (int)$this->connection->errno;
$retval = false;
$is_error = true;
} else {
$stmt = $this->connection->stmt_init();
if (!$stmt->prepare($sql)) {
- $this->error = $stmt->error;
- $this->errorno = $stmt->errno;
+ $this->error = (string)$stmt->error;
+ $this->errorno = (int)$stmt->errno;
$retval = false;
$is_error = true;
break;
}
if (!$stmt->execute()) {
- $this->error = $this->connection->error;
- $this->errorno = $this->connection->errno;
+ $this->error = (string)$this->connection->error;
+ $this->errorno = (int)$this->connection->errno;
$retval = false;
$is_error = true;
} else {
}
}
- $this->error = $error;
- $this->errorno = (int) $errorno;
+ $this->error = (string)$error;
+ $this->errorno = (int)$errorno;
}
$this->profiler->stopRecording();
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
$condition = ['url' => $arr['url'], 'network' => $arr['network']];
+ $fields = DI::dbaDefinition()->truncateFieldsForTable('fcontact', $fields);
DBA::update('fcontact', $fields, $condition, true);
}
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Model\Post;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\Diaspora;
}
// Retrieve the current logged in user's public contact
- $author_id = Contact::getIdForURL($owner['url']);
+ $author_id = Contact::getPublicIdByUserId($uid);
if (empty($author_id)) {
Logger::info('Empty public contact');
return false;
$new_item = [
'guid' => System::createUUID(),
'uri' => self::newURI(),
- 'uid' => $item['uid'],
+ 'uid' => $uid,
'contact-id' => $owner['id'],
'wall' => $item['wall'],
'origin' => 1,
$new_item['diaspora_signed_text'] = json_encode($signed);
}
- $new_item_id = self::insert($new_item);
+ self::insert($new_item, true);
// If the parent item isn't visible then set it to visible
+ // @todo Check if this is still needed
if (!$item['visible']) {
self::update(['visible' => true], ['id' => $item['id']]);
}
-
- $new_item['id'] = $new_item_id;
-
- Hook::callAll('post_local_end', $new_item);
-
return true;
}
$itemId = $this->parameters['id'];
if (in_array($verb, ['announce', 'unannounce'])) {
- $item = Post::selectFirst(['network', 'uri-id', 'uid'], ['id' => $itemId]);
+ $item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [local_user(), 0]]);
if ($item['network'] == Protocol::DIASPORA) {
- Diaspora::performReshare($item['uri-id'], $item['uid']);
+ Diaspora::performReshare($item['uri-id'], local_user());
}
}
{
$item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity', 'post-type', 'private'], ['uri' => $activity['id']]);
if (!DBA::isResult($item)) {
- Logger::warning('No existing item, item will be created', ['uri' => $activity['id']]);
+ Logger::notice('No existing item, item will be created', ['uri' => $activity['id']]);
$item = self::createItem($activity, false);
if (empty($item)) {
Queue::remove($activity);