Merge pull request #7577 from nupplaphil/bug/friendica-7297

Fixing PHP Fatal Error
This commit is contained in:
Hypolite Petovan 2019-08-28 09:42:49 -04:00 committed by GitHub
commit 58949bf1a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View file

@ -4,6 +4,7 @@ namespace Friendica\Database;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\System;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use mysqli;
@ -126,7 +127,7 @@ class Database
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->connected = true;
} catch (PDOException $e) {
/// @TODO At least log exception, don't ignore it!
$this->connected = false;
}
}
@ -484,6 +485,10 @@ class Database
// We are having an own error logging in the function "e"
$called_from_e = ($called_from['function'] == 'e');
if (!isset($this->connection)) {
throw new InternalServerErrorException('The Connection is empty, although connected is set true.');
}
switch ($this->driver) {
case 'pdo':
// If there are no arguments we use "query"

View file

@ -1795,13 +1795,19 @@ class Contact extends BaseObject
/**
* @brief Helper function for "updateFromProbe". Updates personal and public contact
*
* @param array $contact The personal contact entry
* @param integer $id contact id
* @param integer $uid user id
* @param string $url The profile URL of the contact
* @param array $fields The fields that are updated
*
* @throws \Exception
*/
private static function updateContact($id, $uid, $url, array $fields)
{
DBA::update('contact', $fields, ['id' => $id]);
if (!DBA::update('contact', $fields, ['id' => $id])) {
Logger::info('Couldn\'t update contact.', ['id' => $id, 'fields' => $fields]);
return;
}
// Search for duplicated contacts and get rid of them
if (self::handleDuplicates(Strings::normaliseLink($url), $uid, $id) || ($uid != 0)) {
@ -1814,6 +1820,11 @@ class Contact extends BaseObject
// Archive or unarchive the contact. We only need to do this for the public contact.
// The archive/unarchive function will update the personal contacts by themselves.
$contact = DBA::selectFirst('contact', [], ['id' => $id]);
if (!DBA::isResult($contact)) {
Logger::info('Couldn\'t select contact for archival.', ['id' => $id]);
return;
}
if (!empty($fields['success_update'])) {
self::unmarkForArchival($contact);
} elseif (!empty($fields['failure_update'])) {