use Friendica\Object\Search\ContactResult;
use Friendica\Object\Search\ResultList;
use Friendica\Util\Network;
-use Friendica\Util\Strings;
use GuzzleHttp\Psr7\Uri;
/**
*/
public static function getContactsFromLocalDirectory(string $search, int $type = self::TYPE_ALL, int $start = 0, int $itemPage = 80): ResultList
{
- Logger::info('Searching', ['search' => $search, 'type' => $type, 'start' => $start, 'itempage' => $itemPage]);
+ DI::logger()->info('Searching', ['search' => $search, 'type' => $type, 'start' => $start, 'itempage' => $itemPage]);
$contacts = Contact::searchByName($search, $type == self::TYPE_GROUP ? 'community' : '', true);
*/
public static function searchContact(string $search, string $mode, int $page = 1): array
{
- Logger::info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
+ DI::logger()->info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
return [];
try {
$curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTDISCOVER]);
} catch (\Throwable $th) {
- Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
+ DI::logger()->notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
return [];
}
if ($curlResult->isSuccess()) {
}
if ($status) {
- Logger::notice('xml_status returning non_zero: ' . $status . " message=" . $message);
+ DI::logger()->notice('xml_status returning non_zero: ' . $status . " message=" . $message);
}
self::httpExit(XML::fromArray(['result' => $result]), Response::TYPE_XML);
public static function httpError($httpCode, $message = '', $content = '')
{
if ($httpCode >= 400) {
- Logger::debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
+ DI::logger()->debug('Exit with error', ['code' => $httpCode, 'message' => $message, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
}
DI::apiResponse()->setStatus($httpCode, $message);
public static function jsonError($httpCode, $content, $content_type = 'application/json')
{
if ($httpCode >= 400) {
- Logger::debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
+ DI::logger()->debug('Exit with error', ['code' => $httpCode, 'content_type' => $content_type, 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
}
DI::apiResponse()->setStatus($httpCode);
self::jsonExit($content, $content_type);
public static function externalRedirect($url, $code = 302)
{
if (empty(parse_url($url, PHP_URL_SCHEME))) {
- Logger::warning('No fully qualified URL provided', ['url' => $url]);
+ DI::logger()->warning('No fully qualified URL provided', ['url' => $url]);
DI::baseUrl()->redirect($url);
}
private static function isDirectoryUsable(string $directory): bool
{
if (empty($directory)) {
- Logger::warning('Directory is empty. This shouldn\'t happen.');
+ DI::logger()->warning('Directory is empty. This shouldn\'t happen.');
return false;
}
if (!file_exists($directory)) {
- Logger::info('Path does not exist', ['directory' => $directory, 'user' => static::getUser()]);
+ DI::logger()->info('Path does not exist', ['directory' => $directory, 'user' => static::getUser()]);
return false;
}
if (is_file($directory)) {
- Logger::warning('Path is a file', ['directory' => $directory, 'user' => static::getUser()]);
+ DI::logger()->warning('Path is a file', ['directory' => $directory, 'user' => static::getUser()]);
return false;
}
if (!is_dir($directory)) {
- Logger::warning('Path is not a directory', ['directory' => $directory, 'user' => static::getUser()]);
+ DI::logger()->warning('Path is not a directory', ['directory' => $directory, 'user' => static::getUser()]);
return false;
}
if (!is_writable($directory)) {
- Logger::warning('Path is not writable', ['directory' => $directory, 'user' => static::getUser()]);
+ DI::logger()->warning('Path is not writable', ['directory' => $directory, 'user' => static::getUser()]);
return false;
}
// If the Lock is acquired, never release it automatically to avoid double updates
if (DI::lock()->acquire('dbupdate', 0, Cache\Enum\Duration::INFINITE)) {
- Logger::notice('Update starting.', ['from' => $stored, 'to' => $current]);
+ DI::logger()->notice('Update starting.', ['from' => $stored, 'to' => $current]);
// Checks if the build changed during Lock acquiring (so no double update occurs)
$retryBuild = DI::config()->get('system', 'build');
}
if ($retryBuild != $build) {
- Logger::notice('Update already done.', ['from' => $build, 'retry' => $retryBuild, 'to' => $current]);
+ DI::logger()->notice('Update already done.', ['from' => $build, 'retry' => $retryBuild, 'to' => $current]);
DI::lock()->release('dbupdate');
return '';
}
// run the pre_update_nnnn functions in update.php
for ($version = $stored + 1; $version <= $current; $version++) {
- Logger::notice('Execute pre update.', ['version' => $version]);
+ DI::logger()->notice('Execute pre update.', ['version' => $version]);
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing pre update %d',
DateTimeFormat::utcNow() . ' ' . date('e'), $version));
$r = self::runUpdateFunction($version, 'pre_update', $sendMail);
if (!$r) {
- Logger::warning('Pre update failed', ['version' => $version]);
+ DI::logger()->warning('Pre update failed', ['version' => $version]);
DI::config()->set('system', 'update', Update::FAILED);
DI::lock()->release('dbupdate');
DI::config()->beginTransaction()
->commit();
return $r;
} else {
- Logger::notice('Pre update executed.', ['version' => $version]);
+ DI::logger()->notice('Pre update executed.', ['version' => $version]);
}
}
// update the structure in one call
- Logger::notice('Execute structure update');
+ DI::logger()->notice('Execute structure update');
$retval = DBStructure::performUpdate(false, $verbose);
if (!empty($retval)) {
if ($sendMail) {
$retval
);
}
- Logger::error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
+ DI::logger()->error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
DI::config()->set('system', 'update', Update::FAILED);
DI::lock()->release('dbupdate');
DI::config()->beginTransaction()
->commit();
return $retval;
} else {
- Logger::notice('Database structure update finished.', ['from' => $stored, 'to' => $current]);
+ DI::logger()->notice('Database structure update finished.', ['from' => $stored, 'to' => $current]);
}
// run the update_nnnn functions in update.php
for ($version = $stored + 1; $version <= $current; $version++) {
- Logger::notice('Execute post update.', ['version' => $version]);
+ DI::logger()->notice('Execute post update.', ['version' => $version]);
DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing post update %d',
DateTimeFormat::utcNow() . ' ' . date('e'), $version));
$r = self::runUpdateFunction($version, 'update', $sendMail);
if (!$r) {
- Logger::warning('Post update failed', ['version' => $version]);
+ DI::logger()->warning('Post update failed', ['version' => $version]);
DI::config()->set('system', 'update', Update::FAILED);
DI::lock()->release('dbupdate');
DI::config()->beginTransaction()
return $r;
} else {
DI::config()->set('system', 'build', $version);
- Logger::notice('Post update executed.', ['version' => $version]);
+ DI::logger()->notice('Post update executed.', ['version' => $version]);
}
}
->delete('system', 'maintenance_reason')
->commit();
- Logger::notice('Update success.', ['from' => $stored, 'to' => $current]);
+ DI::logger()->notice('Update success.', ['from' => $stored, 'to' => $current]);
if ($sendMail) {
self::updateSuccessful($stored, $current);
}
} else {
- Logger::warning('Update lock could not be acquired');
+ DI::logger()->warning('Update lock could not be acquired');
}
}
}
{
$funcname = $prefix . '_' . $version;
- Logger::notice('Update function start.', ['function' => $funcname]);
+ DI::logger()->notice('Update function start.', ['function' => $funcname]);
if (function_exists($funcname)) {
// There could be a lot of processes running or about to run.
if (DI::lock()->acquire('dbupdate_function', 120, Cache\Enum\Duration::INFINITE)) {
// call the specific update
- Logger::notice('Pre update function start.', ['function' => $funcname]);
+ DI::logger()->notice('Pre update function start.', ['function' => $funcname]);
$retval = $funcname();
- Logger::notice('Update function done.', ['function' => $funcname]);
+ DI::logger()->notice('Update function done.', ['function' => $funcname]);
if ($retval) {
if ($sendMail) {
DI::l10n()->t('Update %s failed. See error logs.', $version)
);
}
- Logger::error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
+ DI::logger()->error('Update function ERROR.', ['function' => $funcname, 'retval' => $retval]);
DI::lock()->release('dbupdate_function');
return false;
} else {
DI::lock()->release('dbupdate_function');
- Logger::notice('Update function finished.', ['function' => $funcname]);
+ DI::logger()->notice('Update function finished.', ['function' => $funcname]);
return true;
}
} else {
- Logger::error('Locking failed.', ['function' => $funcname]);
+ DI::logger()->error('Locking failed.', ['function' => $funcname]);
return false;
}
} else {
- Logger::notice('Update function skipped.', ['function' => $funcname]);
+ DI::logger()->notice('Update function skipped.', ['function' => $funcname]);
return true;
}
}
{
$adminEmails = User::getAdminListForEmailing(['uid', 'language', 'email']);
if (!$adminEmails) {
- Logger::warning('Cannot notify administrators .', ['update' => $update_id, 'message' => $error_message]);
+ DI::logger()->warning('Cannot notify administrators .', ['update' => $update_id, 'message' => $error_message]);
return;
}
DI::emailer()->send($email);
}
- Logger::alert('Database structure update failed.', ['error' => $error_message]);
+ DI::logger()->alert('Database structure update failed.', ['error' => $error_message]);
}
/**
DI::emailer()->send($email);
}
- Logger::debug('Database structure update successful.');
+ DI::logger()->debug('Database structure update successful.');
}
}