From abb50fbf62d373b2fa985bc2403e0eadcdbd257b Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 29 Oct 2018 14:10:45 +0100 Subject: [PATCH 01/68] Install to Module - Move Install to Module - Some Bugfixings --- mod/install.php | 271 --------------------------- src/Core/Install.php | 14 +- src/Module/Install.php | 330 +++++++++++++++++++++++++++++++++ tests/src/Core/InstallTest.php | 16 +- 4 files changed, 344 insertions(+), 287 deletions(-) delete mode 100644 mod/install.php create mode 100644 src/Module/Install.php diff --git a/mod/install.php b/mod/install.php deleted file mode 100644 index 5a0794b35..000000000 --- a/mod/install.php +++ /dev/null @@ -1,271 +0,0 @@ -argc == 2 && $a->argv[1] == "testrewrite") { - echo "ok"; - killme(); - } - - // We overwrite current theme css, because during install we could not have a working mod_rewrite - // so we could not have a css at all. Here we set a static css file for the install procedure pages - - $a->setConfigValue('system', 'value', '../install'); - $a->theme['stylesheet'] = System::baseUrl()."/view/install/style.css"; - - global $install_wizard_pass; - if (x($_POST, 'pass')) { - $install_wizard_pass = intval($_POST['pass']); - } - -} - -function install_post(App $a) { - global $install_wizard_pass; - - switch($install_wizard_pass) { - case 1: - case 2: - return; - break; // just in case return don't return :) - case 3: - $dbhost = notags(trim($_POST['dbhost'])); - $dbuser = notags(trim($_POST['dbuser'])); - $dbpass = notags(trim($_POST['dbpass'])); - $dbdata = notags(trim($_POST['dbdata'])); - $phpath = notags(trim($_POST['phpath'])); - - require_once("include/dba.php"); - if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) { - $a->data['db_conn_failed'] = true; - } - - return; - break; - case 4: - $urlpath = $a->getURLPath(); - $dbhost = notags(trim($_POST['dbhost'])); - $dbuser = notags(trim($_POST['dbuser'])); - $dbpass = notags(trim($_POST['dbpass'])); - $dbdata = notags(trim($_POST['dbdata'])); - $phpath = notags(trim($_POST['phpath'])); - $timezone = notags(trim($_POST['timezone'])); - $language = notags(trim($_POST['language'])); - $adminmail = notags(trim($_POST['adminmail'])); - - // connect to db - DBA::connect($dbhost, $dbuser, $dbpass, $dbdata); - - $install = new Install(); - - $errors = $install->createConfig($phpath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $a->getBasePath()); - - if ($errors !== true) { - $a->data['data'] = $errors; - return; - } - - $errors = DBStructure::update(false, true, true); - - if ($errors) { - $a->data['db_failed'] = $errors; - } else { - $a->data['db_installed'] = true; - } - - return; - break; - } -} - -function install_content(App $a) { - - global $install_wizard_pass; - $o = ''; - $wizard_status = ""; - $install_title = L10n::t('Friendica Communications Server - Setup'); - - if (x($a->data, 'db_conn_failed')) { - $install_wizard_pass = 2; - $wizard_status = L10n::t('Could not connect to database.'); - } - if (x($a->data, 'db_create_failed')) { - $install_wizard_pass = 2; - $wizard_status = L10n::t('Could not create table.'); - } - - $db_return_text = ""; - if (x($a->data, 'db_installed')) { - $txt = '

'; - $txt .= L10n::t('Your Friendica site database has been installed.') . EOL; - $db_return_text .= $txt; - } - - if (x($a->data, 'db_failed')) { - $txt = L10n::t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; - $txt .= L10n::t('Please see the file "INSTALL.txt".') . EOL ."


"; - $txt .= "
".$a->data['db_failed'] . "
". EOL; - $db_return_text .= $txt; - } - - if (DBA::$connected) { - $r = q("SELECT COUNT(*) as `total` FROM `user`"); - if (DBA::isResult($r) && $r[0]['total']) { - $install_wizard_pass = 2; - $wizard_status = L10n::t('Database already in use.'); - } - } - - if (x($a->data, 'txt') && strlen($a->data['txt'])) { - $db_return_text .= manual_config($a); - } - - if ($db_return_text != "") { - $tpl = get_markup_template('install.tpl'); - return replace_macros($tpl, [ - '$title' => $install_title, - '$pass' => "", - '$text' => $db_return_text . what_next(), - ]); - } - - switch ($install_wizard_pass) { - case 1: { // System check - - $phpath = defaults($_POST, 'phpath', 'php'); - - $install = new Install($phpath); - - $status = $install->checkAll($a->getBasePath(), $a->getBaseURL()); - - $tpl = get_markup_template('install_checks.tpl'); - $o .= replace_macros($tpl, [ - '$title' => $install_title, - '$pass' => L10n::t('System check'), - '$checks' => $install->getChecks(), - '$passed' => $status, - '$see_install' => L10n::t('Please see the file "INSTALL.txt".'), - '$next' => L10n::t('Next'), - '$reload' => L10n::t('Check again'), - '$phpath' => $phpath, - '$baseurl' => $a->getBaseURL(), - ]); - return $o; - }; break; - - case 2: { // Database config - - $dbhost = notags(trim(defaults($_POST, 'dbhost' , 'localhost'))); - $dbuser = notags(trim(defaults($_POST, 'dbuser' , '' ))); - $dbpass = notags(trim(defaults($_POST, 'dbpass' , '' ))); - $dbdata = notags(trim(defaults($_POST, 'dbdata' , '' ))); - $phpath = notags(trim(defaults($_POST, 'phpath' , '' ))); - $adminmail = notags(trim(defaults($_POST, 'adminmail', '' ))); - - $tpl = get_markup_template('install_db.tpl'); - $o .= replace_macros($tpl, [ - '$title' => $install_title, - '$pass' => L10n::t('Database connection'), - '$info_01' => L10n::t('In order to install Friendica we need to know how to connect to your database.'), - '$info_02' => L10n::t('Please contact your hosting provider or site administrator if you have questions about these settings.'), - '$info_03' => L10n::t('The database you specify below should already exist. If it does not, please create it before continuing.'), - - '$status' => $wizard_status, - - '$dbhost' => ['dbhost', L10n::t('Database Server Name'), $dbhost, '', 'required'], - '$dbuser' => ['dbuser', L10n::t('Database Login Name'), $dbuser, '', 'required', 'autofocus'], - '$dbpass' => ['dbpass', L10n::t('Database Login Password'), $dbpass, L10n::t("For security reasons the password must not be empty"), 'required'], - '$dbdata' => ['dbdata', L10n::t('Database Name'), $dbdata, '', 'required'], - '$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'], - - '$lbl_10' => L10n::t('Please select a default timezone for your website'), - - '$baseurl' => $a->getBaseURL(), - - '$phpath' => $phpath, - - '$submit' => L10n::t('Submit'), - ]); - return $o; - }; break; - case 3: { // Site settings - $dbhost = ((x($_POST, 'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'); - $dbuser = notags(trim($_POST['dbuser'])); - $dbpass = notags(trim($_POST['dbpass'])); - $dbdata = notags(trim($_POST['dbdata'])); - $phpath = notags(trim($_POST['phpath'])); - - $adminmail = notags(trim($_POST['adminmail'])); - $timezone = ((x($_POST, 'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles'); - /* Installed langs */ - $lang_choices = L10n::getAvailableLanguages(); - - $tpl = get_markup_template('install_settings.tpl'); - $o .= replace_macros($tpl, [ - '$title' => $install_title, - '$pass' => L10n::t('Site settings'), - - '$status' => $wizard_status, - - '$dbhost' => $dbhost, - '$dbuser' => $dbuser, - '$dbpass' => $dbpass, - '$dbdata' => $dbdata, - '$phpath' => $phpath, - - '$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'], - - - '$timezone' => Temporal::getTimezoneField('timezone', L10n::t('Please select a default timezone for your website'), $timezone, ''), - '$language' => ['language', L10n::t('System Language:'), 'en', L10n::t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices], - '$baseurl' => $a->getBaseURL(), - - '$submit' => L10n::t('Submit'), - - ]); - return $o; - }; break; - - } -} - -function manual_config(App $a) { - $data = htmlentities($a->data['txt'],ENT_COMPAT, 'UTF-8'); - $o = L10n::t('The database configuration file "config/local.ini.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); - $o .= ""; - return $o; -} - -function load_database_rem($v, $i) { - $l = trim($i); - if (strlen($l)>1 && ($l[0] == "-" || ($l[0] == "/" && $l[1] == "*"))) { - return $v; - } else { - return $v."\n".$i; - } -} - -function what_next() { - $baseurl = System::baseUrl(); - return - L10n::t('

What next

') - ."

".L10n::t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.') - .L10n::t('Please see the file "INSTALL.txt".') - ."

" - .L10n::t('Go to your new Friendica node registration page and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.', $baseurl) - ."

"; -} diff --git a/src/Core/Install.php b/src/Core/Install.php index 448f77c01..28b8828ad 100644 --- a/src/Core/Install.php +++ b/src/Core/Install.php @@ -49,13 +49,12 @@ class Install /** * Checks the current installation environment. There are optional and mandatory checks. * - * @param string $basepath The basepath of Friendica * @param string $baseurl The baseurl of Friendica * @param string $phpath Optional path to the PHP binary * * @return bool if the check succeed */ - public function checkAll($basepath, $baseurl, $phpath = null) + public function checkAll($baseurl, $phpath = null) { $returnVal = true; @@ -85,7 +84,7 @@ class Install $returnVal = false; } - if (!$this->checkHtAccess($basepath, $baseurl)) { + if (!$this->checkHtAccess($baseurl)) { $returnVal = false; } @@ -444,24 +443,23 @@ class Install * * Checks, if "url_rewrite" is enabled in the ".htaccess" file * - * @param string $basepath The basepath of the app * @param string $baseurl The baseurl of the app * @return bool false if something required failed */ - public function checkHtAccess($basepath, $baseurl) + public function checkHtAccess($baseurl) { $status = true; $help = ""; $error_msg = ""; if (function_exists('curl_init')) { - $fetchResult = Network::fetchUrlFull($basepath . "/install/testrewrite"); + $fetchResult = Network::fetchUrlFull($baseurl . "/install/testrewrite"); $url = normalise_link($baseurl . "/install/testrewrite"); - if ($fetchResult->getBody() != "ok") { + if ($fetchResult->getReturnCode() != 204) { $fetchResult = Network::fetchUrlFull($url); } - if ($fetchResult->getBody() != "ok") { + if ($fetchResult->getReturnCode() != 204) { $status = false; $help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.'); $error_msg = []; diff --git a/src/Module/Install.php b/src/Module/Install.php new file mode 100644 index 000000000..bb132a11d --- /dev/null +++ b/src/Module/Install.php @@ -0,0 +1,330 @@ +getArgumentValue(1, '') == 'testrewrite') { + // Status Code 204 means that it worked without content + Core\System::httpExit(204); + } + + // We overwrite current theme css, because during install we clould not have a working mod_rewrite + // so we could not have a css at all. Here we set a static css file for the install procedure pages + $a->setConfigValue('system', 'value', '../install'); + $a->theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css'; + + self::$currentWizardStep = defaults($_POST, 'pass', self::SYSTEM_CHECK); + } + + public static function post() + { + $a = self::getApp(); + + switch (self::$currentWizardStep) { + case self::SYSTEM_CHECK: + case self::DATABASE_CONFIG: + // Nothing to do in these steps + return; + + case self::SITE_SETTINGS: + $dbhost = notags(trim(defaults($_POST, 'dbhost', self::DEFAULT_HOST))); + $dbuser = notags(trim(defaults($_POST, 'dbuser', ''))); + $dbpass = notags(trim(defaults($_POST, 'dbpass', ''))); + $dbdata = notags(trim(defaults($_POST, 'dbdata', ''))); + + require_once 'include/dba.php'; + if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) { + $a->data['db_conn_failed'] = true; + } + + return; + + case self::FINISHED: + $urlpath = $a->getURLPath(); + $dbhost = notags(trim(defaults($_POST, 'dbhost', self::DEFAULT_HOST))); + $dbuser = notags(trim(defaults($_POST, 'dbuser', ''))); + $dbpass = notags(trim(defaults($_POST, 'dbpass', ''))); + $dbdata = notags(trim(defaults($_POST, 'dbdata', ''))); + $phpath = notags(trim(defaults($_POST, 'phpath', ''))); + $timezone = notags(trim(defaults($_POST, 'timezone', self::DEFAULT_TZ))); + $language = notags(trim(defaults($_POST, 'language', self::DEFAULT_LANG))); + $adminmail = notags(trim(defaults($_POST, 'adminmail', ''))); + + // connect to db + DBA::connect($dbhost, $dbuser, $dbpass, $dbdata); + + $install = new Core\Install(); + + $errors = $install->createConfig($phpath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $a->getBasePath()); + + if ($errors !== true) { + $a->data['txt'] = $errors; + return; + } + + $errors = DBStructure::update(false, true, true); + + if ($errors) { + $a->data['db_failed'] = $errors; + } else { + $a->data['db_installed'] = true; + } + + return; + + default: + return; + } + } + + public static function content() + { + $a = self::getApp(); + + $output = ''; + + $install_title = L10n::t('Friendica Communctions Server - Setup'); + $wizard_status = self::checkWizardStatus($a); + + switch (self::$currentWizardStep) { + case self::SYSTEM_CHECK: + $phppath = defaults($_POST, 'phpath', null); + + $install = new Core\Install(); + $status = $install->checkAll($a->getBaseURL(), $phppath); + + $tpl = get_markup_template('install_checks.tpl'); + $output .= replace_macros($tpl, [ + '$title' => $install_title, + '$pass' => L10n::t('System check'), + '$checks' => $install->getChecks(), + '$passed' => $status, + '$see_install' => L10n::t('Please see the file "Install.txt".'), + '$next' => L10n::t('Next'), + '$reload' => L10n::t('Check again'), + '$phpath' => $phppath, + '$baseurl' => $a->getBaseURL() + ]); + break; + + case self::DATABASE_CONFIG: + $dbhost = notags(trim(defaults($_POST, 'dbhost' , self::DEFAULT_HOST))); + $dbuser = notags(trim(defaults($_POST, 'dbuser' , ''))); + $dbpass = notags(trim(defaults($_POST, 'dbpass' , ''))); + $dbdata = notags(trim(defaults($_POST, 'dbdata' , ''))); + $phpath = notags(trim(defaults($_POST, 'phpath' , ''))); + $adminmail = notags(trim(defaults($_POST, 'adminmail', ''))); + + $tpl = get_markup_template('install_db.tpl'); + $output .= replace_macros($tpl, [ + '$title' => $install_title, + '$pass' => L10n::t('Database connection'), + '$info_01' => L10n::t('In order to install Friendica we need to know how to connect to your database.'), + '$info_02' => L10n::t('Please contact your hosting provider or site administrator if you have questions about these settings.'), + '$info_03' => L10n::t('The database you specify below should already exist. If it does not, please create it before continuing.'), + '$status' => $wizard_status, + '$dbhost' => ['dbhost', + L10n::t('Database Server Name'), + $dbhost, + '', + 'required'], + '$dbuser' => ['dbuser', + L10n::t('Database Login Name'), + $dbuser, + '', + 'required', + 'autofocus'], + '$dbpass' => ['dbpass', + L10n::t('Database Login Password'), + $dbpass, + L10n::t("For security reasons the password must not be empty"), + 'required'], + '$dbdata' => ['dbdata', + L10n::t('Database Name'), + $dbdata, + '', + 'required'], + '$adminmail' => ['adminmail', + L10n::t('Site administrator email address'), + $adminmail, + L10n::t('Your account email address must match this in order to use the web admin panel.'), + 'required', + 'autofocus', + 'email'], + '$lbl_10' => L10n::t('Please select a default timezone for your website'), + '$baseurl' => $a->getBaseURL(), + '$phpath' => $phpath, + '$submit' => L10n::t('Submit') + ]); + break; + case self::SITE_SETTINGS: + $dbhost = notags(trim(defaults($_POST, 'dbhost', self::DEFAULT_HOST))); + $dbuser = notags(trim(defaults($_POST, 'dbuser', '' ))); + $dbpass = notags(trim(defaults($_POST, 'dbpass', '' ))); + $dbdata = notags(trim(defaults($_POST, 'dbdata', '' ))); + $phpath = notags(trim(defaults($_POST, 'phpath', '' ))); + + $adminmail = notags(trim(defaults($_POST, 'adminmail', ''))); + + $timezone = defaults($_POST, 'timezone', self::DEFAULT_TZ); + /* Installed langs */ + $lang_choices = L10n::getAvailableLanguages(); + + $tpl = get_markup_template('install_settings.tpl'); + $output .= replace_macros($tpl, [ + '$title' => $install_title, + '$pass' => L10n::t('Site settings'), + '$status' => $wizard_status, + '$dbhost' => $dbhost, + '$dbuser' => $dbuser, + '$dbpass' => $dbpass, + '$dbdata' => $dbdata, + '$phpath' => $phpath, + '$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'], + '$timezone' => Temporal::getTimezoneField('timezone', L10n::t('Please select a default timezone for your website'), $timezone, ''), + '$language' => ['language', + L10n::t('System Language:'), # + self::DEFAULT_LANG, + L10n::t('Set the default language for your Friendica installation interface and to send emails.'), + $lang_choices], + '$baseurl' => $a->getBaseURL(), + '$submit' => L10n::t('Submit') + ]); + break; + + case self::FINISHED: + $db_return_text = ""; + + if (defaults($a->data, 'db_installed', false)) { + $txt = '

'; + $txt .= L10n::t('Your Friendica site database has been installed.') . EOL; + $db_return_text .= $txt; + } + + if (defaults($a->data, 'db_failed', false)) { + $txt = L10n::t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; + $txt .= L10n::t('Please see the file "INSTALL.txt".') . EOL ."


"; + $txt .= "
".$a->data['db_failed'] . "
". EOL; + $db_return_text .= $txt; + } + + if (isset($a->data['txt']) && strlen($a->data['txt'])) { + $db_return_text .= self::manualConfig($a); + } + + $tpl = get_markup_template('install.tpl'); + $output .= replace_macros($tpl, [ + '$title' => $install_title, + '$pass' => "", + '$text' => $db_return_text . self::whatNext($a), + ]); + + break; + } + + return $output; + } + + /** + * @param App $a The global Friendica App + * + * @return string The status of Wizard steps + */ + private static function checkWizardStatus($a) + { + $wizardStatus = ""; + + if (defaults($a->data, 'db_conn_failed', false)) { + self::$currentWizardStep = 2; + $wizardStatus = L10n::t('Could not connect to database.'); + } + + if (defaults($a->data, 'db_create_failed', false)) { + self::$currentWizardStep = 2; + $wizardStatus = L10n::t('Could not create table.'); + } + + if (DBA::connected()) { + if (DBA::count('user')) { + self::$currentWizardStep = 2; + $wizardStatus = L10n::t('Database already in use.'); + } + } + + return $wizardStatus; + } + + /** + * Creates the text for manual config + * + * @param App $a The global App + * + * @return string The manual config text + */ + private static function manualConfig($a) { + $data = htmlentities($a->data['txt'],ENT_COMPAT, 'UTF-8'); + $output = L10n::t('The database configuration file "config/local.ini.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); + $output .= ""; + return $output; + } + + /** + * Creates the text for the next steps + * + * @param App $a The global App + * + * @return string The text for the next steps + */ + private static function whatNext($a) { + $baseurl = $a->getBaseUrl(); + return + L10n::t('

What next

') + ."

".L10n::t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.') + .L10n::t('Please see the file "INSTALL.txt".') + ."

" + .L10n::t('Go to your new Friendica node registration page and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.', $baseurl) + ."

"; + } +} diff --git a/tests/src/Core/InstallTest.php b/tests/src/Core/InstallTest.php index 9d3672c54..b44104d5f 100644 --- a/tests/src/Core/InstallTest.php +++ b/tests/src/Core/InstallTest.php @@ -185,8 +185,8 @@ class InstallTest extends TestCase // Mocking the CURL Response $curlResult = \Mockery::mock('Friendica\Network\CurlResult'); $curlResult - ->shouldReceive('getBody') - ->andReturn('not ok'); + ->shouldReceive('getReturnCode') + ->andReturn('404'); $curlResult ->shouldReceive('getRedirectUrl') ->andReturn(''); @@ -213,7 +213,7 @@ class InstallTest extends TestCase $install = new Install(); - $this->assertFalse($install->checkHtAccess('https://test', 'https://test')); + $this->assertFalse($install->checkHtAccess('https://test')); $this->assertSame('test Error', $install->getChecks()[0]['error_msg']['msg']); } @@ -225,14 +225,14 @@ class InstallTest extends TestCase // Mocking the failed CURL Response $curlResultF = \Mockery::mock('Friendica\Network\CurlResult'); $curlResultF - ->shouldReceive('getBody') - ->andReturn('not ok'); + ->shouldReceive('getReturnCode') + ->andReturn('404'); // Mocking the working CURL Response $curlResultW = \Mockery::mock('Friendica\Network\CurlResult'); $curlResultW - ->shouldReceive('getBody') - ->andReturn('ok'); + ->shouldReceive('getReturnCode') + ->andReturn('204'); // Mocking the CURL Request $networkMock = \Mockery::mock('alias:Friendica\Util\Network'); @@ -253,7 +253,7 @@ class InstallTest extends TestCase $install = new Install(); - $this->assertTrue($install->checkHtAccess('https://test', 'https://test')); + $this->assertTrue($install->checkHtAccess('https://test')); } /** From cfae736660921071c5d4356990a01754ef8e2d2b Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 29 Oct 2018 14:39:09 +0100 Subject: [PATCH 02/68] Code Standards --- src/Module/Install.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Module/Install.php b/src/Module/Install.php index bb132a11d..362255974 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -50,8 +50,8 @@ class Install extends BaseModule Core\System::httpExit(204); } - // We overwrite current theme css, because during install we clould not have a working mod_rewrite - // so we could not have a css at all. Here we set a static css file for the install procedure pages + // We overwrite current theme css, because during install we may not have a working mod_rewrite + // so we may not have a css at all. Here we set a static css file for the install procedure pages $a->setConfigValue('system', 'value', '../install'); $a->theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css'; @@ -303,8 +303,9 @@ class Install extends BaseModule * * @return string The manual config text */ - private static function manualConfig($a) { - $data = htmlentities($a->data['txt'],ENT_COMPAT, 'UTF-8'); + private static function manualConfig($a) + { + $data = htmlentities($a->data['txt'], ENT_COMPAT, 'UTF-8'); $output = L10n::t('The database configuration file "config/local.ini.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $output .= ""; return $output; @@ -317,14 +318,15 @@ class Install extends BaseModule * * @return string The text for the next steps */ - private static function whatNext($a) { + private static function whatNext($a) + { $baseurl = $a->getBaseUrl(); return L10n::t('

What next

') - ."

".L10n::t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.') - .L10n::t('Please see the file "INSTALL.txt".') - ."

" - .L10n::t('Go to your new Friendica node registration page and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.', $baseurl) - ."

"; + . "

".L10n::t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.') + . L10n::t('Please see the file "INSTALL.txt".') + . "

" + . L10n::t('Go to your new Friendica node registration page and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.', $baseurl) + . "

"; } } From 64149c41b45d6c4d2210ec3fc0fb59e1d3b92077 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 29 Oct 2018 14:40:50 +0100 Subject: [PATCH 03/68] Replacing error message --- src/Core/Install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Install.php b/src/Core/Install.php index 28b8828ad..0a97e93d8 100644 --- a/src/Core/Install.php +++ b/src/Core/Install.php @@ -461,7 +461,7 @@ class Install if ($fetchResult->getReturnCode() != 204) { $status = false; - $help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.'); + $help = L10n::t('Url rewrite in .htaccess is not working. Make sure you copied .htaccess-dist to .htaccess.'); $error_msg = []; $error_msg['head'] = L10n::t('Error message from Curl when fetching'); $error_msg['url'] = $fetchResult->getRedirectUrl(); From f0382ab919b3848dd4dce9717a4f7cc7910c19d7 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 29 Oct 2018 18:44:39 +0100 Subject: [PATCH 04/68] Refactoring Installation - centralized installation - renamed Core\Install to Core\Installer - avoid using $a->data[] for states - removed unnecessary code --- src/Core/Console/AutomaticInstallation.php | 84 ++++----- src/Core/{Install.php => Installer.php} | 72 +++++++- src/Module/Install.php | 161 +++++------------- .../{InstallTest.php => InstallerTest.php} | 34 ++-- view/templates/install.tpl | 11 -- view/templates/install_db.tpl | 11 +- view/templates/install_finished.tpl | 13 ++ view/templates/install_settings.tpl | 4 - 8 files changed, 185 insertions(+), 205 deletions(-) rename src/Core/{Install.php => Installer.php} (87%) rename tests/src/Core/{InstallTest.php => InstallerTest.php} (94%) delete mode 100644 view/templates/install.tpl create mode 100644 view/templates/install_finished.tpl diff --git a/src/Core/Console/AutomaticInstallation.php b/src/Core/Console/AutomaticInstallation.php index c4e542e76..491e82603 100644 --- a/src/Core/Console/AutomaticInstallation.php +++ b/src/Core/Console/AutomaticInstallation.php @@ -5,7 +5,7 @@ namespace Friendica\Core\Console; use Asika\SimpleConsole\Console; use Friendica\BaseObject; use Friendica\Core\Config; -use Friendica\Core\Install; +use Friendica\Core\Installer; use Friendica\Core\Theme; use Friendica\Database\DBA; use Friendica\Database\DBStructure; @@ -76,7 +76,7 @@ HELP; $a = BaseObject::getApp(); - $install = new Install(); + $installer = new Installer(); // if a config file is set, $config_file = $this->getOption(['f', 'file']); @@ -111,7 +111,7 @@ HELP; $tz = $this->getOption(['T', 'tz'], (!empty('FRIENDICA_TZ')) ? getenv('FRIENDICA_TZ') : ''); $lang = $this->getOption(['L', 'lang'], (!empty('FRIENDICA_LANG')) ? getenv('FRIENDICA_LANG') : ''); - $install->createConfig( + $installer->createConfig( $php_path, $url_path, ((!empty($db_port)) ? $db_host . ':' . $db_port : $db_host), @@ -130,14 +130,10 @@ HELP; // Check basic setup $this->out("Checking basic setup...\n"); - $checkResults = []; + $installer->resetChecks(); - $this->runBasicChecks($install); - - $checkResults['basic'] = $install->getChecks(); - $errorMessage = $this->extractErrors($checkResults['basic']); - - if ($errorMessage !== '') { + if (!$this->runBasicChecks($installer)) { + $errorMessage = $this->extractErrors($installer->getChecks()); throw new RuntimeException($errorMessage); } @@ -146,11 +142,10 @@ HELP; // Check database connection $this->out("Checking database...\n"); - $checkResults['db'] = array(); - $checkResults['db'][] = $this->runDatabaseCheck($db_host, $db_user, $db_pass, $db_data); - $errorMessage = $this->extractErrors($checkResults['db']); + $installer->resetChecks(); - if ($errorMessage !== '') { + if (!$installer->checkDB($db_host, $db_user, $db_pass, $db_data)) { + $errorMessage = $this->extractErrors($installer->getChecks()); throw new RuntimeException($errorMessage); } @@ -159,10 +154,11 @@ HELP; // Install database $this->out("Inserting data into database...\n"); - $checkResults['data'] = DBStructure::update(false, true, true); + $installer->resetChecks(); - if ($checkResults['data'] !== '') { - throw new RuntimeException("ERROR: DB Database creation error. Is the DB empty?\n"); + if (!$installer->installDatabase()) { + $errorMessage = $this->extractErrors($installer->getChecks()); + throw new RuntimeException($errorMessage); } $this->out(" Complete!\n\n"); @@ -182,16 +178,30 @@ HELP; } /** - * @param Install $install the Installer instance + * @param Installer $install the Installer instance + * + * @return bool true if checks were successfully, otherwise false */ - private function runBasicChecks(Install $install) + private function runBasicChecks(Installer $install) { + $checked = true; + $install->resetChecks(); - $install->checkFunctions(); - $install->checkImagick(); - $install->checkLocalIni(); - $install->checkSmarty3(); - $install->checkKeys(); + if (!$install->checkFunctions()) { + $checked = false; + } + if (!$install->checkImagick()) { + $checked = false; + } + if (!$install->checkLocalIni()) { + $checked = false; + } + if (!$install->checkSmarty3()) { + $checked = false; + } + if ($install->checkKeys()) { + $checked = false; + } if (!empty(Config::get('config', 'php_path'))) { if (!$install->checkPHP(Config::get('config', 'php_path'), true)) { @@ -202,32 +212,8 @@ HELP; } $this->out(" NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.\n"); - } - /** - * @param $db_host - * @param $db_user - * @param $db_pass - * @param $db_data - * - * @return array - */ - private function runDatabaseCheck($db_host, $db_user, $db_pass, $db_data) - { - $result = array( - 'title' => 'MySQL Connection', - 'required' => true, - 'status' => true, - 'help' => '', - ); - - - if (!DBA::connect($db_host, $db_user, $db_pass, $db_data)) { - $result['status'] = false; - $result['help'] = 'Failed, please check your MySQL settings and credentials.'; - } - - return $result; + return $checked; } /** diff --git a/src/Core/Install.php b/src/Core/Installer.php similarity index 87% rename from src/Core/Install.php rename to src/Core/Installer.php index 0a97e93d8..03d888b7e 100644 --- a/src/Core/Install.php +++ b/src/Core/Installer.php @@ -6,14 +6,21 @@ namespace Friendica\Core; use DOMDocument; use Exception; +use Friendica\Database\DBA; +use Friendica\Database\DBStructure; use Friendica\Object\Image; use Friendica\Util\Network; /** * Contains methods for installation purpose of Friendica */ -class Install +class Installer { + // Default values for the install page + const DEFAULT_LANG = 'en'; + const DEFAULT_TZ = 'America/Los_Angeles'; + const DEFAULT_HOST = 'localhost'; + /** * @var array the check outcomes */ @@ -54,7 +61,7 @@ class Install * * @return bool if the check succeed */ - public function checkAll($baseurl, $phpath = null) + public function checkEnvironment($baseurl, $phpath = null) { $returnVal = true; @@ -107,12 +114,12 @@ class Install * @param string $adminmail Mail-Adress of the administrator * @param string $basepath The basepath of Friendica * - * @return bool|string true if the config was created, the text if something went wrong + * @return bool true if the config was created, otherwise false */ public function createConfig($phppath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $basepath) { $tpl = get_markup_template('local.ini.tpl'); - $txt = replace_macros($tpl,[ + $txt = replace_macros($tpl, [ '$phpath' => $phppath, '$dbhost' => $dbhost, '$dbuser' => $dbuser, @@ -127,10 +134,31 @@ class Install $result = file_put_contents($basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php', $txt); if (!$result) { - return $txt; - } else { - return true; + $this->addCheck(L10n::t('The database configuration file "config/local.ini.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'), false, false, htmlentities($txt, ENT_COMPAT, 'UTF-8')); } + + return $result; + } + + /*** + * Installs the DB-Scheme for Friendica + * + * @return bool true if the installation was successful, otherwise false + */ + public function installDatabase() + { + $result = DBStructure::update(false, true, true); + + if ($result) { + $txt = L10n::t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; + $txt .= L10n::t('Please see the file "INSTALL.txt".'); + + $this->addCheck($txt, false, true, htmlentities($result, ENT_COMPAT, 'UTF-8')); + + return false; + } + + return true; } /** @@ -508,4 +536,34 @@ class Install // Imagick is not required return true; } + + /** + * Checking the Database connection and if it is available for the current installation + * + * @param string $dbhost Hostname/IP of the Friendica Database + * @param string $dbuser Username of the Database connection credentials + * @param string $dbpass Password of the Database connection credentials + * @param string $dbdata Name of the Database + * + * @return bool true if the check was successful, otherwise false + */ + public function checkDB($dbhost, $dbuser, $dbpass, $dbdata) + { + require_once 'include/dba.php'; + if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) { + $this->addCheck(L10n::t('Could not connect to database.'), false, true, ''); + + return false; + } + + if (DBA::connected()) { + if (DBA::count('user') > 0) { + $this->addCheck(L10n::t('Database already in use.'), false, true, ''); + + return false; + } + } + + return true; + } } diff --git a/src/Module/Install.php b/src/Module/Install.php index 362255974..e09f23a18 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -29,16 +29,16 @@ class Install extends BaseModule */ const FINISHED = 4; - // Default values for the install page - const DEFAULT_LANG = 'en'; - const DEFAULT_TZ = 'America/Los_Angeles'; - const DEFAULT_HOST = 'localhost'; - /** * @var int The current step of the wizard */ private static $currentWizardStep; + /** + * @var Core\Installer The installer + */ + private static $installer; + public static function init() { $a = self::getApp(); @@ -52,9 +52,9 @@ class Install extends BaseModule // We overwrite current theme css, because during install we may not have a working mod_rewrite // so we may not have a css at all. Here we set a static css file for the install procedure pages - $a->setConfigValue('system', 'value', '../install'); $a->theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css'; + self::$installer = new Core\Installer(); self::$currentWizardStep = defaults($_POST, 'pass', self::SYSTEM_CHECK); } @@ -66,56 +66,44 @@ class Install extends BaseModule case self::SYSTEM_CHECK: case self::DATABASE_CONFIG: // Nothing to do in these steps - return; + break; case self::SITE_SETTINGS: - $dbhost = notags(trim(defaults($_POST, 'dbhost', self::DEFAULT_HOST))); + $dbhost = notags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST))); $dbuser = notags(trim(defaults($_POST, 'dbuser', ''))); $dbpass = notags(trim(defaults($_POST, 'dbpass', ''))); $dbdata = notags(trim(defaults($_POST, 'dbdata', ''))); - require_once 'include/dba.php'; - if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) { - $a->data['db_conn_failed'] = true; + // If we cannot connect to the database, return to the previous step + if (!self::$installer->checkDB($dbhost, $dbuser, $dbpass, $dbdata)) { + self::$currentWizardStep = self::DATABASE_CONFIG; } - return; + break; case self::FINISHED: $urlpath = $a->getURLPath(); - $dbhost = notags(trim(defaults($_POST, 'dbhost', self::DEFAULT_HOST))); + $dbhost = notags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST))); $dbuser = notags(trim(defaults($_POST, 'dbuser', ''))); $dbpass = notags(trim(defaults($_POST, 'dbpass', ''))); $dbdata = notags(trim(defaults($_POST, 'dbdata', ''))); $phpath = notags(trim(defaults($_POST, 'phpath', ''))); - $timezone = notags(trim(defaults($_POST, 'timezone', self::DEFAULT_TZ))); - $language = notags(trim(defaults($_POST, 'language', self::DEFAULT_LANG))); + $timezone = notags(trim(defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ))); + $language = notags(trim(defaults($_POST, 'language', Core\Installer::DEFAULT_LANG))); $adminmail = notags(trim(defaults($_POST, 'adminmail', ''))); - // connect to db - DBA::connect($dbhost, $dbuser, $dbpass, $dbdata); + // If we cannot connect to the database, return to the Database config wizard + if (!self::$installer->checkDB($dbhost, $dbuser, $dbpass, $dbdata)) { + self::$currentWizardStep = self::DATABASE_CONFIG; + } - $install = new Core\Install(); - - $errors = $install->createConfig($phpath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $a->getBasePath()); - - if ($errors !== true) { - $a->data['txt'] = $errors; + if (!self::$installer->createConfig($phpath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $a->getBasePath())) { return; } - $errors = DBStructure::update(false, true, true); + self::$installer->installDatabase(); - if ($errors) { - $a->data['db_failed'] = $errors; - } else { - $a->data['db_installed'] = true; - } - - return; - - default: - return; + break; } } @@ -126,20 +114,18 @@ class Install extends BaseModule $output = ''; $install_title = L10n::t('Friendica Communctions Server - Setup'); - $wizard_status = self::checkWizardStatus($a); switch (self::$currentWizardStep) { case self::SYSTEM_CHECK: $phppath = defaults($_POST, 'phpath', null); - $install = new Core\Install(); - $status = $install->checkAll($a->getBaseURL(), $phppath); + $status = self::$installer->checkEnvironment($a->getBaseURL(), $phppath); $tpl = get_markup_template('install_checks.tpl'); $output .= replace_macros($tpl, [ '$title' => $install_title, '$pass' => L10n::t('System check'), - '$checks' => $install->getChecks(), + '$checks' => self::$installer->getChecks(), '$passed' => $status, '$see_install' => L10n::t('Please see the file "Install.txt".'), '$next' => L10n::t('Next'), @@ -150,12 +136,12 @@ class Install extends BaseModule break; case self::DATABASE_CONFIG: - $dbhost = notags(trim(defaults($_POST, 'dbhost' , self::DEFAULT_HOST))); - $dbuser = notags(trim(defaults($_POST, 'dbuser' , ''))); - $dbpass = notags(trim(defaults($_POST, 'dbpass' , ''))); - $dbdata = notags(trim(defaults($_POST, 'dbdata' , ''))); - $phpath = notags(trim(defaults($_POST, 'phpath' , ''))); - $adminmail = notags(trim(defaults($_POST, 'adminmail', ''))); + $dbhost = notags(trim(defaults($_POST, 'dbhost' , Core\Installer::DEFAULT_HOST))); + $dbuser = notags(trim(defaults($_POST, 'dbuser' , '' ))); + $dbpass = notags(trim(defaults($_POST, 'dbpass' , '' ))); + $dbdata = notags(trim(defaults($_POST, 'dbdata' , '' ))); + $phpath = notags(trim(defaults($_POST, 'phpath' , '' ))); + $adminmail = notags(trim(defaults($_POST, 'adminmail', '' ))); $tpl = get_markup_template('install_db.tpl'); $output .= replace_macros($tpl, [ @@ -164,7 +150,7 @@ class Install extends BaseModule '$info_01' => L10n::t('In order to install Friendica we need to know how to connect to your database.'), '$info_02' => L10n::t('Please contact your hosting provider or site administrator if you have questions about these settings.'), '$info_03' => L10n::t('The database you specify below should already exist. If it does not, please create it before continuing.'), - '$status' => $wizard_status, + 'checks' => self::$installer->getChecks(), '$dbhost' => ['dbhost', L10n::t('Database Server Name'), $dbhost, @@ -199,24 +185,25 @@ class Install extends BaseModule '$submit' => L10n::t('Submit') ]); break; + case self::SITE_SETTINGS: - $dbhost = notags(trim(defaults($_POST, 'dbhost', self::DEFAULT_HOST))); - $dbuser = notags(trim(defaults($_POST, 'dbuser', '' ))); - $dbpass = notags(trim(defaults($_POST, 'dbpass', '' ))); - $dbdata = notags(trim(defaults($_POST, 'dbdata', '' ))); - $phpath = notags(trim(defaults($_POST, 'phpath', '' ))); + $dbhost = notags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST))); + $dbuser = notags(trim(defaults($_POST, 'dbuser', '' ))); + $dbpass = notags(trim(defaults($_POST, 'dbpass', '' ))); + $dbdata = notags(trim(defaults($_POST, 'dbdata', '' ))); + $phpath = notags(trim(defaults($_POST, 'phpath', '' ))); $adminmail = notags(trim(defaults($_POST, 'adminmail', ''))); - $timezone = defaults($_POST, 'timezone', self::DEFAULT_TZ); + $timezone = defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ); /* Installed langs */ $lang_choices = L10n::getAvailableLanguages(); $tpl = get_markup_template('install_settings.tpl'); $output .= replace_macros($tpl, [ '$title' => $install_title, + '$checks' => self::$installer->getChecks(), '$pass' => L10n::t('Site settings'), - '$status' => $wizard_status, '$dbhost' => $dbhost, '$dbuser' => $dbuser, '$dbpass' => $dbpass, @@ -225,8 +212,8 @@ class Install extends BaseModule '$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'], '$timezone' => Temporal::getTimezoneField('timezone', L10n::t('Please select a default timezone for your website'), $timezone, ''), '$language' => ['language', - L10n::t('System Language:'), # - self::DEFAULT_LANG, + L10n::t('System Language:'), + Core\Installer::DEFAULT_LANG, L10n::t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices], '$baseurl' => $a->getBaseURL(), @@ -237,28 +224,18 @@ class Install extends BaseModule case self::FINISHED: $db_return_text = ""; - if (defaults($a->data, 'db_installed', false)) { + if (count(self::$installer->getChecks()) == 0) { $txt = '

'; $txt .= L10n::t('Your Friendica site database has been installed.') . EOL; $db_return_text .= $txt; } - if (defaults($a->data, 'db_failed', false)) { - $txt = L10n::t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; - $txt .= L10n::t('Please see the file "INSTALL.txt".') . EOL ."


"; - $txt .= "
".$a->data['db_failed'] . "
". EOL; - $db_return_text .= $txt; - } - - if (isset($a->data['txt']) && strlen($a->data['txt'])) { - $db_return_text .= self::manualConfig($a); - } - - $tpl = get_markup_template('install.tpl'); + $tpl = get_markup_template('install_finished.tpl'); $output .= replace_macros($tpl, [ - '$title' => $install_title, - '$pass' => "", - '$text' => $db_return_text . self::whatNext($a), + '$title' => $install_title, + '$checks' => self::$installer->getChecks(), + '$pass' => L10n::t('Installation finished'), + '$text' => $db_return_text . self::whatNext($a), ]); break; @@ -267,50 +244,6 @@ class Install extends BaseModule return $output; } - /** - * @param App $a The global Friendica App - * - * @return string The status of Wizard steps - */ - private static function checkWizardStatus($a) - { - $wizardStatus = ""; - - if (defaults($a->data, 'db_conn_failed', false)) { - self::$currentWizardStep = 2; - $wizardStatus = L10n::t('Could not connect to database.'); - } - - if (defaults($a->data, 'db_create_failed', false)) { - self::$currentWizardStep = 2; - $wizardStatus = L10n::t('Could not create table.'); - } - - if (DBA::connected()) { - if (DBA::count('user')) { - self::$currentWizardStep = 2; - $wizardStatus = L10n::t('Database already in use.'); - } - } - - return $wizardStatus; - } - - /** - * Creates the text for manual config - * - * @param App $a The global App - * - * @return string The manual config text - */ - private static function manualConfig($a) - { - $data = htmlentities($a->data['txt'], ENT_COMPAT, 'UTF-8'); - $output = L10n::t('The database configuration file "config/local.ini.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); - $output .= ""; - return $output; - } - /** * Creates the text for the next steps * diff --git a/tests/src/Core/InstallTest.php b/tests/src/Core/InstallerTest.php similarity index 94% rename from tests/src/Core/InstallTest.php rename to tests/src/Core/InstallerTest.php index b44104d5f..a4ee20b8c 100644 --- a/tests/src/Core/InstallTest.php +++ b/tests/src/Core/InstallerTest.php @@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase; * @runTestsInSeparateProcesses * @preserveGlobalState disabled */ -class InstallTest extends TestCase +class InstallerTest extends TestCase { use VFSTrait; @@ -74,11 +74,11 @@ class InstallTest extends TestCase public function testCheckKeys() { $this->setFunctions(['openssl_pkey_new' => false]); - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkKeys()); $this->setFunctions(['openssl_pkey_new' => true]); - $install = new Install(); + $install = new Installer(); $this->assertTrue($install->checkKeys()); } @@ -88,7 +88,7 @@ class InstallTest extends TestCase public function testCheckFunctions() { $this->setFunctions(['curl_init' => false]); - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkFunctions()); $this->assertCheckExist(3, L10n::t('libCurl PHP module'), @@ -98,7 +98,7 @@ class InstallTest extends TestCase $install->getChecks()); $this->setFunctions(['imagecreatefromjpeg' => false]); - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkFunctions()); $this->assertCheckExist(4, L10n::t('GD graphics PHP module'), @@ -108,7 +108,7 @@ class InstallTest extends TestCase $install->getChecks()); $this->setFunctions(['openssl_public_encrypt' => false]); - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkFunctions()); $this->assertCheckExist(5, L10n::t('OpenSSL PHP module'), @@ -118,7 +118,7 @@ class InstallTest extends TestCase $install->getChecks()); $this->setFunctions(['mb_strlen' => false]); - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkFunctions()); $this->assertCheckExist(6, L10n::t('mb_string PHP module'), @@ -128,7 +128,7 @@ class InstallTest extends TestCase $install->getChecks()); $this->setFunctions(['iconv_strlen' => false]); - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkFunctions()); $this->assertCheckExist(7, L10n::t('iconv PHP module'), @@ -138,7 +138,7 @@ class InstallTest extends TestCase $install->getChecks()); $this->setFunctions(['posix_kill' => false]); - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkFunctions()); $this->assertCheckExist(8, L10n::t('POSIX PHP module'), @@ -155,7 +155,7 @@ class InstallTest extends TestCase 'iconv_strlen' => true, 'posix_kill' => true ]); - $install = new Install(); + $install = new Installer(); $this->assertTrue($install->checkFunctions()); } @@ -166,14 +166,14 @@ class InstallTest extends TestCase { $this->assertTrue($this->root->hasChild('config/local.ini.php')); - $install = new Install(); + $install = new Installer(); $this->assertTrue($install->checkLocalIni()); $this->delConfigFile('local.ini.php'); $this->assertFalse($this->root->hasChild('config/local.ini.php')); - $install = new Install(); + $install = new Installer(); $this->assertTrue($install->checkLocalIni()); } @@ -211,7 +211,7 @@ class InstallTest extends TestCase // needed because of "normalise_link" require_once __DIR__ . '/../../../include/text.php'; - $install = new Install(); + $install = new Installer(); $this->assertFalse($install->checkHtAccess('https://test')); $this->assertSame('test Error', $install->getChecks()[0]['error_msg']['msg']); @@ -251,7 +251,7 @@ class InstallTest extends TestCase // needed because of "normalise_link" require_once __DIR__ . '/../../../include/text.php'; - $install = new Install(); + $install = new Installer(); $this->assertTrue($install->checkHtAccess('https://test')); } @@ -268,7 +268,7 @@ class InstallTest extends TestCase $this->setClasses(['Imagick' => true]); - $install = new Install(); + $install = new Installer(); // even there is no supported type, Imagick should return true (because it is not required) $this->assertTrue($install->checkImagick()); @@ -293,7 +293,7 @@ class InstallTest extends TestCase $this->setClasses(['Imagick' => true]); - $install = new Install(); + $install = new Installer(); // even there is no supported type, Imagick should return true (because it is not required) $this->assertTrue($install->checkImagick()); @@ -309,7 +309,7 @@ class InstallTest extends TestCase { $this->setClasses(['Imagick' => false]); - $install = new Install(); + $install = new Installer(); // even there is no supported type, Imagick should return true (because it is not required) $this->assertTrue($install->checkImagick()); diff --git a/view/templates/install.tpl b/view/templates/install.tpl deleted file mode 100644 index 24ae02242..000000000 --- a/view/templates/install.tpl +++ /dev/null @@ -1,11 +0,0 @@ - - -

{{$title}}

-

{{$pass}}

- - -{{if $status}} -

{{$status}}

-{{/if}} - -{{$text}} diff --git a/view/templates/install_db.tpl b/view/templates/install_db.tpl index 6b6c1c1e6..6c018db72 100644 --- a/view/templates/install_db.tpl +++ b/view/templates/install_db.tpl @@ -10,9 +10,14 @@ {{$info_03}}

-{{if $status}} -

{{$status}}

-{{/if}} + + {{foreach $checks as $check}} +
{{$check.title}} + {{if ! $check.status}} + Requirement not satisfied + {{/if}} + {{/foreach}} +
diff --git a/view/templates/install_finished.tpl b/view/templates/install_finished.tpl new file mode 100644 index 000000000..5c8d765e3 --- /dev/null +++ b/view/templates/install_finished.tpl @@ -0,0 +1,13 @@ + + +

{{$title}}

+

{{$pass}}

+ + +{{foreach $checks as $check}} +Requirement not satisfied +{{$check.title}} + +{{/foreach}} + +{{$text}} diff --git a/view/templates/install_settings.tpl b/view/templates/install_settings.tpl index 5584e1436..55e5ea34b 100644 --- a/view/templates/install_settings.tpl +++ b/view/templates/install_settings.tpl @@ -4,10 +4,6 @@

{{$pass}}

-{{if $status}} -

{{$status}}

-{{/if}} - From cf39c9df81ccca60132267f59b9963f90cfa2d51 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Tue, 30 Oct 2018 11:30:19 +0100 Subject: [PATCH 05/68] Bugfixings - moved testargs.php to util directory - Switch Environment check before config at automatic install - checkPHP() is now finding the PHP binary too - Bugfixing checkPHP() & required returned wrong status - removing not used $_POST['phpath'] in web installer --- src/Core/Console/AutomaticInstallation.php | 57 +++++++++++-------- src/Core/Installer.php | 43 +++++++++++--- src/Module/Install.php | 4 +- .../AutomaticInstallationConsoleTest.php | 9 ++- testargs.php => util/testargs.php | 0 5 files changed, 77 insertions(+), 36 deletions(-) rename testargs.php => util/testargs.php (100%) diff --git a/src/Core/Console/AutomaticInstallation.php b/src/Core/Console/AutomaticInstallation.php index 491e82603..294009ada 100644 --- a/src/Core/Console/AutomaticInstallation.php +++ b/src/Core/Console/AutomaticInstallation.php @@ -78,6 +78,20 @@ HELP; $installer = new Installer(); + $this->out(" Complete!\n\n"); + + // Check Environment + $this->out("Checking environment...\n"); + + $installer->resetChecks(); + + if (!$this->runBasicChecks($installer)) { + $errorMessage = $this->extractErrors($installer->getChecks()); + throw new RuntimeException($errorMessage); + } + + $this->out(" Complete!\n\n"); + // if a config file is set, $config_file = $this->getOption(['f', 'file']); @@ -111,6 +125,10 @@ HELP; $tz = $this->getOption(['T', 'tz'], (!empty('FRIENDICA_TZ')) ? getenv('FRIENDICA_TZ') : ''); $lang = $this->getOption(['L', 'lang'], (!empty('FRIENDICA_LANG')) ? getenv('FRIENDICA_LANG') : ''); + if (empty($php_path)) { + $php_path = $installer->getPHPPath(); + } + $installer->createConfig( $php_path, $url_path, @@ -127,18 +145,6 @@ HELP; $this->out(" Complete!\n\n"); - // Check basic setup - $this->out("Checking basic setup...\n"); - - $installer->resetChecks(); - - if (!$this->runBasicChecks($installer)) { - $errorMessage = $this->extractErrors($installer->getChecks()); - throw new RuntimeException($errorMessage); - } - - $this->out(" Complete!\n\n"); - // Check database connection $this->out("Checking database...\n"); @@ -178,37 +184,38 @@ HELP; } /** - * @param Installer $install the Installer instance + * @param Installer $installer the Installer instance * * @return bool true if checks were successfully, otherwise false */ - private function runBasicChecks(Installer $install) + private function runBasicChecks(Installer $installer) { $checked = true; - $install->resetChecks(); - if (!$install->checkFunctions()) { + $installer->resetChecks(); + if (!$installer->checkFunctions()) { $checked = false; } - if (!$install->checkImagick()) { + if (!$installer->checkImagick()) { $checked = false; } - if (!$install->checkLocalIni()) { + if (!$installer->checkLocalIni()) { $checked = false; } - if (!$install->checkSmarty3()) { + if (!$installer->checkSmarty3()) { $checked = false; } - if ($install->checkKeys()) { + if (!$installer->checkKeys()) { $checked = false; } + $php_path = null; if (!empty(Config::get('config', 'php_path'))) { - if (!$install->checkPHP(Config::get('config', 'php_path'), true)) { - throw new RuntimeException(" ERROR: The php_path is not valid in the config.\n"); - } - } else { - throw new RuntimeException(" ERROR: The php_path is not set in the config.\n"); + $php_path = Config::get('config', 'php_path'); + } + + if (!$installer->checkPHP($php_path, true)) { + $checked = false; } $this->out(" NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.\n"); diff --git a/src/Core/Installer.php b/src/Core/Installer.php index 03d888b7e..cb871e2df 100644 --- a/src/Core/Installer.php +++ b/src/Core/Installer.php @@ -26,6 +26,11 @@ class Installer */ private $checks; + /** + * @var string The path to the PHP binary + */ + private $phppath = null; + /** * Returns all checks made * @@ -36,6 +41,22 @@ class Installer return $this->checks; } + /** + * Returns the PHP path + * + * @return string the PHP Path + */ + public function getPHPPath() + { + // if not set, determine the PHP path + if (!isset($this->phppath)) { + $this->checkPHP(); + $this->resetChecks(); + } + + return $this->phppath; + } + /** * Resets all checks */ @@ -197,11 +218,17 @@ class Installer */ public function checkPHP($phppath = null, $required = false) { - $passed = $passed2 = $passed3 = false; - if (isset($phppath)) { - $passed = file_exists($phppath); - } else { - $phppath = trim(shell_exec('which php')); + $passed = false; + $passed2 = false; + $passed3 = false; + + if (!isset($phppath)) { + $phppath = 'php'; + } + + $passed = file_exists($phppath); + if (!$passed) { + $phppath = trim(shell_exec('which ' . $phppath)); $passed = strlen($phppath); } @@ -232,12 +259,12 @@ class Installer $this->addCheck(L10n::t('PHP cli binary'), $passed2, true, $help); } else { // return if it was required - return $required; + return !$required; } if ($passed2) { $str = autoname(8); - $cmd = "$phppath testargs.php $str"; + $cmd = "$phppath util/testargs.php $str"; $result = trim(shell_exec($cmd)); $passed3 = $result == $str; $help = ""; @@ -557,7 +584,7 @@ class Installer } if (DBA::connected()) { - if (DBA::count('user') > 0) { + if (DBStructure::existsTable('user')) { $this->addCheck(L10n::t('Database already in use.'), false, true, ''); return false; diff --git a/src/Module/Install.php b/src/Module/Install.php index e09f23a18..2ef2c3229 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -87,7 +87,6 @@ class Install extends BaseModule $dbuser = notags(trim(defaults($_POST, 'dbuser', ''))); $dbpass = notags(trim(defaults($_POST, 'dbpass', ''))); $dbdata = notags(trim(defaults($_POST, 'dbdata', ''))); - $phpath = notags(trim(defaults($_POST, 'phpath', ''))); $timezone = notags(trim(defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ))); $language = notags(trim(defaults($_POST, 'language', Core\Installer::DEFAULT_LANG))); $adminmail = notags(trim(defaults($_POST, 'adminmail', ''))); @@ -95,8 +94,11 @@ class Install extends BaseModule // If we cannot connect to the database, return to the Database config wizard if (!self::$installer->checkDB($dbhost, $dbuser, $dbpass, $dbdata)) { self::$currentWizardStep = self::DATABASE_CONFIG; + return; } + $phpath = self::$installer->getPHPPath(); + if (!self::$installer->createConfig($phpath, $urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $timezone, $language, $adminmail, $a->getBasePath())) { return; } diff --git a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php index ce67cc999..03a05b09b 100644 --- a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php +++ b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php @@ -48,6 +48,8 @@ class AutomaticInstallationConsoleTest extends ConsoleTest Creating config file... + + Complete! CFG; } @@ -56,20 +58,23 @@ CFG; Copying config file... + + Complete! CFG; } $finished = << Date: Tue, 30 Oct 2018 12:47:44 +0100 Subject: [PATCH 06/68] Mocking DBStructure::existsTable() --- .../src/Core/Console/AutomaticInstallationConsoleTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php index 03a05b09b..4e1f269dc 100644 --- a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php +++ b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php @@ -31,6 +31,14 @@ class AutomaticInstallationConsoleTest extends ConsoleTest $this->db_data = getenv('MYSQL_DATABASE'); $this->db_user = getenv('MYSQL_USERNAME') . getenv('MYSQL_USER'); $this->db_pass = getenv('MYSQL_PASSWORD'); + + // Mocking 'DBStructure::existsTable()' because with CI, we cannot create an empty database + // therefore we temporary override the existing database + /// @todo Mocking the DB-Calls of ConsoleTest so we don't need this specific mock anymore + $existsMock = \Mockery::mock('alias:Friendica\Database\DBStructure'); + $existsMock->shouldReceive('existsTable') + ->with('user') + ->andReturn(false); } private function assertConfig($family, $key, $value) From e586e49c824ddc7314fa0fe66349b749d170eb3e Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Tue, 30 Oct 2018 12:58:15 +0100 Subject: [PATCH 07/68] Bugfixing missing 'REQUEST_URI' for relative path installation --- src/App.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/App.php b/src/App.php index ff118ac72..2acb7eb36 100644 --- a/src/App.php +++ b/src/App.php @@ -505,6 +505,7 @@ class App $relative_script_path = defaults($_SERVER, 'REDIRECT_URI' , $relative_script_path); $relative_script_path = defaults($_SERVER, 'REDIRECT_SCRIPT_URL', $relative_script_path); $relative_script_path = defaults($_SERVER, 'SCRIPT_URL' , $relative_script_path); + $relative_script_path = defaults($_SERVER, 'REQUEST_URI' , $relative_script_path); $this->urlPath = $this->getConfigValue('system', 'urlpath'); From d6d593d724cd8d510bd1f6b2fd3302873cde3bca Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 29 Oct 2018 16:10:35 -0400 Subject: [PATCH 08/68] Create Logger class Create Core\Logger class and point old functions to the new ones. --- include/text.php | 102 +++---------------------------- src/Core/Logger.php | 142 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 94 deletions(-) create mode 100644 src/Core/Logger.php diff --git a/include/text.php b/include/text.php index 2d497bd58..d8546e2e8 100644 --- a/include/text.php +++ b/include/text.php @@ -23,6 +23,8 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; use Friendica\Util\Proxy as ProxyUtils; +use Friendica\Core\Logger; + require_once "include/conversation.php"; /** @@ -380,9 +382,6 @@ function attribute_contains($attr, $s) { } -/* setup int->string log level map */ -$LOGGER_LEVELS = []; - /** * @brief Logs the given message at the given log level * @@ -398,57 +397,9 @@ $LOGGER_LEVELS = []; * @param string $msg * @param int $level */ -function logger($msg, $level = LOGGER_INFO) { - $a = get_app(); - global $LOGGER_LEVELS; - - $debugging = Config::get('system', 'debugging'); - $logfile = Config::get('system', 'logfile'); - $loglevel = intval(Config::get('system', 'loglevel')); - - if ( - !$debugging - || !$logfile - || $level > $loglevel - ) { - return; - } - - if (count($LOGGER_LEVELS) == 0) { - foreach (get_defined_constants() as $k => $v) { - if (substr($k, 0, 7) == "LOGGER_") { - $LOGGER_LEVELS[$v] = substr($k, 7, 7); - } - } - } - - $process_id = session_id(); - - if ($process_id == '') { - $process_id = get_app()->process_id; - } - - $callers = debug_backtrace(); - - if (count($callers) > 1) { - $function = $callers[1]['function']; - } else { - $function = ''; - } - - $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", - DateTimeFormat::utcNow(DateTimeFormat::ATOM), - $process_id, - $LOGGER_LEVELS[$level], - basename($callers[0]['file']), - $callers[0]['line'], - $function, - $msg - ); - - $stamp1 = microtime(true); - @file_put_contents($logfile, $logline, FILE_APPEND); - $a->saveTimestamp($stamp1, "file"); +function logger($msg, $level = LOGGER_INFO) +{ + Logger::logger($msg, $level); } /** @@ -469,46 +420,9 @@ function logger($msg, $level = LOGGER_INFO) { * @param string $msg * @param int $level */ -function dlogger($msg, $level = LOGGER_INFO) { - $a = get_app(); - - $logfile = Config::get('system', 'dlogfile'); - if (!$logfile) { - return; - } - - $dlogip = Config::get('system', 'dlogip'); - if (!is_null($dlogip) && $_SERVER['REMOTE_ADDR'] != $dlogip) { - return; - } - - if (count($LOGGER_LEVELS) == 0) { - foreach (get_defined_constants() as $k => $v) { - if (substr($k, 0, 7) == "LOGGER_") { - $LOGGER_LEVELS[$v] = substr($k, 7, 7); - } - } - } - - $process_id = session_id(); - - if ($process_id == '') { - $process_id = $a->process_id; - } - - $callers = debug_backtrace(); - $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n", - DateTimeFormat::utcNow(), - $process_id, - basename($callers[0]['file']), - $callers[0]['line'], - $callers[1]['function'], - $msg - ); - - $stamp1 = microtime(true); - @file_put_contents($logfile, $logline, FILE_APPEND); - $a->saveTimestamp($stamp1, "file"); +function dlogger($msg, $level = LOGGER_INFO) +{ + Logger::dlogger($msg, $level); } diff --git a/src/Core/Logger.php b/src/Core/Logger.php new file mode 100644 index 000000000..061343867 --- /dev/null +++ b/src/Core/Logger.php @@ -0,0 +1,142 @@ + $loglevel + ) { + return; + } + + if (count($LOGGER_LEVELS) == 0) { + foreach (get_defined_constants() as $k => $v) { + if (substr($k, 0, 7) == "LOGGER_") { + $LOGGER_LEVELS[$v] = substr($k, 7, 7); + } + } + } + + $process_id = session_id(); + + if ($process_id == '') { + $process_id = get_app()->process_id; + } + + $callers = debug_backtrace(); + + if (count($callers) > 1) { + $function = $callers[1]['function']; + } else { + $function = ''; + } + + $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", + DateTimeFormat::utcNow(DateTimeFormat::ATOM), + $process_id, + $LOGGER_LEVELS[$level], + basename($callers[0]['file']), + $callers[0]['line'], + $function, + $msg + ); + + $stamp1 = microtime(true); + @file_put_contents($logfile, $logline, FILE_APPEND); + $a->saveTimestamp($stamp1, "file"); + } + + /** + * @brief An alternative logger for development. + * Works largely as logger() but allows developers + * to isolate particular elements they are targetting + * personally without background noise + * + * log levels: + * LOGGER_WARNING + * LOGGER_INFO (default) + * LOGGER_TRACE + * LOGGER_DEBUG + * LOGGER_DATA + * LOGGER_ALL + * + * @global array $LOGGER_LEVELS + * @param string $msg + * @param int $level + */ + public static function dlogger($msg, $level = LOGGER_INFO) + { + $a = get_app(); + + $logfile = Config::get('system', 'dlogfile'); + if (!$logfile) { + return; + } + + $dlogip = Config::get('system', 'dlogip'); + if (!is_null($dlogip) && $_SERVER['REMOTE_ADDR'] != $dlogip) { + return; + } + + if (count($LOGGER_LEVELS) == 0) { + foreach (get_defined_constants() as $k => $v) { + if (substr($k, 0, 7) == "LOGGER_") { + $LOGGER_LEVELS[$v] = substr($k, 7, 7); + } + } + } + + $process_id = session_id(); + + if ($process_id == '') { + $process_id = $a->process_id; + } + + $callers = debug_backtrace(); + $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n", + DateTimeFormat::utcNow(), + $process_id, + basename($callers[0]['file']), + $callers[0]['line'], + $callers[1]['function'], + $msg + ); + + $stamp1 = microtime(true); + @file_put_contents($logfile, $logline, FILE_APPEND); + $a->saveTimestamp($stamp1, "file"); + } +} \ No newline at end of file From 14fde5dc9b1915392601fb94efc6224c01f2b216 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 29 Oct 2018 17:20:46 -0400 Subject: [PATCH 09/68] Log function implement log() function. --- bin/daemon.php | 13 +- include/api.php | 97 +++---- include/conversation.php | 3 +- include/enotify.php | 17 +- include/items.php | 17 +- include/text.php | 4 +- mod/acl.php | 3 +- mod/admin.php | 5 +- mod/crepair.php | 3 +- mod/dfrn_confirm.php | 27 +- mod/dfrn_notify.php | 49 ++-- mod/dfrn_poll.php | 21 +- mod/dfrn_request.php | 5 +- mod/display.php | 3 +- mod/events.php | 3 +- mod/filer.php | 3 +- mod/filerm.php | 3 +- mod/item.php | 23 +- mod/network.php | 3 +- mod/nodeinfo.php | 15 +- mod/openid.php | 5 +- mod/parse_url.php | 5 +- mod/photos.php | 21 +- mod/poco.php | 11 +- mod/poke.php | 5 +- mod/profile.php | 3 +- mod/pubsub.php | 27 +- mod/pubsubhubbub.php | 21 +- mod/receive.php | 17 +- mod/redir.php | 9 +- mod/register.php | 3 +- mod/salmon.php | 25 +- mod/search.php | 9 +- mod/settings.php | 5 +- mod/statistics_json.php | 3 +- mod/subthread.php | 5 +- mod/tagger.php | 7 +- mod/uimport.php | 3 +- mod/wall_upload.php | 11 +- mod/wallmessage.php | 5 +- mod/worker.php | 5 +- src/App.php | 26 +- src/BaseModule.php | 9 +- src/Content/Text/BBCode.php | 17 +- src/Core/Addon.php | 9 +- src/Core/Authentication.php | 7 +- src/Core/Cache/MemcachedCacheDriver.php | 5 +- src/Core/L10n.php | 3 +- src/Core/Lock.php | 3 +- src/Core/Logger.php | 6 +- src/Core/NotificationsManager.php | 3 +- src/Core/Session/CacheSessionHandler.php | 3 +- src/Core/Session/DatabaseSessionHandler.php | 3 +- src/Core/System.php | 5 +- src/Core/Theme.php | 7 +- src/Core/UserImport.php | 21 +- src/Core/Worker.php | 81 +++--- src/Database/DBA.php | 25 +- src/Database/DBStructure.php | 9 +- src/Database/PostUpdate.php | 39 +-- src/Model/APContact.php | 3 +- src/Model/Contact.php | 15 +- src/Model/Conversation.php | 5 +- src/Model/Event.php | 3 +- src/Model/GContact.php | 27 +- src/Model/Group.php | 3 +- src/Model/Item.php | 149 +++++------ src/Model/Mail.php | 5 +- src/Model/Profile.php | 19 +- src/Model/PushSubscriber.php | 15 +- src/Model/Queue.php | 11 +- src/Model/User.php | 5 +- src/Module/Inbox.php | 2 +- src/Module/Login.php | 7 +- src/Module/Magic.php | 11 +- src/Module/Owa.php | 9 +- src/Network/CurlResult.php | 8 +- src/Network/FKOAuth1.php | 5 +- src/Network/FKOAuthDataStore.php | 11 +- src/Network/Probe.php | 45 ++-- src/Object/Image.php | 21 +- src/Object/Post.php | 11 +- src/Object/Thread.php | 13 +- src/Protocol/ActivityPub/Processor.php | 43 +-- src/Protocol/ActivityPub/Receiver.php | 67 ++--- src/Protocol/ActivityPub/Transmitter.php | 15 +- src/Protocol/DFRN.php | 143 +++++----- src/Protocol/Diaspora.php | 279 ++++++++++---------- src/Protocol/Email.php | 13 +- src/Protocol/Feed.php | 15 +- src/Protocol/OStatus.php | 79 +++--- src/Protocol/PortableContact.php | 67 ++--- src/Protocol/Salmon.php | 15 +- src/Util/Crypto.php | 11 +- src/Util/DateTimeFormat.php | 3 +- src/Util/Emailer.php | 5 +- src/Util/HTTPSignature.php | 13 +- src/Util/JsonLD.php | 7 +- src/Util/LDSignature.php | 3 +- src/Util/Network.php | 15 +- src/Util/ParseUrl.php | 7 +- src/Util/XML.php | 13 +- src/Worker/APDelivery.php | 5 +- src/Worker/CheckVersion.php | 9 +- src/Worker/Cron.php | 9 +- src/Worker/CronJobs.php | 13 +- src/Worker/DBClean.php | 81 +++--- src/Worker/Delivery.php | 39 +-- src/Worker/Directory.php | 3 +- src/Worker/DiscoverPoCo.php | 29 +- src/Worker/Expire.php | 29 +- src/Worker/GProbe.php | 7 +- src/Worker/Notifier.php | 53 ++-- src/Worker/OnePoll.php | 85 +++--- src/Worker/ProfileUpdate.php | 5 +- src/Worker/PubSubPublish.php | 9 +- src/Worker/Queue.php | 21 +- src/Worker/SpoolPost.php | 7 +- src/Worker/TagUpdate.php | 5 +- src/Worker/UpdateGContact.php | 5 +- view/theme/frio/theme.php | 5 +- view/theme/vier/style.php | 3 +- 122 files changed, 1280 insertions(+), 1161 deletions(-) diff --git a/bin/daemon.php b/bin/daemon.php index f0f5826d9..1ae55be78 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -9,6 +9,7 @@ use Friendica\App; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -97,7 +98,7 @@ if ($mode == "stop") { unlink($pidfile); - logger("Worker daemon process $pid was killed.", LOGGER_DEBUG); + Logger::log("Worker daemon process $pid was killed.", LOGGER_DEBUG); Config::set('system', 'worker_daemon_mode', false); die("Worker daemon process $pid was killed.\n"); @@ -107,7 +108,7 @@ if (!empty($pid) && posix_kill($pid, 0)) { die("Daemon process $pid is already running.\n"); } -logger('Starting worker daemon.', LOGGER_DEBUG); +Logger::log('Starting worker daemon.', LOGGER_DEBUG); if (!$foreground) { echo "Starting worker daemon.\n"; @@ -155,7 +156,7 @@ $last_cron = 0; // Now running as a daemon. while (true) { if (!$do_cron && ($last_cron + $wait_interval) < time()) { - logger('Forcing cron worker call.', LOGGER_DEBUG); + Logger::log('Forcing cron worker call.', LOGGER_DEBUG); $do_cron = true; } @@ -169,7 +170,7 @@ while (true) { $last_cron = time(); } - logger("Sleeping", LOGGER_DEBUG); + Logger::log("Sleeping", LOGGER_DEBUG); $start = time(); do { $seconds = (time() - $start); @@ -186,10 +187,10 @@ while (true) { if ($timeout) { $do_cron = true; - logger("Woke up after $wait_interval seconds.", LOGGER_DEBUG); + Logger::log("Woke up after $wait_interval seconds.", LOGGER_DEBUG); } else { $do_cron = false; - logger("Worker jobs are calling to be forked.", LOGGER_DEBUG); + Logger::log("Worker jobs are calling to be forked.", LOGGER_DEBUG); } } diff --git a/include/api.php b/include/api.php index 86f2e3b2a..b2a91097d 100644 --- a/include/api.php +++ b/include/api.php @@ -15,6 +15,7 @@ use Friendica\Core\Addon; use Friendica\Core\Authentication; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\NotificationsManager; use Friendica\Core\PConfig; use Friendica\Core\Protocol; @@ -96,9 +97,9 @@ function api_source() return "Twidere"; } - logger("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], LOGGER_DEBUG); + Logger::log("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], LOGGER_DEBUG); } else { - logger("Empty user-agent", LOGGER_DEBUG); + Logger::log("Empty user-agent", LOGGER_DEBUG); } return "api"; @@ -180,7 +181,7 @@ function api_login(App $a) var_dump($consumer, $token); die(); } catch (Exception $e) { - logger($e); + Logger::log($e); } // workaround for HTTP-auth in CGI mode @@ -194,7 +195,7 @@ function api_login(App $a) } if (!x($_SERVER, 'PHP_AUTH_USER')) { - logger('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); throw new UnauthorizedException("This API requires login"); } @@ -235,7 +236,7 @@ function api_login(App $a) } if (!DBA::isResult($record)) { - logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); //header('HTTP/1.0 401 Unauthorized'); //die('This api requires login'); @@ -308,19 +309,19 @@ function api_call(App $a) api_login($a); } - logger('API call for ' . $a->user['username'] . ': ' . $a->query_string); - logger('API parameters: ' . print_r($_REQUEST, true)); + Logger::log('API call for ' . $a->user['username'] . ': ' . $a->query_string); + Logger::log('API parameters: ' . print_r($_REQUEST, true)); $stamp = microtime(true); $return = call_user_func($info['func'], $type); $duration = (float) (microtime(true) - $stamp); - logger("API call duration: " . round($duration, 2) . "\t" . $a->query_string, LOGGER_DEBUG); + Logger::log("API call duration: " . round($duration, 2) . "\t" . $a->query_string, LOGGER_DEBUG); if (Config::get("system", "profiler")) { $duration = microtime(true)-$a->performance["start"]; /// @TODO round() really everywhere? - logger( + Logger::log( parse_url($a->query_string, PHP_URL_PATH) . ": " . sprintf( "Database: %s/%s, Cache %s/%s, Network: %s, I/O: %s, Other: %s, Total: %s", round($a->performance["database"] - $a->performance["database_write"], 3), @@ -375,7 +376,7 @@ function api_call(App $a) $o .= $func . ": " . $time . "\n"; } } - logger($o, LOGGER_DEBUG); + Logger::log($o, LOGGER_DEBUG); } } @@ -412,7 +413,7 @@ function api_call(App $a) } } - logger('API call not implemented: ' . $a->query_string); + Logger::log('API call not implemented: ' . $a->query_string); throw new NotImplementedException(); } catch (HTTPException $e) { header("HTTP/1.1 {$e->httpcode} {$e->httpdesc}"); @@ -521,7 +522,7 @@ function api_get_user(App $a, $contact_id = null) $extra_query = ""; $url = ""; - logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG); + Logger::log("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG); // Searching for contact URL if (!is_null($contact_id) && (intval($contact_id) == 0)) { @@ -605,7 +606,7 @@ function api_get_user(App $a, $contact_id = null) } } - logger("api_get_user: user ".$user, LOGGER_DEBUG); + Logger::log("api_get_user: user ".$user, LOGGER_DEBUG); if (!$user) { if (api_user() === false) { @@ -617,7 +618,7 @@ function api_get_user(App $a, $contact_id = null) } } - logger('api_user: ' . $extra_query . ', user: ' . $user); + Logger::log('api_user: ' . $extra_query . ', user: ' . $user); // user info $uinfo = q( @@ -1033,7 +1034,7 @@ function api_statuses_mediap($type) $a = get_app(); if (api_user() === false) { - logger('api_statuses_update: no user'); + Logger::log('api_statuses_update: no user'); throw new ForbiddenException(); } $user_info = api_get_user($a); @@ -1081,7 +1082,7 @@ function api_statuses_update($type) $a = get_app(); if (api_user() === false) { - logger('api_statuses_update: no user'); + Logger::log('api_statuses_update: no user'); throw new ForbiddenException(); } @@ -1135,7 +1136,7 @@ function api_statuses_update($type) $posts_day = DBA::count('thread', $condition); if ($posts_day > $throttle_day) { - logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG); + Logger::log('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG); // die(api_error($type, L10n::t("Daily posting limit of %d posts reached. The post was rejected.", $throttle_day)); throw new TooManyRequestsException(L10n::tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day)); } @@ -1149,7 +1150,7 @@ function api_statuses_update($type) $posts_week = DBA::count('thread', $condition); if ($posts_week > $throttle_week) { - logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG); + Logger::log('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG); // die(api_error($type, L10n::t("Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week))); throw new TooManyRequestsException(L10n::tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week)); } @@ -1163,7 +1164,7 @@ function api_statuses_update($type) $posts_month = DBA::count('thread', $condition); if ($posts_month > $throttle_month) { - logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG); + Logger::log('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG); // die(api_error($type, L10n::t("Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month)); throw new TooManyRequestsException(L10n::t("Monthly posting limit of %d post reached. The post was rejected.", "Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month)); } @@ -1223,7 +1224,7 @@ function api_media_upload() $a = get_app(); if (api_user() === false) { - logger('no user'); + Logger::log('no user'); throw new ForbiddenException(); } @@ -1248,7 +1249,7 @@ function api_media_upload() "h" => $media["height"], "image_type" => $media["type"]]; - logger("Media uploaded: " . print_r($returndata, true), LOGGER_DEBUG); + Logger::log("Media uploaded: " . print_r($returndata, true), LOGGER_DEBUG); return ["media" => $returndata]; } @@ -1268,7 +1269,7 @@ function api_status_show($type, $item_id = 0) $user_info = api_get_user($a); - logger('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG); + Logger::log('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG); if ($type == "raw") { $privacy_sql = "AND NOT `private`"; @@ -1344,7 +1345,7 @@ function api_status_show($type, $item_id = 0) unset($status_info["user"]["uid"]); unset($status_info["user"]["self"]); - logger('status_info: '.print_r($status_info, true), LOGGER_DEBUG); + Logger::log('status_info: '.print_r($status_info, true), LOGGER_DEBUG); if ($type == "raw") { return $status_info; @@ -1824,7 +1825,7 @@ function api_statuses_show($type) $id = intval(defaults($a->argv, 4, 0)); } - logger('API: api_statuses_show: ' . $id); + Logger::log('API: api_statuses_show: ' . $id); $conversation = !empty($_REQUEST['conversation']); @@ -1906,7 +1907,7 @@ function api_conversation_show($type) $id = intval(defaults($a->argv, 4, 0)); } - logger('API: api_conversation_show: '.$id); + Logger::log('API: api_conversation_show: '.$id); // try to fetch the item for the local user - or the public item, if there is no local one $item = Item::selectFirst(['parent-uri'], ['id' => $id]); @@ -1977,7 +1978,7 @@ function api_statuses_repeat($type) $id = intval(defaults($a->argv, 4, 0)); } - logger('API: api_statuses_repeat: '.$id); + Logger::log('API: api_statuses_repeat: '.$id); $fields = ['body', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink']; $item = Item::selectFirst($fields, ['id' => $id, 'private' => false]); @@ -2042,7 +2043,7 @@ function api_statuses_destroy($type) $id = intval(defaults($a->argv, 4, 0)); } - logger('API: api_statuses_destroy: '.$id); + Logger::log('API: api_statuses_destroy: '.$id); $ret = api_statuses_show($type); @@ -2137,7 +2138,7 @@ function api_statuses_user_timeline($type) throw new ForbiddenException(); } - logger( + Logger::log( "api_statuses_user_timeline: api_user: ". api_user() . "\nuser_info: ".print_r($user_info, true) . "\n_REQUEST: ".print_r($_REQUEST, true), @@ -2294,7 +2295,7 @@ function api_favorites($type) // in friendica starred item are private // return favorites only for self - logger('api_favorites: self:' . $user_info['self']); + Logger::log('api_favorites: self:' . $user_info['self']); if ($user_info['self'] == 0) { $ret = []; @@ -3649,7 +3650,7 @@ function api_friendships_destroy($type) $contact_id = defaults($_REQUEST, 'user_id'); if (empty($contact_id)) { - logger("No user_id specified", LOGGER_DEBUG); + Logger::log("No user_id specified", LOGGER_DEBUG); throw new BadRequestException("no user_id specified"); } @@ -3657,7 +3658,7 @@ function api_friendships_destroy($type) $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => 0, 'self' => false]); if(!DBA::isResult($contact)) { - logger("No contact found for ID" . $contact_id, LOGGER_DEBUG); + Logger::log("No contact found for ID" . $contact_id, LOGGER_DEBUG); throw new NotFoundException("no contact found to given ID"); } @@ -3669,12 +3670,12 @@ function api_friendships_destroy($type) $contact = DBA::selectFirst('contact', [], $condition); if (!DBA::isResult($contact)) { - logger("Not following Contact", LOGGER_DEBUG); + Logger::log("Not following Contact", LOGGER_DEBUG); throw new NotFoundException("Not following Contact"); } if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { - logger("Not supported", LOGGER_DEBUG); + Logger::log("Not supported", LOGGER_DEBUG); throw new ExpectationFailedException("Not supported"); } @@ -3685,7 +3686,7 @@ function api_friendships_destroy($type) Contact::terminateFriendship($owner, $contact, $dissolve); } else { - logger("No owner found", LOGGER_DEBUG); + Logger::log("No owner found", LOGGER_DEBUG); throw new NotFoundException("Error Processing Request"); } @@ -4485,7 +4486,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ if ($imagedata) { $filetype = $imagedata['mime']; } - logger( + Logger::log( "File upload src: " . $src . " - filename: " . $filename . " - size: " . $filesize . " - type: " . $filetype, LOGGER_DEBUG @@ -4520,7 +4521,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ } if ($max_length > 0) { $Image->scaleDown($max_length); - logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG); + Logger::log("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG); } $width = $Image->getWidth(); $height = $Image->getHeight(); @@ -4530,17 +4531,17 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ if ($mediatype == "photo") { // upload normal image (scales 0, 1, 2) - logger("photo upload: starting new photo upload", LOGGER_DEBUG); + Logger::log("photo upload: starting new photo upload", LOGGER_DEBUG); $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 0, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - logger("photo upload: image upload with scale 0 (original size) failed"); + Logger::log("photo upload: image upload with scale 0 (original size) failed"); } if ($width > 640 || $height > 640) { $Image->scaleDown(640); $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 1, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - logger("photo upload: image upload with scale 1 (640x640) failed"); + Logger::log("photo upload: image upload with scale 1 (640x640) failed"); } } @@ -4548,19 +4549,19 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ $Image->scaleDown(320); $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 2, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - logger("photo upload: image upload with scale 2 (320x320) failed"); + Logger::log("photo upload: image upload with scale 2 (320x320) failed"); } } - logger("photo upload: new photo upload ended", LOGGER_DEBUG); + Logger::log("photo upload: new photo upload ended", LOGGER_DEBUG); } elseif ($mediatype == "profileimage") { // upload profile image (scales 4, 5, 6) - logger("photo upload: starting new profile image upload", LOGGER_DEBUG); + Logger::log("photo upload: starting new profile image upload", LOGGER_DEBUG); if ($width > 300 || $height > 300) { $Image->scaleDown(300); $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 4, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - logger("photo upload: profile image upload with scale 4 (300x300) failed"); + Logger::log("photo upload: profile image upload with scale 4 (300x300) failed"); } } @@ -4568,7 +4569,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ $Image->scaleDown(80); $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 5, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - logger("photo upload: profile image upload with scale 5 (80x80) failed"); + Logger::log("photo upload: profile image upload with scale 5 (80x80) failed"); } } @@ -4576,11 +4577,11 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ $Image->scaleDown(48); $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 6, $profile, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { - logger("photo upload: profile image upload with scale 6 (48x48) failed"); + Logger::log("photo upload: profile image upload with scale 6 (48x48) failed"); } } $Image->__destruct(); - logger("photo upload: new profile image upload ended", LOGGER_DEBUG); + Logger::log("photo upload: new profile image upload ended", LOGGER_DEBUG); } if (isset($r) && $r) { @@ -4807,7 +4808,7 @@ function api_friendica_remoteauth() 'sec' => $sec, 'expire' => time() + 45]; DBA::insert('profile_check', $fields); - logger($contact['name'] . ' ' . $sec, LOGGER_DEBUG); + Logger::log($contact['name'] . ' ' . $sec, LOGGER_DEBUG); $dest = ($url ? '&destination_url=' . $url : ''); System::externalRedirect( @@ -5055,7 +5056,7 @@ function api_in_reply_to($item) // https://github.com/friendica/friendica/issues/1010 // This is a bugfix for that. if (intval($in_reply_to['status_id']) == intval($item['id'])) { - logger('this message should never appear: id: '.$item['id'].' similar to reply-to: '.$in_reply_to['status_id'], LOGGER_DEBUG); + Logger::log('this message should never appear: id: '.$item['id'].' similar to reply-to: '.$in_reply_to['status_id'], LOGGER_DEBUG); $in_reply_to['status_id'] = null; $in_reply_to['user_id'] = null; $in_reply_to['status_id_str'] = null; diff --git a/include/conversation.php b/include/conversation.php index 27cbd4289..47adfc0df 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -11,6 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -751,7 +752,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ $threads = $conv->getTemplateData($conv_responses); if (!$threads) { - logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); + Logger::log('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); $threads = []; } } diff --git a/include/enotify.php b/include/enotify.php index 5665f485f..fe2cc1f33 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -7,6 +7,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; @@ -29,7 +30,7 @@ function notification($params) // Temporary logging for finding the origin if (!isset($params['language']) || !isset($params['uid'])) { - logger('Missing parameters.' . System::callstack()); + Logger::log('Missing parameters.' . System::callstack()); } // Ensure that the important fields are set at any time @@ -37,7 +38,7 @@ function notification($params) $user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]); if (!DBA::isResult($user)) { - logger('Unknown user ' . $params['uid']); + Logger::log('Unknown user ' . $params['uid']); return; } @@ -133,7 +134,7 @@ function notification($params) if ($params['type'] == NOTIFY_COMMENT) { $thread = Item::selectFirstThreadForUser($params['uid'] ,['ignored'], ['iid' => $parent_id]); if (DBA::isResult($thread) && $thread["ignored"]) { - logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG); + Logger::log("Thread ".$parent_id." will be ignored", LOGGER_DEBUG); L10n::popLang(); return; } @@ -452,7 +453,7 @@ function notification($params) $itemlink = $h['itemlink']; if ($show_in_notification_page) { - logger("adding notification entry", LOGGER_DEBUG); + Logger::log("adding notification entry", LOGGER_DEBUG); do { $dups = false; $hash = random_string(); @@ -529,14 +530,14 @@ function notification($params) || $params['type'] == NOTIFY_SYSTEM || $params['type'] == SYSTEM_EMAIL) { - logger('sending notification email'); + Logger::log('sending notification email'); if (isset($params['parent']) && (intval($params['parent']) != 0)) { $id_for_parent = $params['parent']."@".$hostname; // Is this the first email notification for this parent item and user? if (!DBA::exists('notify-threads', ['master-parent-item' => $params['parent'], 'receiver-uid' => $params['uid']])) { - logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG); + Logger::log("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG); $fields = ['notify-id' => $notify_id, 'master-parent-item' => $params['parent'], 'receiver-uid' => $params['uid'], 'parent-item' => 0]; @@ -545,11 +546,11 @@ function notification($params) $additional_mail_header .= "Message-ID: <${id_for_parent}>\n"; $log_msg = "include/enotify: No previous notification found for this parent:\n". " parent: ${params['parent']}\n"." uid : ${params['uid']}\n"; - logger($log_msg, LOGGER_DEBUG); + Logger::log($log_msg, LOGGER_DEBUG); } else { // If not, just "follow" the thread. $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n"; - logger("There's already a notification for this parent.", LOGGER_DEBUG); + Logger::log("There's already a notification for this parent.", LOGGER_DEBUG); } } diff --git a/include/items.php b/include/items.php index 54ae7a82c..72ae3a8e8 100644 --- a/include/items.php +++ b/include/items.php @@ -8,6 +8,7 @@ use Friendica\Content\Feature; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -109,7 +110,7 @@ function query_page_info($url, $photo = "", $keywords = false, $keyword_blacklis $data["images"][0]["src"] = $photo; } - logger('fetch page info for ' . $url . ' ' . print_r($data, true), LOGGER_DEBUG); + Logger::log('fetch page info for ' . $url . ' ' . print_r($data, true), LOGGER_DEBUG); if (!$keywords && isset($data["keywords"])) { unset($data["keywords"]); @@ -167,7 +168,7 @@ function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, function add_page_info_to_body($body, $texturl = false, $no_photos = false) { - logger('add_page_info_to_body: fetch page info for body ' . $body, LOGGER_DEBUG); + Logger::log('add_page_info_to_body: fetch page info for body ' . $body, LOGGER_DEBUG); $URLSearchString = "^\[\]"; @@ -251,7 +252,7 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0 // Test - remove before flight //$tempfile = tempnam(get_temppath(), "ostatus2"); //file_put_contents($tempfile, $xml); - logger("Consume OStatus messages ", LOGGER_DEBUG); + Logger::log("Consume OStatus messages ", LOGGER_DEBUG); OStatus::import($xml, $importer, $contact, $hub); } @@ -260,7 +261,7 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0 if ($contact['network'] === Protocol::FEED) { if ($pass < 2) { - logger("Consume feeds", LOGGER_DEBUG); + Logger::log("Consume feeds", LOGGER_DEBUG); Feed::import($xml, $importer, $contact, $hub); } @@ -268,10 +269,10 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0 } if ($contact['network'] === Protocol::DFRN) { - logger("Consume DFRN messages", LOGGER_DEBUG); + Logger::log("Consume DFRN messages", LOGGER_DEBUG); $dfrn_importer = DFRN::getImporter($contact["id"], $importer["uid"]); if (!empty($dfrn_importer)) { - logger("Now import the DFRN feed"); + Logger::log("Now import the DFRN feed"); DFRN::import($xml, $dfrn_importer, true); return; } @@ -310,7 +311,7 @@ function subscribe_to_hub($url, array $importer, array $contact, $hubmode = 'sub $params= 'hub.mode=' . $hubmode . '&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token; - logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token); + Logger::log('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token); if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) { DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]); @@ -318,7 +319,7 @@ function subscribe_to_hub($url, array $importer, array $contact, $hubmode = 'sub $postResult = Network::post($url, $params); - logger('subscribe_to_hub: returns: ' . $postResult->getReturnCode(), LOGGER_DEBUG); + Logger::log('subscribe_to_hub: returns: ' . $postResult->getReturnCode(), LOGGER_DEBUG); return; diff --git a/include/text.php b/include/text.php index d8546e2e8..48351f59e 100644 --- a/include/text.php +++ b/include/text.php @@ -399,7 +399,7 @@ function attribute_contains($attr, $s) { */ function logger($msg, $level = LOGGER_INFO) { - Logger::logger($msg, $level); + Logger::log($msg, $level); } /** @@ -422,7 +422,7 @@ function logger($msg, $level = LOGGER_INFO) */ function dlogger($msg, $level = LOGGER_INFO) { - Logger::dlogger($msg, $level); + Logger::devLog($msg, $level); } diff --git a/mod/acl.php b/mod/acl.php index 48c45f293..36cfd42e7 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Content\Widget; use Friendica\Core\ACL; use Friendica\Core\Addon; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model\Contact; @@ -34,7 +35,7 @@ function acl_content(App $a) $search = $_REQUEST['query']; } - logger("Searching for ".$search." - type ".$type." conversation ".$conv_id, LOGGER_DEBUG); + Logger::log("Searching for ".$search." - type ".$type." conversation ".$conv_id, LOGGER_DEBUG); if ($search != '') { $sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'"; diff --git a/mod/admin.php b/mod/admin.php index 5de292916..8d19f01e3 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -13,6 +13,7 @@ use Friendica\Content\Text\Markdown; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Theme; use Friendica\Core\Worker; @@ -910,7 +911,7 @@ function admin_page_summary(App $a) $users+= $u['count']; } - logger('accounts: ' . print_r($accounts, true), LOGGER_DATA); + Logger::log('accounts: ' . print_r($accounts, true), LOGGER_DATA); $pending = Register::getPendingCount(); @@ -2499,7 +2500,7 @@ function admin_page_features_post(App $a) { BaseModule::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features'); - logger('postvars: ' . print_r($_POST, true), LOGGER_DATA); + Logger::log('postvars: ' . print_r($_POST, true), LOGGER_DATA); $features = Feature::get(false); diff --git a/mod/crepair.php b/mod/crepair.php index 1cf562d64..1ca04af50 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model; @@ -78,7 +79,7 @@ function crepair_post(App $a) ); if ($photo) { - logger('mod-crepair: updating photo from ' . $photo); + Logger::log('mod-crepair: updating photo from ' . $photo); Model\Contact::updateAvatar($photo, local_user(), $contact['id']); } diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index c41105966..8c897c76d 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -20,6 +20,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -76,7 +77,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) // These data elements may come from either the friend request notification form or $handsfree array. if (is_array($handsfree)) { - logger('Confirm in handsfree mode'); + Logger::log('Confirm in handsfree mode'); $dfrn_id = $handsfree['dfrn_id']; $intro_id = $handsfree['intro_id']; $duplex = $handsfree['duplex']; @@ -99,9 +100,9 @@ function dfrn_confirm_post(App $a, $handsfree = null) $cid = 0; } - logger('Confirming request for dfrn_id (issued) ' . $dfrn_id); + Logger::log('Confirming request for dfrn_id (issued) ' . $dfrn_id); if ($cid) { - logger('Confirming follower with contact_id: ' . $cid); + Logger::log('Confirming follower with contact_id: ' . $cid); } /* @@ -124,7 +125,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) intval($uid) ); if (!DBA::isResult($r)) { - logger('Contact not found in DB.'); + Logger::log('Contact not found in DB.'); notice(L10n::t('Contact not found.') . EOL); notice(L10n::t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL); return; @@ -211,7 +212,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) $params['page'] = 2; } - logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params, true), LOGGER_DATA); + Logger::log('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params, true), LOGGER_DATA); /* * @@ -223,7 +224,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) $res = Network::post($dfrn_confirm, $params, null, $redirects, 120)->getBody(); - logger(' Confirm: received data: ' . $res, LOGGER_DATA); + Logger::log(' Confirm: received data: ' . $res, LOGGER_DATA); // Now figure out what they responded. Try to be robust if the remote site is // having difficulty and throwing up errors of some kind. @@ -248,7 +249,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) if (stristr($res, " $dfrn_id, 'challenge' => $challenge])) { - logger('could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge); + Logger::log('could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge); System::xmlExit(3, 'Could not match challenge'); } @@ -71,7 +72,7 @@ function dfrn_notify_post(App $a) { $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]); if (!DBA::isResult($user)) { - logger('User not found for nickname ' . $a->argv[1]); + Logger::log('User not found for nickname ' . $a->argv[1]); System::xmlExit(3, 'User not found'); } @@ -94,7 +95,7 @@ function dfrn_notify_post(App $a) { $contact = DBA::selectFirst('contact', ['id'], $condition); if (!DBA::isResult($contact)) { - logger('contact not found for dfrn_id ' . $dfrn_id); + Logger::log('contact not found for dfrn_id ' . $dfrn_id); System::xmlExit(3, 'Contact not found'); } @@ -117,12 +118,12 @@ function dfrn_notify_post(App $a) { $importer = Contact::updateSslPolicy($importer, $ssl_policy); - logger('data: ' . $data, LOGGER_DATA); + Logger::log('data: ' . $data, LOGGER_DATA); if ($dissolve == 1) { // Relationship is dissolved permanently Contact::remove($importer['id']); - logger('relationship dissolved : ' . $importer['name'] . ' dissolved ' . $importer['username']); + Logger::log('relationship dissolved : ' . $importer['name'] . ' dissolved ' . $importer['username']); System::xmlExit(0, 'relationship dissolved'); } @@ -134,12 +135,12 @@ function dfrn_notify_post(App $a) { // if local rino is lower than remote rino, abort: should not happen! // but only for $remote_rino > 1, because old code did't send rino version if ($rino_remote > 1 && $rino < $rino_remote) { - logger("rino version '$rino_remote' is lower than supported '$rino'"); + Logger::log("rino version '$rino_remote' is lower than supported '$rino'"); System::xmlExit(0, "rino version '$rino_remote' is lower than supported '$rino'"); } $rawkey = hex2bin(trim($key)); - logger('rino: md5 raw key: ' . md5($rawkey), LOGGER_DATA); + Logger::log('rino: md5 raw key: ' . md5($rawkey), LOGGER_DATA); $final_key = ''; @@ -165,14 +166,14 @@ function dfrn_notify_post(App $a) { $data = DFRN::aesDecrypt(hex2bin($data), $final_key); break; default: - logger("rino: invalid sent version '$rino_remote'"); + Logger::log("rino: invalid sent version '$rino_remote'"); System::xmlExit(0, "Invalid sent version '$rino_remote'"); } - logger('rino: decrypted data: ' . $data, LOGGER_DATA); + Logger::log('rino: decrypted data: ' . $data, LOGGER_DATA); } - logger('Importing post from ' . $importer['addr'] . ' to ' . $importer['nickname'] . ' with the RINO ' . $rino_remote . ' encryption.', LOGGER_DEBUG); + Logger::log('Importing post from ' . $importer['addr'] . ' to ' . $importer['nickname'] . ' with the RINO ' . $rino_remote . ' encryption.', LOGGER_DEBUG); $ret = DFRN::import($data, $importer); System::xmlExit($ret, 'Processed'); @@ -191,7 +192,7 @@ function dfrn_dispatch_public($postdata) // Fetch the corresponding public contact $contact = Contact::getDetailsByAddr($msg['author'], 0); if (!$contact) { - logger('Contact not found for address ' . $msg['author']); + Logger::log('Contact not found for address ' . $msg['author']); System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } @@ -199,11 +200,11 @@ function dfrn_dispatch_public($postdata) // This should never fail if (empty($importer)) { - logger('Contact not found for address ' . $msg['author']); + Logger::log('Contact not found for address ' . $msg['author']); System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } - logger('Importing post from ' . $msg['author'] . ' with the public envelope.', LOGGER_DEBUG); + Logger::log('Importing post from ' . $msg['author'] . ' with the public envelope.', LOGGER_DEBUG); // Now we should be able to import it $ret = DFRN::import($msg['message'], $importer); @@ -223,7 +224,7 @@ function dfrn_dispatch_private($user, $postdata) // Otherwise there should be a public contact $cid = Contact::getIdForURL($msg['author']); if (!$cid) { - logger('Contact not found for address ' . $msg['author']); + Logger::log('Contact not found for address ' . $msg['author']); System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } } @@ -232,11 +233,11 @@ function dfrn_dispatch_private($user, $postdata) // This should never fail if (empty($importer)) { - logger('Contact not found for address ' . $msg['author']); + Logger::log('Contact not found for address ' . $msg['author']); System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } - logger('Importing post from ' . $msg['author'] . ' to ' . $user['nickname'] . ' with the private envelope.', LOGGER_DEBUG); + Logger::log('Importing post from ' . $msg['author'] . ' to ' . $user['nickname'] . ' with the private envelope.', LOGGER_DEBUG); // Now we should be able to import it $ret = DFRN::import($msg['message'], $importer); @@ -258,7 +259,7 @@ function dfrn_notify_content(App $a) { $type = ""; $last_update = ""; - logger('new notification dfrn_id=' . $dfrn_id); + Logger::log('new notification dfrn_id=' . $dfrn_id); $direction = (-1); if (strpos($dfrn_id,':') == 1) { @@ -276,11 +277,11 @@ function dfrn_notify_content(App $a) { 'type' => $type, 'last_update' => $last_update]; DBA::insert('challenge', $fields); - logger('challenge=' . $hash, LOGGER_DATA); + Logger::log('challenge=' . $hash, LOGGER_DATA); $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]); if (!DBA::isResult($user)) { - logger('User not found for nickname ' . $a->argv[1]); + Logger::log('User not found for nickname ' . $a->argv[1]); killme(); } @@ -305,18 +306,18 @@ function dfrn_notify_content(App $a) { $contact = DBA::selectFirst('contact', ['id'], $condition); if (!DBA::isResult($contact)) { - logger('contact not found for dfrn_id ' . $dfrn_id); + Logger::log('contact not found for dfrn_id ' . $dfrn_id); System::xmlExit(3, 'Contact not found'); } // $importer in this case contains the contact record for the remote contact joined with the user record of our user. $importer = DFRN::getImporter($contact['id'], $user['uid']); if (empty($importer)) { - logger('No importer data found for user ' . $a->argv[1] . ' and contact ' . $dfrn_id); + Logger::log('No importer data found for user ' . $a->argv[1] . ' and contact ' . $dfrn_id); killme(); } - logger("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DATA); + Logger::log("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DATA); $challenge = ''; $encrypted_id = ''; @@ -344,7 +345,7 @@ function dfrn_notify_content(App $a) { $rino = Config::get('system', 'rino_encrypt'); $rino = intval($rino); - logger("Local rino version: ". $rino, LOGGER_DATA); + Logger::log("Local rino version: ". $rino, LOGGER_DATA); // if requested rino is lower than enabled local rino, lower local rino version // if requested rino is higher than enabled local rino, reply with local rino diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 354cf6b4c..814bd555c 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -7,6 +7,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Module\Login; @@ -68,7 +69,7 @@ function dfrn_poll_init(App $a) $user = $r[0]['nickname']; } - logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user); + Logger::log('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user); header("Content-type: application/atom+xml"); echo DFRN::feed('', $user, $last_update, 0, $hidewall); killme(); @@ -104,7 +105,7 @@ function dfrn_poll_init(App $a) if (DBA::isResult($r)) { $s = Network::fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check'); - logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA); + Logger::log("dfrn_poll: old profile returns " . $s, LOGGER_DATA); if (strlen($s)) { $xml = XML::parseString($s); @@ -191,7 +192,7 @@ function dfrn_poll_init(App $a) } if ($final_dfrn_id != $orig_id) { - logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); + Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); // did not decode properly - cannot trust this site System::xmlExit(3, 'Bad decryption'); } @@ -238,7 +239,7 @@ function dfrn_poll_post(App $a) if ($ptype === 'profile-check') { if (strlen($challenge) && strlen($sec)) { - logger('dfrn_poll: POST: profile-check'); + Logger::log('dfrn_poll: POST: profile-check'); DBA::delete('profile_check', ["`expire` < ?", time()]); $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", @@ -283,7 +284,7 @@ function dfrn_poll_post(App $a) } if ($final_dfrn_id != $orig_id) { - logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); + Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); // did not decode properly - cannot trust this site System::xmlExit(3, 'Bad decryption'); } @@ -372,7 +373,7 @@ function dfrn_poll_post(App $a) // NOTREACHED } else { // Update the writable flag if it changed - logger('dfrn_poll: post request feed: ' . print_r($_POST, true), LOGGER_DATA); + Logger::log('dfrn_poll: post request feed: ' . print_r($_POST, true), LOGGER_DATA); if ($dfrn_version >= 2.21) { if ($perm === 'rw') { $writable = 1; @@ -510,15 +511,15 @@ function dfrn_poll_content(App $a) ])->getBody(); } - logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); + Logger::log("dfrn_poll: sec profile: " . $s, LOGGER_DATA); if (strlen($s) && strstr($s, 'challenge . ' expecting ' . $hash); - logger('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec); + Logger::log('dfrn_poll: secure profile: challenge: ' . $xml->challenge . ' expecting ' . $hash); + Logger::log('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec); if (((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) { $_SESSION['authenticated'] = 1; diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 141e5e5ac..d49975a1f 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -15,6 +15,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -57,7 +58,7 @@ function dfrn_request_init(App $a) function dfrn_request_post(App $a) { if (($a->argc != 2) || (!count($a->profile))) { - logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); + Logger::log('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); return; } @@ -297,7 +298,7 @@ function dfrn_request_post(App $a) $network = Protocol::DFRN; } - logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG); + Logger::log('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG); if ($network === Protocol::DFRN) { $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", diff --git a/mod/display.php b/mod/display.php index e4a17804b..aeab0aae5 100644 --- a/mod/display.php +++ b/mod/display.php @@ -10,6 +10,7 @@ use Friendica\Content\Text\HTML; use Friendica\Core\ACL; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -74,7 +75,7 @@ function display_init(App $a) } if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) { - logger('Directly serving XML for id '.$item["id"], LOGGER_DEBUG); + Logger::log('Directly serving XML for id '.$item["id"], LOGGER_DEBUG); displayShowFeed($item["id"], false); } diff --git a/mod/events.php b/mod/events.php index 81ab79c72..0e582c52d 100644 --- a/mod/events.php +++ b/mod/events.php @@ -9,6 +9,7 @@ use Friendica\Content\Nav; use Friendica\Content\Widget\CalendarExport; use Friendica\Core\ACL; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -47,7 +48,7 @@ function events_init(App $a) function events_post(App $a) { - logger('post: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('post: ' . print_r($_REQUEST, true), LOGGER_DATA); if (!local_user()) { return; diff --git a/mod/filer.php b/mod/filer.php index d8c89f855..cd2a41dfd 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -4,6 +4,7 @@ */ use Friendica\App; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; require_once 'include/items.php'; @@ -17,7 +18,7 @@ function filer_content(App $a) $term = unxmlify(trim(defaults($_GET, 'term', ''))); $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); - logger('filer: tag ' . $term . ' item ' . $item_id); + Logger::log('filer: tag ' . $term . ' item ' . $item_id); if ($item_id && strlen($term)) { // file item diff --git a/mod/filerm.php b/mod/filerm.php index 733d67b59..18908c3bb 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -1,6 +1,7 @@ argc > 1) ? intval($a->argv[1]) : 0); - logger('filerm: tag ' . $term . ' item ' . $item_id); + Logger::log('filerm: tag ' . $term . ' item ' . $item_id); if ($item_id && strlen($term)) { file_tag_unsave_file(local_user(),$item_id,$term, $category); diff --git a/mod/item.php b/mod/item.php index 34174a36d..ce00562a8 100644 --- a/mod/item.php +++ b/mod/item.php @@ -22,6 +22,7 @@ use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Core\Worker; @@ -56,7 +57,7 @@ function item_post(App $a) { Addon::callHooks('post_local_start', $_REQUEST); - logger('postvars ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('postvars ' . print_r($_REQUEST, true), LOGGER_DATA); $api_source = defaults($_REQUEST, 'api_source', false); @@ -72,7 +73,7 @@ function item_post(App $a) { */ if (!$preview && !empty($_REQUEST['post_id_random'])) { if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { - logger("item post: duplicate post", LOGGER_DEBUG); + Logger::log("item post: duplicate post", LOGGER_DEBUG); item_post_return(System::baseUrl(), $api_source, $return_path); } else { $_SESSION['post-random'] = $_REQUEST['post_id_random']; @@ -130,7 +131,7 @@ function item_post(App $a) { } if ($parent) { - logger('mod_item: item_post parent=' . $parent); + Logger::log('mod_item: item_post parent=' . $parent); } $post_id = intval(defaults($_REQUEST, 'post_id', 0)); @@ -153,7 +154,7 @@ function item_post(App $a) { // Check for multiple posts with the same message id (when the post was created via API) if (($message_id != '') && ($profile_uid != 0)) { if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) { - logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG); + Logger::log("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG); return 0; } } @@ -669,7 +670,7 @@ function item_post(App $a) { $datarray["author-network"] = Protocol::DFRN; $o = conversation($a, [array_merge($contact_record, $datarray)], new Pager($a->query_string), 'search', false, true); - logger('preview: ' . $o); + Logger::log('preview: ' . $o); echo json_encode(['preview' => $o]); exit(); } @@ -677,7 +678,7 @@ function item_post(App $a) { Addon::callHooks('post_local',$datarray); if (!empty($datarray['cancel'])) { - logger('mod_item: post cancelled by addon.'); + Logger::log('mod_item: post cancelled by addon.'); if ($return_path) { $a->internalRedirect($return_path); } @@ -714,7 +715,7 @@ function item_post(App $a) { file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); if (!empty($_REQUEST['return']) && strlen($return_path)) { - logger('return: ' . $return_path); + Logger::log('return: ' . $return_path); $a->internalRedirect($return_path); } killme(); @@ -736,14 +737,14 @@ function item_post(App $a) { $post_id = Item::insert($datarray); if (!$post_id) { - logger("Item wasn't stored."); + Logger::log("Item wasn't stored."); $a->internalRedirect($return_path); } $datarray = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); if (!DBA::isResult($datarray)) { - logger("Item with id ".$post_id." couldn't be fetched."); + Logger::log("Item with id ".$post_id." couldn't be fetched."); $a->internalRedirect($return_path); } @@ -833,7 +834,7 @@ function item_post(App $a) { // We don't fork a new process since this is done anyway with the following command Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "CreateShadowEntry", $post_id); - logger('post_complete'); + Logger::log('post_complete'); if ($api_source) { return $post_id; @@ -861,7 +862,7 @@ function item_post_return($baseurl, $api_source, $return_path) $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload']; } - logger('post_json: ' . print_r($json, true), LOGGER_DEBUG); + Logger::log('post_json: ' . print_r($json, true), LOGGER_DEBUG); echo json_encode($json); killme(); diff --git a/mod/network.php b/mod/network.php index 6f02e8c11..6ba353d7e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -15,6 +15,7 @@ use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -871,7 +872,7 @@ function networkThreadedView(App $a, $update, $parent) $_SESSION['network_last_date'] = $tag_top_limit; } - logger('Tagged items: ' . count($data) . ' - ' . $bottom_limit . ' - ' . $top_limit . ' - ' . local_user().' - '.(int)$update); + Logger::log('Tagged items: ' . count($data) . ' - ' . $bottom_limit . ' - ' . $top_limit . ' - ' . local_user().' - '.(int)$update); $s = []; foreach ($r as $item) { $s[$item['uri']] = $item; diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index ed0166838..7b747be21 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -8,6 +8,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Util\Network; @@ -172,7 +173,7 @@ function nodeinfo_cron() { return; } - logger('cron_start'); + Logger::log('cron_start'); $users = q("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item` FROM `user` @@ -203,22 +204,22 @@ function nodeinfo_cron() { Config::set('nodeinfo', 'active_users_halfyear', $active_users_halfyear); Config::set('nodeinfo', 'active_users_monthly', $active_users_monthly); - logger('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, LOGGER_DEBUG); + Logger::log('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, LOGGER_DEBUG); } $local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]); Config::set('nodeinfo', 'local_posts', $local_posts); - logger('local_posts: ' . $local_posts, LOGGER_DEBUG); + Logger::log('local_posts: ' . $local_posts, LOGGER_DEBUG); $local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]); Config::set('nodeinfo', 'local_comments', $local_comments); - logger('local_comments: ' . $local_comments, LOGGER_DEBUG); + Logger::log('local_comments: ' . $local_comments, LOGGER_DEBUG); // Now trying to register $url = 'http://the-federation.info/register/'.$a->getHostName(); - logger('registering url: '.$url, LOGGER_DEBUG); + Logger::log('registering url: '.$url, LOGGER_DEBUG); $ret = Network::fetchUrl($url); - logger('registering answer: '.$ret, LOGGER_DEBUG); + Logger::log('registering answer: '.$ret, LOGGER_DEBUG); - logger('cron_end'); + Logger::log('cron_end'); } diff --git a/mod/openid.php b/mod/openid.php index 93a07a4b4..e97607304 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -7,6 +7,7 @@ use Friendica\App; use Friendica\Core\Authentication; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; @@ -16,7 +17,7 @@ function openid_content(App $a) { if($noid) $a->internalRedirect(); - logger('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA); + Logger::log('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA); if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) { @@ -27,7 +28,7 @@ function openid_content(App $a) { $authid = $_REQUEST['openid_identity']; if(! strlen($authid)) { - logger(L10n::t('OpenID protocol error. No ID returned.') . EOL); + Logger::log(L10n::t('OpenID protocol error. No ID returned.') . EOL); $a->internalRedirect(); } diff --git a/mod/parse_url.php b/mod/parse_url.php index f35c584fe..a1bacb0d8 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -11,6 +11,7 @@ */ use Friendica\App; use Friendica\Core\Addon; +use Friendica\Core\Logger; use Friendica\Util\Network; use Friendica\Util\ParseUrl; @@ -54,7 +55,7 @@ function parse_url_content(App $a) } } - logger($url); + Logger::log($url); // Check if the URL is an image, video or audio file. If so format // the URL with the corresponding BBCode media tag @@ -114,7 +115,7 @@ function parse_url_content(App $a) $result = sprintf($template, $url, ($title) ? $title : $url, $text) . $str_tags; - logger('(unparsed): returns: ' . $result); + Logger::log('(unparsed): returns: ' . $result); echo $result; exit(); diff --git a/mod/photos.php b/mod/photos.php index f5b1bf919..ad6922c1e 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -12,6 +12,7 @@ use Friendica\Core\ACL; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -141,9 +142,9 @@ function photos_init(App $a) { function photos_post(App $a) { - logger('mod-photos: photos_post: begin' , LOGGER_DEBUG); - logger('mod_photos: REQUEST ' . print_r($_REQUEST, true), LOGGER_DATA); - logger('mod_photos: FILES ' . print_r($_FILES, true), LOGGER_DATA); + Logger::log('mod-photos: photos_post: begin' , LOGGER_DEBUG); + Logger::log('mod_photos: REQUEST ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('mod_photos: FILES ' . print_r($_FILES, true), LOGGER_DATA); $phototypes = Image::supportedTypes(); @@ -189,7 +190,7 @@ function photos_post(App $a) if (!$owner_record) { notice(L10n::t('Contact information unavailable') . EOL); - logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid); + Logger::log('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid); killme(); } @@ -379,7 +380,7 @@ function photos_post(App $a) } if (!empty($_POST['rotate']) && (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) { - logger('rotate'); + Logger::log('rotate'); $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 0 LIMIT 1", DBA::escape($resource_id), @@ -706,7 +707,7 @@ function photos_post(App $a) $album = !empty($_REQUEST['album']) ? notags(trim($_REQUEST['album'])) : ''; $newalbum = !empty($_REQUEST['newalbum']) ? notags(trim($_REQUEST['newalbum'])) : ''; - logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); if (!strlen($album)) { if (strlen($newalbum)) { @@ -799,7 +800,7 @@ function photos_post(App $a) $type = Image::guessType($filename); } - logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG); + Logger::log('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG); $maximagesize = Config::get('system', 'maximagesize'); @@ -819,14 +820,14 @@ function photos_post(App $a) return; } - logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG); $imagedata = @file_get_contents($src); $image = new Image($imagedata, $type); if (!$image->isValid()) { - logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG); notice(L10n::t('Unable to process image.') . EOL); @unlink($src); $foo = 0; @@ -855,7 +856,7 @@ function photos_post(App $a) $r = Photo::store($image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); if (!$r) { - logger('mod/photos.php: photos_post(): image store failed', LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): image store failed', LOGGER_DEBUG); notice(L10n::t('Image upload failed.') . EOL); killme(); } diff --git a/mod/poco.php b/mod/poco.php index a16495326..915029954 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -8,6 +8,7 @@ use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Core\Cache; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -121,7 +122,7 @@ function poco_init(App $a) { $itemsPerPage = ((x($_GET, 'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults); if ($global) { - logger("Start global query", LOGGER_DEBUG); + Logger::log("Start global query", LOGGER_DEBUG); $contacts = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND NOT `hide` AND `network` IN ('%s', '%s', '%s') AND `updated` > `last_failure` ORDER BY `updated` DESC LIMIT %d, %d", DBA::escape($update_limit), @@ -132,7 +133,7 @@ function poco_init(App $a) { intval($itemsPerPage) ); } elseif ($system_mode) { - logger("Start system mode query", LOGGER_DEBUG); + Logger::log("Start system mode query", LOGGER_DEBUG); $contacts = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`, `profile`.`gender` AS `pgender`, `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type` @@ -144,7 +145,7 @@ function poco_init(App $a) { intval($itemsPerPage) ); } else { - logger("Start query for user " . $user['nickname'], LOGGER_DEBUG); + Logger::log("Start query for user " . $user['nickname'], LOGGER_DEBUG); $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`) AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra LIMIT %d, %d", @@ -157,7 +158,7 @@ function poco_init(App $a) { intval($itemsPerPage) ); } - logger("Query done", LOGGER_DEBUG); + Logger::log("Query done", LOGGER_DEBUG); $ret = []; if (x($_GET, 'sorted')) { @@ -369,7 +370,7 @@ function poco_init(App $a) { } else { System::httpExit(500); } - logger("End of poco", LOGGER_DEBUG); + Logger::log("End of poco", LOGGER_DEBUG); if ($format === 'xml') { header('Content-type: text/xml'); diff --git a/mod/poke.php b/mod/poke.php index 3318b0fcd..bf5b7e72d 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -16,6 +16,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -53,7 +54,7 @@ function poke_init(App $a) $parent = (x($_GET,'parent') ? intval($_GET['parent']) : 0); - logger('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG); + Logger::log('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -62,7 +63,7 @@ function poke_init(App $a) ); if (!DBA::isResult($r)) { - logger('poke: no contact ' . $contact_id); + Logger::log('poke: no contact ' . $contact_id); return; } diff --git a/mod/profile.php b/mod/profile.php index d068fca47..e56f7085e 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -11,6 +11,7 @@ use Friendica\Core\ACL; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBA; @@ -37,7 +38,7 @@ function profile_init(App $a) if (DBA::isResult($r)) { $a->internalRedirect('profile/' . $r[0]['nickname']); } else { - logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG); + Logger::log('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG); notice(L10n::t('Requested profile is not available.') . EOL); $a->error = 404; return; diff --git a/mod/pubsub.php b/mod/pubsub.php index f4c7e311c..2b3752358 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -1,6 +1,7 @@ $nick, 'account_expired' => false, 'account_removed' => false]); if (!DBA::isResult($owner)) { - logger('Local account not found: ' . $nick); + Logger::log('Local account not found: ' . $nick); hub_return(false, ''); } @@ -58,12 +59,12 @@ function pubsub_init(App $a) $contact = DBA::selectFirst('contact', ['id', 'poll'], $condition); if (!DBA::isResult($contact)) { - logger('Contact ' . $contact_id . ' not found.'); + Logger::log('Contact ' . $contact_id . ' not found.'); hub_return(false, ''); } if (!empty($hub_topic) && !link_compare($hub_topic, $contact['poll'])) { - logger('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); + Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); hub_return(false, ''); } @@ -71,13 +72,13 @@ function pubsub_init(App $a) // Don't allow outsiders to unsubscribe us. if (($hub_mode === 'unsubscribe') && empty($hub_verify)) { - logger('Bogus unsubscribe'); + Logger::log('Bogus unsubscribe'); hub_return(false, ''); } if (!empty($hub_mode)) { DBA::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]); - logger($hub_mode . ' success for contact ' . $contact_id . '.'); + Logger::log($hub_mode . ' success for contact ' . $contact_id . '.'); } hub_return(true, $hub_challenge); } @@ -87,8 +88,8 @@ function pubsub_post(App $a) { $xml = file_get_contents('php://input'); - logger('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']); - logger('Data: ' . $xml, LOGGER_DATA); + Logger::log('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']); + Logger::log('Data: ' . $xml, LOGGER_DATA); $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); @@ -106,16 +107,16 @@ function pubsub_post(App $a) if (!empty($author['contact-id'])) { $condition = ['id' => $author['contact-id'], 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false]; $contact = DBA::selectFirst('contact', [], $condition); - logger('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.'); + Logger::log('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.'); } if (!DBA::isResult($contact)) { - logger('Contact ' . $author["author-link"] . ' (' . $contact_id . ') for user ' . $nick . " wasn't found - ignored. XML: " . $xml); + Logger::log('Contact ' . $author["author-link"] . ' (' . $contact_id . ') for user ' . $nick . " wasn't found - ignored. XML: " . $xml); hub_post_return(); } } if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != Protocol::FEED)) { - logger('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.'); + Logger::log('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.'); hub_post_return(); } @@ -125,7 +126,7 @@ function pubsub_post(App $a) hub_post_return(); } - logger('Import item for ' . $nick . ' from ' . $contact['nick'] . ' (' . $contact['id'] . ')'); + Logger::log('Import item for ' . $nick . ' from ' . $contact['nick'] . ' (' . $contact['id'] . ')'); $feedhub = ''; consume_feed($xml, $importer, $contact, $feedhub); diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index d7b204e89..ea27f0482 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -2,6 +2,7 @@ use Friendica\App; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\PushSubscriber; @@ -42,11 +43,11 @@ function pubsubhubbub_init(App $a) { } elseif ($hub_mode === 'unsubscribe') { $subscribe = 0; } else { - logger("Invalid hub_mode=$hub_mode, ignoring."); + Logger::log("Invalid hub_mode=$hub_mode, ignoring."); System::httpExit(404); } - logger("$hub_mode request from " . $_SERVER['REMOTE_ADDR']); + Logger::log("$hub_mode request from " . $_SERVER['REMOTE_ADDR']); // get the nick name from the topic, a bit hacky but needed as a fallback $nick = substr(strrchr($hub_topic, "/"), 1); @@ -57,7 +58,7 @@ function pubsubhubbub_init(App $a) { } if (!$nick) { - logger('Bad hub_topic=$hub_topic, ignoring.'); + Logger::log('Bad hub_topic=$hub_topic, ignoring.'); System::httpExit(404); } @@ -65,13 +66,13 @@ function pubsubhubbub_init(App $a) { $condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]; $owner = DBA::selectFirst('user', ['uid', 'hidewall'], $condition); if (!DBA::isResult($owner)) { - logger('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback); + Logger::log('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback); System::httpExit(404); } // abort if user's wall is supposed to be private if ($owner['hidewall']) { - logger('Local user ' . $nick . 'has chosen to hide wall, ignoring.'); + Logger::log('Local user ' . $nick . 'has chosen to hide wall, ignoring.'); System::httpExit(403); } @@ -80,14 +81,14 @@ function pubsubhubbub_init(App $a) { 'pending' => false, 'self' => true]; $contact = DBA::selectFirst('contact', ['poll'], $condition); if (!DBA::isResult($contact)) { - logger('Self contact for user ' . $owner['uid'] . ' not found.'); + Logger::log('Self contact for user ' . $owner['uid'] . ' not found.'); System::httpExit(404); } // sanity check that topic URLs are the same $hub_topic2 = str_replace('/feed/', '/dfrn_poll/', $hub_topic); if (!link_compare($hub_topic, $contact['poll']) && !link_compare($hub_topic2, $contact['poll'])) { - logger('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); + Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']); System::httpExit(404); } @@ -110,14 +111,14 @@ function pubsubhubbub_init(App $a) { // give up if the HTTP return code wasn't a success (2xx) if ($ret < 200 || $ret > 299) { - logger("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring."); + Logger::log("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring."); System::httpExit(404); } // check that the correct hub_challenge code was echoed back if (trim($body) !== $hub_challenge) { - logger("Subscriber did not echo back hub.challenge, ignoring."); - logger("\"$hub_challenge\" != \"".trim($body)."\""); + Logger::log("Subscriber did not echo back hub.challenge, ignoring."); + Logger::log("\"$hub_challenge\" != \"".trim($body)."\""); System::httpExit(404); } diff --git a/mod/receive.php b/mod/receive.php index 80be7d2a2..af90007e3 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Protocol\Diaspora; @@ -18,7 +19,7 @@ function receive_post(App $a) { $enabled = intval(Config::get('system', 'diaspora_enabled')); if (!$enabled) { - logger('mod-diaspora: disabled'); + Logger::log('mod-diaspora: disabled'); System::httpExit(500); } @@ -41,7 +42,7 @@ function receive_post(App $a) // It is an application/x-www-form-urlencoded - logger('mod-diaspora: receiving post', LOGGER_DEBUG); + Logger::log('mod-diaspora: receiving post', LOGGER_DEBUG); if (empty($_POST['xml'])) { $postdata = file_get_contents("php://input"); @@ -49,29 +50,29 @@ function receive_post(App $a) System::httpExit(500); } - logger('mod-diaspora: message is in the new format', LOGGER_DEBUG); + Logger::log('mod-diaspora: message is in the new format', LOGGER_DEBUG); $msg = Diaspora::decodeRaw($importer, $postdata); } else { $xml = urldecode($_POST['xml']); - logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG); + Logger::log('mod-diaspora: decode message in the old format', LOGGER_DEBUG); $msg = Diaspora::decode($importer, $xml); if ($public && !$msg) { - logger('mod-diaspora: decode message in the new format', LOGGER_DEBUG); + Logger::log('mod-diaspora: decode message in the new format', LOGGER_DEBUG); $msg = Diaspora::decodeRaw($importer, $xml); } } - logger('mod-diaspora: decoded', LOGGER_DEBUG); + Logger::log('mod-diaspora: decoded', LOGGER_DEBUG); - logger('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA); + Logger::log('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA); if (!is_array($msg)) { System::httpExit(500); } - logger('mod-diaspora: dispatching', LOGGER_DEBUG); + Logger::log('mod-diaspora: dispatching', LOGGER_DEBUG); $ret = true; if ($public) { diff --git a/mod/redir.php b/mod/redir.php index 5ba8276ee..6cdbc94dc 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -2,6 +2,7 @@ use Friendica\App; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -51,7 +52,7 @@ function redir_init(App $a) { if (!empty($a->contact['id']) && $a->contact['id'] == $cid) { // Local user is already authenticated. $target_url = defaults($url, $contact_url); - logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG); + Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG); $a->redirect($target_url); } } @@ -72,7 +73,7 @@ function redir_init(App $a) { if ($v['uid'] == $_SESSION['visitor_visiting'] && $v['cid'] == $_SESSION['visitor_id']) { // Remote user is already authenticated. $target_url = defaults($url, $contact_url); - logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG); + Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG); $a->redirect($target_url); } } @@ -98,7 +99,7 @@ function redir_init(App $a) { 'sec' => $sec, 'expire' => time() + 45]; DBA::insert('profile_check', $fields); - logger('mod_redir: ' . $contact['name'] . ' ' . $sec, LOGGER_DEBUG); + Logger::log('mod_redir: ' . $contact['name'] . ' ' . $sec, LOGGER_DEBUG); $dest = (!empty($url) ? '&destination_url=' . $url : ''); @@ -120,7 +121,7 @@ function redir_init(App $a) { $url .= $separator . 'zrl=' . urlencode($my_profile); } - logger('redirecting to ' . $url, LOGGER_DEBUG); + Logger::log('redirecting to ' . $url, LOGGER_DEBUG); $a->redirect($url); } diff --git a/mod/register.php b/mod/register.php index 0a139ad75..73b57124a 100644 --- a/mod/register.php +++ b/mod/register.php @@ -9,6 +9,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Core\Worker; @@ -186,7 +187,7 @@ function register_content(App $a) if ($max_dailies) { $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); if ($r && $r[0]['total'] >= $max_dailies) { - logger('max daily registrations exceeded.'); + Logger::log('max daily registrations exceeded.'); notice(L10n::t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); return; } diff --git a/mod/salmon.php b/mod/salmon.php index bd4b3773c..bb44199dc 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -3,6 +3,7 @@ * @file mod/salmon.php */ use Friendica\App; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -20,7 +21,7 @@ function salmon_post(App $a, $xml = '') { $xml = file_get_contents('php://input'); } - logger('new salmon ' . $xml, LOGGER_DATA); + Logger::log('new salmon ' . $xml, LOGGER_DATA); $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $mentions = (($a->argc > 2 && $a->argv[2] === 'mention') ? true : false); @@ -49,7 +50,7 @@ function salmon_post(App $a, $xml = '') { $base = $dom; if (empty($base)) { - logger('unable to locate salmon data in xml '); + Logger::log('unable to locate salmon data in xml '); System::httpExit(400); } @@ -87,18 +88,18 @@ function salmon_post(App $a, $xml = '') { $author_link = $author["author-link"]; if(! $author_link) { - logger('Could not retrieve author URI.'); + Logger::log('Could not retrieve author URI.'); System::httpExit(400); } // Once we have the author URI, go to the web and try to find their public key - logger('Fetching key for ' . $author_link); + Logger::log('Fetching key for ' . $author_link); $key = Salmon::getKey($author_link, $keyhash); if(! $key) { - logger('Could not retrieve author key.'); + Logger::log('Could not retrieve author key.'); System::httpExit(400); } @@ -107,7 +108,7 @@ function salmon_post(App $a, $xml = '') { $m = base64url_decode($key_info[1]); $e = base64url_decode($key_info[2]); - logger('key details: ' . print_r($key_info,true), LOGGER_DEBUG); + Logger::log('key details: ' . print_r($key_info,true), LOGGER_DEBUG); $pubkey = Crypto::meToPem($m, $e); @@ -118,23 +119,23 @@ function salmon_post(App $a, $xml = '') { $mode = 1; if (! $verify) { - logger('message did not verify using protocol. Trying compliant format.'); + Logger::log('message did not verify using protocol. Trying compliant format.'); $verify = Crypto::rsaVerify($compliant_format, $signature, $pubkey); $mode = 2; } if (! $verify) { - logger('message did not verify using padding. Trying old statusnet format.'); + Logger::log('message did not verify using padding. Trying old statusnet format.'); $verify = Crypto::rsaVerify($stnet_signed_data, $signature, $pubkey); $mode = 3; } if (! $verify) { - logger('Message did not verify. Discarding.'); + Logger::log('Message did not verify. Discarding.'); System::httpExit(400); } - logger('Message verified with mode '.$mode); + Logger::log('Message verified with mode '.$mode); /* @@ -155,7 +156,7 @@ function salmon_post(App $a, $xml = '') { ); if (!DBA::isResult($r)) { - logger('Author ' . $author_link . ' unknown to user ' . $importer['uid'] . '.'); + Logger::log('Author ' . $author_link . ' unknown to user ' . $importer['uid'] . '.'); if (PConfig::get($importer['uid'], 'system', 'ostatus_autofriend')) { $result = Contact::createFromProbe($importer['uid'], $author_link); @@ -177,7 +178,7 @@ function salmon_post(App $a, $xml = '') { //if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == Contact::FOLLOWER) || ($r[0]['blocked']))) { if (DBA::isResult($r) && $r[0]['blocked']) { - logger('Ignoring this author.'); + Logger::log('Ignoring this author.'); System::httpExit(202); // NOTREACHED } diff --git a/mod/search.php b/mod/search.php index e5ac7588e..852043f30 100644 --- a/mod/search.php +++ b/mod/search.php @@ -10,6 +10,7 @@ use Friendica\Content\Pager; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Item; @@ -204,7 +205,7 @@ function search_content(App $a) { $pager = new Pager($a->query_string); if ($tag) { - logger("Start tag search for '".$search."'", LOGGER_DEBUG); + Logger::log("Start tag search for '".$search."'", LOGGER_DEBUG); $condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `otype` = ? AND `type` = ? AND `term` = ?", @@ -227,7 +228,7 @@ function search_content(App $a) { $r = []; } } else { - logger("Start fulltext search for '".$search."'", LOGGER_DEBUG); + Logger::log("Start fulltext search for '".$search."'", LOGGER_DEBUG); $condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `body` LIKE CONCAT('%',?,'%')", @@ -254,12 +255,12 @@ function search_content(App $a) { '$title' => $title ]); - logger("Start Conversation for '".$search."'", LOGGER_DEBUG); + Logger::log("Start Conversation for '".$search."'", LOGGER_DEBUG); $o .= conversation($a, $r, $pager, 'search', false, false, 'commented', local_user()); $o .= $pager->renderMinimal(count($r)); - logger("Done '".$search."'", LOGGER_DEBUG); + Logger::log("Done '".$search."'", LOGGER_DEBUG); return $o; } diff --git a/mod/settings.php b/mod/settings.php index 52c5f42cf..2973a7f72 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -11,6 +11,7 @@ use Friendica\Core\ACL; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Core\Theme; @@ -269,7 +270,7 @@ function settings_post(App $a) intval($mail_pubmail), intval(local_user()) ); - logger("mail: updating mailaccount. Response: ".print_r($r, true)); + Logger::log("mail: updating mailaccount. Response: ".print_r($r, true)); $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval(local_user()) ); @@ -547,7 +548,7 @@ function settings_post(App $a) // If openid has changed or if there's an openid but no openidserver, try and discover it. if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) { if (Network::isUrlValid($openid)) { - logger('updating openidserver'); + Logger::log('updating openidserver'); $open_id_obj = new LightOpenID($a->getHostName()); $open_id_obj->identity = $openid; $openidserver = $open_id_obj->discover($open_id_obj->identity); diff --git a/mod/statistics_json.php b/mod/statistics_json.php index da95d5379..173f6db13 100644 --- a/mod/statistics_json.php +++ b/mod/statistics_json.php @@ -7,6 +7,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\System; function statistics_json_init(App $a) { @@ -56,6 +57,6 @@ function statistics_json_init(App $a) { header("Content-Type: application/json"); echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); - logger("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA); + Logger::log("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA); killme(); } diff --git a/mod/subthread.php b/mod/subthread.php index 0082021df..36cf835c2 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Item; @@ -26,7 +27,7 @@ function subthread_content(App $a) { $item = Item::selectFirst([], $condition); if (empty($item_id) || !DBA::isResult($item)) { - logger('subthread: no item ' . $item_id); + Logger::log('subthread: no item ' . $item_id); return; } @@ -62,7 +63,7 @@ function subthread_content(App $a) { } if (!$owner) { - logger('like: no owner'); + Logger::log('like: no owner'); return; } diff --git a/mod/tagger.php b/mod/tagger.php index f661968f3..edfcd7bd1 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -28,13 +29,13 @@ function tagger_content(App $a) { $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); - logger('tagger: tag ' . $term . ' item ' . $item_id); + Logger::log('tagger: tag ' . $term . ' item ' . $item_id); $item = Item::selectFirst([], ['id' => $item_id]); if (!$item_id || !DBA::isResult($item)) { - logger('tagger: no item ' . $item_id); + Logger::log('tagger: no item ' . $item_id); return; } @@ -60,7 +61,7 @@ function tagger_content(App $a) { if (DBA::isResult($r)) { $contact = $r[0]; } else { - logger('tagger: no contact_id'); + Logger::log('tagger: no contact_id'); return; } diff --git a/mod/uimport.php b/mod/uimport.php index 704439216..3c80b671b 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -7,6 +7,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\UserImport; function uimport_post(App $a) @@ -33,7 +34,7 @@ function uimport_content(App $a) if ($max_dailies) { $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); if ($r && $r[0]['total'] >= $max_dailies) { - logger('max daily registrations exceeded.'); + Logger::log('max daily registrations exceeded.'); notice(L10n::t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); return; } diff --git a/mod/wall_upload.php b/mod/wall_upload.php index c23c3adbc..63c7d8278 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -10,6 +10,7 @@ use Friendica\App; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Database\DBA; @@ -19,7 +20,7 @@ use Friendica\Object\Image; function wall_upload_post(App $a, $desktopmode = true) { - logger("wall upload: starting new upload", LOGGER_DEBUG); + Logger::log("wall upload: starting new upload", LOGGER_DEBUG); $r_json = (x($_GET, 'response') && $_GET['response'] == 'json'); $album = (x($_GET, 'album') ? notags(trim($_GET['album'])) : ''); @@ -186,7 +187,7 @@ function wall_upload_post(App $a, $desktopmode = true) $filetype = $imagedata['mime']; } - logger("File upload src: " . $src . " - filename: " . $filename . + Logger::log("File upload src: " . $src . " - filename: " . $filename . " - size: " . $filesize . " - type: " . $filetype, LOGGER_DEBUG); $maximagesize = Config::get('system', 'maximagesize'); @@ -225,7 +226,7 @@ function wall_upload_post(App $a, $desktopmode = true) } if ($max_length > 0) { $Image->scaleDown($max_length); - logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG); + Logger::log("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG); } $width = $Image->getWidth(); @@ -300,11 +301,11 @@ function wall_upload_post(App $a, $desktopmode = true) echo json_encode(['picture' => $picture]); killme(); } - logger("upload done", LOGGER_DEBUG); + Logger::log("upload done", LOGGER_DEBUG); return $picture; } - logger("upload done", LOGGER_DEBUG); + Logger::log("upload done", LOGGER_DEBUG); if ($r_json) { echo json_encode(['ok' => true]); diff --git a/mod/wallmessage.php b/mod/wallmessage.php index dcec6ef9c..af1de6c06 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -4,6 +4,7 @@ */ use Friendica\App; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Mail; @@ -30,7 +31,7 @@ function wallmessage_post(App $a) { ); if (! DBA::isResult($r)) { - logger('wallmessage: no recipient'); + Logger::log('wallmessage: no recipient'); return; } @@ -93,7 +94,7 @@ function wallmessage_content(App $a) { if (! DBA::isResult($r)) { notice(L10n::t('No recipient.') . EOL); - logger('wallmessage: no recipient'); + Logger::log('wallmessage: no recipient'); return; } diff --git a/mod/worker.php b/mod/worker.php index c18155c5f..00cb6699d 100644 --- a/mod/worker.php +++ b/mod/worker.php @@ -5,6 +5,7 @@ */ use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; @@ -33,7 +34,7 @@ function worker_init() Worker::startProcess(); - logger("Front end worker started: ".getmypid()); + Logger::log("Front end worker started: ".getmypid()); Worker::callWorker(); @@ -55,7 +56,7 @@ function worker_init() Worker::endProcess(); - logger("Front end worker ended: ".getmypid()); + Logger::log("Front end worker ended: ".getmypid()); killme(); } diff --git a/src/App.php b/src/App.php index 2acb7eb36..e0513be04 100644 --- a/src/App.php +++ b/src/App.php @@ -1101,10 +1101,10 @@ class App $processlist = DBA::processlist(); if ($processlist['list'] != '') { - logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG); + Core\Logger::log('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG); if ($processlist['amount'] > $max_processes) { - logger('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', LOGGER_DEBUG); + Core\Logger::log('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', LOGGER_DEBUG); return true; } } @@ -1150,7 +1150,7 @@ class App $reached = ($free < $min_memory); if ($reached) { - logger('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, LOGGER_DEBUG); + Core\Logger::log('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, LOGGER_DEBUG); } return $reached; @@ -1180,7 +1180,7 @@ class App $load = Core\System::currentLoad(); if ($load) { if (intval($load) > $maxsysload) { - logger('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.'); + Core\Logger::log('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.'); return true; } } @@ -1222,7 +1222,7 @@ class App $resource = proc_open($cmdline . ' &', [], $foo, $this->getBasePath()); } if (!is_resource($resource)) { - logger('We got no resource for command ' . $cmdline, LOGGER_DEBUG); + Core\Logger::log('We got no resource for command ' . $cmdline, LOGGER_DEBUG); return; } proc_close($resource); @@ -1253,27 +1253,27 @@ class App public static function isDirectoryUsable($directory, $check_writable = true) { if ($directory == '') { - logger('Directory is empty. This shouldn\'t happen.', LOGGER_DEBUG); + Core\Logger::log('Directory is empty. This shouldn\'t happen.', LOGGER_DEBUG); return false; } if (!file_exists($directory)) { - logger('Path "' . $directory . '" does not exist for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" does not exist for user ' . self::getSystemUser(), LOGGER_DEBUG); return false; } if (is_file($directory)) { - logger('Path "' . $directory . '" is a file for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" is a file for user ' . self::getSystemUser(), LOGGER_DEBUG); return false; } if (!is_dir($directory)) { - logger('Path "' . $directory . '" is not a directory for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" is not a directory for user ' . self::getSystemUser(), LOGGER_DEBUG); return false; } if ($check_writable && !is_writable($directory)) { - logger('Path "' . $directory . '" is not writable for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" is not writable for user ' . self::getSystemUser(), LOGGER_DEBUG); return false; } @@ -1646,7 +1646,7 @@ class App } else { // Someone came with an invalid parameter, maybe as a DDoS attempt // We simply stop processing here - logger("Invalid ZRL parameter " . $_GET['zrl'], LOGGER_DEBUG); + Core\Logger::log("Invalid ZRL parameter " . $_GET['zrl'], LOGGER_DEBUG); Core\System::httpExit(403, ['title' => '403 Forbidden']); } } @@ -1785,11 +1785,11 @@ class App } if (!empty($_SERVER['QUERY_STRING']) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) { - logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']); + Core\Logger::log('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']); $this->internalRedirect($_SERVER['REQUEST_URI']); } - logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); + Core\Logger::log('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . Core\L10n::t('Not Found')); $tpl = get_markup_template("404.tpl"); diff --git a/src/BaseModule.php b/src/BaseModule.php index 522f0b783..2f46883ed 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -3,6 +3,7 @@ namespace Friendica; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; /** @@ -136,8 +137,8 @@ abstract class BaseModule extends BaseObject { if (!self::checkFormSecurityToken($typename, $formname)) { $a = get_app(); - logger('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); - logger('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); + Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); notice(self::getFormSecurityStandardErrorMessage()); $a->internalRedirect($err_redirect); } @@ -147,8 +148,8 @@ abstract class BaseModule extends BaseObject { if (!self::checkFormSecurityToken($typename, $formname)) { $a = get_app(); - logger('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); - logger('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); + Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); header('HTTP/1.1 403 Forbidden'); killme(); } diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index be2054067..9426677c2 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -15,6 +15,7 @@ use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Model\Contact; @@ -379,7 +380,7 @@ class BBCode extends BaseObject $c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism', $s, $matches, PREG_SET_ORDER); if ($c) { foreach ($matches as $mtch) { - logger('scale_external_image: ' . $mtch[1]); + Logger::log('scale_external_image: ' . $mtch[1]); $hostname = str_replace('www.', '', substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3)); if (stristr($mtch[1], $hostname)) { @@ -414,7 +415,7 @@ class BBCode extends BaseObject $Image->scaleDown(640); $new_width = $Image->getWidth(); $new_height = $Image->getHeight(); - logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG); + Logger::log('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG); $s = str_replace( $mtch[0], '[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]' @@ -423,7 +424,7 @@ class BBCode extends BaseObject : ''), $s ); - logger('scale_external_images: new string: ' . $s, LOGGER_DEBUG); + Logger::log('scale_external_images: new string: ' . $s, LOGGER_DEBUG); } } } @@ -451,7 +452,7 @@ class BBCode extends BaseObject // than the maximum, then don't waste time looking for the images if ($maxlen && (strlen($body) > $maxlen)) { - logger('the total body length exceeds the limit', LOGGER_DEBUG); + Logger::log('the total body length exceeds the limit', LOGGER_DEBUG); $orig_body = $body; $new_body = ''; @@ -471,7 +472,7 @@ class BBCode extends BaseObject if (($textlen + $img_start) > $maxlen) { if ($textlen < $maxlen) { - logger('the limit happens before an embedded image', LOGGER_DEBUG); + Logger::log('the limit happens before an embedded image', LOGGER_DEBUG); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); $textlen = $maxlen; } @@ -485,7 +486,7 @@ class BBCode extends BaseObject if (($textlen + $img_end) > $maxlen) { if ($textlen < $maxlen) { - logger('the limit happens before the end of a non-embedded image', LOGGER_DEBUG); + Logger::log('the limit happens before the end of a non-embedded image', LOGGER_DEBUG); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); $textlen = $maxlen; } @@ -508,11 +509,11 @@ class BBCode extends BaseObject if (($textlen + strlen($orig_body)) > $maxlen) { if ($textlen < $maxlen) { - logger('the limit happens after the end of the last image', LOGGER_DEBUG); + Logger::log('the limit happens after the end of the last image', LOGGER_DEBUG); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); } } else { - logger('the text size with embedded images extracted did not violate the limit', LOGGER_DEBUG); + Logger::log('the text size with embedded images extracted did not violate the limit', LOGGER_DEBUG); $new_body = $new_body . $orig_body; } diff --git a/src/Core/Addon.php b/src/Core/Addon.php index 1ec873053..a06982820 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -6,6 +6,7 @@ namespace Friendica\Core; use Friendica\App; use Friendica\BaseObject; +use Friendica\Core\Logger; use Friendica\Database\DBA; /** @@ -75,7 +76,7 @@ class Addon extends BaseObject */ public static function uninstall($addon) { - logger("Addons: uninstalling " . $addon); + Logger::log("Addons: uninstalling " . $addon); DBA::delete('addon', ['name' => $addon]); @include_once('addon/' . $addon . '/' . $addon . '.php'); @@ -100,7 +101,7 @@ class Addon extends BaseObject if (!file_exists('addon/' . $addon . '/' . $addon . '.php')) { return false; } - logger("Addons: installing " . $addon); + Logger::log("Addons: installing " . $addon); $t = @filemtime('addon/' . $addon . '/' . $addon . '.php'); @include_once('addon/' . $addon . '/' . $addon . '.php'); if (function_exists($addon . '_install')) { @@ -125,7 +126,7 @@ class Addon extends BaseObject } return true; } else { - logger("Addons: FAILED installing " . $addon); + Logger::log("Addons: FAILED installing " . $addon); return false; } } @@ -155,7 +156,7 @@ class Addon extends BaseObject $t = @filemtime($fname); foreach ($installed as $i) { if (($i['name'] == $addon) && ($i['timestamp'] != $t)) { - logger('Reloading addon: ' . $i['name']); + Logger::log('Reloading addon: ' . $i['name']); @include_once($fname); if (function_exists($addon . '_uninstall')) { diff --git a/src/Core/Authentication.php b/src/Core/Authentication.php index 5371cc91e..83effcb01 100644 --- a/src/Core/Authentication.php +++ b/src/Core/Authentication.php @@ -9,6 +9,7 @@ use Friendica\BaseObject; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; @@ -153,10 +154,10 @@ class Authentication extends BaseObject } if ($login_initial) { - logger('auth_identities: ' . print_r($a->identities, true), LOGGER_DEBUG); + Logger::log('auth_identities: ' . print_r($a->identities, true), LOGGER_DEBUG); } if ($login_refresh) { - logger('auth_identities refresh: ' . print_r($a->identities, true), LOGGER_DEBUG); + Logger::log('auth_identities refresh: ' . print_r($a->identities, true), LOGGER_DEBUG); } $contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]); @@ -184,7 +185,7 @@ class Authentication extends BaseObject * The week ensures that sessions will expire after some inactivity. */ if (!empty($_SESSION['remember'])) { - logger('Injecting cookie for remembered user ' . $a->user['nickname']); + Logger::log('Injecting cookie for remembered user ' . $a->user['nickname']); self::setCookie(604800, $user_record); unset($_SESSION['remember']); } diff --git a/src/Core/Cache/MemcachedCacheDriver.php b/src/Core/Cache/MemcachedCacheDriver.php index 1a6b2a9ae..5f2556deb 100644 --- a/src/Core/Cache/MemcachedCacheDriver.php +++ b/src/Core/Cache/MemcachedCacheDriver.php @@ -3,6 +3,7 @@ namespace Friendica\Core\Cache; use Friendica\Core\Cache; +use Friendica\Core\Logger; use Exception; use Friendica\Network\HTTPException\InternalServerErrorException; @@ -64,7 +65,7 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr if ($this->memcached->getResultCode() == Memcached::RES_SUCCESS) { return $this->filterArrayKeysByPrefix($keys, $prefix); } else { - logger('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL); + Logger::log('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL); return []; } } @@ -83,7 +84,7 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr if ($this->memcached->getResultCode() === Memcached::RES_SUCCESS) { $return = $value; } else { - logger('Memcached \'get\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL); + Logger::log('Memcached \'get\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL); } return $return; diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 45b70e062..2efce66ff 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -6,6 +6,7 @@ namespace Friendica\Core; use Friendica\BaseObject; use Friendica\Database\DBA; +use Friendica\Core\Logger; use Friendica\Core\System; require_once 'boot.php'; @@ -271,7 +272,7 @@ class L10n extends BaseObject public static function tt($singular, $plural, $count) { if (!is_numeric($count)) { - logger('Non numeric count called by ' . System::callstack(20)); + Logger::log('Non numeric count called by ' . System::callstack(20)); } if (!self::$lang) { diff --git a/src/Core/Lock.php b/src/Core/Lock.php index 9892f1f4e..4a737e381 100644 --- a/src/Core/Lock.php +++ b/src/Core/Lock.php @@ -7,6 +7,7 @@ namespace Friendica\Core; * @brief Functions for preventing parallel execution of functions */ +use Friendica\Core\Logger; use Friendica\Core\Cache\CacheDriverFactory; use Friendica\Core\Cache\IMemoryCacheDriver; @@ -83,7 +84,7 @@ class Lock } return; } catch (\Exception $exception) { - logger('Using Cache driver for locking failed: ' . $exception->getMessage()); + Logger::log('Using Cache driver for locking failed: ' . $exception->getMessage()); } } diff --git a/src/Core/Logger.php b/src/Core/Logger.php index 061343867..2eae6b57e 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -24,7 +24,7 @@ class Logger * @param string $msg * @param int $level */ - public static function logger($msg, $level = LOGGER_INFO) + public static function log($msg, $level = LOGGER_INFO) { $a = get_app(); global $LOGGER_LEVELS; @@ -81,7 +81,7 @@ class Logger /** * @brief An alternative logger for development. - * Works largely as logger() but allows developers + * Works largely as log() but allows developers * to isolate particular elements they are targetting * personally without background noise * @@ -97,7 +97,7 @@ class Logger * @param string $msg * @param int $level */ - public static function dlogger($msg, $level = LOGGER_INFO) + public static function devLog($msg, $level = LOGGER_INFO) { $a = get_app(); diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index 9250bc2e5..d75dd18d9 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -9,6 +9,7 @@ namespace Friendica\Core; use Friendica\BaseObject; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model\Contact; @@ -358,7 +359,7 @@ class NotificationsManager extends BaseObject break; } /// @todo Check if this part here is used at all - logger('Complete data: ' . json_encode($it) . ' - ' . System::callstack(20), LOGGER_DEBUG); + Logger::log('Complete data: ' . json_encode($it) . ' - ' . System::callstack(20), LOGGER_DEBUG); $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = XML::parseString($xmlhead . $it['object']); diff --git a/src/Core/Session/CacheSessionHandler.php b/src/Core/Session/CacheSessionHandler.php index 3ebdb99e1..a819702b3 100644 --- a/src/Core/Session/CacheSessionHandler.php +++ b/src/Core/Session/CacheSessionHandler.php @@ -4,6 +4,7 @@ namespace Friendica\Core\Session; use Friendica\BaseObject; use Friendica\Core\Cache; +use Friendica\Core\Logger; use Friendica\Core\Session; use SessionHandlerInterface; @@ -33,7 +34,7 @@ class CacheSessionHandler extends BaseObject implements SessionHandlerInterface Session::$exists = true; return $data; } - logger("no data for session $session_id", LOGGER_TRACE); + Logger::log("no data for session $session_id", LOGGER_TRACE); return ''; } diff --git a/src/Core/Session/DatabaseSessionHandler.php b/src/Core/Session/DatabaseSessionHandler.php index f249b37fd..ba01dddd9 100644 --- a/src/Core/Session/DatabaseSessionHandler.php +++ b/src/Core/Session/DatabaseSessionHandler.php @@ -3,6 +3,7 @@ namespace Friendica\Core\Session; use Friendica\BaseObject; +use Friendica\Core\Logger; use Friendica\Core\Session; use Friendica\Database\DBA; use SessionHandlerInterface; @@ -34,7 +35,7 @@ class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterfa Session::$exists = true; return $session['data']; } - logger("no data for session $session_id", LOGGER_TRACE); + Logger::log("no data for session $session_id", LOGGER_TRACE); return ''; } diff --git a/src/Core/System.php b/src/Core/System.php index 6079d9e22..07f0b6b17 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -5,6 +5,7 @@ namespace Friendica\Core; use Friendica\BaseObject; +use Friendica\Core\Logger; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\XML; @@ -100,7 +101,7 @@ class System extends BaseObject } if ($st) { - logger('xml_status returning non_zero: ' . $st . " message=" . $message); + Logger::log('xml_status returning non_zero: ' . $st . " message=" . $message); } header("Content-type: text/xml"); @@ -134,7 +135,7 @@ class System extends BaseObject $err = 'OK'; } - logger('http_status_exit ' . $val); + Logger::log('http_status_exit ' . $val); header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err); if (isset($description["title"])) { diff --git a/src/Core/Theme.php b/src/Core/Theme.php index 7e5b89d2f..e5026904b 100644 --- a/src/Core/Theme.php +++ b/src/Core/Theme.php @@ -6,6 +6,7 @@ namespace Friendica\Core; +use Friendica\Core\Logger; use Friendica\Core\System; require_once 'boot.php'; @@ -106,7 +107,7 @@ class Theme // install and uninstall theme public static function uninstall($theme) { - logger("Addons: uninstalling theme " . $theme); + Logger::log("Addons: uninstalling theme " . $theme); include_once "view/theme/$theme/theme.php"; if (function_exists("{$theme}_uninstall")) { @@ -123,7 +124,7 @@ class Theme return false; } - logger("Addons: installing theme $theme"); + Logger::log("Addons: installing theme $theme"); include_once "view/theme/$theme/theme.php"; @@ -132,7 +133,7 @@ class Theme $func(); return true; } else { - logger("Addons: FAILED installing theme $theme"); + Logger::log("Addons: FAILED installing theme $theme"); return false; } } diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index 18aabec08..fa9f05e2d 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -5,6 +5,7 @@ namespace Friendica\Core; use Friendica\App; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model\Photo; @@ -37,7 +38,7 @@ class UserImport private static function checkCols($table, &$arr) { $query = sprintf("SHOW COLUMNS IN `%s`", DBA::escape($table)); - logger("uimport: $query", LOGGER_DEBUG); + Logger::log("uimport: $query", LOGGER_DEBUG); $r = q($query); $tcols = []; // get a plain array of column names @@ -68,7 +69,7 @@ class UserImport $cols = implode("`,`", array_map(['Friendica\Database\DBA', 'escape'], array_keys($arr))); $vals = implode("','", array_map(['Friendica\Database\DBA', 'escape'], array_values($arr))); $query = "INSERT INTO `$table` (`$cols`) VALUES ('$vals')"; - logger("uimport: $query", LOGGER_TRACE); + Logger::log("uimport: $query", LOGGER_TRACE); if (self::IMPORT_DEBUG) { return true; @@ -85,7 +86,7 @@ class UserImport */ public static function importAccount(App $a, $file) { - logger("Start user import from " . $file['tmp_name']); + Logger::log("Start user import from " . $file['tmp_name']); /* STEPS 1. checks @@ -143,7 +144,7 @@ class UserImport // import user $r = self::dbImportAssoc('user', $account['user']); if ($r === false) { - logger("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_INFO); notice(L10n::t("User creation error")); return; } @@ -161,7 +162,7 @@ class UserImport $profile['uid'] = $newuid; $r = self::dbImportAssoc('profile', $profile); if ($r === false) { - logger("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); info(L10n::t("User profile creation error")); DBA::delete('user', ['uid' => $newuid]); return; @@ -199,7 +200,7 @@ class UserImport $contact['uid'] = $newuid; $r = self::dbImportAssoc('contact', $contact); if ($r === false) { - logger("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); $errorcount++; } else { $contact['newid'] = self::lastInsertId(); @@ -213,7 +214,7 @@ class UserImport $group['uid'] = $newuid; $r = self::dbImportAssoc('group', $group); if ($r === false) { - logger("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); } else { $group['newid'] = self::lastInsertId(); } @@ -238,7 +239,7 @@ class UserImport if ($import == 2) { $r = self::dbImportAssoc('group_member', $group_member); if ($r === false) { - logger("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); } } } @@ -256,7 +257,7 @@ class UserImport ); if ($r === false) { - logger("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); } } @@ -264,7 +265,7 @@ class UserImport $pconfig['uid'] = $newuid; $r = self::dbImportAssoc('pconfig', $pconfig); if ($r === false) { - logger("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); } } diff --git a/src/Core/Worker.php b/src/Core/Worker.php index a3c588460..77e38532c 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -5,6 +5,7 @@ namespace Friendica\Core; use Friendica\BaseObject; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Model\Process; use Friendica\Util\DateTimeFormat; @@ -42,7 +43,7 @@ class Worker // At first check the maximum load. We shouldn't continue with a high load if ($a->isMaxLoadReached()) { - logger('Pre check: maximum load reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: maximum load reached, quitting.', LOGGER_DEBUG); return; } @@ -58,25 +59,25 @@ class Worker // Count active workers and compare them with a maximum value that depends on the load if (self::tooMuchWorkers()) { - logger('Pre check: Active worker limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: Active worker limit reached, quitting.', LOGGER_DEBUG); return; } // Do we have too few memory? if ($a->isMinMemoryReached()) { - logger('Pre check: Memory limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: Memory limit reached, quitting.', LOGGER_DEBUG); return; } // Possibly there are too much database connections if (self::maxConnectionsReached()) { - logger('Pre check: maximum connections reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: maximum connections reached, quitting.', LOGGER_DEBUG); return; } // Possibly there are too much database processes that block the system if ($a->isMaxProcessesReached()) { - logger('Pre check: maximum processes reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: maximum processes reached, quitting.', LOGGER_DEBUG); return; } @@ -99,7 +100,7 @@ class Worker // The work will be done if (!self::execute($entry)) { - logger('Process execution failed, quitting.', LOGGER_DEBUG); + Logger::log('Process execution failed, quitting.', LOGGER_DEBUG); return; } @@ -117,14 +118,14 @@ class Worker $stamp = (float)microtime(true); // Count active workers and compare them with a maximum value that depends on the load if (self::tooMuchWorkers()) { - logger('Active worker limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Active worker limit reached, quitting.', LOGGER_DEBUG); Lock::release('worker'); return; } // Check free memory if ($a->isMinMemoryReached()) { - logger('Memory limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Memory limit reached, quitting.', LOGGER_DEBUG); Lock::release('worker'); return; } @@ -134,7 +135,7 @@ class Worker // Quit the worker once every 5 minutes if (time() > ($starttime + 300)) { - logger('Process lifetime reached, quitting.', LOGGER_DEBUG); + Logger::log('Process lifetime reached, quitting.', LOGGER_DEBUG); return; } } @@ -143,7 +144,7 @@ class Worker if (Config::get('system', 'worker_daemon_mode', false)) { self::IPCSetJobState(false); } - logger("Couldn't select a workerqueue entry, quitting process " . getmypid() . ".", LOGGER_DEBUG); + Logger::log("Couldn't select a workerqueue entry, quitting process " . getmypid() . ".", LOGGER_DEBUG); } /** @@ -213,19 +214,19 @@ class Worker // Quit when in maintenance if (Config::get('system', 'maintenance', false, true)) { - logger("Maintenance mode - quit process ".$mypid, LOGGER_DEBUG); + Logger::log("Maintenance mode - quit process ".$mypid, LOGGER_DEBUG); return false; } // Constantly check the number of parallel database processes if ($a->isMaxProcessesReached()) { - logger("Max processes reached for process ".$mypid, LOGGER_DEBUG); + Logger::log("Max processes reached for process ".$mypid, LOGGER_DEBUG); return false; } // Constantly check the number of available database connections to let the frontend be accessible at any time if (self::maxConnectionsReached()) { - logger("Max connection reached for process ".$mypid, LOGGER_DEBUG); + Logger::log("Max connection reached for process ".$mypid, LOGGER_DEBUG); return false; } @@ -270,7 +271,7 @@ class Worker } if (!validate_include($include)) { - logger("Include file ".$argv[0]." is not valid!"); + Logger::log("Include file ".$argv[0]." is not valid!"); DBA::delete('workerqueue', ['id' => $queue["id"]]); return true; } @@ -302,7 +303,7 @@ class Worker } self::$db_duration = (microtime(true) - $stamp); } else { - logger("Function ".$funcname." does not exist"); + Logger::log("Function ".$funcname." does not exist"); DBA::delete('workerqueue', ['id' => $queue["id"]]); } @@ -328,7 +329,7 @@ class Worker $new_process_id = System::processID("wrk"); - logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]." - Process PID: ".$new_process_id); + Logger::log("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]." - Process PID: ".$new_process_id); $stamp = (float)microtime(true); @@ -378,7 +379,7 @@ class Worker * The execution time is the productive time. * By changing parameters like the maximum number of workers we can check the effectivness. */ - logger( + Logger::log( 'DB: '.number_format(self::$db_duration, 2). ' - Lock: '.number_format(self::$lock_duration, 2). ' - Rest: '.number_format($up_duration - self::$db_duration - self::$lock_duration, 2). @@ -389,16 +390,16 @@ class Worker self::$lock_duration = 0; if ($duration > 3600) { - logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 1 hour (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 1 hour (".round($duration/60, 3).")", LOGGER_DEBUG); } elseif ($duration > 600) { - logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 10 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 10 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); } elseif ($duration > 300) { - logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 5 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 5 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); } elseif ($duration > 120) { - logger("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 2 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 2 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); } - logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - done in ".$duration." seconds. Process PID: ".$new_process_id); + Logger::log("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - done in ".$duration." seconds. Process PID: ".$new_process_id); // Write down the performance values into the log if (Config::get("system", "profiler")) { @@ -453,7 +454,7 @@ class Worker } } - logger( + Logger::log( "ID ".$queue["id"].": ".$funcname.": ".sprintf( "DB: %s/%s, Cache: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s".$o, number_format($a->performance["database"] - $a->performance["database_write"], 2), @@ -474,7 +475,7 @@ class Worker $cooldown = Config::get("system", "worker_cooldown", 0); if ($cooldown > 0) { - logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds"); + Logger::log("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds"); sleep($cooldown); } } @@ -518,12 +519,12 @@ class Worker $used = DBA::numRows($r); DBA::close($r); - logger("Connection usage (user values): ".$used."/".$max, LOGGER_DEBUG); + Logger::log("Connection usage (user values): ".$used."/".$max, LOGGER_DEBUG); $level = ($used / $max) * 100; if ($level >= $maxlevel) { - logger("Maximum level (".$maxlevel."%) of user connections reached: ".$used."/".$max); + Logger::log("Maximum level (".$maxlevel."%) of user connections reached: ".$used."/".$max); return true; } } @@ -546,14 +547,14 @@ class Worker if ($used == 0) { return false; } - logger("Connection usage (system values): ".$used."/".$max, LOGGER_DEBUG); + Logger::log("Connection usage (system values): ".$used."/".$max, LOGGER_DEBUG); $level = $used / $max * 100; if ($level < $maxlevel) { return false; } - logger("Maximum level (".$level."%) of system connections reached: ".$used."/".$max); + Logger::log("Maximum level (".$level."%) of system connections reached: ".$used."/".$max); return true; } @@ -594,7 +595,7 @@ class Worker // How long is the process already running? $duration = (time() - strtotime($entry["executed"])) / 60; if ($duration > $max_duration) { - logger("Worker process ".$entry["pid"]." (".substr(json_encode($argv), 0, 50).") took more than ".$max_duration." minutes. It will be killed now."); + Logger::log("Worker process ".$entry["pid"]." (".substr(json_encode($argv), 0, 50).") took more than ".$max_duration." minutes. It will be killed now."); posix_kill($entry["pid"], SIGTERM); // We killed the stale process. @@ -614,7 +615,7 @@ class Worker ['id' => $entry["id"]] ); } else { - logger("Worker process ".$entry["pid"]." (".substr(json_encode($argv), 0, 50).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG); + Logger::log("Worker process ".$entry["pid"]." (".substr(json_encode($argv), 0, 50).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG); } } } @@ -697,16 +698,16 @@ class Worker $high_running = self::processWithPriorityActive($top_priority); if (!$high_running && ($top_priority > PRIORITY_UNDEFINED) && ($top_priority < PRIORITY_NEGLIGIBLE)) { - logger("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG); + Logger::log("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG); $queues = $active + 1; } } - logger("Load: " . $load ."/" . $maxsysload . " - processes: " . $deferred . "/" . $active . "/" . $entries . $processlist . " - maximum: " . $queues . "/" . $maxqueues, LOGGER_DEBUG); + Logger::log("Load: " . $load ."/" . $maxsysload . " - processes: " . $deferred . "/" . $active . "/" . $entries . $processlist . " - maximum: " . $queues . "/" . $maxqueues, LOGGER_DEBUG); // Are there fewer workers running as possible? Then fork a new one. if (!Config::get("system", "worker_dont_fork", false) && ($queues > ($active + 1)) && ($entries > 1)) { - logger("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG); + Logger::log("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG); if (Config::get('system', 'worker_daemon_mode', false)) { self::IPCSetJobState(true); } else { @@ -779,11 +780,11 @@ class Worker ++$high; } } - logger("Highest priority: ".$highest_priority." Total processes: ".count($priorities)." Count high priority processes: ".$high, LOGGER_DEBUG); + Logger::log("Highest priority: ".$highest_priority." Total processes: ".count($priorities)." Count high priority processes: ".$high, LOGGER_DEBUG); $passing_slow = (($high/count($priorities)) > (2/3)); if ($passing_slow) { - logger("Passing slower processes than priority ".$highest_priority, LOGGER_DEBUG); + Logger::log("Passing slower processes than priority ".$highest_priority, LOGGER_DEBUG); } return $passing_slow; } @@ -816,7 +817,7 @@ class Worker $slope = $queue_length / pow($lower_job_limit, $exponent); $limit = min($queue_length, ceil($slope * pow($jobs, $exponent))); - logger('Deferred: ' . $deferred . ' - Total: ' . $jobs . ' - Maximum: ' . $queue_length . ' - jobs per queue: ' . $limit, LOGGER_DEBUG); + Logger::log('Deferred: ' . $deferred . ' - Total: ' . $jobs . ' - Maximum: ' . $queue_length . ' - jobs per queue: ' . $limit, LOGGER_DEBUG); $ids = []; if (self::passingSlow($highest_priority)) { // Are there waiting processes with a higher priority than the currently highest? @@ -975,7 +976,7 @@ class Worker self::runCron(); - logger('Call worker', LOGGER_DEBUG); + Logger::log('Call worker', LOGGER_DEBUG); self::spawnWorker(); return; } @@ -1014,7 +1015,7 @@ class Worker */ private static function runCron() { - logger('Add cron entries', LOGGER_DEBUG); + Logger::log('Add cron entries', LOGGER_DEBUG); // Check for spooled items self::add(PRIORITY_HIGH, "SpoolPost"); @@ -1152,7 +1153,7 @@ class Worker $id = $queue['id']; if ($retrial > 14) { - logger('Id ' . $id . ' had been tried 14 times. We stop now.', LOGGER_DEBUG); + Logger::log('Id ' . $id . ' had been tried 14 times. We stop now.', LOGGER_DEBUG); return; } @@ -1160,7 +1161,7 @@ class Worker $delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1)); $next = DateTimeFormat::utc('now + ' . $delay . ' seconds'); - logger('Defer execution ' . $retrial . ' of id ' . $id . ' to ' . $next, LOGGER_DEBUG); + Logger::log('Defer execution ' . $retrial . ' of id ' . $id . ' to ' . $next, LOGGER_DEBUG); $fields = ['retrial' => $retrial + 1, 'next_try' => $next, 'executed' => DBA::NULL_DATETIME, 'pid' => 0]; DBA::update('workerqueue', $fields, ['id' => $id]); diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 6249537c0..618415142 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -6,6 +6,7 @@ namespace Friendica\Database; // Please use App->getConfigVariable() instead. //use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Util\DateTimeFormat; use mysqli; @@ -412,7 +413,7 @@ class DBA if ((substr_count($sql, '?') != count($args)) && (count($args) > 0)) { // Question: Should we continue or stop the query here? - logger('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true), LOGGER_DEBUG); + Logger::log('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true), LOGGER_DEBUG); } $sql = self::cleanQuery($sql); @@ -552,7 +553,7 @@ class DBA $error = self::$error; $errorno = self::$errorno; - logger('DB Error '.self::$errorno.': '.self::$error."\n". + Logger::log('DB Error '.self::$errorno.': '.self::$error."\n". System::callstack(8)."\n".self::replaceParameters($sql, $args)); // On a lost connection we try to reconnect - but only once. @@ -560,14 +561,14 @@ class DBA if (self::$in_retrial || !self::reconnect()) { // It doesn't make sense to continue when the database connection was lost if (self::$in_retrial) { - logger('Giving up retrial because of database error '.$errorno.': '.$error); + Logger::log('Giving up retrial because of database error '.$errorno.': '.$error); } else { - logger("Couldn't reconnect after database error ".$errorno.': '.$error); + Logger::log("Couldn't reconnect after database error ".$errorno.': '.$error); } exit(1); } else { // We try it again - logger('Reconnected after database error '.$errorno.': '.$error); + Logger::log('Reconnected after database error '.$errorno.': '.$error); self::$in_retrial = true; $ret = self::p($sql, $args); self::$in_retrial = false; @@ -636,13 +637,13 @@ class DBA $error = self::$error; $errorno = self::$errorno; - logger('DB Error '.self::$errorno.': '.self::$error."\n". + Logger::log('DB Error '.self::$errorno.': '.self::$error."\n". System::callstack(8)."\n".self::replaceParameters($sql, $params)); // On a lost connection we simply quit. // A reconnect like in self::p could be dangerous with modifications if ($errorno == 2006) { - logger('Giving up because of database error '.$errorno.': '.$error); + Logger::log('Giving up because of database error '.$errorno.': '.$error); exit(1); } @@ -835,7 +836,7 @@ class DBA public static function insert($table, $param, $on_duplicate_update = false) { if (empty($table) || empty($param)) { - logger('Table and fields have to be set'); + Logger::log('Table and fields have to be set'); return false; } @@ -1051,7 +1052,7 @@ class DBA public static function delete($table, array $conditions, array $options = [], $in_process = false, array &$callstack = []) { if (empty($table) || empty($conditions)) { - logger('Table and conditions have to be set'); + Logger::log('Table and conditions have to be set'); return false; } @@ -1142,7 +1143,7 @@ class DBA if ((count($command['conditions']) > 1) || is_int($first_key)) { $sql = "DELETE FROM `" . $command['table'] . "`" . $condition_string; - logger(self::replaceParameters($sql, $conditions), LOGGER_DATA); + Logger::log(self::replaceParameters($sql, $conditions), LOGGER_DATA); if (!self::e($sql, $conditions)) { if ($do_transaction) { @@ -1172,7 +1173,7 @@ class DBA $sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" . substr(str_repeat("?, ", count($field_values)), 0, -2) . ");"; - logger(self::replaceParameters($sql, $field_values), LOGGER_DATA); + Logger::log(self::replaceParameters($sql, $field_values), LOGGER_DATA); if (!self::e($sql, $field_values)) { if ($do_transaction) { @@ -1223,7 +1224,7 @@ class DBA public static function update($table, $fields, $condition, $old_fields = []) { if (empty($table) || empty($fields) || empty($condition)) { - logger('Table, fields and condition have to be set'); + Logger::log('Table, fields and condition have to be set'); return false; } diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 9abae944a..1297979ea 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -8,6 +8,7 @@ use Exception; use Friendica\Core\Config; use Friendica\Core\Hook; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Util\DateTimeFormat; require_once 'boot.php'; @@ -69,7 +70,7 @@ class DBStructure // No valid result? if (!DBA::isResult($adminlist)) { - logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_INFO); + Logger::log(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_INFO); // Don't continue return; @@ -100,7 +101,7 @@ class DBStructure } //try the logger - logger("CRITICAL: Database structure update failed: ".$error_message); + Logger::log("CRITICAL: Database structure update failed: ".$error_message); } @@ -221,7 +222,7 @@ class DBStructure $errors = ''; - logger('updating structure', LOGGER_DEBUG); + Logger::log('updating structure', LOGGER_DEBUG); // Get the current structure $database = []; @@ -234,7 +235,7 @@ class DBStructure foreach ($tables AS $table) { $table = current($table); - logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG); + Logger::log(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG); $database[$table] = self::tableStructure($table); } } diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index dbadcbbb1..00e95fa2f 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -5,6 +5,7 @@ namespace Friendica\Database; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Model\Contact; use Friendica\Model\Item; @@ -52,7 +53,7 @@ class PostUpdate return true; } - logger("Start", LOGGER_DEBUG); + Logger::log("Start", LOGGER_DEBUG); $end_id = Config::get("system", "post_update_1194_end"); if (!$end_id) { @@ -63,7 +64,7 @@ class PostUpdate } } - logger("End ID: ".$end_id, LOGGER_DEBUG); + Logger::log("End ID: ".$end_id, LOGGER_DEBUG); $start_id = Config::get("system", "post_update_1194_start"); @@ -82,14 +83,14 @@ class PostUpdate DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA), DBA::escape(Protocol::OSTATUS)); if (!$r) { Config::set("system", "post_update_version", 1194); - logger("Update is done", LOGGER_DEBUG); + Logger::log("Update is done", LOGGER_DEBUG); return true; } else { Config::set("system", "post_update_1194_start", $r[0]["id"]); $start_id = Config::get("system", "post_update_1194_start"); } - logger("Start ID: ".$start_id, LOGGER_DEBUG); + Logger::log("Start ID: ".$start_id, LOGGER_DEBUG); $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1", intval($start_id), intval($end_id), @@ -99,13 +100,13 @@ class PostUpdate } else { $pos_id = $end_id; } - logger("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG); + Logger::log("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG); q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3, intval($start_id), intval($pos_id), DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA), DBA::escape(Protocol::OSTATUS)); - logger("Done", LOGGER_DEBUG); + Logger::log("Done", LOGGER_DEBUG); } /** @@ -122,7 +123,7 @@ class PostUpdate return true; } - logger("Start", LOGGER_DEBUG); + Logger::log("Start", LOGGER_DEBUG); $r = q("SELECT `contact`.`id`, `contact`.`last-item`, (SELECT MAX(`changed`) FROM `item` USE INDEX (`uid_wall_changed`) WHERE `wall` AND `uid` = `user`.`uid`) AS `lastitem_date` FROM `user` @@ -138,7 +139,7 @@ class PostUpdate } Config::set("system", "post_update_version", 1206); - logger("Done", LOGGER_DEBUG); + Logger::log("Done", LOGGER_DEBUG); return true; } @@ -156,7 +157,7 @@ class PostUpdate $id = Config::get("system", "post_update_version_1279_id", 0); - logger("Start from item " . $id, LOGGER_DEBUG); + Logger::log("Start from item " . $id, LOGGER_DEBUG); $fields = array_merge(Item::MIXED_CONTENT_FIELDLIST, ['network', 'author-id', 'owner-id', 'tag', 'file', 'author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link', 'id', @@ -170,7 +171,7 @@ class PostUpdate $items = Item::select($fields, $condition, $params); if (DBA::errorNo() != 0) { - logger('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage()); + Logger::log('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage()); return false; } @@ -225,7 +226,7 @@ class PostUpdate Config::set("system", "post_update_version_1279_id", $id); - logger("Processed rows: " . $rows . " - last processed item: " . $id, LOGGER_DEBUG); + Logger::log("Processed rows: " . $rows . " - last processed item: " . $id, LOGGER_DEBUG); if ($start_id == $id) { // Set all deprecated fields to "null" if they contain an empty string @@ -237,13 +238,13 @@ class PostUpdate foreach ($nullfields as $field) { $fields = [$field => null]; $condition = [$field => '']; - logger("Setting '" . $field . "' to null if empty.", LOGGER_DEBUG); + Logger::log("Setting '" . $field . "' to null if empty.", LOGGER_DEBUG); // Important: This has to be a "DBA::update", not a "Item::update" DBA::update('item', $fields, $condition); } Config::set("system", "post_update_version", 1279); - logger("Done", LOGGER_DEBUG); + Logger::log("Done", LOGGER_DEBUG); return true; } @@ -306,7 +307,7 @@ class PostUpdate $id = Config::get("system", "post_update_version_1281_id", 0); - logger("Start from item " . $id, LOGGER_DEBUG); + Logger::log("Start from item " . $id, LOGGER_DEBUG); $fields = ['id', 'guid', 'uri', 'uri-id', 'parent-uri', 'parent-uri-id', 'thr-parent', 'thr-parent-id']; @@ -317,7 +318,7 @@ class PostUpdate $items = DBA::select('item', $fields, $condition, $params); if (DBA::errorNo() != 0) { - logger('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage()); + Logger::log('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage()); return false; } @@ -358,17 +359,17 @@ class PostUpdate Config::set("system", "post_update_version_1281_id", $id); - logger("Processed rows: " . $rows . " - last processed item: " . $id, LOGGER_DEBUG); + Logger::log("Processed rows: " . $rows . " - last processed item: " . $id, LOGGER_DEBUG); if ($start_id == $id) { - logger("Updating item-uri in item-activity", LOGGER_DEBUG); + Logger::log("Updating item-uri in item-activity", LOGGER_DEBUG); DBA::e("UPDATE `item-activity` INNER JOIN `item-uri` ON `item-uri`.`uri` = `item-activity`.`uri` SET `item-activity`.`uri-id` = `item-uri`.`id` WHERE `item-activity`.`uri-id` IS NULL"); - logger("Updating item-uri in item-content", LOGGER_DEBUG); + Logger::log("Updating item-uri in item-content", LOGGER_DEBUG); DBA::e("UPDATE `item-content` INNER JOIN `item-uri` ON `item-uri`.`uri` = `item-content`.`uri` SET `item-content`.`uri-id` = `item-uri`.`id` WHERE `item-content`.`uri-id` IS NULL"); Config::set("system", "post_update_version", 1281); - logger("Done", LOGGER_DEBUG); + Logger::log("Done", LOGGER_DEBUG); return true; } diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 72c644ab9..e5dd27e0e 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -7,6 +7,7 @@ namespace Friendica\Model; use Friendica\BaseObject; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Protocol\ActivityPub; use Friendica\Util\Network; @@ -192,7 +193,7 @@ class APContact extends BaseObject // Update the gcontact table DBA::update('gcontact', $contact_fields, ['nurl' => normalise_link($url)]); - logger('Updated profile for ' . $url, LOGGER_DEBUG); + Logger::log('Updated profile for ' . $url, LOGGER_DEBUG); return $apcontact; } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index f653f9ccd..155b304ab 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -9,6 +9,7 @@ use Friendica\Content\Pager; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Core\Worker; @@ -586,7 +587,7 @@ class Contact extends BaseObject return; } } elseif (!isset($contact['url'])) { - logger('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), LOGGER_DEBUG); + Logger::log('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), LOGGER_DEBUG); } // Contact already archived or "self" contact? => nothing to do @@ -1027,7 +1028,7 @@ class Contact extends BaseObject */ public static function getIdForURL($url, $uid = 0, $no_update = false, $default = [], $in_loop = false) { - logger("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), LOGGER_DEBUG); + Logger::log("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), LOGGER_DEBUG); $contact_id = 0; @@ -1618,7 +1619,7 @@ class Contact extends BaseObject } if (($network != '') && ($ret['network'] != $network)) { - logger('Expected network ' . $network . ' does not match actual network ' . $ret['network']); + Logger::log('Expected network ' . $network . ' does not match actual network ' . $ret['network']); return $result; } @@ -1770,10 +1771,10 @@ class Contact extends BaseObject } } elseif ($contact['network'] == Protocol::DIASPORA) { $ret = Diaspora::sendShare($a->user, $contact); - logger('share returns: ' . $ret); + Logger::log('share returns: ' . $ret); } elseif ($contact['network'] == Protocol::ACTIVITYPUB) { $ret = ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid); - logger('Follow returns: ' . $ret); + Logger::log('Follow returns: ' . $ret); } } @@ -1855,7 +1856,7 @@ class Contact extends BaseObject // send email notification to owner? } else { if (DBA::exists('contact', ['nurl' => normalise_link($url), 'uid' => $importer['uid'], 'pending' => true])) { - logger('ignoring duplicated connection request from pending contact ' . $url); + Logger::log('ignoring duplicated connection request from pending contact ' . $url); return; } // create contact record @@ -1961,7 +1962,7 @@ class Contact extends BaseObject $r = q("SELECT * FROM `contact` WHERE `bd` != '' AND `bd` > '0001-01-01' AND SUBSTRING(`bd`, 1, 4) != `bdyear` "); if (DBA::isResult($r)) { foreach ($r as $rr) { - logger('update_contact_birthday: ' . $rr['bd']); + Logger::log('update_contact_birthday: ' . $rr['bd']); $nextbd = DateTimeFormat::utcNow('Y') . substr($rr['bd'], 4); diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index 25075dcfb..3332d93e0 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -5,6 +5,7 @@ namespace Friendica\Model; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; @@ -82,12 +83,12 @@ class Conversation unset($conversation['source']); } if (!DBA::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) { - logger('Conversation: update for ' . $conversation['item-uri'] . ' from ' . $old_conv['protocol'] . ' to ' . $conversation['protocol'] . ' failed', + Logger::log('Conversation: update for ' . $conversation['item-uri'] . ' from ' . $old_conv['protocol'] . ' to ' . $conversation['protocol'] . ' failed', LOGGER_DEBUG); } } else { if (!DBA::insert('conversation', $conversation, true)) { - logger('Conversation: insert for ' . $conversation['item-uri'] . ' (protocol ' . $conversation['protocol'] . ') failed', + Logger::log('Conversation: insert for ' . $conversation['item-uri'] . ' (protocol ' . $conversation['protocol'] . ') failed', LOGGER_DEBUG); } } diff --git a/src/Model/Event.php b/src/Model/Event.php index e9a4d4b3f..3ec6fb1a8 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -9,6 +9,7 @@ use Friendica\BaseObject; use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBA; @@ -224,7 +225,7 @@ class Event extends BaseObject } DBA::delete('event', ['id' => $event_id]); - logger("Deleted event ".$event_id, LOGGER_DEBUG); + Logger::log("Deleted event ".$event_id, LOGGER_DEBUG); } /** diff --git a/src/Model/GContact.php b/src/Model/GContact.php index cc7775377..a220a5921 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -8,6 +8,7 @@ namespace Friendica\Model; use Exception; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Core\Worker; @@ -256,7 +257,7 @@ class GContact intval($cid) ); - // logger("countCommonFriends: $uid $cid {$r[0]['total']}"); + // Logger::log("countCommonFriends: $uid $cid {$r[0]['total']}"); if (DBA::isResult($r)) { return $r[0]['total']; } @@ -588,7 +589,7 @@ class GContact } if ($new_url != $url) { - logger("Cleaned contact url ".$url." to ".$new_url." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Cleaned contact url ".$url." to ".$new_url." - Called by: ".System::callstack(), LOGGER_DEBUG); } return $new_url; @@ -605,7 +606,7 @@ class GContact if (($contact["network"] == Protocol::OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) { $data = Probe::uri($contact["url"]); if ($contact["network"] == Protocol::OSTATUS) { - logger("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); $contact["url"] = $data["url"]; $contact["addr"] = $data["addr"]; $contact["alias"] = $data["alias"]; @@ -629,12 +630,12 @@ class GContact $last_contact_str = ''; if (empty($contact["network"])) { - logger("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); return false; } if (in_array($contact["network"], [Protocol::PHANTOM])) { - logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); return false; } @@ -702,7 +703,7 @@ class GContact DBA::unlock(); if ($doprobing) { - logger("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG); + Logger::log("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG); Worker::add(PRIORITY_LOW, 'GProbe', $contact["url"]); } @@ -807,19 +808,19 @@ class GContact if ((($contact["generation"] > 0) && ($contact["generation"] <= $public_contact[0]["generation"])) || ($public_contact[0]["generation"] == 0)) { foreach ($fields as $field => $data) { if ($contact[$field] != $public_contact[0][$field]) { - logger("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$public_contact[0][$field]."'", LOGGER_DEBUG); + Logger::log("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$public_contact[0][$field]."'", LOGGER_DEBUG); $update = true; } } if ($contact["generation"] < $public_contact[0]["generation"]) { - logger("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$public_contact[0]["generation"]."'", LOGGER_DEBUG); + Logger::log("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$public_contact[0]["generation"]."'", LOGGER_DEBUG); $update = true; } } if ($update) { - logger("Update gcontact for ".$contact["url"], LOGGER_DEBUG); + Logger::log("Update gcontact for ".$contact["url"], LOGGER_DEBUG); $condition = ['`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)', normalise_link($contact["url"]), $contact["generation"]]; $contact["updated"] = DateTimeFormat::utc($contact["updated"]); @@ -843,7 +844,7 @@ class GContact // The quality of the gcontact table is mostly lower than the public contact $public_contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]); if (DBA::isResult($public_contact)) { - logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG); + Logger::log("Update public contact ".$public_contact["id"], LOGGER_DEBUG); Contact::updateAvatar($contact["photo"], 0, $public_contact["id"]); @@ -885,7 +886,7 @@ class GContact $data = Probe::uri($url); if (in_array($data["network"], [Protocol::PHANTOM])) { - logger("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); return; } @@ -916,7 +917,7 @@ class GContact ); if (!DBA::isResult($r)) { - logger('Cannot find user with uid=' . $uid, LOGGER_INFO); + Logger::log('Cannot find user with uid=' . $uid, LOGGER_INFO); return false; } @@ -953,7 +954,7 @@ class GContact */ public static function fetchGsUsers($server) { - logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG); + Logger::log("Fetching users from GNU Social server ".$server, LOGGER_DEBUG); $url = $server."/main/statistics"; diff --git a/src/Model/Group.php b/src/Model/Group.php index 4d0bd87e6..0bc8794f8 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -7,6 +7,7 @@ namespace Friendica\Model; use Friendica\BaseModule; use Friendica\BaseObject; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Util\Security; @@ -325,7 +326,7 @@ class Group extends BaseObject 'selected' => $gid == $group['id'] ? 'true' : '' ]; } - logger('groups: ' . print_r($display_groups, true)); + Logger::log('groups: ' . print_r($display_groups, true)); if ($label == '') { $label = L10n::t('Default privacy group for new contacts'); diff --git a/src/Model/Item.php b/src/Model/Item.php index d874f9aed..7f70dc9bc 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -11,6 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\Lock; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -960,7 +961,7 @@ class Item extends BaseObject } elseif ($item['uid'] == $uid) { self::deleteById($item['id'], PRIORITY_HIGH); } else { - logger('Wrong ownership. Not deleting item ' . $item['id']); + Logger::log('Wrong ownership. Not deleting item ' . $item['id']); } } DBA::close($items); @@ -983,12 +984,12 @@ class Item extends BaseObject 'icid', 'iaid', 'psid']; $item = self::selectFirst($fields, ['id' => $item_id]); if (!DBA::isResult($item)) { - logger('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG); + Logger::log('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG); return false; } if ($item['deleted']) { - logger('Item with ID ' . $item_id . ' has already been deleted.', LOGGER_DEBUG); + Logger::log('Item with ID ' . $item_id . ' has already been deleted.', LOGGER_DEBUG); return false; } @@ -1089,7 +1090,7 @@ class Item extends BaseObject } } - logger('Item with ID ' . $item_id . " has been deleted.", LOGGER_DEBUG); + Logger::log('Item with ID ' . $item_id . " has been deleted.", LOGGER_DEBUG); return true; } @@ -1192,7 +1193,7 @@ class Item extends BaseObject if (!empty($contact_id)) { return $contact_id; } - logger('Missing contact-id. Called by: '.System::callstack(), LOGGER_DEBUG); + Logger::log('Missing contact-id. Called by: '.System::callstack(), LOGGER_DEBUG); /* * First we are looking for a suitable contact that matches with the author of the post * This is done only for comments @@ -1213,7 +1214,7 @@ class Item extends BaseObject $contact_id = $self["id"]; } } - logger("Contact-id was missing for post ".$item['guid']." from user id ".$item['uid']." - now set to ".$contact_id, LOGGER_DEBUG); + Logger::log("Contact-id was missing for post ".$item['guid']." from user id ".$item['uid']." - now set to ".$contact_id, LOGGER_DEBUG); return $contact_id; } @@ -1298,7 +1299,7 @@ class Item extends BaseObject $item['gravity'] = GRAVITY_COMMENT; } else { $item['gravity'] = GRAVITY_UNKNOWN; // Should not happen - logger('Unknown gravity for verb: ' . $item['verb'], LOGGER_DEBUG); + Logger::log('Unknown gravity for verb: ' . $item['verb'], LOGGER_DEBUG); } $uid = intval($item['uid']); @@ -1315,7 +1316,7 @@ class Item extends BaseObject $expire_date = time() - ($expire_interval * 86400); $created_date = strtotime($item['created']); if ($created_date < $expire_date) { - logger('item-store: item created ('.date('c', $created_date).') before expiration time ('.date('c', $expire_date).'). ignored. ' . print_r($item,true), LOGGER_DEBUG); + Logger::log('item-store: item created ('.date('c', $created_date).') before expiration time ('.date('c', $expire_date).'). ignored. ' . print_r($item,true), LOGGER_DEBUG); return 0; } } @@ -1333,7 +1334,7 @@ class Item extends BaseObject if (DBA::isResult($existing)) { // We only log the entries with a different user id than 0. Otherwise we would have too many false positives if ($uid != 0) { - logger("Item with uri ".$item['uri']." already existed for user ".$uid." with id ".$existing["id"]." target network ".$existing["network"]." - new network: ".$item['network']); + Logger::log("Item with uri ".$item['uri']." already existed for user ".$uid." with id ".$existing["id"]." target network ".$existing["network"]." - new network: ".$item['network']); } return $existing["id"]; @@ -1384,7 +1385,7 @@ class Item extends BaseObject // When there is no content then we don't post it if ($item['body'].$item['title'] == '') { - logger('No body, no title.'); + Logger::log('No body, no title.'); return 0; } @@ -1411,7 +1412,7 @@ class Item extends BaseObject $item['author-id'] = defaults($item, 'author-id', Contact::getIdForURL($item["author-link"], 0, false, $default)); if (Contact::isBlocked($item["author-id"])) { - logger('Contact '.$item["author-id"].' is blocked, item '.$item["uri"].' will not be stored'); + Logger::log('Contact '.$item["author-id"].' is blocked, item '.$item["uri"].' will not be stored'); return 0; } @@ -1421,22 +1422,22 @@ class Item extends BaseObject $item['owner-id'] = defaults($item, 'owner-id', Contact::getIdForURL($item["owner-link"], 0, false, $default)); if (Contact::isBlocked($item["owner-id"])) { - logger('Contact '.$item["owner-id"].' is blocked, item '.$item["uri"].' will not be stored'); + Logger::log('Contact '.$item["owner-id"].' is blocked, item '.$item["uri"].' will not be stored'); return 0; } if ($item['network'] == Protocol::PHANTOM) { - logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG); + Logger::log('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG); $item['network'] = Protocol::DFRN; - logger("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG); + Logger::log("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG); } // Checking if there is already an item with the same guid - logger('Checking for an item for user '.$item['uid'].' on network '.$item['network'].' with the guid '.$item['guid'], LOGGER_DEBUG); + Logger::log('Checking for an item for user '.$item['uid'].' on network '.$item['network'].' with the guid '.$item['guid'], LOGGER_DEBUG); $condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']]; if (self::exists($condition)) { - logger('found item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network'], LOGGER_DEBUG); + Logger::log('found item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network'], LOGGER_DEBUG); return 0; } @@ -1517,15 +1518,15 @@ class Item extends BaseObject } // If its a post from myself then tag the thread as "mention" - logger("Checking if parent ".$parent_id." has to be tagged as mention for user ".$item['uid'], LOGGER_DEBUG); + Logger::log("Checking if parent ".$parent_id." has to be tagged as mention for user ".$item['uid'], LOGGER_DEBUG); $user = DBA::selectFirst('user', ['nickname'], ['uid' => $item['uid']]); if (DBA::isResult($user)) { $self = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']); $self_id = Contact::getIdForURL($self, 0, true); - logger("'myself' is ".$self_id." for parent ".$parent_id." checking against ".$item['author-id']." and ".$item['owner-id'], LOGGER_DEBUG); + Logger::log("'myself' is ".$self_id." for parent ".$parent_id." checking against ".$item['author-id']." and ".$item['owner-id'], LOGGER_DEBUG); if (($item['author-id'] == $self_id) || ($item['owner-id'] == $self_id)) { DBA::update('thread', ['mention' => true], ['iid' => $parent_id]); - logger("tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG); + Logger::log("tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG); } } } else { @@ -1534,12 +1535,12 @@ class Item extends BaseObject * we don't have or can't see the original post. */ if ($force_parent) { - logger('$force_parent=true, reply converted to top-level post.'); + Logger::log('$force_parent=true, reply converted to top-level post.'); $parent_id = 0; $item['parent-uri'] = $item['uri']; $item['gravity'] = GRAVITY_PARENT; } else { - logger('item parent '.$item['parent-uri'].' for '.$item['uid'].' was not found - ignoring item'); + Logger::log('item parent '.$item['parent-uri'].' for '.$item['uid'].' was not found - ignoring item'); return 0; } @@ -1553,7 +1554,7 @@ class Item extends BaseObject $condition = ["`uri` = ? AND `network` IN (?, ?) AND `uid` = ?", $item['uri'], $item['network'], Protocol::DFRN, $item['uid']]; if (self::exists($condition)) { - logger('duplicated item with the same uri found. '.print_r($item,true)); + Logger::log('duplicated item with the same uri found. '.print_r($item,true)); return 0; } @@ -1561,7 +1562,7 @@ class Item extends BaseObject if (in_array($item['network'], [Protocol::DFRN, Protocol::DIASPORA])) { $condition = ['guid' => $item['guid'], 'uid' => $item['uid']]; if (self::exists($condition)) { - logger('duplicated item with the same guid found. '.print_r($item,true)); + Logger::log('duplicated item with the same guid found. '.print_r($item,true)); return 0; } } else { @@ -1569,7 +1570,7 @@ class Item extends BaseObject $condition = ["`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?", $item['body'], $item['network'], $item['created'], $item['contact-id'], $item['uid']]; if (self::exists($condition)) { - logger('duplicated item with the same body found. '.print_r($item,true)); + Logger::log('duplicated item with the same body found. '.print_r($item,true)); return 0; } } @@ -1616,7 +1617,7 @@ class Item extends BaseObject unset($item['api_source']); if (x($item, 'cancel')) { - logger('post cancelled by addon.'); + Logger::log('post cancelled by addon.'); return 0; } @@ -1627,12 +1628,12 @@ class Item extends BaseObject */ if ($item["uid"] == 0) { if (self::exists(['uri' => trim($item['uri']), 'uid' => 0])) { - logger('Global item already stored. URI: '.$item['uri'].' on network '.$item['network'], LOGGER_DEBUG); + Logger::log('Global item already stored. URI: '.$item['uri'].' on network '.$item['network'], LOGGER_DEBUG); return 0; } } - logger('' . print_r($item,true), LOGGER_DATA); + Logger::log('' . print_r($item,true), LOGGER_DATA); if (array_key_exists('tag', $item)) { $tags = $item['tag']; @@ -1700,14 +1701,14 @@ class Item extends BaseObject $item = array_merge($item, $delivery_data); file_put_contents($spool, json_encode($item)); - logger("Item wasn't stored - Item was spooled into file ".$file, LOGGER_DEBUG); + Logger::log("Item wasn't stored - Item was spooled into file ".$file, LOGGER_DEBUG); } return 0; } if ($current_post == 0) { // This is one of these error messages that never should occur. - logger("couldn't find created item - we better quit now."); + Logger::log("couldn't find created item - we better quit now."); DBA::rollback(); return 0; } @@ -1718,7 +1719,7 @@ class Item extends BaseObject if ($entries > 1) { // There are duplicates. We delete our just created entry. - logger('Duplicated post occurred. uri = ' . $item['uri'] . ' uid = ' . $item['uid']); + Logger::log('Duplicated post occurred. uri = ' . $item['uri'] . ' uid = ' . $item['uid']); // Yes, we could do a rollback here - but we are having many users with MyISAM. DBA::delete('item', ['id' => $current_post]); @@ -1726,12 +1727,12 @@ class Item extends BaseObject return 0; } elseif ($entries == 0) { // This really should never happen since we quit earlier if there were problems. - logger("Something is terribly wrong. We haven't found our created entry."); + Logger::log("Something is terribly wrong. We haven't found our created entry."); DBA::rollback(); return 0; } - logger('created item '.$current_post); + Logger::log('created item '.$current_post); self::updateContact($item); if (!$parent_id || ($item['parent-uri'] === $item['uri'])) { @@ -1759,7 +1760,7 @@ class Item extends BaseObject */ if (base64_encode(base64_decode(base64_decode($dsprsig->signature))) == base64_decode($dsprsig->signature)) { $dsprsig->signature = base64_decode($dsprsig->signature); - logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG); + Logger::log("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG); } if (!empty($dsprsig->signed_text) && empty($dsprsig->signature) && empty($dsprsig->signer)) { @@ -1790,7 +1791,7 @@ class Item extends BaseObject Addon::callHooks('post_remote_end', $posted_item); } } else { - logger('new item not found in DB, id ' . $current_post); + Logger::log('new item not found in DB, id ' . $current_post); } } @@ -1895,20 +1896,20 @@ class Item extends BaseObject // To avoid timing problems, we are using locks. $locked = Lock::acquire('item_insert_activity'); if (!$locked) { - logger("Couldn't acquire lock for URI " . $item['uri'] . " - proceeding anyway."); + Logger::log("Couldn't acquire lock for URI " . $item['uri'] . " - proceeding anyway."); } // Do we already have this content? $item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-id' => $item['uri-id']]); if (DBA::isResult($item_activity)) { $item['iaid'] = $item_activity['id']; - logger('Fetched activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')'); + Logger::log('Fetched activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')'); } elseif (DBA::insert('item-activity', $fields)) { $item['iaid'] = DBA::lastInsertId(); - logger('Inserted activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')'); + Logger::log('Inserted activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')'); } else { // This shouldn't happen. - logger('Could not insert activity for URI ' . $item['uri'] . ' - should not happen'); + Logger::log('Could not insert activity for URI ' . $item['uri'] . ' - should not happen'); Lock::release('item_insert_activity'); return false; } @@ -1937,20 +1938,20 @@ class Item extends BaseObject // To avoid timing problems, we are using locks. $locked = Lock::acquire('item_insert_content'); if (!$locked) { - logger("Couldn't acquire lock for URI " . $item['uri'] . " - proceeding anyway."); + Logger::log("Couldn't acquire lock for URI " . $item['uri'] . " - proceeding anyway."); } // Do we already have this content? $item_content = DBA::selectFirst('item-content', ['id'], ['uri-id' => $item['uri-id']]); if (DBA::isResult($item_content)) { $item['icid'] = $item_content['id']; - logger('Fetched content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')'); + Logger::log('Fetched content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')'); } elseif (DBA::insert('item-content', $fields)) { $item['icid'] = DBA::lastInsertId(); - logger('Inserted content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')'); + Logger::log('Inserted content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')'); } else { // This shouldn't happen. - logger('Could not insert content for URI ' . $item['uri'] . ' - should not happen'); + Logger::log('Could not insert content for URI ' . $item['uri'] . ' - should not happen'); } if ($locked) { Lock::release('item_insert_content'); @@ -1976,7 +1977,7 @@ class Item extends BaseObject $fields = ['activity' => $activity_index]; - logger('Update activity for ' . json_encode($condition)); + Logger::log('Update activity for ' . json_encode($condition)); DBA::update('item-activity', $fields, $condition, true); @@ -2005,7 +2006,7 @@ class Item extends BaseObject $fields = $condition; } - logger('Update content for ' . json_encode($condition)); + Logger::log('Update content for ' . json_encode($condition)); DBA::update('item-content', $fields, $condition, true); } @@ -2144,9 +2145,9 @@ class Item extends BaseObject $distributed = self::insert($item, false, $notify, true); if (!$distributed) { - logger("Distributed public item " . $itemid . " for user " . $uid . " wasn't stored", LOGGER_DEBUG); + Logger::log("Distributed public item " . $itemid . " for user " . $uid . " wasn't stored", LOGGER_DEBUG); } else { - logger("Distributed public item " . $itemid . " for user " . $uid . " with id " . $distributed, LOGGER_DEBUG); + Logger::log("Distributed public item " . $itemid . " for user " . $uid . " with id " . $distributed, LOGGER_DEBUG); } } @@ -2209,7 +2210,7 @@ class Item extends BaseObject $public_shadow = self::insert($item, false, false, true); - logger("Stored public shadow for thread ".$itemid." under id ".$public_shadow, LOGGER_DEBUG); + Logger::log("Stored public shadow for thread ".$itemid." under id ".$public_shadow, LOGGER_DEBUG); } } @@ -2266,7 +2267,7 @@ class Item extends BaseObject $public_shadow = self::insert($item, false, false, true); - logger("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG); + Logger::log("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG); // If this was a comment to a Diaspora post we don't get our comment back. // This means that we have to distribute the comment by ourselves. @@ -2543,7 +2544,7 @@ class Item extends BaseObject foreach ($matches as $mtch) { if (link_compare($link, $mtch[1]) || link_compare($dlink, $mtch[1])) { $mention = true; - logger('mention found: ' . $mtch[2]); + Logger::log('mention found: ' . $mtch[2]); } } } @@ -2553,7 +2554,7 @@ class Item extends BaseObject !$item['wall'] && !$item['origin'] && ($item['id'] == $item['parent'])) { // mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment) // delete it! - logger("no-mention top-level post to community or private group. delete."); + Logger::log("no-mention top-level post to community or private group. delete."); DBA::delete('item', ['id' => $item_id]); return true; } @@ -2612,29 +2613,29 @@ class Item extends BaseObject // Prevent the forwarding of posts that are forwarded if (!empty($datarray["extid"]) && ($datarray["extid"] == Protocol::DFRN)) { - logger('Already forwarded', LOGGER_DEBUG); + Logger::log('Already forwarded', LOGGER_DEBUG); return false; } // Prevent to forward already forwarded posts if ($datarray["app"] == $a->getHostName()) { - logger('Already forwarded (second test)', LOGGER_DEBUG); + Logger::log('Already forwarded (second test)', LOGGER_DEBUG); return false; } // Only forward posts if ($datarray["verb"] != ACTIVITY_POST) { - logger('No post', LOGGER_DEBUG); + Logger::log('No post', LOGGER_DEBUG); return false; } if (($contact['network'] != Protocol::FEED) && $datarray['private']) { - logger('Not public', LOGGER_DEBUG); + Logger::log('Not public', LOGGER_DEBUG); return false; } $datarray2 = $datarray; - logger('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG); + Logger::log('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG); if ($contact['remote_self'] == 2) { $self = DBA::selectFirst('contact', ['id', 'name', 'url', 'thumb'], ['uid' => $contact['uid'], 'self' => true]); @@ -2674,7 +2675,7 @@ class Item extends BaseObject if ($contact['network'] != Protocol::FEED) { // Store the original post $result = self::insert($datarray2, false, false); - logger('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), LOGGER_DEBUG); + Logger::log('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), LOGGER_DEBUG); } else { $datarray["app"] = "Feed"; $result = true; @@ -2704,7 +2705,7 @@ class Item extends BaseObject return $s; } - logger('check for photos', LOGGER_DEBUG); + Logger::log('check for photos', LOGGER_DEBUG); $site = substr(System::baseUrl(), strpos(System::baseUrl(), '://')); $orig_body = $s; @@ -2718,7 +2719,7 @@ class Item extends BaseObject $img_st_close++; // make it point to AFTER the closing bracket $image = substr($orig_body, $img_start + $img_st_close, $img_len); - logger('found photo ' . $image, LOGGER_DEBUG); + Logger::log('found photo ' . $image, LOGGER_DEBUG); if (stristr($image, $site . '/photo/')) { // Only embed locally hosted photos @@ -2760,7 +2761,7 @@ class Item extends BaseObject // If a custom width and height were specified, apply before embedding if (preg_match("/\[img\=([0-9]*)x([0-9]*)\]/is", substr($orig_body, $img_start, $img_st_close), $match)) { - logger('scaling photo', LOGGER_DEBUG); + Logger::log('scaling photo', LOGGER_DEBUG); $width = intval($match[1]); $height = intval($match[2]); @@ -2773,9 +2774,9 @@ class Item extends BaseObject } } - logger('replacing photo', LOGGER_DEBUG); + Logger::log('replacing photo', LOGGER_DEBUG); $image = 'data:' . $type . ';base64,' . base64_encode($data); - logger('replaced: ' . $image, LOGGER_DATA); + Logger::log('replaced: ' . $image, LOGGER_DATA); } } } @@ -2938,7 +2939,7 @@ class Item extends BaseObject ++$expired; } DBA::close($items); - logger('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); + Logger::log('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); } public static function firstPostDate($uid, $wall = false) @@ -2994,18 +2995,18 @@ class Item extends BaseObject $activity = ACTIVITY_ATTENDMAYBE; break; default: - logger('like: unknown verb ' . $verb . ' for item ' . $item_id); + Logger::log('like: unknown verb ' . $verb . ' for item ' . $item_id); return false; } // Enable activity toggling instead of on/off $event_verb_flag = $activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE; - logger('like: verb ' . $verb . ' item ' . $item_id); + Logger::log('like: verb ' . $verb . ' item ' . $item_id); $item = self::selectFirst(self::ITEM_FIELDLIST, ['`id` = ? OR `uri` = ?', $item_id, $item_id]); if (!DBA::isResult($item)) { - logger('like: unknown item ' . $item_id); + Logger::log('like: unknown item ' . $item_id); return false; } @@ -3017,14 +3018,14 @@ class Item extends BaseObject } if (!Security::canWriteToUserWall($uid)) { - logger('like: unable to write on wall ' . $uid); + Logger::log('like: unable to write on wall ' . $uid); return false; } // Retrieves the local post owner $owner_self_contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'self' => true]); if (!DBA::isResult($owner_self_contact)) { - logger('like: unknown owner ' . $uid); + Logger::log('like: unknown owner ' . $uid); return false; } @@ -3033,7 +3034,7 @@ class Item extends BaseObject $author_contact = DBA::selectFirst('contact', ['url'], ['id' => $author_id]); if (!DBA::isResult($author_contact)) { - logger('like: unknown author ' . $author_id); + Logger::log('like: unknown author ' . $author_id); return false; } @@ -3045,7 +3046,7 @@ class Item extends BaseObject $item_contact_id = Contact::getIdForURL($author_contact['url'], $uid, true); $item_contact = DBA::selectFirst('contact', [], ['id' => $item_contact_id]); if (!DBA::isResult($item_contact)) { - logger('like: unknown item contact ' . $item_contact_id); + Logger::log('like: unknown item contact ' . $item_contact_id); return false; } } @@ -3147,7 +3148,7 @@ class Item extends BaseObject if (!$onlyshadow) { $result = DBA::insert('thread', $item); - logger("Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); + Logger::log("Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); } } @@ -3179,26 +3180,26 @@ class Item extends BaseObject $result = DBA::update('thread', $fields, ['iid' => $itemid]); - logger("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result, LOGGER_DEBUG); + Logger::log("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result, LOGGER_DEBUG); } private static function deleteThread($itemid, $itemuri = "") { $item = DBA::selectFirst('thread', ['uid'], ['iid' => $itemid]); if (!DBA::isResult($item)) { - logger('No thread found for id '.$itemid, LOGGER_DEBUG); + Logger::log('No thread found for id '.$itemid, LOGGER_DEBUG); return; } $result = DBA::delete('thread', ['iid' => $itemid], ['cascade' => false]); - logger("deleteThread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); + Logger::log("deleteThread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); if ($itemuri != "") { $condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]]; if (!self::exists($condition)) { DBA::delete('item', ['uri' => $itemuri, 'uid' => 0]); - logger("deleteThread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG); + Logger::log("deleteThread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG); } } } diff --git a/src/Model/Mail.php b/src/Model/Mail.php index 49247ca69..815b0051d 100644 --- a/src/Model/Mail.php +++ b/src/Model/Mail.php @@ -6,6 +6,7 @@ namespace Friendica\Model; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -87,7 +88,7 @@ class Mail } if (!$convid) { - logger('send message: conversation not found.'); + Logger::log('send message: conversation not found.'); return -4; } @@ -200,7 +201,7 @@ class Mail } if (!$convid) { - logger('send message: conversation not found.'); + Logger::log('send message: conversation not found.'); return -4; } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 53b98fb62..92e27f175 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -12,6 +12,7 @@ use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -106,7 +107,7 @@ class Profile $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]); if (!DBA::isResult($user) && empty($profiledata)) { - logger('profile error: ' . $a->query_string, LOGGER_DEBUG); + Logger::log('profile error: ' . $a->query_string, LOGGER_DEBUG); notice(L10n::t('Requested account is not available.') . EOL); $a->error = 404; return; @@ -124,7 +125,7 @@ class Profile $pdata = self::getByNickname($nickname, $user['uid'], $profile); if (empty($pdata) && empty($profiledata)) { - logger('profile error: ' . $a->query_string, LOGGER_DEBUG); + Logger::log('profile error: ' . $a->query_string, LOGGER_DEBUG); notice(L10n::t('Requested profile is not available.') . EOL); $a->error = 404; return; @@ -1020,27 +1021,27 @@ class Profile // Try to find the public contact entry of the visitor. $cid = Contact::getIdForURL($my_url); if (!$cid) { - logger('No contact record found for ' . $my_url, LOGGER_DEBUG); + Logger::log('No contact record found for ' . $my_url, LOGGER_DEBUG); return; } $contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]); if (DBA::isResult($contact) && remote_user() && remote_user() == $contact['id']) { - logger('The visitor ' . $my_url . ' is already authenticated', LOGGER_DEBUG); + Logger::log('The visitor ' . $my_url . ' is already authenticated', LOGGER_DEBUG); return; } // Avoid endless loops $cachekey = 'zrlInit:' . $my_url; if (Cache::get($cachekey)) { - logger('URL ' . $my_url . ' already tried to authenticate.', LOGGER_DEBUG); + Logger::log('URL ' . $my_url . ' already tried to authenticate.', LOGGER_DEBUG); return; } else { Cache::set($cachekey, true, Cache::MINUTE); } - logger('Not authenticated. Invoking reverse magic-auth for ' . $my_url, LOGGER_DEBUG); + Logger::log('Not authenticated. Invoking reverse magic-auth for ' . $my_url, LOGGER_DEBUG); Worker::add(PRIORITY_LOW, 'GProbe', $my_url); @@ -1061,7 +1062,7 @@ class Profile // We have to check if the remote server does understand /magic without invoking something $serverret = Network::curl($basepath . '/magic'); if ($serverret->isSuccess()) { - logger('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, LOGGER_DEBUG); + Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, LOGGER_DEBUG); System::externalRedirect($magic_path); } } @@ -1092,7 +1093,7 @@ class Profile // Try to find the public contact entry of the visitor. $cid = Contact::getIdForURL($visitor_handle); if(!$cid) { - logger('owt: unable to finger ' . $visitor_handle, LOGGER_DEBUG); + Logger::log('owt: unable to finger ' . $visitor_handle, LOGGER_DEBUG); return; } @@ -1121,7 +1122,7 @@ class Profile info(L10n::t('OpenWebAuth: %1$s welcomes %2$s', $a->getHostName(), $visitor['name'])); - logger('OpenWebAuth: auth success from ' . $visitor['addr'], LOGGER_DEBUG); + Logger::log('OpenWebAuth: auth success from ' . $visitor['addr'], LOGGER_DEBUG); } public static function zrl($s, $force = false) diff --git a/src/Model/PushSubscriber.php b/src/Model/PushSubscriber.php index e024878a5..4f85ffba5 100644 --- a/src/Model/PushSubscriber.php +++ b/src/Model/PushSubscriber.php @@ -4,6 +4,7 @@ */ namespace Friendica\Model; +use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; @@ -45,7 +46,7 @@ class PushSubscriber $priority = $default_priority; } - logger('Publish feed to ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' with priority ' . $priority, LOGGER_DEBUG); + Logger::log('Publish feed to ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' with priority ' . $priority, LOGGER_DEBUG); Worker::add($priority, 'PubSubPublish', (int)$subscriber['id']); } @@ -88,9 +89,9 @@ class PushSubscriber 'secret' => $hub_secret]; DBA::insert('push_subscriber', $fields); - logger("Successfully subscribed [$hub_callback] for $nick"); + Logger::log("Successfully subscribed [$hub_callback] for $nick"); } else { - logger("Successfully unsubscribed [$hub_callback] for $nick"); + Logger::log("Successfully unsubscribed [$hub_callback] for $nick"); // we do nothing here, since the row was already deleted } } @@ -115,10 +116,10 @@ class PushSubscriber if ($days > 60) { DBA::update('push_subscriber', ['push' => -1, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]); - logger('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', LOGGER_DEBUG); + Logger::log('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', LOGGER_DEBUG); } else { DBA::update('push_subscriber', ['push' => 0, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]); - logger('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', LOGGER_DEBUG); + Logger::log('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', LOGGER_DEBUG); } } else { // Calculate the delay until the next trial @@ -128,7 +129,7 @@ class PushSubscriber $retrial = $retrial + 1; DBA::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], ['id' => $id]); - logger('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next, LOGGER_DEBUG); + Logger::log('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next, LOGGER_DEBUG); } } @@ -148,6 +149,6 @@ class PushSubscriber // set last_update to the 'created' date of the last item, and reset push=0 $fields = ['push' => 0, 'next_try' => DBA::NULL_DATETIME, 'last_update' => $last_update]; DBA::update('push_subscriber', $fields, ['id' => $id]); - logger('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', LOGGER_DEBUG); + Logger::log('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', LOGGER_DEBUG); } } diff --git a/src/Model/Queue.php b/src/Model/Queue.php index 0284d72b7..7ffc64bf9 100644 --- a/src/Model/Queue.php +++ b/src/Model/Queue.php @@ -5,6 +5,7 @@ namespace Friendica\Model; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; @@ -17,7 +18,7 @@ class Queue */ public static function updateTime($id) { - logger('queue: requeue item ' . $id); + Logger::log('queue: requeue item ' . $id); $queue = DBA::selectFirst('queue', ['retrial'], ['id' => $id]); if (!DBA::isResult($queue)) { return; @@ -41,7 +42,7 @@ class Queue */ public static function removeItem($id) { - logger('queue: remove queue item ' . $id); + Logger::log('queue: remove queue item ' . $id); DBA::delete('queue', ['id' => $id]); } @@ -100,10 +101,10 @@ class Queue if (DBA::isResult($r)) { if ($batch && ($r[0]['total'] > $batch_queue)) { - logger('too many queued items for batch server ' . $cid . ' - discarding message'); + Logger::log('too many queued items for batch server ' . $cid . ' - discarding message'); return; } elseif ((! $batch) && ($r[0]['total'] > $max_queue)) { - logger('too many queued items for contact ' . $cid . ' - discarding message'); + Logger::log('too many queued items for contact ' . $cid . ' - discarding message'); return; } } @@ -117,6 +118,6 @@ class Queue 'content' => $msg, 'batch' =>($batch) ? 1 : 0 ]); - logger('Added item ' . $guid . ' for ' . $cid); + Logger::log('Added item ' . $guid . ' for ' . $cid); } } diff --git a/src/Model/User.php b/src/Model/User.php index bdea5e28f..29809b2cd 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -10,6 +10,7 @@ use Exception; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -470,7 +471,7 @@ class User $username_max_length = max(1, min(64, intval(Config::get('system', 'username_max_length', 48)))); if ($username_min_length > $username_max_length) { - logger(L10n::t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length), LOGGER_WARNING); + Logger::log(L10n::t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length), LOGGER_WARNING); $tmp = $username_min_length; $username_min_length = $username_max_length; $username_max_length = $tmp; @@ -785,7 +786,7 @@ class User $a = get_app(); - logger('Removing user: ' . $uid); + Logger::log('Removing user: ' . $uid); $user = DBA::selectFirst('user', [], ['uid' => $uid]); diff --git a/src/Module/Inbox.php b/src/Module/Inbox.php index c190be4d1..25312bdf3 100644 --- a/src/Module/Inbox.php +++ b/src/Module/Inbox.php @@ -36,7 +36,7 @@ class Inbox extends BaseModule $tempfile = tempnam(get_temppath(), $filename); file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); - logger('Incoming message stored under ' . $tempfile); + Logger::log('Incoming message stored under ' . $tempfile); */ if (!empty($a->argv[1])) { $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]); diff --git a/src/Module/Login.php b/src/Module/Login.php index df918c44c..a91c17b73 100644 --- a/src/Module/Login.php +++ b/src/Module/Login.php @@ -10,6 +10,7 @@ use Friendica\Core\Addon; use Friendica\Core\Authentication; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\User; @@ -146,7 +147,7 @@ class Login extends BaseModule ); } } catch (Exception $e) { - logger('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']); + Logger::log('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']); info('Login failed. Please check your credentials.' . EOL); $a->internalRedirect(); } @@ -195,7 +196,7 @@ class Login extends BaseModule ); if (DBA::isResult($user)) { if ($data->hash != Authentication::getCookieHashForUser($user)) { - logger("Hash for user " . $data->uid . " doesn't fit."); + Logger::log("Hash for user " . $data->uid . " doesn't fit."); Authentication::deleteSession(); $a->internalRedirect(); } @@ -231,7 +232,7 @@ class Login extends BaseModule $check = Config::get('system', 'paranoia'); // extra paranoia - if the IP changed, log them out if ($check && ($_SESSION['addr'] != $_SERVER['REMOTE_ADDR'])) { - logger('Session address changed. Paranoid setting in effect, blocking session. ' . + Logger::log('Session address changed. Paranoid setting in effect, blocking session. ' . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); Authentication::deleteSession(); $a->internalRedirect(); diff --git a/src/Module/Magic.php b/src/Module/Magic.php index 1da03b9c1..08836a7b9 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -5,9 +5,10 @@ namespace Friendica\Module; use Friendica\BaseModule; +use Friendica\Core\Logger; +use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; -use Friendica\Core\System; use Friendica\Util\HTTPSignature; use Friendica\Util\Network; @@ -22,9 +23,9 @@ class Magic extends BaseModule { $a = self::getApp(); $ret = ['success' => false, 'url' => '', 'message' => '']; - logger('magic mdule: invoked', LOGGER_DEBUG); + Logger::log('magic mdule: invoked', LOGGER_DEBUG); - logger('args: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('args: ' . print_r($_REQUEST, true), LOGGER_DATA); $addr = ((x($_REQUEST, 'addr')) ? $_REQUEST['addr'] : ''); $dest = ((x($_REQUEST, 'dest')) ? $_REQUEST['dest'] : ''); @@ -41,7 +42,7 @@ class Magic extends BaseModule } if (!$cid) { - logger('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG); + Logger::log('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG); // @TODO Finding a more elegant possibility to redirect to either internal or external URL $a->redirect($dest); } @@ -55,7 +56,7 @@ class Magic extends BaseModule return $ret; } - logger('Contact is already authenticated', LOGGER_DEBUG); + Logger::log('Contact is already authenticated', LOGGER_DEBUG); System::externalRedirect($dest); } diff --git a/src/Module/Owa.php b/src/Module/Owa.php index 7a5fe128c..a1d11e947 100644 --- a/src/Module/Owa.php +++ b/src/Module/Owa.php @@ -5,6 +5,7 @@ namespace Friendica\Module; use Friendica\BaseModule; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; @@ -57,8 +58,8 @@ class Owa extends BaseModule $verified = HTTPSignature::verifyMagic($contact['pubkey']); if ($verified && $verified['header_signed'] && $verified['header_valid']) { - logger('OWA header: ' . print_r($verified, true), LOGGER_DATA); - logger('OWA success: ' . $contact['addr'], LOGGER_DATA); + Logger::log('OWA header: ' . print_r($verified, true), LOGGER_DATA); + Logger::log('OWA success: ' . $contact['addr'], LOGGER_DATA); $ret['success'] = true; $token = random_string(32); @@ -75,10 +76,10 @@ class Owa extends BaseModule openssl_public_encrypt($token, $result, $contact['pubkey']); $ret['encrypted_token'] = base64url_encode($result); } else { - logger('OWA fail: ' . $contact['id'] . ' ' . $contact['addr'] . ' ' . $contact['url'], LOGGER_DEBUG); + Logger::log('OWA fail: ' . $contact['id'] . ' ' . $contact['addr'] . ' ' . $contact['url'], LOGGER_DEBUG); } } else { - logger('Contact not found: ' . $handle, LOGGER_DEBUG); + Logger::log('Contact not found: ' . $handle, LOGGER_DEBUG); } } } diff --git a/src/Network/CurlResult.php b/src/Network/CurlResult.php index e246f4fa5..aef719300 100644 --- a/src/Network/CurlResult.php +++ b/src/Network/CurlResult.php @@ -2,7 +2,7 @@ namespace Friendica\Network; - +use Friendica\Core\Logger; use Friendica\Network\HTTPException\InternalServerErrorException; /** @@ -104,7 +104,7 @@ class CurlResult $this->errorNumber = $errorNumber; $this->error = $error; - logger($url . ': ' . $this->returnCode . " " . $result, LOGGER_DATA); + Logger::log($url . ': ' . $this->returnCode . " " . $result, LOGGER_DATA); $this->parseBodyHeader($result); $this->checkSuccess(); @@ -134,8 +134,8 @@ class CurlResult $this->isSuccess = ($this->returnCode >= 200 && $this->returnCode <= 299) || $this->errorNumber == 0; if (!$this->isSuccess) { - logger('error: ' . $this->url . ': ' . $this->returnCode . ' - ' . $this->error, LOGGER_INFO); - logger('debug: ' . print_r($this->info, true), LOGGER_DATA); + Logger::log('error: ' . $this->url . ': ' . $this->returnCode . ' - ' . $this->error, LOGGER_INFO); + Logger::log('debug: ' . print_r($this->info, true), LOGGER_DATA); } if (!$this->isSuccess && $this->errorNumber == CURLE_OPERATION_TIMEDOUT) { diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php index 64ac4e7be..97c5bccc9 100644 --- a/src/Network/FKOAuth1.php +++ b/src/Network/FKOAuth1.php @@ -5,6 +5,7 @@ namespace Friendica\Network; use Friendica\Core\Addon; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBA; @@ -34,12 +35,12 @@ class FKOAuth1 extends OAuthServer */ public function loginUser($uid) { - logger("FKOAuth1::loginUser $uid"); + Logger::log("FKOAuth1::loginUser $uid"); $a = get_app(); $record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]); if (!DBA::isResult($record)) { - logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); } diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index 8453ac829..44e14f215 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -10,6 +10,7 @@ namespace Friendica\Network; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Database\DBA; use OAuthConsumer; use OAuthDataStore; @@ -39,7 +40,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function lookup_consumer($consumer_key) { - logger(__function__ . ":" . $consumer_key); + Logger::log(__function__ . ":" . $consumer_key); $s = DBA::select('clients', ['client_id', 'pw', 'redirect_uri'], ['client_id' => $consumer_key]); $r = DBA::toArray($s); @@ -59,7 +60,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function lookup_token($consumer, $token_type, $token) { - logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token); + Logger::log(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token); $s = DBA::select('tokens', ['id', 'secret', 'scope', 'expires', 'uid'], ['client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token]); $r = DBA::toArray($s); @@ -99,7 +100,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function new_request_token($consumer, $callback = null) { - logger(__function__ . ":" . $consumer . ", " . $callback); + Logger::log(__function__ . ":" . $consumer . ", " . $callback); $key = self::genToken(); $sec = self::genToken(); @@ -134,7 +135,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function new_access_token($token, $consumer, $verifier = null) { - logger(__function__ . ":" . $token . ", " . $consumer . ", " . $verifier); + Logger::log(__function__ . ":" . $token . ", " . $consumer . ", " . $verifier); // return a new access token attached to this consumer // for the user associated with this token if the request token @@ -145,7 +146,7 @@ class FKOAuthDataStore extends OAuthDataStore // get user for this verifier $uverifier = Config::get("oauth", $verifier); - logger(__function__ . ":" . $verifier . "," . $uverifier); + Logger::log(__function__ . ":" . $verifier . "," . $uverifier); if (is_null($verifier) || ($uverifier !== false)) { $key = self::genToken(); diff --git a/src/Network/Probe.php b/src/Network/Probe.php index f892c3a5c..894d9abe5 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -12,6 +12,7 @@ namespace Friendica\Network; use DOMDocument; use Friendica\Core\Cache; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -109,7 +110,7 @@ class Probe $xrd_timeout = Config::get('system', 'xrd_timeout', 20); $redirects = 0; - logger("Probing for ".$host, LOGGER_DEBUG); + Logger::log("Probing for ".$host, LOGGER_DEBUG); $xrd = null; $curlResult = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']); @@ -122,7 +123,7 @@ class Probe if (!is_object($xrd)) { $curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']); if ($curlResult->isTimeout()) { - logger("Probing timeout for " . $url, LOGGER_DEBUG); + Logger::log("Probing timeout for " . $url, LOGGER_DEBUG); return false; } $xml = $curlResult->getBody(); @@ -130,13 +131,13 @@ class Probe $host_url = 'http://'.$host; } if (!is_object($xrd)) { - logger("No xrd object found for ".$host, LOGGER_DEBUG); + Logger::log("No xrd object found for ".$host, LOGGER_DEBUG); return []; } $links = XML::elementToArray($xrd); if (!isset($links["xrd"]["link"])) { - logger("No xrd data found for ".$host, LOGGER_DEBUG); + Logger::log("No xrd data found for ".$host, LOGGER_DEBUG); return []; } @@ -164,7 +165,7 @@ class Probe self::$baseurl = "http://".$host; - logger("Probing successful for ".$host, LOGGER_DEBUG); + Logger::log("Probing successful for ".$host, LOGGER_DEBUG); return $lrdd; } @@ -194,7 +195,7 @@ class Probe $profile_link = ''; $links = self::lrdd($webbie); - logger('webfingerDfrn: '.$webbie.':'.print_r($links, true), LOGGER_DATA); + Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), LOGGER_DATA); if (count($links)) { foreach ($links as $link) { if ($link['@attributes']['rel'] === NAMESPACE_DFRN) { @@ -253,7 +254,7 @@ class Probe } if (!$lrdd) { - logger("No lrdd data found for ".$uri, LOGGER_DEBUG); + Logger::log("No lrdd data found for ".$uri, LOGGER_DEBUG); return []; } @@ -285,7 +286,7 @@ class Probe } if (!is_array($webfinger["links"])) { - logger("No webfinger links found for ".$uri, LOGGER_DEBUG); + Logger::log("No webfinger links found for ".$uri, LOGGER_DEBUG); return false; } @@ -595,7 +596,7 @@ class Probe $lrdd = self::hostMeta($host); } if (!$lrdd) { - logger('No XRD data was found for '.$uri, LOGGER_DEBUG); + Logger::log('No XRD data was found for '.$uri, LOGGER_DEBUG); return self::feed($uri); } $nick = array_pop($path_parts); @@ -630,12 +631,12 @@ class Probe } if (!$lrdd) { - logger('No XRD data was found for '.$uri, LOGGER_DEBUG); + Logger::log('No XRD data was found for '.$uri, LOGGER_DEBUG); return self::mail($uri, $uid); } $addr = $uri; } else { - logger("Uri ".$uri." was not detectable", LOGGER_DEBUG); + Logger::log("Uri ".$uri." was not detectable", LOGGER_DEBUG); return false; } @@ -680,7 +681,7 @@ class Probe $result = false; - logger("Probing ".$uri, LOGGER_DEBUG); + Logger::log("Probing ".$uri, LOGGER_DEBUG); if (in_array($network, ["", Protocol::DFRN])) { $result = self::dfrn($webfinger); @@ -716,7 +717,7 @@ class Probe $result["url"] = $uri; } - logger($uri." is ".$result["network"], LOGGER_DEBUG); + Logger::log($uri." is ".$result["network"], LOGGER_DEBUG); if (empty($result["baseurl"])) { $pos = strpos($result["url"], $host); @@ -751,7 +752,7 @@ class Probe $webfinger = json_decode($data, true); if (is_array($webfinger)) { if (!isset($webfinger["links"])) { - logger("No json webfinger links for ".$url, LOGGER_DEBUG); + Logger::log("No json webfinger links for ".$url, LOGGER_DEBUG); return false; } return $webfinger; @@ -760,13 +761,13 @@ class Probe // If it is not JSON, maybe it is XML $xrd = XML::parseString($data, false); if (!is_object($xrd)) { - logger("No webfinger data retrievable for ".$url, LOGGER_DEBUG); + Logger::log("No webfinger data retrievable for ".$url, LOGGER_DEBUG); return false; } $xrd_arr = XML::elementToArray($xrd); if (!isset($xrd_arr["xrd"]["link"])) { - logger("No XML webfinger links for ".$url, LOGGER_DEBUG); + Logger::log("No XML webfinger links for ".$url, LOGGER_DEBUG); return false; } @@ -815,13 +816,13 @@ class Probe } $content = $curlResult->getBody(); if (!$content) { - logger("Empty body for ".$noscrape_url, LOGGER_DEBUG); + Logger::log("Empty body for ".$noscrape_url, LOGGER_DEBUG); return false; } $json = json_decode($content, true); if (!is_array($json)) { - logger("No json data for ".$noscrape_url, LOGGER_DEBUG); + Logger::log("No json data for ".$noscrape_url, LOGGER_DEBUG); return false; } @@ -927,7 +928,7 @@ class Probe { $data = []; - logger("Check profile ".$profile_link, LOGGER_DEBUG); + Logger::log("Check profile ".$profile_link, LOGGER_DEBUG); // Fetch data via noscrape - this is faster $noscrape_url = str_replace(["/hcard/", "/profile/"], "/noscrape/", $profile_link); @@ -961,7 +962,7 @@ class Probe $prof_data["fn"] = defaults($data, 'name' , null); $prof_data["key"] = defaults($data, 'pubkey' , null); - logger("Result for profile ".$profile_link.": ".print_r($prof_data, true), LOGGER_DEBUG); + Logger::log("Result for profile ".$profile_link.": ".print_r($prof_data, true), LOGGER_DEBUG); return $prof_data; } @@ -1632,7 +1633,7 @@ class Probe } $msgs = Email::poll($mbox, $uri); - logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG); + Logger::log('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG); if (!count($msgs)) { return false; @@ -1714,7 +1715,7 @@ class Probe $fixed = $scheme.$host.$port.$path.$query.$fragment; - logger('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, LOGGER_DATA); + Logger::log('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, LOGGER_DATA); return $fixed; } diff --git a/src/Object/Image.php b/src/Object/Image.php index a76599223..6449bf09a 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -9,6 +9,7 @@ use Friendica\App; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; @@ -482,7 +483,7 @@ class Image break; } - // logger('exif: ' . print_r($exif,true)); + // Logger::log('exif: ' . print_r($exif,true)); return $exif; } @@ -726,7 +727,7 @@ class Image */ public static function guessType($filename, $fromcurl = false, $header = '') { - logger('Image: guessType: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG); + Logger::log('Image: guessType: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG); $type = null; if ($fromcurl) { $a = get_app(); @@ -764,7 +765,7 @@ class Image } } } - logger('Image: guessType: type='.$type, LOGGER_DEBUG); + Logger::log('Image: guessType: type='.$type, LOGGER_DEBUG); return $type; } @@ -890,7 +891,7 @@ class Image ); if (!DBA::isResult($r)) { - logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG); + Logger::log("Can't detect user data for uid ".$uid, LOGGER_DEBUG); return([]); } @@ -901,10 +902,10 @@ class Image /// $community_page = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false); if ((strlen($imagedata) == 0) && ($url == "")) { - logger("No image data and no url provided", LOGGER_DEBUG); + Logger::log("No image data and no url provided", LOGGER_DEBUG); return([]); } elseif (strlen($imagedata) == 0) { - logger("Uploading picture from ".$url, LOGGER_DEBUG); + Logger::log("Uploading picture from ".$url, LOGGER_DEBUG); $stamp1 = microtime(true); $imagedata = @file_get_contents($url); @@ -914,7 +915,7 @@ class Image $maximagesize = Config::get('system', 'maximagesize'); if (($maximagesize) && (strlen($imagedata) > $maximagesize)) { - logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG); + Logger::log("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG); return([]); } @@ -928,7 +929,7 @@ class Image if (!isset($data["mime"])) { unlink($tempfile); - logger("File is no picture", LOGGER_DEBUG); + Logger::log("File is no picture", LOGGER_DEBUG); return([]); } @@ -936,7 +937,7 @@ class Image if (!$Image->isValid()) { unlink($tempfile); - logger("Picture is no valid picture", LOGGER_DEBUG); + Logger::log("Picture is no valid picture", LOGGER_DEBUG); return([]); } @@ -967,7 +968,7 @@ class Image $r = Photo::store($Image, $uid, $visitor, $hash, $tempfile, L10n::t('Wall Photos'), 0, 0, $defperm); if (!$r) { - logger("Picture couldn't be stored", LOGGER_DEBUG); + Logger::log("Picture couldn't be stored", LOGGER_DEBUG); return([]); } diff --git a/src/Object/Post.php b/src/Object/Post.php index e8bc29ac0..08e0fbaa3 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -10,6 +10,7 @@ use Friendica\Content\Feature; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -487,10 +488,10 @@ class Post extends BaseObject { $item_id = $item->getId(); if (!$item_id) { - logger('[ERROR] Post::addChild : Item has no ID!!', LOGGER_DEBUG); + Logger::log('[ERROR] Post::addChild : Item has no ID!!', LOGGER_DEBUG); return false; } elseif ($this->getChild($item->getId())) { - logger('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', LOGGER_DEBUG); + Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', LOGGER_DEBUG); return false; } /* @@ -584,7 +585,7 @@ class Post extends BaseObject return true; } } - logger('[WARN] Item::removeChild : Item is not a child (' . $id . ').', LOGGER_DEBUG); + Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', LOGGER_DEBUG); return false; } @@ -650,7 +651,7 @@ class Post extends BaseObject public function getDataValue($name) { if (!isset($this->data[$name])) { - // logger('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', LOGGER_DEBUG); + // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', LOGGER_DEBUG); return false; } @@ -667,7 +668,7 @@ class Post extends BaseObject private function setTemplate($name) { if (!x($this->available_templates, $name)) { - logger('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', LOGGER_DEBUG); + Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', LOGGER_DEBUG); return false; } diff --git a/src/Object/Thread.php b/src/Object/Thread.php index 08c04f546..e9a2a0638 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -5,6 +5,7 @@ namespace Friendica\Object; use Friendica\BaseObject; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Object\Post; use Friendica\Util\Security; @@ -77,7 +78,7 @@ class Thread extends BaseObject $this->writable = $writable; break; default: - logger('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', LOGGER_DEBUG); + Logger::log('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', LOGGER_DEBUG); return false; break; } @@ -137,12 +138,12 @@ class Thread extends BaseObject $item_id = $item->getId(); if (!$item_id) { - logger('[ERROR] Conversation::addThread : Item has no ID!!', LOGGER_DEBUG); + Logger::log('[ERROR] Conversation::addThread : Item has no ID!!', LOGGER_DEBUG); return false; } if ($this->getParent($item->getId())) { - logger('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG); return false; } @@ -150,12 +151,12 @@ class Thread extends BaseObject * Only add will be displayed */ if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) { - logger('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG); return false; } if ($item->getDataValue('verb') === ACTIVITY_LIKE || $item->getDataValue('verb') === ACTIVITY_DISLIKE) { - logger('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', LOGGER_DEBUG); return false; } @@ -189,7 +190,7 @@ class Thread extends BaseObject $item_data = $item->getTemplateData($conv_responses); if (!$item_data) { - logger('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').', LOGGER_DEBUG); return false; } $result[] = $item_data; diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 964499af1..df1ba7dbd 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -5,6 +5,7 @@ namespace Friendica\Protocol\ActivityPub; use Friendica\Database\DBA; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Model\Conversation; use Friendica\Model\Contact; @@ -140,7 +141,7 @@ class Processor } if (($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) { - logger('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.'); + Logger::log('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.'); self::fetchMissingActivity($activity['reply-to-id'], $activity); } @@ -158,7 +159,7 @@ class Processor { $owner = Contact::getIdForURL($activity['actor']); - logger('Deleting item ' . $activity['object_id'] . ' from ' . $owner, LOGGER_DEBUG); + Logger::log('Deleting item ' . $activity['object_id'] . ' from ' . $owner, LOGGER_DEBUG); Item::delete(['uri' => $activity['object_id'], 'owner-id' => $owner]); } @@ -211,7 +212,7 @@ class Processor } $event_id = Event::store($event); - logger('Event '.$event_id.' was stored', LOGGER_DEBUG); + Logger::log('Event '.$event_id.' was stored', LOGGER_DEBUG); } /** @@ -225,7 +226,7 @@ class Processor /// @todo What to do with $activity['context']? if (($item['gravity'] != GRAVITY_PARENT) && !Item::exists(['uri' => $item['parent-uri']])) { - logger('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', LOGGER_DEBUG); + Logger::log('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', LOGGER_DEBUG); return; } @@ -238,7 +239,7 @@ class Processor $item['owner-link'] = $activity['actor']; $item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true); } else { - logger('Ignoring actor because of thread completion.', LOGGER_DEBUG); + Logger::log('Ignoring actor because of thread completion.', LOGGER_DEBUG); $item['owner-link'] = $item['author-link']; $item['owner-id'] = $item['author-id']; } @@ -284,7 +285,7 @@ class Processor } $item_id = Item::insert($item); - logger('Storing for user ' . $item['uid'] . ': ' . $item_id); + Logger::log('Storing for user ' . $item['uid'] . ': ' . $item_id); } } @@ -302,7 +303,7 @@ class Processor $object = ActivityPub::fetchContent($url); if (empty($object)) { - logger('Activity ' . $url . ' was not fetchable, aborting.'); + Logger::log('Activity ' . $url . ' was not fetchable, aborting.'); return; } @@ -322,7 +323,7 @@ class Processor $ldactivity['thread-completion'] = true; ActivityPub\Receiver::processActivity($ldactivity); - logger('Activity ' . $url . ' had been fetched and processed.'); + Logger::log('Activity ' . $url . ' had been fetched and processed.'); } /** @@ -360,7 +361,7 @@ class Processor } DBA::update('contact', ['hub-verify' => $activity['id']], ['id' => $cid]); - logger('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']); + Logger::log('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']); } /** @@ -374,7 +375,7 @@ class Processor return; } - logger('Updating profile for ' . $activity['object_id'], LOGGER_DEBUG); + Logger::log('Updating profile for ' . $activity['object_id'], LOGGER_DEBUG); APContact::getByURL($activity['object_id'], true); } @@ -386,12 +387,12 @@ class Processor public static function deletePerson($activity) { if (empty($activity['object_id']) || empty($activity['actor'])) { - logger('Empty object id or actor.', LOGGER_DEBUG); + Logger::log('Empty object id or actor.', LOGGER_DEBUG); return; } if ($activity['object_id'] != $activity['actor']) { - logger('Object id does not match actor.', LOGGER_DEBUG); + Logger::log('Object id does not match actor.', LOGGER_DEBUG); return; } @@ -401,7 +402,7 @@ class Processor } DBA::close($contacts); - logger('Deleted contact ' . $activity['object_id'], LOGGER_DEBUG); + Logger::log('Deleted contact ' . $activity['object_id'], LOGGER_DEBUG); } /** @@ -420,7 +421,7 @@ class Processor $cid = Contact::getIdForURL($activity['actor'], $uid); if (empty($cid)) { - logger('No contact found for ' . $activity['actor'], LOGGER_DEBUG); + Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG); return; } @@ -435,7 +436,7 @@ class Processor $condition = ['id' => $cid]; DBA::update('contact', $fields, $condition); - logger('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG); } /** @@ -454,7 +455,7 @@ class Processor $cid = Contact::getIdForURL($activity['actor'], $uid); if (empty($cid)) { - logger('No contact found for ' . $activity['actor'], LOGGER_DEBUG); + Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG); return; } @@ -462,9 +463,9 @@ class Processor if (DBA::exists('contact', ['id' => $cid, 'rel' => Contact::SHARING, 'pending' => true])) { Contact::remove($cid); - logger('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', LOGGER_DEBUG); + Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', LOGGER_DEBUG); } else { - logger('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', LOGGER_DEBUG); + Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', LOGGER_DEBUG); } } @@ -507,7 +508,7 @@ class Processor $cid = Contact::getIdForURL($activity['actor'], $uid); if (empty($cid)) { - logger('No contact found for ' . $activity['actor'], LOGGER_DEBUG); + Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG); return; } @@ -519,7 +520,7 @@ class Processor } Contact::removeFollower($owner, $contact); - logger('Undo following request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Undo following request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG); } /** @@ -534,7 +535,7 @@ class Processor return; } - logger('Change existing contact ' . $cid . ' from ' . $contact['network'] . ' to ActivityPub.'); + Logger::log('Change existing contact ' . $cid . ' from ' . $contact['network'] . ' to ActivityPub.'); Contact::updateFromProbe($cid, Protocol::ACTIVITYPUB); } } diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 8bc9d7646..707d0308a 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -6,6 +6,7 @@ namespace Friendica\Protocol\ActivityPub; use Friendica\Database\DBA; use Friendica\Util\HTTPSignature; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Model\Contact; use Friendica\Model\APContact; @@ -59,16 +60,16 @@ class Receiver { $http_signer = HTTPSignature::getSigner($body, $header); if (empty($http_signer)) { - logger('Invalid HTTP signature, message will be discarded.', LOGGER_DEBUG); + Logger::log('Invalid HTTP signature, message will be discarded.', LOGGER_DEBUG); return; } else { - logger('HTTP signature is signed by ' . $http_signer, LOGGER_DEBUG); + Logger::log('HTTP signature is signed by ' . $http_signer, LOGGER_DEBUG); } $activity = json_decode($body, true); if (empty($activity)) { - logger('Invalid body.', LOGGER_DEBUG); + Logger::log('Invalid body.', LOGGER_DEBUG); return; } @@ -76,31 +77,31 @@ class Receiver $actor = JsonLD::fetchElement($ldactivity, 'as:actor'); - logger('Message for user ' . $uid . ' is from actor ' . $actor, LOGGER_DEBUG); + Logger::log('Message for user ' . $uid . ' is from actor ' . $actor, LOGGER_DEBUG); if (LDSignature::isSigned($activity)) { $ld_signer = LDSignature::getSigner($activity); if (empty($ld_signer)) { - logger('Invalid JSON-LD signature from ' . $actor, LOGGER_DEBUG); + Logger::log('Invalid JSON-LD signature from ' . $actor, LOGGER_DEBUG); } if (!empty($ld_signer && ($actor == $http_signer))) { - logger('The HTTP and the JSON-LD signature belong to ' . $ld_signer, LOGGER_DEBUG); + Logger::log('The HTTP and the JSON-LD signature belong to ' . $ld_signer, LOGGER_DEBUG); $trust_source = true; } elseif (!empty($ld_signer)) { - logger('JSON-LD signature is signed by ' . $ld_signer, LOGGER_DEBUG); + Logger::log('JSON-LD signature is signed by ' . $ld_signer, LOGGER_DEBUG); $trust_source = true; } elseif ($actor == $http_signer) { - logger('Bad JSON-LD signature, but HTTP signer fits the actor.', LOGGER_DEBUG); + Logger::log('Bad JSON-LD signature, but HTTP signer fits the actor.', LOGGER_DEBUG); $trust_source = true; } else { - logger('Invalid JSON-LD signature and the HTTP signer is different.', LOGGER_DEBUG); + Logger::log('Invalid JSON-LD signature and the HTTP signer is different.', LOGGER_DEBUG); $trust_source = false; } } elseif ($actor == $http_signer) { - logger('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', LOGGER_DEBUG); + Logger::log('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', LOGGER_DEBUG); $trust_source = true; } else { - logger('No JSON-LD signature, different actor.', LOGGER_DEBUG); + Logger::log('No JSON-LD signature, different actor.', LOGGER_DEBUG); $trust_source = false; } @@ -159,7 +160,7 @@ class Receiver { $actor = JsonLD::fetchElement($activity, 'as:actor'); if (empty($actor)) { - logger('Empty actor', LOGGER_DEBUG); + Logger::log('Empty actor', LOGGER_DEBUG); return []; } @@ -175,11 +176,11 @@ class Receiver $receivers = array_merge($receivers, $additional); } - logger('Receivers: ' . json_encode($receivers), LOGGER_DEBUG); + Logger::log('Receivers: ' . json_encode($receivers), LOGGER_DEBUG); $object_id = JsonLD::fetchElement($activity, 'as:object'); if (empty($object_id)) { - logger('No object found', LOGGER_DEBUG); + Logger::log('No object found', LOGGER_DEBUG); return []; } @@ -192,7 +193,7 @@ class Receiver } $object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source); if (empty($object_data)) { - logger("Object data couldn't be processed", LOGGER_DEBUG); + Logger::log("Object data couldn't be processed", LOGGER_DEBUG); return []; } // We had been able to retrieve the object data - so we can trust the source @@ -229,7 +230,7 @@ class Receiver $object_data['actor'] = $actor; $object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers); - logger('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], LOGGER_DEBUG); + Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], LOGGER_DEBUG); return $object_data; } @@ -272,17 +273,17 @@ class Receiver { $type = JsonLD::fetchElement($activity, '@type'); if (!$type) { - logger('Empty type', LOGGER_DEBUG); + Logger::log('Empty type', LOGGER_DEBUG); return; } if (!JsonLD::fetchElement($activity, 'as:object')) { - logger('Empty object', LOGGER_DEBUG); + Logger::log('Empty object', LOGGER_DEBUG); return; } if (!JsonLD::fetchElement($activity, 'as:actor')) { - logger('Empty actor', LOGGER_DEBUG); + Logger::log('Empty actor', LOGGER_DEBUG); return; } @@ -290,12 +291,12 @@ class Receiver // $trust_source is called by reference and is set to true if the content was retrieved successfully $object_data = self::prepareObjectData($activity, $uid, $trust_source); if (empty($object_data)) { - logger('No object data found', LOGGER_DEBUG); + Logger::log('No object data found', LOGGER_DEBUG); return; } if (!$trust_source) { - logger('No trust for activity type "' . $type . '", so we quit now.', LOGGER_DEBUG); + Logger::log('No trust for activity type "' . $type . '", so we quit now.', LOGGER_DEBUG); return; } @@ -384,7 +385,7 @@ class Receiver break; default: - logger('Unknown activity: ' . $type . ' ' . $object_data['object_type'], LOGGER_DEBUG); + Logger::log('Unknown activity: ' . $type . ' ' . $object_data['object_type'], LOGGER_DEBUG); break; } } @@ -414,9 +415,9 @@ class Receiver $profile = APContact::getByURL($actor); $followers = defaults($profile, 'followers', ''); - logger('Actor: ' . $actor . ' - Followers: ' . $followers, LOGGER_DEBUG); + Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, LOGGER_DEBUG); } else { - logger('Empty actor', LOGGER_DEBUG); + Logger::log('Empty actor', LOGGER_DEBUG); $followers = ''; } @@ -486,7 +487,7 @@ class Receiver return; } - logger('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub'); + Logger::log('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub'); $photo = defaults($profile, 'photo', null); unset($profile['photo']); @@ -500,7 +501,7 @@ class Receiver // Send a new follow request to be sure that the connection still exists if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) { ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid); - logger('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, LOGGER_DEBUG); } } @@ -570,27 +571,27 @@ class Receiver $data = ActivityPub::fetchContent($object_id); if (!empty($data)) { $object = JsonLD::compact($data); - logger('Fetched content for ' . $object_id, LOGGER_DEBUG); + Logger::log('Fetched content for ' . $object_id, LOGGER_DEBUG); } else { - logger('Empty content for ' . $object_id . ', check if content is available locally.', LOGGER_DEBUG); + Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', LOGGER_DEBUG); $item = Item::selectFirst([], ['uri' => $object_id]); if (!DBA::isResult($item)) { - logger('Object with url ' . $object_id . ' was not found locally.', LOGGER_DEBUG); + Logger::log('Object with url ' . $object_id . ' was not found locally.', LOGGER_DEBUG); return false; } - logger('Using already stored item for url ' . $object_id, LOGGER_DEBUG); + Logger::log('Using already stored item for url ' . $object_id, LOGGER_DEBUG); $data = ActivityPub\Transmitter::createNote($item); $object = JsonLD::compact($data); } } else { - logger('Using original object for url ' . $object_id, LOGGER_DEBUG); + Logger::log('Using original object for url ' . $object_id, LOGGER_DEBUG); } $type = JsonLD::fetchElement($object, '@type'); if (empty($type)) { - logger('Empty type', LOGGER_DEBUG); + Logger::log('Empty type', LOGGER_DEBUG); return false; } @@ -606,7 +607,7 @@ class Receiver return self::fetchObject($object_id); } - logger('Unhandled object type: ' . $type, LOGGER_DEBUG); + Logger::log('Unhandled object type: ' . $type, LOGGER_DEBUG); } /** diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index ed2a84e71..d9535f0b6 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -6,6 +6,7 @@ namespace Friendica\Protocol\ActivityPub; use Friendica\BaseObject; use Friendica\Database\DBA; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Util\HTTPSignature; use Friendica\Core\Protocol; @@ -1015,7 +1016,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1044,7 +1045,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1073,7 +1074,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - logger('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1098,7 +1099,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - logger('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, LOGGER_DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -1126,7 +1127,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - logger('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); + Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -1154,7 +1155,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - logger('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); + Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -1183,7 +1184,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - logger('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); + Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 1dcc1197a..95921eecb 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -17,6 +17,7 @@ use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -175,7 +176,7 @@ class DFRN ); if (! DBA::isResult($r)) { - logger(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_WARNING); + Logger::log(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_WARNING); killme(); } @@ -211,7 +212,7 @@ class DFRN ); if (! DBA::isResult($r)) { - logger(sprintf('No contact found for uid=%d', $owner_id), LOGGER_WARNING); + Logger::log(sprintf('No contact found for uid=%d', $owner_id), LOGGER_WARNING); killme(); } @@ -1171,7 +1172,7 @@ class DFRN if (!$dissolve && !$legacy_transport) { $curlResult = self::transmit($owner, $contact, $atom); if ($curlResult >= 200) { - logger('Delivery via Diaspora transport layer was successful with status ' . $curlResult); + Logger::log('Delivery via Diaspora transport layer was successful with status ' . $curlResult); return $curlResult; } } @@ -1188,7 +1189,7 @@ class DFRN $rino = Config::get('system', 'rino_encrypt'); $rino = intval($rino); - logger("Local rino version: ". $rino, LOGGER_DEBUG); + Logger::log("Local rino version: ". $rino, LOGGER_DEBUG); $ssl_val = intval(Config::get('system', 'ssl_policy')); $ssl_policy = ''; @@ -1208,7 +1209,7 @@ class DFRN $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino='.$rino : ''); - logger('dfrn_deliver: ' . $url); + Logger::log('dfrn_deliver: ' . $url); $curlResult = Network::curl($url); @@ -1225,7 +1226,7 @@ class DFRN return -3; // timed out } - logger('dfrn_deliver: ' . $xml, LOGGER_DATA); + Logger::log('dfrn_deliver: ' . $xml, LOGGER_DATA); if (empty($xml)) { Contact::markForArchival($contact); @@ -1233,8 +1234,8 @@ class DFRN } if (strpos($xml, 'rino); $page = (($owner['page-flags'] == Contact::PAGE_COMMUNITY) ? 1 : 0); - logger("Remote rino version: ".$rino_remote_version." for ".$contact["url"], LOGGER_DEBUG); + Logger::log("Remote rino version: ".$rino_remote_version." for ".$contact["url"], LOGGER_DEBUG); if ($owner['page-flags'] == Contact::PAGE_PRVGROUP) { $page = 2; @@ -1297,7 +1298,7 @@ class DFRN } if ($final_dfrn_id != $orig_id) { - logger('dfrn_deliver: wrong dfrn_id.'); + Logger::log('dfrn_deliver: wrong dfrn_id.'); // did not decode properly - cannot trust this site Contact::markForArchival($contact); return 3; @@ -1325,7 +1326,7 @@ class DFRN if ($rino > 0 && $rino_remote_version > 0 && (! $dissolve)) { - logger('rino version: '. $rino_remote_version); + Logger::log('rino version: '. $rino_remote_version); switch ($rino_remote_version) { case 1: @@ -1334,7 +1335,7 @@ class DFRN break; default: - logger("rino: invalid requested version '$rino_remote_version'"); + Logger::log("rino: invalid requested version '$rino_remote_version'"); Contact::markForArchival($contact); return -8; } @@ -1359,19 +1360,19 @@ class DFRN } } - logger('md5 rawkey ' . md5($postvars['key'])); + Logger::log('md5 rawkey ' . md5($postvars['key'])); $postvars['key'] = bin2hex($postvars['key']); } - logger('dfrn_deliver: ' . "SENDING: " . print_r($postvars, true), LOGGER_DATA); + Logger::log('dfrn_deliver: ' . "SENDING: " . print_r($postvars, true), LOGGER_DATA); $postResult = Network::post($contact['notify'], $postvars); $xml = $postResult->getBody(); - logger('dfrn_deliver: ' . "RECEIVED: " . $xml, LOGGER_DATA); + Logger::log('dfrn_deliver: ' . "RECEIVED: " . $xml, LOGGER_DATA); $curl_stat = $postResult->getReturnCode(); if (empty($curl_stat) || empty($xml)) { @@ -1385,8 +1386,8 @@ class DFRN } if (strpos($xml, 'message)) { - logger('Delivery returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG); + Logger::log('Delivery returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG); } if (($res->status >= 200) && ($res->status <= 299)) { @@ -1429,14 +1430,14 @@ class DFRN if (!$public_batch) { if (empty($contact['addr'])) { - logger('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.'); + Logger::log('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.'); if (Contact::updateFromProbe($contact['id'])) { $new_contact = DBA::selectFirst('contact', ['addr'], ['id' => $contact['id']]); $contact['addr'] = $new_contact['addr']; } if (empty($contact['addr'])) { - logger('Unable to find contact handle for ' . $contact['id'] . ' - ' . $contact['url']); + Logger::log('Unable to find contact handle for ' . $contact['id'] . ' - ' . $contact['url']); Contact::markForArchival($contact); return -21; } @@ -1444,7 +1445,7 @@ class DFRN $fcontact = Diaspora::personByHandle($contact['addr']); if (empty($fcontact)) { - logger('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']); + Logger::log('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']); Contact::markForArchival($contact); return -22; } @@ -1473,7 +1474,7 @@ class DFRN $curl_stat = $postResult->getReturnCode(); if (empty($curl_stat) || empty($xml)) { - logger('Empty answer from ' . $contact['id'] . ' - ' . $dest_url); + Logger::log('Empty answer from ' . $contact['id'] . ' - ' . $dest_url); Contact::markForArchival($contact); return -9; // timed out } @@ -1484,8 +1485,8 @@ class DFRN } if (strpos($xml, 'message)) { - logger('Transmit to ' . $dest_url . ' returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG); + Logger::log('Transmit to ' . $dest_url . ' returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG); } if (($res->status >= 200) && ($res->status <= 299)) { @@ -1525,7 +1526,7 @@ class DFRN return; } - logger('updating birthday: ' . $birthday . ' for contact ' . $contact['id']); + Logger::log('updating birthday: ' . $birthday . ' for contact ' . $contact['id']); $bdtext = L10n::t('%s\'s birthday', $contact['name']); $bdtext2 = L10n::t('Happy Birthday %s', ' [url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'); @@ -1575,7 +1576,7 @@ class DFRN $author["network"] = $contact_old["network"]; } else { if (!$onlyfetch) { - logger("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, LOGGER_DEBUG); + Logger::log("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, LOGGER_DEBUG); } $author["contact-unknown"] = true; @@ -1624,11 +1625,11 @@ class DFRN } if (empty($author['avatar'])) { - logger('Empty author: ' . $xml); + Logger::log('Empty author: ' . $xml); } if (DBA::isResult($contact_old) && !$onlyfetch) { - logger("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", LOGGER_DEBUG); + Logger::log("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", LOGGER_DEBUG); $poco = ["url" => $contact_old["url"]]; @@ -1689,7 +1690,7 @@ class DFRN // If the "hide" element is present then the profile isn't searchable. $hide = intval(XML::getFirstNodeValue($xpath, $element . "/dfrn:hide/text()", $context) == "true"); - logger("Hidden status for contact " . $contact_old["url"] . ": " . $hide, LOGGER_DEBUG); + Logger::log("Hidden status for contact " . $contact_old["url"] . ": " . $hide, LOGGER_DEBUG); // If the contact isn't searchable then set the contact to "hidden". // Problem: This can be manually overridden by the user. @@ -1761,20 +1762,20 @@ class DFRN $contact[$field] = DateTimeFormat::utc($contact[$field]); if (strtotime($contact[$field]) > strtotime($contact_old[$field])) { - logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG); + Logger::log("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG); $update = true; } } foreach ($fields as $field => $data) { if ($contact[$field] != $contact_old[$field]) { - logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG); + Logger::log("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG); $update = true; } } if ($update) { - logger("Update contact data for contact " . $contact["id"] . " (" . $contact["nick"] . ")", LOGGER_DEBUG); + Logger::log("Update contact data for contact " . $contact["id"] . " (" . $contact["nick"] . ")", LOGGER_DEBUG); q( "UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', @@ -1881,7 +1882,7 @@ class DFRN */ private static function processMail($xpath, $mail, $importer) { - logger("Processing mails"); + Logger::log("Processing mails"); /// @TODO Rewrite this to one statement $msg = []; @@ -1921,7 +1922,7 @@ class DFRN notification($notif_params); - logger("Mail is processed, notification was sent."); + Logger::log("Mail is processed, notification was sent."); } /** @@ -1937,7 +1938,7 @@ class DFRN { $a = get_app(); - logger("Processing suggestions"); + Logger::log("Processing suggestions"); /// @TODO Rewrite this to one statement $suggest = []; @@ -2053,7 +2054,7 @@ class DFRN */ private static function processRelocation($xpath, $relocation, $importer) { - logger("Processing relocations"); + Logger::log("Processing relocations"); /// @TODO Rewrite this to one statement $relocate = []; @@ -2088,7 +2089,7 @@ class DFRN ); if (!DBA::isResult($r)) { - logger("Query failed to execute, no result returned in " . __FUNCTION__); + Logger::log("Query failed to execute, no result returned in " . __FUNCTION__); return false; } @@ -2115,7 +2116,7 @@ class DFRN Contact::updateAvatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true); - logger('Contacts are updated.'); + Logger::log('Contacts are updated.'); /// @TODO /// merge with current record, current contents have priority @@ -2174,7 +2175,7 @@ class DFRN if ($importer["page-flags"] == Contact::PAGE_COMMUNITY || $importer["page-flags"] == Contact::PAGE_PRVGROUP) { $sql_extra = ""; $community = true; - logger("possible community action"); + Logger::log("possible community action"); } else { $sql_extra = " AND `contact`.`self` AND `item`.`wall` "; } @@ -2211,7 +2212,7 @@ class DFRN */ if ($is_a_remote_action && $community && (!$r[0]["forum_mode"]) && (!$r[0]["wall"])) { $is_a_remote_action = false; - logger("not a community action"); + Logger::log("not a community action"); } if ($is_a_remote_action) { @@ -2298,7 +2299,7 @@ class DFRN */ private static function processVerbs($entrytype, $importer, &$item, &$is_like) { - logger("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, LOGGER_DEBUG); + Logger::log("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, LOGGER_DEBUG); if (($entrytype == DFRN::TOP_LEVEL)) { // The filling of the the "contact" variable is done for legcy reasons @@ -2310,22 +2311,22 @@ class DFRN // Big question: Do we need these functions? They were part of the "consume_feed" function. // This function once was responsible for DFRN and OStatus. if (activity_match($item["verb"], ACTIVITY_FOLLOW)) { - logger("New follower"); + Logger::log("New follower"); Contact::addRelationship($importer, $contact, $item, $nickname); return false; } if (activity_match($item["verb"], ACTIVITY_UNFOLLOW)) { - logger("Lost follower"); + Logger::log("Lost follower"); Contact::removeFollower($importer, $contact, $item); return false; } if (activity_match($item["verb"], ACTIVITY_REQ_FRIEND)) { - logger("New friend request"); + Logger::log("New friend request"); Contact::addRelationship($importer, $contact, $item, $nickname, true); return false; } if (activity_match($item["verb"], ACTIVITY_UNFRIEND)) { - logger("Lost sharer"); + Logger::log("Lost sharer"); Contact::removeSharer($importer, $contact, $item); return false; } @@ -2369,7 +2370,7 @@ class DFRN $item_tag = Item::selectFirst(['id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]); if (!DBA::isResult($item_tag)) { - logger("Query failed to execute, no result returned in " . __FUNCTION__); + Logger::log("Query failed to execute, no result returned in " . __FUNCTION__); return false; } @@ -2445,7 +2446,7 @@ class DFRN */ private static function processEntry($header, $xpath, $entry, $importer, $xml) { - logger("Processing entries"); + Logger::log("Processing entries"); $item = $header; @@ -2463,7 +2464,7 @@ class DFRN ); // Is there an existing item? if (DBA::isResult($current) && !self::isEditedTimestampNewer($current, $item)) { - logger("Item ".$item["uri"]." (".$item['edited'].") already existed.", LOGGER_DEBUG); + Logger::log("Item ".$item["uri"]." (".$item['edited'].") already existed.", LOGGER_DEBUG); return; } @@ -2671,10 +2672,10 @@ class DFRN // Is it an event? if (($item["object-type"] == ACTIVITY_OBJ_EVENT) && !$owner_unknown) { - logger("Item ".$item["uri"]." seems to contain an event.", LOGGER_DEBUG); + Logger::log("Item ".$item["uri"]." seems to contain an event.", LOGGER_DEBUG); $ev = Event::fromBBCode($item["body"]); if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) { - logger("Event in item ".$item["uri"]." was found.", LOGGER_DEBUG); + Logger::log("Event in item ".$item["uri"]." was found.", LOGGER_DEBUG); $ev["cid"] = $importer["id"]; $ev["uid"] = $importer["importer_uid"]; $ev["uri"] = $item["uri"]; @@ -2690,20 +2691,20 @@ class DFRN } $event_id = Event::store($ev); - logger("Event ".$event_id." was stored", LOGGER_DEBUG); + Logger::log("Event ".$event_id." was stored", LOGGER_DEBUG); return; } } } if (!self::processVerbs($entrytype, $importer, $item, $is_like)) { - logger("Exiting because 'processVerbs' told us so", LOGGER_DEBUG); + Logger::log("Exiting because 'processVerbs' told us so", LOGGER_DEBUG); return; } // This check is done here to be able to receive connection requests in "processVerbs" if (($entrytype == DFRN::TOP_LEVEL) && $owner_unknown) { - logger("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . ".", LOGGER_DEBUG); + Logger::log("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . ".", LOGGER_DEBUG); return; } @@ -2711,9 +2712,9 @@ class DFRN // Update content if 'updated' changes if (DBA::isResult($current)) { if (self::updateContent($current, $item, $importer, $entrytype)) { - logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG); + Logger::log("Item ".$item["uri"]." was updated.", LOGGER_DEBUG); } else { - logger("Item " . $item["uri"] . " already existed.", LOGGER_DEBUG); + Logger::log("Item " . $item["uri"] . " already existed.", LOGGER_DEBUG); } return; } @@ -2723,7 +2724,7 @@ class DFRN $parent = 0; if ($posted_id) { - logger("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, LOGGER_DEBUG); + Logger::log("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, LOGGER_DEBUG); if ($item['uid'] == 0) { Item::distribute($posted_id); @@ -2733,7 +2734,7 @@ class DFRN } } else { // $entrytype == DFRN::TOP_LEVEL if (($importer["uid"] == 0) && ($importer["importer_uid"] != 0)) { - logger("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored.", LOGGER_DEBUG); + Logger::log("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored.", LOGGER_DEBUG); return; } if (!link_compare($item["owner-link"], $importer["url"])) { @@ -2743,13 +2744,13 @@ class DFRN * the tgroup delivery code called from Item::insert will correct it if it's a forum, * but we're going to unconditionally correct it here so that the post will always be owned by our contact. */ - logger('Correcting item owner.', LOGGER_DEBUG); + Logger::log('Correcting item owner.', LOGGER_DEBUG); $item["owner-link"] = $importer["url"]; $item["owner-id"] = Contact::getIdForURL($importer["url"], 0); } if (($importer["rel"] == Contact::FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) { - logger("Contact ".$importer["id"]." is only follower and tgroup check was negative.", LOGGER_DEBUG); + Logger::log("Contact ".$importer["id"]." is only follower and tgroup check was negative.", LOGGER_DEBUG); return; } @@ -2763,7 +2764,7 @@ class DFRN $posted_id = $notify; } - logger("Item was stored with id ".$posted_id, LOGGER_DEBUG); + Logger::log("Item was stored with id ".$posted_id, LOGGER_DEBUG); if ($item['uid'] == 0) { Item::distribute($posted_id); @@ -2786,7 +2787,7 @@ class DFRN */ private static function processDeletion($xpath, $deletion, $importer) { - logger("Processing deletions"); + Logger::log("Processing deletions"); $uri = null; foreach ($deletion->attributes as $attributes) { @@ -2802,18 +2803,18 @@ class DFRN $condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]]; $item = Item::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted'], $condition); if (!DBA::isResult($item)) { - logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG); return; } if (strstr($item['file'], '[')) { - logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " is filed. So it won't be deleted.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " is filed. So it won't be deleted.", LOGGER_DEBUG); return; } // When it is a starting post it has to belong to the person that wants to delete it if (($item['id'] == $item['parent']) && ($item['contact-id'] != $importer["id"])) { - logger("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG); return; } @@ -2821,7 +2822,7 @@ class DFRN if (($item['id'] != $item['parent']) && ($item['contact-id'] != $importer["id"])) { $condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]]; if (!Item::exists($condition)) { - logger("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG); return; } } @@ -2830,7 +2831,7 @@ class DFRN return; } - logger('deleting item '.$item['id'].' uri='.$uri, LOGGER_DEBUG); + Logger::log('deleting item '.$item['id'].' uri='.$uri, LOGGER_DEBUG); Item::delete(['id' => $item['id']]); } @@ -2884,7 +2885,7 @@ class DFRN self::fetchauthor($xpath, $doc->firstChild, $importer, "dfrn:owner", false, $xml); } - logger("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG); + Logger::log("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG); // is it a public forum? Private forums aren't exposed with this method $forum = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:community/text()")); @@ -2950,7 +2951,7 @@ class DFRN self::processEntry($header, $xpath, $entry, $importer, $xml); } } - logger("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG); + Logger::log("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG); return 200; } @@ -3035,7 +3036,7 @@ class DFRN $url = curPageURL(); - logger('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); + Logger::log('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); $dest = (($url) ? '&destination_url=' . $url : ''); System::externalRedirect($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest); @@ -3090,7 +3091,7 @@ class DFRN foreach ($matches as $mtch) { if (link_compare($link, $mtch[1]) || link_compare($dlink, $mtch[1])) { $mention = true; - logger('mention found: ' . $mtch[2]); + Logger::log('mention found: ' . $mtch[2]); } } } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index e532b565d..516e7c63d 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -15,6 +15,7 @@ use Friendica\Content\Text\Markdown; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -260,7 +261,7 @@ class Diaspora if (base64_encode(base64_decode(base64_decode($signature))) == base64_decode($signature)) { $signature = base64_decode($signature); - logger("Repaired double encoded signature from Diaspora/Hubzilla handle ".$handle." - level ".$level, LOGGER_DEBUG); + Logger::log("Repaired double encoded signature from Diaspora/Hubzilla handle ".$handle." - level ".$level, LOGGER_DEBUG); // Do a recursive call to be able to fix even multiple levels if ($level < 10) { @@ -283,14 +284,14 @@ class Diaspora $basedom = XML::parseString($envelope); if (!is_object($basedom)) { - logger("Envelope is no XML file"); + Logger::log("Envelope is no XML file"); return false; } $children = $basedom->children('http://salmon-protocol.org/ns/magic-env'); if (sizeof($children) == 0) { - logger("XML has no children"); + Logger::log("XML has no children"); return false; } @@ -315,19 +316,19 @@ class Diaspora $signable_data = $msg.".".base64url_encode($type).".".base64url_encode($encoding).".".base64url_encode($alg); if ($handle == '') { - logger('No author could be decoded. Discarding. Message: ' . $envelope); + Logger::log('No author could be decoded. Discarding. Message: ' . $envelope); return false; } $key = self::key($handle); if ($key == '') { - logger("Couldn't get a key for handle " . $handle . ". Discarding."); + Logger::log("Couldn't get a key for handle " . $handle . ". Discarding."); return false; } $verify = Crypto::rsaVerify($signable_data, $sig, $key); if (!$verify) { - logger('Message from ' . $handle . ' did not verify. Discarding.'); + Logger::log('Message from ' . $handle . ' did not verify. Discarding.'); return false; } @@ -388,7 +389,7 @@ class Diaspora $j_outer_key_bundle = json_decode($outer_key_bundle); if (!is_object($j_outer_key_bundle)) { - logger('Outer Salmon did not verify. Discarding.'); + Logger::log('Outer Salmon did not verify. Discarding.'); if ($no_exit) { return false; } else { @@ -407,7 +408,7 @@ class Diaspora $basedom = XML::parseString($xml); if (!is_object($basedom)) { - logger('Received data does not seem to be an XML. Discarding. '.$xml); + Logger::log('Received data does not seem to be an XML. Discarding. '.$xml); if ($no_exit) { return false; } else { @@ -433,7 +434,7 @@ class Diaspora $key_id = $base->sig[0]->attributes()->key_id[0]; $author_addr = base64_decode($key_id); if ($author_addr == '') { - logger('No author could be decoded. Discarding. Message: ' . $xml); + Logger::log('No author could be decoded. Discarding. Message: ' . $xml); if ($no_exit) { return false; } else { @@ -443,7 +444,7 @@ class Diaspora $key = self::key($author_addr); if ($key == '') { - logger("Couldn't get a key for handle " . $author_addr . ". Discarding."); + Logger::log("Couldn't get a key for handle " . $author_addr . ". Discarding."); if ($no_exit) { return false; } else { @@ -453,7 +454,7 @@ class Diaspora $verify = Crypto::rsaVerify($signed_data, $signature, $key); if (!$verify) { - logger('Message did not verify. Discarding.'); + Logger::log('Message did not verify. Discarding.'); if ($no_exit) { return false; } else { @@ -483,7 +484,7 @@ class Diaspora $basedom = XML::parseString($xml); if (!is_object($basedom)) { - logger("XML is not parseable."); + Logger::log("XML is not parseable."); return false; } $children = $basedom->children('https://joindiaspora.com/protocol'); @@ -497,7 +498,7 @@ class Diaspora } else { // This happens with posts from a relais if (!$importer) { - logger("This is no private post in the old format", LOGGER_DEBUG); + Logger::log("This is no private post in the old format", LOGGER_DEBUG); return false; } @@ -516,7 +517,7 @@ class Diaspora $decrypted = self::aesDecrypt($outer_key, $outer_iv, $ciphertext); - logger('decrypted: '.$decrypted, LOGGER_DEBUG); + Logger::log('decrypted: '.$decrypted, LOGGER_DEBUG); $idom = XML::parseString($decrypted); $inner_iv = base64_decode($idom->iv); @@ -539,7 +540,7 @@ class Diaspora } if (!$base) { - logger('unable to locate salmon data in xml'); + Logger::log('unable to locate salmon data in xml'); System::httpExit(400); } @@ -577,29 +578,29 @@ class Diaspora } if (!$author_link) { - logger('Could not retrieve author URI.'); + Logger::log('Could not retrieve author URI.'); System::httpExit(400); } // Once we have the author URI, go to the web and try to find their public key // (first this will look it up locally if it is in the fcontact cache) // This will also convert diaspora public key from pkcs#1 to pkcs#8 - logger('Fetching key for '.$author_link); + Logger::log('Fetching key for '.$author_link); $key = self::key($author_link); if (!$key) { - logger('Could not retrieve author key.'); + Logger::log('Could not retrieve author key.'); System::httpExit(400); } $verify = Crypto::rsaVerify($signed_data, $signature, $key); if (!$verify) { - logger('Message did not verify. Discarding.'); + Logger::log('Message did not verify. Discarding.'); System::httpExit(400); } - logger('Message verified.'); + Logger::log('Message verified.'); return ['message' => (string)$inner_decrypted, 'author' => unxmlify($author_link), @@ -618,12 +619,12 @@ class Diaspora { $enabled = intval(Config::get("system", "diaspora_enabled")); if (!$enabled) { - logger("diaspora is disabled"); + Logger::log("diaspora is disabled"); return false; } if (!($fields = self::validPosting($msg))) { - logger("Invalid posting"); + Logger::log("Invalid posting"); return false; } @@ -652,7 +653,7 @@ class Diaspora if (is_null($fields)) { $private = true; if (!($fields = self::validPosting($msg))) { - logger("Invalid posting"); + Logger::log("Invalid posting"); return false; } } else { @@ -661,12 +662,12 @@ class Diaspora $type = $fields->getName(); - logger("Received message type ".$type." from ".$sender." for user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Received message type ".$type." from ".$sender." for user ".$importer["uid"], LOGGER_DEBUG); switch ($type) { case "account_migration": if (!$private) { - logger('Message with type ' . $type . ' is not private, quitting.'); + Logger::log('Message with type ' . $type . ' is not private, quitting.'); return false; } return self::receiveAccountMigration($importer, $fields); @@ -679,14 +680,14 @@ class Diaspora case "contact": if (!$private) { - logger('Message with type ' . $type . ' is not private, quitting.'); + Logger::log('Message with type ' . $type . ' is not private, quitting.'); return false; } return self::receiveContactRequest($importer, $fields); case "conversation": if (!$private) { - logger('Message with type ' . $type . ' is not private, quitting.'); + Logger::log('Message with type ' . $type . ' is not private, quitting.'); return false; } return self::receiveConversation($importer, $msg, $fields); @@ -696,14 +697,14 @@ class Diaspora case "message": if (!$private) { - logger('Message with type ' . $type . ' is not private, quitting.'); + Logger::log('Message with type ' . $type . ' is not private, quitting.'); return false; } return self::receiveMessage($importer, $fields); case "participation": if (!$private) { - logger('Message with type ' . $type . ' is not private, quitting.'); + Logger::log('Message with type ' . $type . ' is not private, quitting.'); return false; } return self::receiveParticipation($importer, $fields); @@ -716,7 +717,7 @@ class Diaspora case "profile": if (!$private) { - logger('Message with type ' . $type . ' is not private, quitting.'); + Logger::log('Message with type ' . $type . ' is not private, quitting.'); return false; } return self::receiveProfile($importer, $fields); @@ -731,7 +732,7 @@ class Diaspora return self::receiveStatusMessage($importer, $fields, $msg["message"]); default: - logger("Unknown message type ".$type); + Logger::log("Unknown message type ".$type); return false; } @@ -753,7 +754,7 @@ class Diaspora $data = XML::parseString($msg["message"]); if (!is_object($data)) { - logger("No valid XML ".$msg["message"], LOGGER_DEBUG); + Logger::log("No valid XML ".$msg["message"], LOGGER_DEBUG); return false; } @@ -771,7 +772,7 @@ class Diaspora $type = $element->getName(); $orig_type = $type; - logger("Got message type ".$type.": ".$msg["message"], LOGGER_DATA); + Logger::log("Got message type ".$type.": ".$msg["message"], LOGGER_DATA); // All retractions are handled identically from now on. // In the new version there will only be "retraction". @@ -847,7 +848,7 @@ class Diaspora // This is something that shouldn't happen at all. if (in_array($type, ["status_message", "reshare", "profile"])) { if ($msg["author"] != $fields->author) { - logger("Message handle is not the same as envelope sender. Quitting this message."); + Logger::log("Message handle is not the same as envelope sender. Quitting this message."); return false; } } @@ -858,31 +859,31 @@ class Diaspora } // No author_signature? This is a must, so we quit. if (!isset($author_signature)) { - logger("No author signature for type ".$type." - Message: ".$msg["message"], LOGGER_DEBUG); + Logger::log("No author signature for type ".$type." - Message: ".$msg["message"], LOGGER_DEBUG); return false; } if (isset($parent_author_signature)) { $key = self::key($msg["author"]); if (empty($key)) { - logger("No key found for parent author ".$msg["author"], LOGGER_DEBUG); + Logger::log("No key found for parent author ".$msg["author"], LOGGER_DEBUG); return false; } if (!Crypto::rsaVerify($signed_data, $parent_author_signature, $key, "sha256")) { - logger("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, LOGGER_DEBUG); + Logger::log("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, LOGGER_DEBUG); return false; } } $key = self::key($fields->author); if (empty($key)) { - logger("No key found for author ".$fields->author, LOGGER_DEBUG); + Logger::log("No key found for author ".$fields->author, LOGGER_DEBUG); return false; } if (!Crypto::rsaVerify($signed_data, $author_signature, $key, "sha256")) { - logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG); + Logger::log("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG); return false; } else { return $fields; @@ -900,7 +901,7 @@ class Diaspora { $handle = strval($handle); - logger("Fetching diaspora key for: ".$handle); + Logger::log("Fetching diaspora key for: ".$handle); $r = self::personByHandle($handle); if ($r) { @@ -923,7 +924,7 @@ class Diaspora $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]); if (DBA::isResult($person)) { - logger("In cache " . print_r($person, true), LOGGER_DEBUG); + Logger::log("In cache " . print_r($person, true), LOGGER_DEBUG); // update record occasionally so it doesn't get stale $d = strtotime($person["updated"]." +00:00"); @@ -937,7 +938,7 @@ class Diaspora } if (!DBA::isResult($person) || $update) { - logger("create or refresh", LOGGER_DEBUG); + Logger::log("create or refresh", LOGGER_DEBUG); $r = Probe::uri($handle, Protocol::DIASPORA); // Note that Friendica contacts will return a "Diaspora person" @@ -989,7 +990,7 @@ class Diaspora { $handle = false; - logger("contact id is ".$contact_id." - pcontact id is ".$pcontact_id, LOGGER_DEBUG); + Logger::log("contact id is ".$contact_id." - pcontact id is ".$pcontact_id, LOGGER_DEBUG); if ($pcontact_id != 0) { $contact = DBA::selectFirst('contact', ['addr'], ['id' => $pcontact_id]); @@ -1007,7 +1008,7 @@ class Diaspora if (DBA::isResult($r)) { $contact = $r[0]; - logger("contact 'self' = ".$contact['self']." 'url' = ".$contact['url'], LOGGER_DEBUG); + Logger::log("contact 'self' = ".$contact['self']." 'url' = ".$contact['url'], LOGGER_DEBUG); if ($contact['addr'] != "") { $handle = $contact['addr']; @@ -1033,7 +1034,7 @@ class Diaspora */ public static function urlFromContactGuid($fcontact_guid) { - logger("fcontact guid is ".$fcontact_guid, LOGGER_DEBUG); + Logger::log("fcontact guid is ".$fcontact_guid, LOGGER_DEBUG); $r = q( "SELECT `url` FROM `fcontact` WHERE `url` != '' AND `network` = '%s' AND `guid` = '%s'", @@ -1068,14 +1069,14 @@ class Diaspora } if (!$cid) { - logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG); + Logger::log("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG); return false; } $contact = DBA::selectFirst('contact', [], ['id' => $cid]); if (!DBA::isResult($contact)) { // This here shouldn't happen at all - logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG); + Logger::log("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG); return false; } @@ -1108,7 +1109,7 @@ class Diaspora // ); // // $contact["rel"] = Contact::FRIEND; - // logger("defining user ".$contact["nick"]." as friend"); + // Logger::log("defining user ".$contact["nick"]." as friend"); //} // We don't seem to like that person @@ -1145,7 +1146,7 @@ class Diaspora { $contact = self::contactByHandle($importer["uid"], $handle); if (!$contact) { - logger("A Contact for handle ".$handle." and user ".$importer["uid"]." was not found"); + Logger::log("A Contact for handle ".$handle." and user ".$importer["uid"]." was not found"); // If a contact isn't found, we accept it anyway if it is a comment if ($is_comment && ($importer["uid"] != 0)) { return self::contactByHandle(0, $handle); @@ -1157,7 +1158,7 @@ class Diaspora } if (!self::postAllow($importer, $contact, $is_comment)) { - logger("The handle: ".$handle." is not allowed to post to user ".$importer["uid"]); + Logger::log("The handle: ".$handle." is not allowed to post to user ".$importer["uid"]); return false; } return $contact; @@ -1175,7 +1176,7 @@ class Diaspora { $item = Item::selectFirst(['id'], ['uid' => $uid, 'guid' => $guid]); if (DBA::isResult($item)) { - logger("message ".$guid." already exists for user ".$uid); + Logger::log("message ".$guid." already exists for user ".$uid); return $item["id"]; } @@ -1277,7 +1278,7 @@ class Diaspora $server = $serverparts["scheme"]."://".$serverparts["host"]; - logger("Trying to fetch item ".$guid." from ".$server, LOGGER_DEBUG); + Logger::log("Trying to fetch item ".$guid." from ".$server, LOGGER_DEBUG); $msg = self::message($guid, $server); @@ -1285,7 +1286,7 @@ class Diaspora return false; } - logger("Successfully fetched item ".$guid." from ".$server, LOGGER_DEBUG); + Logger::log("Successfully fetched item ".$guid." from ".$server, LOGGER_DEBUG); // Now call the dispatcher return self::dispatchPublic($msg); @@ -1312,16 +1313,16 @@ class Diaspora // This will work for new Diaspora servers and Friendica servers from 3.5 $source_url = $server."/fetch/post/".urlencode($guid); - logger("Fetch post from ".$source_url, LOGGER_DEBUG); + Logger::log("Fetch post from ".$source_url, LOGGER_DEBUG); $envelope = Network::fetchUrl($source_url); if ($envelope) { - logger("Envelope was fetched.", LOGGER_DEBUG); + Logger::log("Envelope was fetched.", LOGGER_DEBUG); $x = self::verifyMagicEnvelope($envelope); if (!$x) { - logger("Envelope could not be verified.", LOGGER_DEBUG); + Logger::log("Envelope could not be verified.", LOGGER_DEBUG); } else { - logger("Envelope was verified.", LOGGER_DEBUG); + Logger::log("Envelope was verified.", LOGGER_DEBUG); } } else { $x = false; @@ -1330,7 +1331,7 @@ class Diaspora // This will work for older Diaspora and Friendica servers if (!$x) { $source_url = $server."/p/".urlencode($guid).".xml"; - logger("Fetch post from ".$source_url, LOGGER_DEBUG); + Logger::log("Fetch post from ".$source_url, LOGGER_DEBUG); $x = Network::fetchUrl($source_url); if (!$x) { @@ -1346,11 +1347,11 @@ class Diaspora if ($source_xml->post->reshare) { // Reshare of a reshare - old Diaspora version - logger("Message is a reshare", LOGGER_DEBUG); + Logger::log("Message is a reshare", LOGGER_DEBUG); return self::message($source_xml->post->reshare->root_guid, $server, ++$level); } elseif ($source_xml->getName() == "reshare") { // Reshare of a reshare - new Diaspora version - logger("Message is a new reshare", LOGGER_DEBUG); + Logger::log("Message is a new reshare", LOGGER_DEBUG); return self::message($source_xml->root_guid, $server, ++$level); } @@ -1365,7 +1366,7 @@ class Diaspora // If this isn't a "status_message" then quit if (!$author) { - logger("Message doesn't seem to be a status message", LOGGER_DEBUG); + Logger::log("Message doesn't seem to be a status message", LOGGER_DEBUG); return false; } @@ -1404,17 +1405,17 @@ class Diaspora } if ($result) { - logger("Fetched missing item ".$guid." - result: ".$result, LOGGER_DEBUG); + Logger::log("Fetched missing item ".$guid." - result: ".$result, LOGGER_DEBUG); $item = Item::selectFirst($fields, $condition); } } if (!DBA::isResult($item)) { - logger("parent item not found: parent: ".$guid." - user: ".$uid); + Logger::log("parent item not found: parent: ".$guid." - user: ".$uid); return false; } else { - logger("parent item found: parent: ".$guid." - user: ".$uid); + Logger::log("parent item found: parent: ".$guid." - user: ".$uid); return $item; } } @@ -1510,17 +1511,17 @@ class Diaspora $contact = self::contactByHandle($importer["uid"], $old_handle); if (!$contact) { - logger("cannot find contact for sender: ".$old_handle." and user ".$importer["uid"]); + Logger::log("cannot find contact for sender: ".$old_handle." and user ".$importer["uid"]); return false; } - logger("Got migration for ".$old_handle.", to ".$new_handle." with user ".$importer["uid"]); + Logger::log("Got migration for ".$old_handle.", to ".$new_handle." with user ".$importer["uid"]); // Check signature $signed_text = 'AccountMigration:'.$old_handle.':'.$new_handle; $key = self::key($old_handle); if (!Crypto::rsaVerify($signed_text, $signature, $key, "sha256")) { - logger('No valid signature for migration.'); + Logger::log('No valid signature for migration.'); return false; } @@ -1530,7 +1531,7 @@ class Diaspora // change the technical stuff in contact and gcontact $data = Probe::uri($new_handle); if ($data['network'] == Protocol::PHANTOM) { - logger('Account for '.$new_handle." couldn't be probed."); + Logger::log('Account for '.$new_handle." couldn't be probed."); return false; } @@ -1550,7 +1551,7 @@ class Diaspora DBA::update('gcontact', $fields, ['addr' => $old_handle]); - logger('Contacts are updated.'); + Logger::log('Contacts are updated.'); return true; } @@ -1573,7 +1574,7 @@ class Diaspora DBA::delete('gcontact', ['addr' => $author]); - logger('Removed contacts for ' . $author); + Logger::log('Removed contacts for ' . $author); return true; } @@ -1634,7 +1635,7 @@ class Diaspora { $item = Item::selectFirst(['uid'], ['origin' => true, 'guid' => $guid]); if (DBA::isResult($item)) { - logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG); + Logger::log("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG); $contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]); if (DBA::isResult($contact)) { return $contact; @@ -1690,7 +1691,7 @@ class Diaspora $person = self::personByHandle($author); if (!is_array($person)) { - logger("unable to find author details"); + Logger::log("unable to find author details"); return false; } @@ -1749,7 +1750,7 @@ class Diaspora } if ($message_id) { - logger("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id, json_encode($data)); } @@ -1792,7 +1793,7 @@ class Diaspora $msg_created_at = DateTimeFormat::utc(notags(unxmlify($mesg->created_at))); if ($msg_conversation_guid != $guid) { - logger("message conversation guid does not belong to the current conversation."); + Logger::log("message conversation guid does not belong to the current conversation."); return false; } @@ -1804,7 +1805,7 @@ class Diaspora DBA::lock('mail'); if (DBA::exists('mail', ['guid' => $msg_guid, 'uid' => $importer["uid"]])) { - logger("duplicate message already delivered.", LOGGER_DEBUG); + Logger::log("duplicate message already delivered.", LOGGER_DEBUG); return false; } @@ -1869,7 +1870,7 @@ class Diaspora $messages = $data->message; if (!count($messages)) { - logger("empty conversation"); + Logger::log("empty conversation"); return false; } @@ -1896,7 +1897,7 @@ class Diaspora } } if (!$conversation) { - logger("unable to create conversation."); + Logger::log("unable to create conversation."); return false; } @@ -1947,7 +1948,7 @@ class Diaspora $person = self::personByHandle($author); if (!is_array($person)) { - logger("unable to find author details"); + Logger::log("unable to find author details"); return false; } @@ -2008,7 +2009,7 @@ class Diaspora } if ($message_id) { - logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id, json_encode($data)); } @@ -2044,7 +2045,7 @@ class Diaspora $conversation = DBA::selectFirst('conv', [], $condition); if (!DBA::isResult($conversation)) { - logger("conversation not available."); + Logger::log("conversation not available."); return false; } @@ -2052,7 +2053,7 @@ class Diaspora $person = self::personByHandle($author); if (!$person) { - logger("unable to find author details"); + Logger::log("unable to find author details"); return false; } @@ -2063,7 +2064,7 @@ class Diaspora DBA::lock('mail'); if (DBA::exists('mail', ['guid' => $guid, 'uid' => $importer["uid"]])) { - logger("duplicate message already delivered.", LOGGER_DEBUG); + Logger::log("duplicate message already delivered.", LOGGER_DEBUG); return false; } @@ -2107,19 +2108,19 @@ class Diaspora $contact_id = Contact::getIdForURL($author); if (!$contact_id) { - logger('Contact not found: '.$author); + Logger::log('Contact not found: '.$author); return false; } $person = self::personByHandle($author); if (!is_array($person)) { - logger("Person not found: ".$author); + Logger::log("Person not found: ".$author); return false; } $item = Item::selectFirst(['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]); if (!DBA::isResult($item)) { - logger('Item not found, no origin or private: '.$parent_guid); + Logger::log('Item not found, no origin or private: '.$parent_guid); return false; } @@ -2131,7 +2132,7 @@ class Diaspora $server = $author; } - logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG); + Logger::log('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG); if (!DBA::exists('participation', ['iid' => $item['id'], 'server' => $server])) { DBA::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]); @@ -2148,7 +2149,7 @@ class Diaspora } else { $cmd = $comment['self'] ? 'like' : 'comment-import'; } - logger("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, LOGGER_DEBUG); + Logger::log("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, LOGGER_DEBUG); Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id); } DBA::close($comments); @@ -2274,7 +2275,7 @@ class Diaspora GContact::link($gcid, $importer["uid"], $contact["id"]); - logger("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], LOGGER_DEBUG); return true; } @@ -2336,7 +2337,7 @@ class Diaspora // That makes us friends. if ($contact) { if ($following) { - logger("Author ".$author." (Contact ".$contact["id"].") wants to follow us.", LOGGER_DEBUG); + Logger::log("Author ".$author." (Contact ".$contact["id"].") wants to follow us.", LOGGER_DEBUG); self::receiveRequestMakeFriend($importer, $contact); // refetch the contact array @@ -2347,36 +2348,36 @@ class Diaspora if (in_array($contact["rel"], [Contact::FRIEND])) { $user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]); if (DBA::isResult($user)) { - logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG); $ret = self::sendShare($user, $contact); } } return true; } else { - logger("Author ".$author." doesn't want to follow us anymore.", LOGGER_DEBUG); + Logger::log("Author ".$author." doesn't want to follow us anymore.", LOGGER_DEBUG); Contact::removeFollower($importer, $contact); return true; } } if (!$following && $sharing && in_array($importer["page-flags"], [Contact::PAGE_SOAPBOX, Contact::PAGE_NORMAL])) { - logger("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG); return false; } elseif (!$following && !$sharing) { - logger("Author ".$author." doesn't want anything - and we don't know the author. Request is ignored.", LOGGER_DEBUG); + Logger::log("Author ".$author." doesn't want anything - and we don't know the author. Request is ignored.", LOGGER_DEBUG); return false; } elseif (!$following && $sharing) { - logger("Author ".$author." wants to share with us.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to share with us.", LOGGER_DEBUG); } elseif ($following && $sharing) { - logger("Author ".$author." wants to have a bidirectional conection.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to have a bidirectional conection.", LOGGER_DEBUG); } elseif ($following && !$sharing) { - logger("Author ".$author." wants to listen to us.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to listen to us.", LOGGER_DEBUG); } $ret = self::personByHandle($author); if (!$ret || ($ret["network"] != Protocol::DIASPORA)) { - logger("Cannot resolve diaspora handle ".$author." for ".$recipient); + Logger::log("Cannot resolve diaspora handle ".$author." for ".$recipient); return false; } @@ -2407,18 +2408,18 @@ class Diaspora $contact_record = self::contactByHandle($importer["uid"], $author); if (!$contact_record) { - logger("unable to locate newly created contact record."); + Logger::log("unable to locate newly created contact record."); return; } - logger("Author ".$author." was added as contact number ".$contact_record["id"].".", LOGGER_DEBUG); + Logger::log("Author ".$author." was added as contact number ".$contact_record["id"].".", LOGGER_DEBUG); Group::addMember(User::getDefaultGroup($importer['uid'], $ret["network"]), $contact_record['id']); Contact::updateAvatar($ret["photo"], $importer['uid'], $contact_record["id"], true); if (in_array($importer["page-flags"], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP])) { - logger("Sending intra message for author ".$author.".", LOGGER_DEBUG); + Logger::log("Sending intra message for author ".$author.".", LOGGER_DEBUG); $hash = random_string().(string)time(); // Generate a confirm_key @@ -2436,7 +2437,7 @@ class Diaspora } else { // automatic friend approval - logger("Does an automatic friend approval for author ".$author.".", LOGGER_DEBUG); + Logger::log("Does an automatic friend approval for author ".$author.".", LOGGER_DEBUG); Contact::updateAvatar($contact_record["photo"], $importer["uid"], $contact_record["id"]); @@ -2470,7 +2471,7 @@ class Diaspora $user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]); if (DBA::isResult($user)) { - logger("Sending share message (Relation: ".$new_relation.") to author ".$author." - Contact: ".$contact_record["id"]." - User: ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Sending share message (Relation: ".$new_relation.") to author ".$author." - Contact: ".$contact_record["id"]." - User: ".$importer["uid"], LOGGER_DEBUG); $ret = self::sendShare($user, $contact_record); // Send the profile data, maybe it weren't transmitted before @@ -2493,7 +2494,7 @@ class Diaspora public static function originalItem($guid, $orig_author) { if (empty($guid)) { - logger('Empty guid. Quitting.'); + Logger::log('Empty guid. Quitting.'); return false; } @@ -2504,7 +2505,7 @@ class Diaspora $item = Item::selectFirst($fields, $condition); if (DBA::isResult($item)) { - logger("reshared message ".$guid." already exists on system."); + Logger::log("reshared message ".$guid." already exists on system."); // Maybe it is already a reshared item? // Then refetch the content, if it is a reshare from a reshare. @@ -2527,17 +2528,17 @@ class Diaspora if (!DBA::isResult($item)) { if (empty($orig_author)) { - logger('Empty author for guid ' . $guid . '. Quitting.'); + Logger::log('Empty author for guid ' . $guid . '. Quitting.'); return false; } $server = "https://".substr($orig_author, strpos($orig_author, "@") + 1); - logger("1st try: reshared message ".$guid." will be fetched via SSL from the server ".$server); + Logger::log("1st try: reshared message ".$guid." will be fetched via SSL from the server ".$server); $stored = self::storeByGuid($guid, $server); if (!$stored) { $server = "http://".substr($orig_author, strpos($orig_author, "@") + 1); - logger("2nd try: reshared message ".$guid." will be fetched without SSL from the server ".$server); + Logger::log("2nd try: reshared message ".$guid." will be fetched without SSL from the server ".$server); $stored = self::storeByGuid($guid, $server); } @@ -2643,7 +2644,7 @@ class Diaspora self::sendParticipation($contact, $datarray); if ($message_id) { - logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id); } @@ -2670,7 +2671,7 @@ class Diaspora $person = self::personByHandle($author); if (!is_array($person)) { - logger("unable to find author detail for ".$author); + Logger::log("unable to find author detail for ".$author); return false; } @@ -2690,13 +2691,13 @@ class Diaspora $r = Item::select($fields, $condition); if (!DBA::isResult($r)) { - logger("Target guid ".$target_guid." was not found on this system for user ".$importer['uid']."."); + Logger::log("Target guid ".$target_guid." was not found on this system for user ".$importer['uid']."."); return false; } while ($item = Item::fetch($r)) { if (strstr($item['file'], '[')) { - logger("Target guid " . $target_guid . " for user " . $item['uid'] . " is filed. So it won't be deleted.", LOGGER_DEBUG); + Logger::log("Target guid " . $target_guid . " for user " . $item['uid'] . " is filed. So it won't be deleted.", LOGGER_DEBUG); continue; } @@ -2705,13 +2706,13 @@ class Diaspora // Only delete it if the parent author really fits if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) { - logger("Thread author ".$parent["author-link"]." and item author ".$item["author-link"]." don't fit to expected contact ".$contact["url"], LOGGER_DEBUG); + Logger::log("Thread author ".$parent["author-link"]." and item author ".$item["author-link"]." don't fit to expected contact ".$contact["url"], LOGGER_DEBUG); continue; } Item::delete(['id' => $item['id']]); - logger("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], LOGGER_DEBUG); + Logger::log("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], LOGGER_DEBUG); } return true; @@ -2732,7 +2733,7 @@ class Diaspora $contact = self::contactByHandle($importer["uid"], $sender); if (!$contact && (in_array($target_type, ["Contact", "Person"]))) { - logger("cannot find contact for sender: ".$sender." and user ".$importer["uid"]); + Logger::log("cannot find contact for sender: ".$sender." and user ".$importer["uid"]); return false; } @@ -2740,7 +2741,7 @@ class Diaspora $contact = []; } - logger("Got retraction for ".$target_type.", sender ".$sender." and user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Got retraction for ".$target_type.", sender ".$sender." and user ".$importer["uid"], LOGGER_DEBUG); switch ($target_type) { case "Comment": @@ -2756,7 +2757,7 @@ class Diaspora break; default: - logger("Unknown target type ".$target_type); + Logger::log("Unknown target type ".$target_type); return false; } return true; @@ -2870,7 +2871,7 @@ class Diaspora self::sendParticipation($contact, $datarray); if ($message_id) { - logger("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id); } @@ -2922,11 +2923,11 @@ class Diaspora */ public static function encodePrivateData($msg, array $user, array $contact, $prvkey, $pubkey) { - logger("Message: ".$msg, LOGGER_DATA); + Logger::log("Message: ".$msg, LOGGER_DATA); // without a public key nothing will work if (!$pubkey) { - logger("pubkey missing: contact id: ".$contact["id"]); + Logger::log("pubkey missing: contact id: ".$contact["id"]); return false; } @@ -3068,11 +3069,11 @@ class Diaspora } if (!$dest_url) { - logger("no url for contact: ".$contact["id"]." batch mode =".$public_batch); + Logger::log("no url for contact: ".$contact["id"]." batch mode =".$public_batch); return 0; } - logger("transmit: ".$logid."-".$guid." ".$dest_url); + Logger::log("transmit: ".$logid."-".$guid." ".$dest_url); if (!$queue_run && Queue::wasDelayed($contact["id"])) { $return_code = 0; @@ -3083,16 +3084,16 @@ class Diaspora $postResult = Network::post($dest_url."/", $envelope, ["Content-Type: ".$content_type]); $return_code = $postResult->getReturnCode(); } else { - logger("test_mode"); + Logger::log("test_mode"); return 200; } } - logger("transmit: ".$logid."-".$guid." to ".$dest_url." returns: ".$return_code); + Logger::log("transmit: ".$logid."-".$guid." to ".$dest_url." returns: ".$return_code); if (!$return_code || (($return_code == 503) && (stristr($postResult->getHeader(), "retry-after")))) { if (!$no_queue && !empty($contact['contact-type']) && ($contact['contact-type'] != Contact::ACCOUNT_TYPE_RELAY)) { - logger("queue message"); + Logger::log("queue message"); // queue message for redelivery Queue::add($contact["id"], Protocol::DIASPORA, $envelope, $public_batch, $guid); } @@ -3140,8 +3141,8 @@ class Diaspora { $msg = self::buildPostXml($type, $message); - logger('message: '.$msg, LOGGER_DATA); - logger('send guid '.$guid, LOGGER_DEBUG); + Logger::log('message: '.$msg, LOGGER_DATA); + Logger::log('send guid '.$guid, LOGGER_DEBUG); // Fallback if the private key wasn't transmitted in the expected field if (empty($owner['uprvkey'])) { @@ -3157,7 +3158,7 @@ class Diaspora $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid); } - logger("guid: ".$guid." result ".$return_code, LOGGER_DEBUG); + Logger::log("guid: ".$guid." result ".$return_code, LOGGER_DEBUG); return $return_code; } @@ -3202,7 +3203,7 @@ class Diaspora "parent_type" => "Post", "parent_guid" => $item["guid"]]; - logger("Send participation for ".$item["guid"]." by ".$author, LOGGER_DEBUG); + Logger::log("Send participation for ".$item["guid"]." by ".$author, LOGGER_DEBUG); // It doesn't matter what we store, we only want to avoid sending repeated notifications for the same item Cache::set($cachekey, $item["guid"], Cache::QUARTER_HOUR); @@ -3231,7 +3232,7 @@ class Diaspora "profile" => $profile, "signature" => $signature]; - logger("Send account migration ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Send account migration ".print_r($message, true), LOGGER_DEBUG); return self::buildAndTransmit($owner, $contact, "account_migration", $message); } @@ -3274,7 +3275,7 @@ class Diaspora "following" => "true", "sharing" => "true"]; - logger("Send share ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Send share ".print_r($message, true), LOGGER_DEBUG); return self::buildAndTransmit($owner, $contact, "contact", $message); } @@ -3294,7 +3295,7 @@ class Diaspora "following" => "false", "sharing" => "false"]; - logger("Send unshare ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Send unshare ".print_r($message, true), LOGGER_DEBUG); return self::buildAndTransmit($owner, $contact, "contact", $message); } @@ -3654,7 +3655,7 @@ class Diaspora $attend_answer = 'tentative'; break; default: - logger('Unknown verb '.$item['verb'].' in item '.$item['guid']); + Logger::log('Unknown verb '.$item['verb'].' in item '.$item['guid']); return false; } @@ -3807,7 +3808,7 @@ class Diaspora $type = "comment"; } - logger("Got relayable data ".$type." for item ".$item["guid"]." (".$item["id"].")", LOGGER_DEBUG); + Logger::log("Got relayable data ".$type." for item ".$item["guid"]." (".$item["id"].")", LOGGER_DEBUG); // Old way - is used by the internal Friendica functions /// @todo Change all signatur storing functions to the new format @@ -3831,13 +3832,13 @@ class Diaspora $message[$field] = $data; } } else { - logger("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$item['signed_text'], LOGGER_DEBUG); + Logger::log("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$item['signed_text'], LOGGER_DEBUG); } } $message["parent_author_signature"] = self::signature($owner, $message); - logger("Relayed data ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Relayed data ".print_r($message, true), LOGGER_DEBUG); return self::buildAndTransmit($owner, $contact, $type, $message, $public_batch, $item["guid"]); } @@ -3871,7 +3872,7 @@ class Diaspora "target_guid" => $item['guid'], "target_type" => $target_type]; - logger("Got message ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Got message ".print_r($message, true), LOGGER_DEBUG); return self::buildAndTransmit($owner, $contact, $msg_type, $message, $public_batch, $item["guid"]); } @@ -3891,7 +3892,7 @@ class Diaspora $cnv = DBA::selectFirst('conv', [], ['id' => $item["convid"], 'uid' => $item["uid"]]); if (!DBA::isResult($cnv)) { - logger("conversation not found."); + Logger::log("conversation not found."); return; } @@ -4107,7 +4108,7 @@ class Diaspora $message = self::createProfileData($uid); foreach ($recips as $recip) { - logger("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG); + Logger::log("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG); self::buildAndTransmit($owner, $recip, "profile", $message, false, "", false); } } @@ -4124,6 +4125,7 @@ class Diaspora { $owner = User::getOwnerDataById($uid); if (empty($owner)) { + Logger::log("No owner post, so not storing signature", LOGGER_DEBUG); return false; } @@ -4153,6 +4155,7 @@ class Diaspora { $owner = User::getOwnerDataById($uid); if (empty($owner)) { + Logger::log("No owner post, so not storing signature", LOGGER_DEBUG); return false; } diff --git a/src/Protocol/Email.php b/src/Protocol/Email.php index 00122e2ea..5dba94ee5 100644 --- a/src/Protocol/Email.php +++ b/src/Protocol/Email.php @@ -4,6 +4,7 @@ */ namespace Friendica\Protocol; +use Friendica\Core\Logger; use Friendica\Content\Text\HTML; use Friendica\Core\Protocol; @@ -28,12 +29,12 @@ class Email $errors = imap_errors(); if (!empty($errors)) { - logger('IMAP Errors occured: ' . json_encode($errors)); + Logger::log('IMAP Errors occured: ' . json_encode($errors)); } $alerts = imap_alerts(); if (!empty($alerts)) { - logger('IMAP Alerts occured: ' . json_encode($alerts)); + Logger::log('IMAP Alerts occured: ' . json_encode($alerts)); } return $mbox; @@ -54,21 +55,21 @@ class Email if (!$search1) { $search1 = []; } else { - logger("Found mails from ".$email_addr, LOGGER_DEBUG); + Logger::log("Found mails from ".$email_addr, LOGGER_DEBUG); } $search2 = @imap_search($mbox, 'TO "' . $email_addr . '"', SE_UID); if (!$search2) { $search2 = []; } else { - logger("Found mails to ".$email_addr, LOGGER_DEBUG); + Logger::log("Found mails to ".$email_addr, LOGGER_DEBUG); } $search3 = @imap_search($mbox, 'CC "' . $email_addr . '"', SE_UID); if (!$search3) { $search3 = []; } else { - logger("Found mails cc ".$email_addr, LOGGER_DEBUG); + Logger::log("Found mails cc ".$email_addr, LOGGER_DEBUG); } $res = array_unique(array_merge($search1, $search2, $search3)); @@ -351,7 +352,7 @@ class Email //$message = '' . $html . ''; //$message = html2plain($html); - logger('notifier: email delivery to ' . $addr); + Logger::log('notifier: email delivery to ' . $addr); mail($addr, $subject, $body, $headers); } diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 39b272a42..32ff61756 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -9,6 +9,7 @@ namespace Friendica\Protocol; use DOMDocument; use DOMXPath; use Friendica\Content\Text\HTML; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -40,12 +41,12 @@ class Feed { $a = get_app(); if (!$simulate) { - logger("Import Atom/RSS feed '".$contact["name"]."' (Contact ".$contact["id"].") for user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Import Atom/RSS feed '".$contact["name"]."' (Contact ".$contact["id"].") for user ".$importer["uid"], LOGGER_DEBUG); } else { - logger("Test Atom/RSS feed", LOGGER_DEBUG); + Logger::log("Test Atom/RSS feed", LOGGER_DEBUG); } if (empty($xml)) { - logger('XML is empty.', LOGGER_DEBUG); + Logger::log('XML is empty.', LOGGER_DEBUG); return; } @@ -199,7 +200,7 @@ class Feed { $header["contact-id"] = $contact["id"]; if (!is_object($entries)) { - logger("There are no entries in this feed.", LOGGER_DEBUG); + Logger::log("There are no entries in this feed.", LOGGER_DEBUG); return; } @@ -248,7 +249,7 @@ class Feed { $importer["uid"], $item["uri"], Protocol::FEED, Protocol::DFRN]; $previous = Item::selectFirst(['id'], $condition); if (DBA::isResult($previous)) { - logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG); + Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG); continue; } } @@ -423,7 +424,7 @@ class Feed { } if (!$simulate) { - logger("Stored feed: ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Stored feed: ".print_r($item, true), LOGGER_DEBUG); $notify = Item::isRemoteSelf($contact, $item); @@ -440,7 +441,7 @@ class Feed { $id = Item::insert($item, false, $notify); - logger("Feed for contact ".$contact["url"]." stored under id ".$id); + Logger::log("Feed for contact ".$contact["url"]." stored under id ".$id); } else { $items[] = $item; } diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index fb78d2ebb..e7be6325b 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -11,6 +11,7 @@ use Friendica\Content\Text\HTML; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Lock; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -195,7 +196,7 @@ class OStatus DBA::update('contact', $contact, ['id' => $contact["id"]], $current); if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) { - logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG); + Logger::log("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG); Contact::updateAvatar($author["author-avatar"], $importer["uid"], $contact["id"]); } @@ -322,7 +323,7 @@ class OStatus self::$conv_list = []; } - logger('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG); + Logger::log('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG); if ($xml == "") { return false; @@ -348,7 +349,7 @@ class OStatus foreach ($hub_attributes as $hub_attribute) { if ($hub_attribute->name == "href") { $hub = $hub_attribute->textContent; - logger("Found hub ".$hub, LOGGER_DEBUG); + Logger::log("Found hub ".$hub, LOGGER_DEBUG); } } } @@ -433,27 +434,27 @@ class OStatus if (in_array($item["verb"], [NAMESPACE_OSTATUS."/unfavorite", ACTIVITY_UNFAVORITE])) { // Ignore "Unfavorite" message - logger("Ignore unfavorite message ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Ignore unfavorite message ".print_r($item, true), LOGGER_DEBUG); continue; } // Deletions come with the same uri, so we check for duplicates after processing deletions if (Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]])) { - logger('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG); continue; } else { - logger('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.', LOGGER_DEBUG); } if ($item["verb"] == ACTIVITY_JOIN) { // ignore "Join" messages - logger("Ignore join message ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Ignore join message ".print_r($item, true), LOGGER_DEBUG); continue; } if ($item["verb"] == "http://mastodon.social/schema/1.0/block") { // ignore mastodon "block" messages - logger("Ignore block message ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Ignore block message ".print_r($item, true), LOGGER_DEBUG); continue; } @@ -470,7 +471,7 @@ class OStatus if ($item["verb"] == ACTIVITY_FAVORITE) { $orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue; - logger("Favorite ".$orig_uri." ".print_r($item, true)); + Logger::log("Favorite ".$orig_uri." ".print_r($item, true)); $item["verb"] = ACTIVITY_LIKE; $item["parent-uri"] = $orig_uri; @@ -480,7 +481,7 @@ class OStatus // http://activitystrea.ms/schema/1.0/rsvp-yes if (!in_array($item["verb"], [ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE])) { - logger("Unhandled verb ".$item["verb"]." ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Unhandled verb ".$item["verb"]." ".print_r($item, true), LOGGER_DEBUG); } self::processPost($xpath, $entry, $item, $importer); @@ -493,10 +494,10 @@ class OStatus // If not, then it depends on this setting $valid = !Config::get('system', 'ostatus_full_threads'); if ($valid) { - logger("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.", LOGGER_DEBUG); } } else { - logger("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported.", LOGGER_DEBUG); } if ($valid) { // Never post a thread when the only interaction by our contact was a like @@ -508,14 +509,14 @@ class OStatus } } if ($valid) { - logger("Item with uri ".self::$itemlist[0]['uri']." will be imported since the thread contains posts or shares.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported since the thread contains posts or shares.", LOGGER_DEBUG); } } } else { // But we will only import complete threads $valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]); if ($valid) { - logger("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", LOGGER_DEBUG); } } @@ -532,25 +533,25 @@ class OStatus foreach (self::$itemlist as $item) { $found = Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]]); if ($found) { - logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG); + Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG); } elseif ($item['contact-id'] < 0) { - logger("Item with uri ".$item["uri"]." is from a blocked contact.", LOGGER_DEBUG); + Logger::log("Item with uri ".$item["uri"]." is from a blocked contact.", LOGGER_DEBUG); } else { // We are having duplicated entries. Hopefully this solves it. if (Lock::acquire('ostatus_process_item_insert')) { $ret = Item::insert($item); Lock::release('ostatus_process_item_insert'); - logger("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret); + Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret); } else { $ret = Item::insert($item); - logger("We couldn't lock - but tried to store the item anyway. Return value is ".$ret); + Logger::log("We couldn't lock - but tried to store the item anyway. Return value is ".$ret); } } } } self::$itemlist = []; } - logger('Processing done for post with URI '.$item["uri"].' for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Processing done for post with URI '.$item["uri"].' for user '.$importer["uid"].'.', LOGGER_DEBUG); } return true; } @@ -564,13 +565,13 @@ class OStatus { $condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'uri' => $item['uri']]; if (!Item::exists($condition)) { - logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it."); + Logger::log('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it."); return; } Item::delete($condition); - logger('Deleted item with uri '.$item['uri'].' for user '.$item['uid']); + Logger::log('Deleted item with uri '.$item['uri'].' for user '.$item['uid']); } /** @@ -706,7 +707,7 @@ class OStatus self::fetchRelated($related, $item["parent-uri"], $importer); } } else { - logger('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG); } } else { $item["parent-uri"] = $item["uri"]; @@ -852,11 +853,11 @@ class OStatus $condition = ['item-uri' => $conv_data['uri'],'protocol' => Conversation::PARCEL_FEED]; if (DBA::exists('conversation', $condition)) { - logger('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG); + Logger::log('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG); DBA::delete('conversation', ['item-uri' => $conv_data['uri']]); } - logger('Store conversation data for uri '.$conv_data['uri'], LOGGER_DEBUG); + Logger::log('Store conversation data for uri '.$conv_data['uri'], LOGGER_DEBUG); Conversation::insert($conv_data); } } @@ -876,7 +877,7 @@ class OStatus { $condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $self, Conversation::PARCEL_DFRN, Conversation::PARCEL_SALMON]; if (DBA::exists('conversation', $condition)) { - logger('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG); + Logger::log('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG); return; } @@ -896,7 +897,7 @@ class OStatus $item["protocol"] = Conversation::PARCEL_SALMON; $item["source"] = $xml; - logger('Conversation '.$item['uri'].' is now fetched.', LOGGER_DEBUG); + Logger::log('Conversation '.$item['uri'].' is now fetched.', LOGGER_DEBUG); } /** @@ -915,11 +916,11 @@ class OStatus $stored = true; $xml = $conversation['source']; if (self::process($xml, $importer, $contact, $hub, $stored, false)) { - logger('Got valid cached XML for URI '.$related_uri, LOGGER_DEBUG); + Logger::log('Got valid cached XML for URI '.$related_uri, LOGGER_DEBUG); return; } if ($conversation['protocol'] == Conversation::PARCEL_SALMON) { - logger('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG); + Logger::log('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG); DBA::delete('conversation', ['item-uri' => $related_uri]); } } @@ -934,7 +935,7 @@ class OStatus $xml = ''; if (stristr($curlResult->getHeader(), 'Content-Type: application/atom+xml')) { - logger('Directly fetched XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('Directly fetched XML for URI ' . $related_uri, LOGGER_DEBUG); $xml = $curlResult->getBody(); } @@ -959,7 +960,7 @@ class OStatus $curlResult = Network::curl($atom_file); if ($curlResult->isSuccess()) { - logger('Fetched XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('Fetched XML for URI ' . $related_uri, LOGGER_DEBUG); $xml = $curlResult->getBody(); } } @@ -971,7 +972,7 @@ class OStatus $curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related).'.atom'); if ($curlResult->isSuccess()) { - logger('GNU Social workaround to fetch XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, LOGGER_DEBUG); $xml = $curlResult->getBody(); } } @@ -982,7 +983,7 @@ class OStatus $curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom'); if ($curlResult->isSuccess()) { - logger('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, LOGGER_DEBUG); $xml = $curlResult->getBody(); } } @@ -993,7 +994,7 @@ class OStatus $conversation = DBA::selectFirst('conversation', ['source'], $condition); if (DBA::isResult($conversation)) { $stored = true; - logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG); + Logger::log('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG); $xml = $conversation['source']; } } @@ -1001,7 +1002,7 @@ class OStatus if ($xml != '') { self::process($xml, $importer, $contact, $hub, $stored, false); } else { - logger("XML couldn't be fetched for URI: ".$related_uri." - href: ".$related, LOGGER_DEBUG); + Logger::log("XML couldn't be fetched for URI: ".$related_uri." - href: ".$related, LOGGER_DEBUG); } return; } @@ -1651,7 +1652,7 @@ class OStatus private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { - logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); + Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); } $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel); @@ -1714,7 +1715,7 @@ class OStatus private static function likeEntry(DOMDocument $doc, array $item, array $owner, $toplevel) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { - logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); + Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); } $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel); @@ -1861,7 +1862,7 @@ class OStatus private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { - logger("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); + Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); } $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel); @@ -2152,7 +2153,7 @@ class OStatus if ((time() - strtotime($owner['last-item'])) < 15*60) { $result = Cache::get($cachekey); if (!$nocache && !is_null($result)) { - logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', LOGGER_DEBUG); + Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', LOGGER_DEBUG); $last_update = $result['last_update']; return $result['feed']; } @@ -2212,7 +2213,7 @@ class OStatus $msg = ['feed' => $feeddata, 'last_update' => $last_update]; Cache::set($cachekey, $msg, Cache::QUARTER_HOUR); - logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG); + Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG); return $feeddata; } diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index bb7ccd564..1cd566336 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -14,6 +14,7 @@ use DOMXPath; use Exception; use Friendica\Content\Text\HTML; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -84,14 +85,14 @@ class PortableContact $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation') ; - logger('load: ' . $url, LOGGER_DEBUG); + Logger::log('load: ' . $url, LOGGER_DEBUG); $fetchresult = Network::fetchUrlFull($url); $s = $fetchresult->getBody(); - logger('load: returns ' . $s, LOGGER_DATA); + Logger::log('load: returns ' . $s, LOGGER_DATA); - logger('load: return code: ' . $fetchresult->getReturnCode(), LOGGER_DEBUG); + Logger::log('load: return code: ' . $fetchresult->getReturnCode(), LOGGER_DEBUG); if (($fetchresult->getReturnCode() > 299) || (! $s)) { return; @@ -99,7 +100,7 @@ class PortableContact $j = json_decode($s, true); - logger('load: json: ' . print_r($j, true), LOGGER_DATA); + Logger::log('load: json: ' . print_r($j, true), LOGGER_DATA); if (!isset($j['entry'])) { return; @@ -199,10 +200,10 @@ class PortableContact GContact::link($gcid, $uid, $cid, $zcid); } catch (Exception $e) { - logger($e->getMessage(), LOGGER_DEBUG); + Logger::log($e->getMessage(), LOGGER_DEBUG); } } - logger("load: loaded $total entries", LOGGER_DEBUG); + Logger::log("load: loaded $total entries", LOGGER_DEBUG); $condition = ["`cid` = ? AND `uid` = ? AND `zcid` = ? AND `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", $cid, $uid, $zcid]; DBA::delete('glink', $condition); @@ -335,7 +336,7 @@ class PortableContact } if (!in_array($gcontacts[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) { - logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG); + Logger::log("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG); return false; } @@ -346,7 +347,7 @@ class PortableContact DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); } - logger("Profile ".$profile.": Server ".$server_url." wasn't reachable.", LOGGER_DEBUG); + Logger::log("Profile ".$profile.": Server ".$server_url." wasn't reachable.", LOGGER_DEBUG); return false; } $contact['server_url'] = $server_url; @@ -426,7 +427,7 @@ class PortableContact $fields = ['last_contact' => DateTimeFormat::utcNow()]; DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); - logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG); return $noscrape["updated"]; } @@ -437,7 +438,7 @@ class PortableContact // If we only can poll the feed, then we only do this once a while if (!$force && !self::updateNeeded($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"])) { - logger("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", LOGGER_DEBUG); GContact::update($contact); return $gcontacts[0]["updated"]; @@ -464,10 +465,10 @@ class PortableContact self::lastUpdated($data["url"], $force); } catch (Exception $e) { - logger($e->getMessage(), LOGGER_DEBUG); + Logger::log($e->getMessage(), LOGGER_DEBUG); } - logger("Profile ".$profile." was deleted", LOGGER_DEBUG); + Logger::log("Profile ".$profile." was deleted", LOGGER_DEBUG); return false; } @@ -475,7 +476,7 @@ class PortableContact $fields = ['last_failure' => DateTimeFormat::utcNow()]; DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); - logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG); return false; } @@ -491,7 +492,7 @@ class PortableContact $fields = ['last_failure' => DateTimeFormat::utcNow()]; DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); - logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG); return false; } @@ -539,7 +540,7 @@ class PortableContact DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); } - logger("Profile ".$profile." was last updated at ".$last_updated, LOGGER_DEBUG); + Logger::log("Profile ".$profile." was last updated at ".$last_updated, LOGGER_DEBUG); return $last_updated; } @@ -662,7 +663,7 @@ class PortableContact foreach ($nodeinfo['links'] as $link) { if (!is_array($link) || empty($link['rel'])) { - logger('Invalid nodeinfo format for ' . $server_url, LOGGER_DEBUG); + Logger::log('Invalid nodeinfo format for ' . $server_url, LOGGER_DEBUG); continue; } if ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/1.0') { @@ -963,7 +964,7 @@ class PortableContact } if (!$force && !self::updateNeeded($gserver["created"], "", $last_failure, $last_contact)) { - logger("Use cached data for server ".$server_url, LOGGER_DEBUG); + Logger::log("Use cached data for server ".$server_url, LOGGER_DEBUG); return ($last_contact >= $last_failure); } } else { @@ -979,7 +980,7 @@ class PortableContact $last_contact = DBA::NULL_DATETIME; $last_failure = DBA::NULL_DATETIME; } - logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG); + Logger::log("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG); $failure = false; $possible_failure = false; @@ -1004,7 +1005,7 @@ class PortableContact // But we want to make sure to only quit if we are mostly sure that this server url fits. if (DBA::isResult($gserver) && ($orig_server_url == $server_url) && ($curlResult->isTimeout())) { - logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG); + Logger::log("Connection to server ".$server_url." timed out.", LOGGER_DEBUG); DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]); return false; } @@ -1019,7 +1020,7 @@ class PortableContact // Quit if there is a timeout if ($curlResult->isTimeout()) { - logger("Connection to server " . $server_url . " timed out.", LOGGER_DEBUG); + Logger::log("Connection to server " . $server_url . " timed out.", LOGGER_DEBUG); DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]); return false; } @@ -1398,9 +1399,9 @@ class PortableContact } if (($last_contact <= $last_failure) && !$failure) { - logger("Server ".$server_url." seems to be alive, but last contact wasn't set - could be a bug", LOGGER_DEBUG); + Logger::log("Server ".$server_url." seems to be alive, but last contact wasn't set - could be a bug", LOGGER_DEBUG); } elseif (($last_contact >= $last_failure) && $failure) { - logger("Server ".$server_url." seems to be dead, but last failure wasn't set - could be a bug", LOGGER_DEBUG); + Logger::log("Server ".$server_url." seems to be dead, but last failure wasn't set - could be a bug", LOGGER_DEBUG); } // Check again if the server exists @@ -1429,7 +1430,7 @@ class PortableContact self::discoverRelay($server_url); } - logger("End discovery for server " . $server_url, LOGGER_DEBUG); + Logger::log("End discovery for server " . $server_url, LOGGER_DEBUG); return !$failure; } @@ -1441,7 +1442,7 @@ class PortableContact */ private static function discoverRelay($server_url) { - logger("Discover relay data for server " . $server_url, LOGGER_DEBUG); + Logger::log("Discover relay data for server " . $server_url, LOGGER_DEBUG); $curlResult = Network::curl($server_url . "/.well-known/x-social-relay"); @@ -1557,7 +1558,7 @@ class PortableContact $r = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", DBA::escape(normalise_link($server_url))); if (!DBA::isResult($r)) { - logger("Call server check for server ".$server_url, LOGGER_DEBUG); + Logger::log("Call server check for server ".$server_url, LOGGER_DEBUG); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $server_url); } } @@ -1642,7 +1643,7 @@ class PortableContact // Fetch all users from the other server $url = $server["poco"] . "/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; - logger("Fetch all users from the server " . $server["url"], LOGGER_DEBUG); + Logger::log("Fetch all users from the server " . $server["url"], LOGGER_DEBUG); $curlResult = Network::curl($url); @@ -1670,7 +1671,7 @@ class PortableContact $curlResult = Network::curl($url); if ($curlResult->isSuccess() && !empty($curlResult->getBody())) { - logger("Fetch all global contacts from the server " . $server["nurl"], LOGGER_DEBUG); + Logger::log("Fetch all global contacts from the server " . $server["nurl"], LOGGER_DEBUG); $data = json_decode($curlResult->getBody(), true); if (!empty($data)) { @@ -1679,7 +1680,7 @@ class PortableContact } if (!$success && (Config::get('system', 'poco_discovery') > 2)) { - logger("Fetch contacts from users of the server " . $server["nurl"], LOGGER_DEBUG); + Logger::log("Fetch contacts from users of the server " . $server["nurl"], LOGGER_DEBUG); self::discoverServerUsers($data, $server); } } @@ -1732,7 +1733,7 @@ class PortableContact continue; } - logger('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], LOGGER_DEBUG); + Logger::log('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], LOGGER_DEBUG); Worker::add(PRIORITY_LOW, 'DiscoverPoCo', 'update_server_directory', (int) $gserver['id']); if (!$complete && ( --$no_of_queries == 0)) { @@ -1762,7 +1763,7 @@ class PortableContact } if ($username != '') { - logger('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], LOGGER_DEBUG); + Logger::log('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], LOGGER_DEBUG); // Fetch all contacts from a given user from the other server $url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation'; @@ -1865,7 +1866,7 @@ class PortableContact if ($generation > 0) { $success = true; - logger("Store profile ".$profile_url, LOGGER_DEBUG); + Logger::log("Store profile ".$profile_url, LOGGER_DEBUG); $gcontact = ["url" => $profile_url, "name" => $name, @@ -1884,10 +1885,10 @@ class PortableContact $gcontact = GContact::sanitize($gcontact); GContact::update($gcontact); } catch (Exception $e) { - logger($e->getMessage(), LOGGER_DEBUG); + Logger::log($e->getMessage(), LOGGER_DEBUG); } - logger("Done for profile ".$profile_url, LOGGER_DEBUG); + Logger::log("Done for profile ".$profile_url, LOGGER_DEBUG); } } return $success; diff --git a/src/Protocol/Salmon.php b/src/Protocol/Salmon.php index e3407844a..29abd77d0 100644 --- a/src/Protocol/Salmon.php +++ b/src/Protocol/Salmon.php @@ -4,6 +4,7 @@ */ namespace Friendica\Protocol; +use Friendica\Core\Logger; use Friendica\Network\Probe; use Friendica\Util\Crypto; use Friendica\Util\Network; @@ -25,7 +26,7 @@ class Salmon { $ret = []; - logger('Fetching salmon key for '.$uri); + Logger::log('Fetching salmon key for '.$uri); $arr = Probe::lrdd($uri); @@ -57,7 +58,7 @@ class Salmon } - logger('Key located: ' . print_r($ret, true)); + Logger::log('Key located: ' . print_r($ret, true)); if (count($ret) == 1) { // We only found one one key so we don't care if the hash matches. @@ -94,12 +95,12 @@ class Salmon } if (! $owner['sprvkey']) { - logger(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.", + Logger::log(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.", $owner['username'], $owner['uid'])); return; } - logger('slapper called for '.$url.'. Data: ' . $slap); + Logger::log('slapper called for '.$url.'. Data: ' . $slap); // create a magic envelope @@ -143,7 +144,7 @@ class Salmon // check for success, e.g. 2xx if ($return_code > 299) { - logger('GNU Social salmon failed. Falling back to compliant mode'); + Logger::log('GNU Social salmon failed. Falling back to compliant mode'); // Now try the compliant mode that normally isn't used for GNU Social $xmldata = ["me:env" => ["me:data" => $data, @@ -166,7 +167,7 @@ class Salmon } if ($return_code > 299) { - logger('compliant salmon failed. Falling back to old status.net'); + Logger::log('compliant salmon failed. Falling back to old status.net'); // Last try. This will most likely fail as well. $xmldata = ["me:env" => ["me:data" => $data, @@ -187,7 +188,7 @@ class Salmon $return_code = $postResult->getReturnCode(); } - logger('slapper for '.$url.' returned ' . $return_code); + Logger::log('slapper for '.$url.' returned ' . $return_code); if (! $return_code) { return -1; diff --git a/src/Util/Crypto.php b/src/Util/Crypto.php index 6a49626bd..2b1ce0f02 100644 --- a/src/Util/Crypto.php +++ b/src/Util/Crypto.php @@ -6,6 +6,7 @@ namespace Friendica\Util; use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Logger; use ASN_BASE; use ASNValue; @@ -232,7 +233,7 @@ class Crypto $result = openssl_pkey_new($openssl_options); if (empty($result)) { - logger('new_keypair: failed'); + Logger::log('new_keypair: failed'); return false; } @@ -347,7 +348,7 @@ class Crypto private static function encapsulateOther($data, $pubkey, $alg) { if (!$pubkey) { - logger('no key. data: '.$data); + Logger::log('no key. data: '.$data); } $fn = 'encrypt' . strtoupper($alg); if (method_exists(__CLASS__, $fn)) { @@ -359,7 +360,7 @@ class Crypto // log the offending call so we can track it down if (!openssl_public_encrypt($key, $k, $pubkey)) { $x = debug_backtrace(); - logger('RSA failed. ' . print_r($x[0], true)); + Logger::log('RSA failed. ' . print_r($x[0], true)); } $result['alg'] = $alg; @@ -388,7 +389,7 @@ class Crypto private static function encapsulateAes($data, $pubkey) { if (!$pubkey) { - logger('aes_encapsulate: no key. data: ' . $data); + Logger::log('aes_encapsulate: no key. data: ' . $data); } $key = random_bytes(32); @@ -399,7 +400,7 @@ class Crypto // log the offending call so we can track it down if (!openssl_public_encrypt($key, $k, $pubkey)) { $x = debug_backtrace(); - logger('aes_encapsulate: RSA failed. ' . print_r($x[0], true)); + Logger::log('aes_encapsulate: RSA failed. ' . print_r($x[0], true)); } $result['alg'] = 'aes256cbc'; diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index e293857ac..8545cd07c 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -6,6 +6,7 @@ namespace Friendica\Util; +use Friendica\Core\Logger; use DateTime; use DateTimeZone; use Exception; @@ -125,7 +126,7 @@ class DateTimeFormat try { $d = new DateTime($s, $from_obj); } catch (Exception $e) { - logger('DateTimeFormat::convert: exception: ' . $e->getMessage()); + Logger::log('DateTimeFormat::convert: exception: ' . $e->getMessage()); $d = new DateTime('now', $from_obj); } diff --git a/src/Util/Emailer.php b/src/Util/Emailer.php index 1dd513c42..b69ceda51 100644 --- a/src/Util/Emailer.php +++ b/src/Util/Emailer.php @@ -6,6 +6,7 @@ namespace Friendica\Util; use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Protocol\Email; @@ -96,8 +97,8 @@ class Emailer $hookdata['headers'], $hookdata['parameters'] ); - logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); - logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG); + Logger::log("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); + Logger::log("return value " . (($res)?"true":"false"), LOGGER_DEBUG); return $res; } } diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index 34fe7a987..cecfe8c26 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -7,6 +7,7 @@ namespace Friendica\Util; use Friendica\BaseObject; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Model\User; use Friendica\Model\APContact; @@ -59,7 +60,7 @@ class HTTPSignature $sig_block = self::parseSigheader($headers['authorization']); if (!$sig_block) { - logger('no signature provided.'); + Logger::log('no signature provided.'); return $result; } @@ -89,7 +90,7 @@ class HTTPSignature $key = $key($sig_block['keyId']); } - logger('Got keyID ' . $sig_block['keyId']); + Logger::log('Got keyID ' . $sig_block['keyId']); if (!$key) { return $result; @@ -97,7 +98,7 @@ class HTTPSignature $x = Crypto::rsaVerify($signed_data, $sig_block['signature'], $key, $algorithm); - logger('verified: ' . $x, LOGGER_DEBUG); + Logger::log('verified: ' . $x, LOGGER_DEBUG); if (!$x) { return $result; @@ -307,7 +308,7 @@ class HTTPSignature $postResult = Network::post($target, $content, $headers); $return_code = $postResult->getReturnCode(); - logger('Transmit to ' . $target . ' returned ' . $return_code); + Logger::log('Transmit to ' . $target . ' returned ' . $return_code); return ($return_code >= 200) && ($return_code <= 299); } @@ -432,12 +433,12 @@ class HTTPSignature $profile = APContact::getByURL($url); if (!empty($profile)) { - logger('Taking key from id ' . $id, LOGGER_DEBUG); + Logger::log('Taking key from id ' . $id, LOGGER_DEBUG); return ['url' => $url, 'pubkey' => $profile['pubkey']]; } elseif ($url != $actor) { $profile = APContact::getByURL($actor); if (!empty($profile)) { - logger('Taking key from actor ' . $actor, LOGGER_DEBUG); + Logger::log('Taking key from actor ' . $actor, LOGGER_DEBUG); return ['url' => $actor, 'pubkey' => $profile['pubkey']]; } } diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index 793f5e9d1..2d16172b7 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -5,6 +5,7 @@ namespace Friendica\Util; use Friendica\Core\Cache; +use Friendica\Core\Logger; use Exception; /** @@ -33,7 +34,7 @@ class JsonLD } if ($recursion > 5) { - logger('jsonld bomb detected at: ' . $url); + Logger::log('jsonld bomb detected at: ' . $url); exit(); } @@ -65,7 +66,7 @@ class JsonLD } catch (Exception $e) { $normalized = false; - logger('normalise error:' . print_r($e, true), LOGGER_DEBUG); + Logger::log('normalise error:' . print_r($e, true), LOGGER_DEBUG); } return $normalized; @@ -98,7 +99,7 @@ class JsonLD } catch (Exception $e) { $compacted = false; - logger('compacting error:' . print_r($e, true), LOGGER_DEBUG); + Logger::log('compacting error:' . print_r($e, true), LOGGER_DEBUG); } return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true); diff --git a/src/Util/LDSignature.php b/src/Util/LDSignature.php index 7776ec96c..e53590cf3 100644 --- a/src/Util/LDSignature.php +++ b/src/Util/LDSignature.php @@ -2,6 +2,7 @@ namespace Friendica\Util; +use Friendica\Core\Logger; use Friendica\Util\JsonLD; use Friendica\Util\DateTimeFormat; use Friendica\Protocol\ActivityPub; @@ -40,7 +41,7 @@ class LDSignature $dhash = self::hash(self::signableData($data)); $x = Crypto::rsaVerify($ohash . $dhash, base64_decode($data['signature']['signatureValue']), $pubkey); - logger('LD-verify: ' . intval($x)); + Logger::log('LD-verify: ' . intval($x)); if (empty($x)) { return false; diff --git a/src/Util/Network.php b/src/Util/Network.php index 3b27a0550..0a36f47f5 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -5,6 +5,7 @@ namespace Friendica\Util; use Friendica\Core\Addon; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Network\CurlResult; @@ -106,7 +107,7 @@ class Network $url = self::unparseURL($parts); if (self::isUrlBlocked($url)) { - logger('domain of ' . $url . ' is blocked', LOGGER_DATA); + Logger::log('domain of ' . $url . ' is blocked', LOGGER_DATA); return CurlResult::createErrorCurl($url); } @@ -212,7 +213,7 @@ class Network if ($curlResponse->isRedirectUrl()) { $redirects++; - logger('curl: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl()); + Logger::log('curl: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl()); @curl_close($ch); return self::curl($curlResponse->getRedirectUrl(), $binary, $redirects, $opts); } @@ -240,7 +241,7 @@ class Network $stamp1 = microtime(true); if (self::isUrlBlocked($url)) { - logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA); + Logger::log('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA); return CurlResult::createErrorCurl($url); } @@ -251,7 +252,7 @@ class Network return CurlResult::createErrorCurl($url); } - logger('post_url: start ' . $url, LOGGER_DATA); + Logger::log('post_url: start ' . $url, LOGGER_DATA); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -314,7 +315,7 @@ class Network if ($curlResponse->isRedirectUrl()) { $redirects++; - logger('post_url: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl()); + Logger::log('post_url: redirect ' . $url . ' to ' . $curlResponse->getRedirectUrl()); curl_close($ch); return self::post($curlResponse->getRedirectUrl(), $params, $headers, $redirects, $timeout); } @@ -323,7 +324,7 @@ class Network $a->saveTimestamp($stamp1, 'network'); - logger('post_url: end ' . $url, LOGGER_DATA); + Logger::log('post_url: end ' . $url, LOGGER_DATA); return $curlResponse; } @@ -527,7 +528,7 @@ class Network $avatar['url'] = System::baseUrl() . '/images/person-300.jpg'; } - logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG); + Logger::log('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG); return $avatar['url']; } diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 24089b9cb..0475eda5a 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -9,6 +9,7 @@ use DOMDocument; use DOMXPath; use Friendica\Content\OEmbed; use Friendica\Core\Addon; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Object\Image; @@ -123,7 +124,7 @@ class ParseUrl } if ($count > 10) { - logger('Endless loop detected for ' . $url, LOGGER_DEBUG); + Logger::log('Endless loop detected for ' . $url, LOGGER_DEBUG); return $siteinfo; } @@ -187,7 +188,7 @@ class ParseUrl } if (($charset != '') && (strtoupper($charset) != 'UTF-8')) { - logger('detected charset ' . $charset, LOGGER_DEBUG); + Logger::log('detected charset ' . $charset, LOGGER_DEBUG); $body = iconv($charset, 'UTF-8//TRANSLIT', $body); } @@ -421,7 +422,7 @@ class ParseUrl } } - logger('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), LOGGER_DEBUG); + Logger::log('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), LOGGER_DEBUG); Addon::callHooks('getsiteinfo', $siteinfo); diff --git a/src/Util/XML.php b/src/Util/XML.php index e06a92d25..5abafec00 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -4,6 +4,7 @@ */ namespace Friendica\Util; +use Friendica\Core\Logger; use DOMXPath; use SimpleXMLElement; @@ -248,7 +249,7 @@ class XML } if (!function_exists('xml_parser_create')) { - logger('Xml::toArray: parser function missing'); + Logger::log('Xml::toArray: parser function missing'); return []; } @@ -263,7 +264,7 @@ class XML } if (! $parser) { - logger('Xml::toArray: xml_parser_create: no resource'); + Logger::log('Xml::toArray: xml_parser_create: no resource'); return []; } @@ -275,9 +276,9 @@ class XML @xml_parser_free($parser); if (! $xml_values) { - logger('Xml::toArray: libxml: parse error: ' . $contents, LOGGER_DATA); + Logger::log('Xml::toArray: libxml: parse error: ' . $contents, LOGGER_DATA); foreach (libxml_get_errors() as $err) { - logger('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message, LOGGER_DATA); + Logger::log('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message, LOGGER_DATA); } libxml_clear_errors(); return; @@ -423,9 +424,9 @@ class XML $x = @simplexml_load_string($s); if (!$x) { - logger('libxml: parse: error: ' . $s, LOGGER_DATA); + Logger::log('libxml: parse: error: ' . $s, LOGGER_DATA); foreach (libxml_get_errors() as $err) { - logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA); + Logger::log('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA); } libxml_clear_errors(); } diff --git a/src/Worker/APDelivery.php b/src/Worker/APDelivery.php index b952249fe..c800ee02d 100644 --- a/src/Worker/APDelivery.php +++ b/src/Worker/APDelivery.php @@ -5,9 +5,10 @@ namespace Friendica\Worker; use Friendica\BaseObject; +use Friendica\Core\Logger; +use Friendica\Core\Worker; use Friendica\Protocol\ActivityPub; use Friendica\Model\Item; -use Friendica\Core\Worker; use Friendica\Util\HTTPSignature; class APDelivery extends BaseObject @@ -22,7 +23,7 @@ class APDelivery extends BaseObject */ public static function execute($cmd, $item_id, $inbox, $uid) { - logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG); + Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG); $success = true; diff --git a/src/Worker/CheckVersion.php b/src/Worker/CheckVersion.php index 3aec6cac1..0d87bb982 100644 --- a/src/Worker/CheckVersion.php +++ b/src/Worker/CheckVersion.php @@ -8,6 +8,7 @@ namespace Friendica\Worker; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Util\Network; @@ -21,7 +22,7 @@ class CheckVersion { public static function execute() { - logger('checkversion: start'); + Logger::log('checkversion: start'); $checkurl = Config::get('system', 'check_new_version_url', 'none'); @@ -36,15 +37,15 @@ class CheckVersion // don't check return; } - logger("Checking VERSION from: ".$checked_url, LOGGER_DEBUG); + Logger::log("Checking VERSION from: ".$checked_url, LOGGER_DEBUG); // fetch the VERSION file $gitversion = DBA::escape(trim(Network::fetchUrl($checked_url))); - logger("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG); + Logger::log("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG); Config::set('system', 'git_friendica_version', $gitversion); - logger('checkversion: end'); + Logger::log('checkversion: end'); return; } diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index 951006333..9b8eb1cfe 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -8,6 +8,7 @@ use Friendica\BaseObject; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -38,12 +39,12 @@ class Cron if ($last) { $next = $last + ($poll_interval * 60); if ($next > time()) { - logger('cron intervall not reached'); + Logger::log('cron intervall not reached'); return; } } - logger('cron: start'); + Logger::log('cron: start'); // Fork the cron jobs in separate parts to avoid problems when one of them is crashing Hook::fork($a->queue['priority'], "cron"); @@ -124,7 +125,7 @@ class Cron // Poll contacts self::pollContacts($parameter, $generation); - logger('cron: end'); + Logger::log('cron: end'); Config::set('system', 'last_cron', time()); @@ -287,7 +288,7 @@ class Cron $priority = PRIORITY_LOW; } - logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]); + Logger::log("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]); Worker::add(['priority' => $priority, 'dont_fork' => true], 'OnePoll', (int)$contact['id']); } diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index a564bd0b0..ae3f48617 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -8,6 +8,7 @@ use Friendica\App; use Friendica\BaseObject; use Friendica\Core\Cache; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Database\PostUpdate; @@ -33,7 +34,7 @@ class CronJobs return; } - logger("Starting cronjob " . $command, LOGGER_DEBUG); + Logger::log("Starting cronjob " . $command, LOGGER_DEBUG); // Call possible post update functions // see src/Database/PostUpdate.php for more details @@ -82,7 +83,7 @@ class CronJobs return; } - logger("Xronjob " . $command . " is unknown.", LOGGER_DEBUG); + Logger::log("Xronjob " . $command . " is unknown.", LOGGER_DEBUG); return; } @@ -211,7 +212,7 @@ class CronJobs // Calculate fragmentation $fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]); - logger("Table " . $table["Name"] . " - Fragmentation level: " . round($fragmentation * 100, 2), LOGGER_DEBUG); + Logger::log("Table " . $table["Name"] . " - Fragmentation level: " . round($fragmentation * 100, 2), LOGGER_DEBUG); // Don't optimize tables that needn't to be optimized if ($fragmentation < $fragmentation_level) { @@ -219,7 +220,7 @@ class CronJobs } // So optimize it - logger("Optimize Table " . $table["Name"], LOGGER_DEBUG); + Logger::log("Optimize Table " . $table["Name"], LOGGER_DEBUG); q("OPTIMIZE TABLE `%s`", DBA::escape($table["Name"])); } } @@ -258,7 +259,7 @@ class CronJobs continue; } - logger("Repair contact " . $contact["id"] . " " . $contact["url"], LOGGER_DEBUG); + Logger::log("Repair contact " . $contact["id"] . " " . $contact["url"], LOGGER_DEBUG); q("UPDATE `contact` SET `batch` = '%s', `notify` = '%s', `poll` = '%s', pubkey = '%s' WHERE `id` = %d", DBA::escape($data["batch"]), DBA::escape($data["notify"]), DBA::escape($data["poll"]), DBA::escape($data["pubkey"]), intval($contact["id"])); @@ -276,7 +277,7 @@ class CronJobs $r = q("SELECT `uid` FROM `user` WHERE NOT EXISTS (SELECT `uid` FROM `contact` WHERE `contact`.`uid` = `user`.`uid` AND `contact`.`self`)"); if (DBA::isResult($r)) { foreach ($r AS $user) { - logger('Create missing self contact for user ' . $user['uid']); + Logger::log('Create missing self contact for user ' . $user['uid']); Contact::createSelfFromUserId($user['uid']); } } diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php index dba9cfd4c..a722fa23b 100644 --- a/src/Worker/DBClean.php +++ b/src/Worker/DBClean.php @@ -7,6 +7,7 @@ namespace Friendica\Worker; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -80,46 +81,46 @@ class DBClean { $last_id = Config::get('system', 'dbclean-last-id-1', 0); - logger("Deleting old global item entries from item table without user copy. Last ID: ".$last_id); + Logger::log("Deleting old global item entries from item table without user copy. Last ID: ".$last_id); $r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `id` >= ? ORDER BY `id` LIMIT ?", $days_unclaimed, $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found global item orphans: ".$count); + Logger::log("found global item orphans: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; DBA::delete('item', ['id' => $orphan["id"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 1, $last_id); } else { - logger("No global item orphans found"); + Logger::log("No global item orphans found"); } DBA::close($r); - logger("Done deleting ".$count." old global item entries from item table without user copy. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." old global item entries from item table without user copy. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-1', $last_id); } elseif ($stage == 2) { $last_id = Config::get('system', 'dbclean-last-id-2', 0); - logger("Deleting items without parents. Last ID: ".$last_id); + Logger::log("Deleting items without parents. Last ID: ".$last_id); $r = DBA::p("SELECT `id` FROM `item` WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`) AND `id` >= ? ORDER BY `id` LIMIT ?", $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found item orphans without parents: ".$count); + Logger::log("found item orphans without parents: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; DBA::delete('item', ['id' => $orphan["id"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 2, $last_id); } else { - logger("No item orphans without parents found"); + Logger::log("No item orphans without parents found"); } DBA::close($r); - logger("Done deleting ".$count." items without parents. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." items without parents. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-2', $last_id); @@ -129,23 +130,23 @@ class DBClean { } elseif ($stage == 3) { $last_id = Config::get('system', 'dbclean-last-id-3', 0); - logger("Deleting orphaned data from thread table. Last ID: ".$last_id); + Logger::log("Deleting orphaned data from thread table. Last ID: ".$last_id); $r = DBA::p("SELECT `iid` FROM `thread` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`) AND `iid` >= ? ORDER BY `iid` LIMIT ?", $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found thread orphans: ".$count); + Logger::log("found thread orphans: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["iid"]; DBA::delete('thread', ['iid' => $orphan["iid"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 3, $last_id); } else { - logger("No thread orphans found"); + Logger::log("No thread orphans found"); } DBA::close($r); - logger("Done deleting ".$count." orphaned data from thread table. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." orphaned data from thread table. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-3', $last_id); @@ -155,23 +156,23 @@ class DBClean { } elseif ($stage == 4) { $last_id = Config::get('system', 'dbclean-last-id-4', 0); - logger("Deleting orphaned data from notify table. Last ID: ".$last_id); + Logger::log("Deleting orphaned data from notify table. Last ID: ".$last_id); $r = DBA::p("SELECT `iid`, `id` FROM `notify` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`) AND `id` >= ? ORDER BY `id` LIMIT ?", $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found notify orphans: ".$count); + Logger::log("found notify orphans: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; DBA::delete('notify', ['iid' => $orphan["iid"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 4, $last_id); } else { - logger("No notify orphans found"); + Logger::log("No notify orphans found"); } DBA::close($r); - logger("Done deleting ".$count." orphaned data from notify table. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." orphaned data from notify table. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-4', $last_id); @@ -181,23 +182,23 @@ class DBClean { } elseif ($stage == 5) { $last_id = Config::get('system', 'dbclean-last-id-5', 0); - logger("Deleting orphaned data from notify-threads table. Last ID: ".$last_id); + Logger::log("Deleting orphaned data from notify-threads table. Last ID: ".$last_id); $r = DBA::p("SELECT `id` FROM `notify-threads` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`) AND `id` >= ? ORDER BY `id` LIMIT ?", $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found notify-threads orphans: ".$count); + Logger::log("found notify-threads orphans: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; DBA::delete('notify-threads', ['id' => $orphan["id"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 5, $last_id); } else { - logger("No notify-threads orphans found"); + Logger::log("No notify-threads orphans found"); } DBA::close($r); - logger("Done deleting ".$count." orphaned data from notify-threads table. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." orphaned data from notify-threads table. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-5', $last_id); @@ -207,23 +208,23 @@ class DBClean { } elseif ($stage == 6) { $last_id = Config::get('system', 'dbclean-last-id-6', 0); - logger("Deleting orphaned data from sign table. Last ID: ".$last_id); + Logger::log("Deleting orphaned data from sign table. Last ID: ".$last_id); $r = DBA::p("SELECT `iid`, `id` FROM `sign` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`) AND `id` >= ? ORDER BY `id` LIMIT ?", $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found sign orphans: ".$count); + Logger::log("found sign orphans: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; DBA::delete('sign', ['iid' => $orphan["iid"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 6, $last_id); } else { - logger("No sign orphans found"); + Logger::log("No sign orphans found"); } DBA::close($r); - logger("Done deleting ".$count." orphaned data from sign table. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." orphaned data from sign table. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-6', $last_id); @@ -233,23 +234,23 @@ class DBClean { } elseif ($stage == 7) { $last_id = Config::get('system', 'dbclean-last-id-7', 0); - logger("Deleting orphaned data from term table. Last ID: ".$last_id); + Logger::log("Deleting orphaned data from term table. Last ID: ".$last_id); $r = DBA::p("SELECT `oid`, `tid` FROM `term` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`) AND `tid` >= ? ORDER BY `tid` LIMIT ?", $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found term orphans: ".$count); + Logger::log("found term orphans: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["tid"]; DBA::delete('term', ['oid' => $orphan["oid"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 7, $last_id); } else { - logger("No term orphans found"); + Logger::log("No term orphans found"); } DBA::close($r); - logger("Done deleting ".$count." orphaned data from term table. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." orphaned data from term table. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-7', $last_id); @@ -263,7 +264,7 @@ class DBClean { $last_id = Config::get('system', 'dbclean-last-id-8', 0); - logger("Deleting expired threads. Last ID: ".$last_id); + Logger::log("Deleting expired threads. Last ID: ".$last_id); $r = DBA::p("SELECT `thread`.`iid` FROM `thread` INNER JOIN `contact` ON `thread`.`contact-id` = `contact`.`id` AND NOT `notify_new_posts` WHERE `thread`.`received` < UTC_TIMESTAMP() - INTERVAL ? DAY @@ -278,17 +279,17 @@ class DBClean { ORDER BY `thread`.`iid` LIMIT ?", $days, $last_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found expired threads: ".$count); + Logger::log("found expired threads: ".$count); while ($thread = DBA::fetch($r)) { $last_id = $thread["iid"]; DBA::delete('thread', ['iid' => $thread["iid"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 8, $last_id); } else { - logger("No expired threads found"); + Logger::log("No expired threads found"); } DBA::close($r); - logger("Done deleting ".$count." expired threads. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." expired threads. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-8', $last_id); } elseif ($stage == 9) { @@ -299,47 +300,47 @@ class DBClean { $last_id = Config::get('system', 'dbclean-last-id-9', 0); $till_id = Config::get('system', 'dbclean-last-id-8', 0); - logger("Deleting old global item entries from expired threads from ID ".$last_id." to ID ".$till_id); + Logger::log("Deleting old global item entries from expired threads from ID ".$last_id." to ID ".$till_id); $r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY AND `id` >= ? AND `id` <= ? ORDER BY `id` LIMIT ?", $last_id, $till_id, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found global item entries from expired threads: ".$count); + Logger::log("found global item entries from expired threads: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["id"]; DBA::delete('item', ['id' => $orphan["id"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 9, $last_id); } else { - logger("No global item entries from expired threads"); + Logger::log("No global item entries from expired threads"); } DBA::close($r); - logger("Done deleting ".$count." old global item entries from expired threads. Last ID: ".$last_id); + Logger::log("Done deleting ".$count." old global item entries from expired threads. Last ID: ".$last_id); Config::set('system', 'dbclean-last-id-9', $last_id); } elseif ($stage == 10) { $last_id = Config::get('system', 'dbclean-last-id-10', 0); $days = intval(Config::get('system', 'dbclean_expire_conversation', 90)); - logger("Deleting old conversations. Last created: ".$last_id); + Logger::log("Deleting old conversations. Last created: ".$last_id); $r = DBA::p("SELECT `received`, `item-uri` FROM `conversation` WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY ORDER BY `received` LIMIT ?", $days, $limit); $count = DBA::numRows($r); if ($count > 0) { - logger("found old conversations: ".$count); + Logger::log("found old conversations: ".$count); while ($orphan = DBA::fetch($r)) { $last_id = $orphan["received"]; DBA::delete('conversation', ['item-uri' => $orphan["item-uri"]]); } Worker::add(PRIORITY_MEDIUM, 'DBClean', 10, $last_id); } else { - logger("No old conversations found"); + Logger::log("No old conversations found"); } DBA::close($r); - logger("Done deleting ".$count." conversations. Last created: ".$last_id); + Logger::log("Done deleting ".$count." conversations. Last created: ".$last_id); Config::set('system', 'dbclean-last-id-10', $last_id); } diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 4feb341b3..b539de5e2 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -7,6 +7,7 @@ namespace Friendica\Worker; use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -33,7 +34,7 @@ class Delivery extends BaseObject public static function execute($cmd, $item_id, $contact_id) { - logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $contact_id, LOGGER_DEBUG); + Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $contact_id, LOGGER_DEBUG); $top_level = false; $followup = false; @@ -78,12 +79,12 @@ class Delivery extends BaseObject DBA::close($itemdata); if (empty($target_item)) { - logger('Item ' . $item_id . "wasn't found. Quitting here."); + Logger::log('Item ' . $item_id . "wasn't found. Quitting here."); return; } if (empty($parent)) { - logger('Parent ' . $parent_id . ' for item ' . $item_id . "wasn't found. Quitting here."); + Logger::log('Parent ' . $parent_id . ' for item ' . $item_id . "wasn't found. Quitting here."); return; } @@ -100,7 +101,7 @@ class Delivery extends BaseObject // The count then showed more than one entry. The additional check should help. // The check for the "count" should be superfluous, but I'm not totally sure by now, so we keep it. if ((($parent['id'] == $item_id) || (count($items) == 1)) && ($parent['uri'] === $parent['parent-uri'])) { - logger('Top level post'); + Logger::log('Top level post'); $top_level = true; } @@ -125,7 +126,7 @@ class Delivery extends BaseObject */ if (!$top_level && ($parent['wall'] == 0) && stristr($target_item['uri'], $localhost)) { - logger('Followup ' . $target_item["guid"], LOGGER_DEBUG); + Logger::log('Followup ' . $target_item["guid"], LOGGER_DEBUG); // local followup to remote post $followup = true; } @@ -140,7 +141,7 @@ class Delivery extends BaseObject } if (empty($items)) { - logger('No delivery data for ' . $cmd . ' - Item ID: ' .$item_id . ' - Contact ID: ' . $contact_id); + Logger::log('No delivery data for ' . $cmd . ' - Item ID: ' .$item_id . ' - Contact ID: ' . $contact_id); } $owner = User::getOwnerDataById($uid); @@ -162,7 +163,7 @@ class Delivery extends BaseObject $contact['network'] = Protocol::DIASPORA; } - logger("Delivering " . $cmd . " followup=$followup - via network " . $contact['network']); + Logger::log("Delivering " . $cmd . " followup=$followup - via network " . $contact['network']); switch ($contact['network']) { @@ -212,7 +213,7 @@ class Delivery extends BaseObject */ private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup) { - logger('Deliver ' . $target_item["guid"] . ' via DFRN to ' . (empty($contact['addr']) ? $contact['url'] : $contact['addr'])); + Logger::log('Deliver ' . $target_item["guid"] . ' via DFRN to ' . (empty($contact['addr']) ? $contact['url'] : $contact['addr'])); if ($cmd == self::MAIL) { $item = $target_item; @@ -240,7 +241,7 @@ class Delivery extends BaseObject $atom = DFRN::entries($msgitems, $owner); } - logger('Notifier entry: ' . $contact["url"] . ' ' . $target_item["guid"] . ' entry: ' . $atom, LOGGER_DATA); + Logger::log('Notifier entry: ' . $contact["url"] . ' ' . $target_item["guid"] . ' entry: ' . $atom, LOGGER_DATA); $basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3)); @@ -284,7 +285,7 @@ class Delivery extends BaseObject // We never spool failed relay deliveries if ($public_dfrn) { - logger('Relay delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status); + Logger::log('Relay delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status); return; } @@ -299,10 +300,10 @@ class Delivery extends BaseObject $deliver_status = DFRN::deliver($owner, $contact, $atom, false, true); } - logger('Delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status); + Logger::log('Delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status); if ($deliver_status < 0) { - logger('Delivery failed: queuing message ' . $target_item["guid"] ); + Logger::log('Delivery failed: queuing message ' . $target_item["guid"] ); Queue::add($contact['id'], Protocol::DFRN, $atom, false, $target_item['guid']); } @@ -342,7 +343,7 @@ class Delivery extends BaseObject $loc = $contact['addr']; } - logger('Deliver ' . $target_item["guid"] . ' via Diaspora to ' . $loc); + Logger::log('Deliver ' . $target_item["guid"] . ' via Diaspora to ' . $loc); if (Config::get('system', 'dfrn_only') || !Config::get('system', 'diaspora_enabled')) { return; @@ -360,7 +361,7 @@ class Delivery extends BaseObject } if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) { // top-level retraction - logger('diaspora retract: ' . $loc); + Logger::log('diaspora retract: ' . $loc); Diaspora::sendRetraction($target_item, $owner, $contact, $public_message); return; } elseif ($cmd == self::RELOCATION) { @@ -368,22 +369,22 @@ class Delivery extends BaseObject return; } elseif ($followup) { // send comments and likes to owner to relay - logger('diaspora followup: ' . $loc); + Logger::log('diaspora followup: ' . $loc); Diaspora::sendFollowup($target_item, $owner, $contact, $public_message); return; } elseif ($target_item['uri'] !== $target_item['parent-uri']) { // we are the relay - send comments, likes and relayable_retractions to our conversants - logger('diaspora relay: ' . $loc); + Logger::log('diaspora relay: ' . $loc); Diaspora::sendRelay($target_item, $owner, $contact, $public_message); return; } elseif ($top_level && !$walltowall) { // currently no workable solution for sending walltowall - logger('diaspora status: ' . $loc); + Logger::log('diaspora status: ' . $loc); Diaspora::sendStatus($target_item, $owner, $contact, $public_message); return; } - logger('Unknown mode ' . $cmd . ' for ' . $loc); + Logger::log('Unknown mode ' . $cmd . ' for ' . $loc); } /** @@ -415,7 +416,7 @@ class Delivery extends BaseObject return; } - logger('Deliver ' . $target_item["guid"] . ' via mail to ' . $contact['addr']); + Logger::log('Deliver ' . $target_item["guid"] . ' via mail to ' . $contact['addr']); $reply_to = ''; $mailacct = DBA::selectFirst('mailacct', ['reply_to'], ['uid' => $owner['uid']]); diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php index 63f2e3b67..33e724ce4 100644 --- a/src/Worker/Directory.php +++ b/src/Worker/Directory.php @@ -8,6 +8,7 @@ namespace Friendica\Worker; use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Util\Network; @@ -33,7 +34,7 @@ class Directory Addon::callHooks('globaldir_update', $arr); - logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG); + Logger::log('Updating directory: ' . $arr['url'], LOGGER_DEBUG); if (strlen($arr['url'])) { Network::fetchUrl($dir . '?url=' . bin2hex($arr['url'])); } diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php index c1583888c..da9142e7d 100644 --- a/src/Worker/DiscoverPoCo.php +++ b/src/Worker/DiscoverPoCo.php @@ -6,6 +6,7 @@ namespace Friendica\Worker; use Friendica\Core\Cache; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -52,11 +53,11 @@ class DiscoverPoCo } elseif ($command == "check_profile") { $mode = 8; } elseif ($command !== "") { - logger("Unknown or missing parameter ".$command."\n"); + Logger::log("Unknown or missing parameter ".$command."\n"); return; } - logger('start '.$search); + Logger::log('start '.$search); if ($mode == 8) { if ($param1 != "") { @@ -89,7 +90,7 @@ class DiscoverPoCo } else { $result .= "failed"; } - logger($result, LOGGER_DEBUG); + Logger::log($result, LOGGER_DEBUG); } elseif ($mode == 3) { GContact::updateSuggestions(); } elseif (($mode == 2) && Config::get('system', 'poco_completion')) { @@ -107,7 +108,7 @@ class DiscoverPoCo } } - logger('end '.$search); + Logger::log('end '.$search); return; } @@ -129,7 +130,7 @@ class DiscoverPoCo if (!PortableContact::updateNeeded($server["created"], "", $server["last_failure"], $server["last_contact"])) { continue; } - logger('Update server status for server '.$server["url"], LOGGER_DEBUG); + Logger::log('Update server status for server '.$server["url"], LOGGER_DEBUG); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $server["url"]); @@ -140,7 +141,7 @@ class DiscoverPoCo } private static function discoverUsers() { - logger("Discover users", LOGGER_DEBUG); + Logger::log("Discover users", LOGGER_DEBUG); $starttime = time(); @@ -184,7 +185,7 @@ class DiscoverPoCo } if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || PortableContact::checkServer($server_url, $user["network"])) { - logger('Check profile '.$user["url"]); + Logger::log('Check profile '.$user["url"]); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "check_profile", $user["url"]); if (++$checked > 100) { @@ -208,7 +209,7 @@ class DiscoverPoCo if (!is_null($data)) { // Only search for the same item every 24 hours if (time() < $data + (60 * 60 * 24)) { - logger("Already searched for ".$search." in the last 24 hours", LOGGER_DEBUG); + Logger::log("Already searched for ".$search." in the last 24 hours", LOGGER_DEBUG); return; } } @@ -221,7 +222,7 @@ class DiscoverPoCo // Check if the contact already exists $exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url)); if (DBA::isResult($exists)) { - logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG); + Logger::log("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG); if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) && ($exists[0]["updated"] < $exists[0]["last_failure"])) { @@ -235,16 +236,16 @@ class DiscoverPoCo $server_url = PortableContact::detectServer($jj->url); if ($server_url != '') { if (!PortableContact::checkServer($server_url)) { - logger("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG); + Logger::log("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG); continue; } - logger("Friendica server ".$server_url." seems to be okay.", LOGGER_DEBUG); + Logger::log("Friendica server ".$server_url." seems to be okay.", LOGGER_DEBUG); } $data = Probe::uri($jj->url); if ($data["network"] == Protocol::DFRN) { - logger("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG); - logger("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG); + Logger::log("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG); + Logger::log("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG); if ($jj->tags != "") { $data["keywords"] = $jj->tags; @@ -254,7 +255,7 @@ class DiscoverPoCo GContact::update($data); } else { - logger("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], LOGGER_DEBUG); + Logger::log("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], LOGGER_DEBUG); } } } diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index de2133bdc..9ff523a12 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -9,6 +9,7 @@ namespace Friendica\Worker; use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Model\Item; @@ -26,7 +27,7 @@ class Expire Hook::loadHooks(); if ($param == 'delete') { - logger('Delete expired items', LOGGER_DEBUG); + Logger::log('Delete expired items', LOGGER_DEBUG); // physically remove anything that has been deleted for more than two months $condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"]; $rows = DBA::select('item', ['id'], $condition); @@ -37,62 +38,62 @@ class Expire // Normally we shouldn't have orphaned data at all. // If we do have some, then we have to check why. - logger('Deleting orphaned item activities - start', LOGGER_DEBUG); + Logger::log('Deleting orphaned item activities - start', LOGGER_DEBUG); $condition = ["NOT EXISTS (SELECT `iaid` FROM `item` WHERE `item`.`iaid` = `item-activity`.`id`)"]; DBA::delete('item-activity', $condition); - logger('Orphaned item activities deleted: ' . DBA::affectedRows(), LOGGER_DEBUG); + Logger::log('Orphaned item activities deleted: ' . DBA::affectedRows(), LOGGER_DEBUG); - logger('Deleting orphaned item content - start', LOGGER_DEBUG); + Logger::log('Deleting orphaned item content - start', LOGGER_DEBUG); $condition = ["NOT EXISTS (SELECT `icid` FROM `item` WHERE `item`.`icid` = `item-content`.`id`)"]; DBA::delete('item-content', $condition); - logger('Orphaned item content deleted: ' . DBA::affectedRows(), LOGGER_DEBUG); + Logger::log('Orphaned item content deleted: ' . DBA::affectedRows(), LOGGER_DEBUG); // make this optional as it could have a performance impact on large sites if (intval(Config::get('system', 'optimize_items'))) { DBA::e("OPTIMIZE TABLE `item`"); } - logger('Delete expired items - done', LOGGER_DEBUG); + Logger::log('Delete expired items - done', LOGGER_DEBUG); return; } elseif (intval($param) > 0) { $user = DBA::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]); if (DBA::isResult($user)) { - logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG); + Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG); Item::expire($user['uid'], $user['expire']); - logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG); + Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG); } return; } elseif ($param == 'hook' && !empty($hook_function)) { foreach (Hook::getByName('expire') as $hook) { if ($hook[1] == $hook_function) { - logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG); + Logger::log("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG); Hook::callSingle($a, 'expire', $hook, $data); } } return; } - logger('expire: start'); + Logger::log('expire: start'); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Expire', 'delete'); $r = DBA::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0"); while ($row = DBA::fetch($r)) { - logger('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', LOGGER_DEBUG); + Logger::log('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', LOGGER_DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Expire', (int)$row['uid']); } DBA::close($r); - logger('expire: calling hooks'); + Logger::log('expire: calling hooks'); foreach (Hook::getByName('expire') as $hook) { - logger("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG); + Logger::log("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Expire', 'hook', $hook[1]); } - logger('expire: end'); + Logger::log('expire: end'); return; } diff --git a/src/Worker/GProbe.php b/src/Worker/GProbe.php index 116ca2070..2f80e1e51 100644 --- a/src/Worker/GProbe.php +++ b/src/Worker/GProbe.php @@ -6,6 +6,7 @@ namespace Friendica\Worker; use Friendica\Core\Cache; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model\GContact; @@ -24,7 +25,7 @@ class GProbe { DBA::escape(normalise_link($url)) ); - logger("gprobe start for ".normalise_link($url), LOGGER_DEBUG); + Logger::log("gprobe start for ".normalise_link($url), LOGGER_DEBUG); if (!DBA::isResult($r)) { // Is it a DDoS attempt? @@ -33,7 +34,7 @@ class GProbe { $result = Cache::get("gprobe:".$urlparts["host"]); if (!is_null($result)) { if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) { - logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG); return; } } @@ -60,7 +61,7 @@ class GProbe { } } - logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG); + Logger::log("gprobe end for ".normalise_link($url), LOGGER_DEBUG); return; } } diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 480938ec5..a6e862e7a 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -8,6 +8,7 @@ use Friendica\BaseObject; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -57,7 +58,7 @@ class Notifier { $a = BaseObject::getApp(); - logger('notifier: invoked: '.$cmd.': '.$item_id, LOGGER_DEBUG); + Logger::log('notifier: invoked: '.$cmd.': '.$item_id, LOGGER_DEBUG); $top_level = false; $recipients = []; @@ -104,7 +105,7 @@ class Notifier $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser(0); foreach ($inboxes as $inbox) { - logger('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + Logger::log('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'APDelivery', Delivery::REMOVAL, '', $inbox, $item_id); } @@ -147,7 +148,7 @@ class Notifier } if ((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) { - logger('notifier: top level post'); + Logger::log('notifier: top level post'); $top_level = true; } } @@ -184,7 +185,7 @@ class Notifier $condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]]; $thr_parent = Item::selectFirst($fields, $condition); - logger('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG); + Logger::log('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG); // This is IMPORTANT!!!! @@ -248,7 +249,7 @@ class Notifier $recipients = [$parent['contact-id']]; $recipients_followup = [$parent['contact-id']]; - logger('notifier: followup '.$target_item["guid"].' to '.$conversant_str, LOGGER_DEBUG); + Logger::log('notifier: followup '.$target_item["guid"].' to '.$conversant_str, LOGGER_DEBUG); //if (!$target_item['private'] && $target_item['wall'] && if (!$target_item['private'] && @@ -278,16 +279,16 @@ class Notifier $push_notify = false; } - logger("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), LOGGER_DEBUG); + Logger::log("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), LOGGER_DEBUG); } else { $followup = false; - logger('Distributing directly '.$target_item["guid"], LOGGER_DEBUG); + Logger::log('Distributing directly '.$target_item["guid"], LOGGER_DEBUG); // don't send deletions onward for other people's stuff if ($target_item['deleted'] && !intval($target_item['wall'])) { - logger('notifier: ignoring delete notification for non-wall item'); + Logger::log('notifier: ignoring delete notification for non-wall item'); return; } @@ -328,7 +329,7 @@ class Notifier } if (count($url_recipients)) { - logger('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true)); + Logger::log('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true)); } $conversants = array_unique($conversants); @@ -345,31 +346,31 @@ class Notifier if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) { $diaspora_delivery = false; - logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG); + Logger::log('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG); // Send a salmon to the parent author $probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['author-id']]); if (DBA::isResult($probed_contact) && !empty($probed_contact["notify"])) { - logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]); + Logger::log('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]); $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"]; } // Send a salmon to the parent owner $probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['owner-id']]); if (DBA::isResult($probed_contact) && !empty($probed_contact["notify"])) { - logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]); + Logger::log('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]); $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"]; } // Send a salmon notification to every person we mentioned in the post $arr = explode(',',$target_item['tag']); foreach ($arr as $x) { - //logger('Checking tag '.$x, LOGGER_DEBUG); + //Logger::log('Checking tag '.$x, LOGGER_DEBUG); $matches = null; if (preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) { $probed_contact = Probe::uri($matches[1]); if ($probed_contact["notify"] != "") { - logger('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]); + Logger::log('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]); $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"]; } } @@ -419,7 +420,7 @@ class Notifier // delivery loop if (DBA::isResult($r)) { foreach ($r as $contact) { - logger("Deliver ".$item_id." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG); + Logger::log("Deliver ".$item_id." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Delivery', $cmd, $item_id, (int)$contact['id']); @@ -432,7 +433,7 @@ class Notifier $slap = OStatus::salmon($target_item, $owner); foreach ($url_recipients as $url) { if ($url) { - logger('notifier: urldelivery: ' . $url); + Logger::log('notifier: urldelivery: ' . $url); $deliver_status = Salmon::slapper($owner, $url, $slap); /// @TODO Redeliver/queue these items on failure, though there is no contact record } @@ -469,19 +470,19 @@ class Notifier $r = array_merge($r2, $r1); if (DBA::isResult($r)) { - logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG); + Logger::log('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG); foreach ($r as $rr) { // except for Diaspora batch jobs // Don't deliver to folks who have already been delivered to if (($rr['network'] !== Protocol::DIASPORA) && (in_array($rr['id'], $conversants))) { - logger('notifier: already delivered id=' . $rr['id']); + Logger::log('notifier: already delivered id=' . $rr['id']); continue; } if (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION]) && !$followup) { - logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]); + Logger::log('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Delivery', $cmd, $item_id, (int)$rr['id']); } @@ -493,13 +494,13 @@ class Notifier // Notify PuSH subscribers (Used for OStatus distribution of regular posts) if ($push_notify) { - logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG); + Logger::log('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG); // Handling the pubsubhubbub requests PushSubscriber::publishFeed($owner['uid'], $a->queue['priority']); } - logger('notifier: calling hooks for ' . $cmd . ' ' . $item_id, LOGGER_DEBUG); + Logger::log('notifier: calling hooks for ' . $cmd . ' ' . $item_id, LOGGER_DEBUG); if ($normal_mode) { Hook::fork($a->queue['priority'], 'notifier_normal', $target_item); @@ -517,15 +518,15 @@ class Notifier if ($target_item['origin']) { $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid); - logger('Origin item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); + Logger::log('Origin item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); } elseif (!DBA::exists('conversation', ['item-uri' => $target_item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB])) { - logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', LOGGER_DEBUG); + Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', LOGGER_DEBUG); return; } else { // Remote items are transmitted via the personal inboxes. // Doing so ensures that the dedicated receiver will get the message. $personal = true; - logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); + Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); } if ($parent['origin']) { @@ -534,7 +535,7 @@ class Notifier } if (empty($inboxes)) { - logger('No inboxes found for item ' . $item_id . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', LOGGER_DEBUG); + Logger::log('No inboxes found for item ' . $item_id . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', LOGGER_DEBUG); return; } @@ -542,7 +543,7 @@ class Notifier ActivityPub\Transmitter::createCachedActivityFromItem($item_id, true); foreach ($inboxes as $inbox) { - logger('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'APDelivery', $cmd, $item_id, $inbox, $uid); diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 5227c7983..6628115f0 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -7,6 +7,7 @@ namespace Friendica\Worker; use Friendica\BaseObject; use Friendica\Content\Text\BBCode; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -29,7 +30,7 @@ class OnePoll require_once 'include/items.php'; - logger('start'); + Logger::log('start'); $manual_id = 0; $generation = 0; @@ -42,7 +43,7 @@ class OnePoll } if (!$contact_id) { - logger('no contact'); + Logger::log('no contact'); return; } @@ -50,7 +51,7 @@ class OnePoll $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]); if (!DBA::isResult($contact)) { - logger('Contact not found or cannot be used.'); + Logger::log('Contact not found or cannot be used.'); return; } @@ -86,7 +87,7 @@ class OnePoll $updated = DateTimeFormat::utcNow(); if ($last_updated) { - logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG); + Logger::log('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG); // The last public item can be older than the last item we got if ($last_updated < $contact['last-item']) { @@ -99,7 +100,7 @@ class OnePoll } else { self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]); Contact::markForArchival($contact); - logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG); + Logger::log('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG); } return; @@ -129,7 +130,7 @@ class OnePoll // Update the contact entry if (($contact['network'] === Protocol::OSTATUS) || ($contact['network'] === Protocol::DIASPORA) || ($contact['network'] === Protocol::DFRN)) { if (!PortableContact::reachable($contact['url'])) { - logger("Skipping probably dead contact ".$contact['url']); + Logger::log("Skipping probably dead contact ".$contact['url']); // set the last-update so we don't keep polling DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]); @@ -138,7 +139,7 @@ class OnePoll if (!Contact::updateFromProbe($contact["id"])) { Contact::markForArchival($contact); - logger('Contact is marked dead'); + Logger::log('Contact is marked dead'); // set the last-update so we don't keep polling DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]); @@ -153,7 +154,7 @@ class OnePoll } if ($importer_uid == 0) { - logger('Ignore public contacts'); + Logger::log('Ignore public contacts'); // set the last-update so we don't keep polling DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]); @@ -165,7 +166,7 @@ class OnePoll ); if (!DBA::isResult($r)) { - logger('No self contact for user '.$importer_uid); + Logger::log('No self contact for user '.$importer_uid); // set the last-update so we don't keep polling DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]); @@ -175,7 +176,7 @@ class OnePoll $importer = $r[0]; $url = ''; - logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}"); + Logger::log("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}"); if ($contact['network'] === Protocol::DFRN) { $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']); @@ -213,10 +214,10 @@ class OnePoll $handshake_xml = $curlResult->getBody(); $html_code = $curlResult->getReturnCode(); - logger('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA); + Logger::log('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA); if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) { - logger("$url appears to be dead - marking for death "); + Logger::log("$url appears to be dead - marking for death "); // dead connection - might be a transient event, or this might // mean the software was uninstalled or the domain expired. @@ -231,7 +232,7 @@ class OnePoll } if (!strstr($handshake_xml, '<')) { - logger('response from ' . $url . ' did not contain XML.'); + Logger::log('response from ' . $url . ' did not contain XML.'); Contact::markForArchival($contact); @@ -244,7 +245,7 @@ class OnePoll $res = XML::parseString($handshake_xml); if (intval($res->status) == 1) { - logger("$url replied status 1 - marking for death "); + Logger::log("$url replied status 1 - marking for death "); // we may not be friends anymore. Will keep trying for one month. // set the last-update so we don't keep polling @@ -253,7 +254,7 @@ class OnePoll Contact::markForArchival($contact); } elseif ($contact['term-date'] > DBA::NULL_DATETIME) { - logger("$url back from the dead - removing mark for death"); + Logger::log("$url back from the dead - removing mark for death"); Contact::unmarkForArchival($contact); } @@ -291,7 +292,7 @@ class OnePoll if ($final_dfrn_id != $orig_id) { // did not decode properly - cannot trust this site - logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id); + Logger::log('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id); // set the last-update so we don't keep polling DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]); @@ -347,7 +348,7 @@ class OnePoll $xml = $curlResult->getBody(); } elseif ($contact['network'] === Protocol::MAIL) { - logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG); + Logger::log("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG); $mail_disabled = ((function_exists('imap_open') && !Config::get('system', 'imap_disabled')) ? 0 : 1); if ($mail_disabled) { @@ -357,7 +358,7 @@ class OnePoll return; } - logger("Mail: Enabled", LOGGER_DEBUG); + Logger::log("Mail: Enabled", LOGGER_DEBUG); $mbox = null; $user = DBA::selectFirst('user', ['prvkey'], ['uid' => $importer_uid]); @@ -370,13 +371,13 @@ class OnePoll openssl_private_decrypt(hex2bin($mailconf['pass']), $password, $user['prvkey']); $mbox = Email::connect($mailbox, $mailconf['user'], $password); unset($password); - logger("Mail: Connect to " . $mailconf['user']); + Logger::log("Mail: Connect to " . $mailconf['user']); if ($mbox) { $fields = ['last_check' => DateTimeFormat::utcNow()]; DBA::update('mailacct', $fields, ['id' => $mailconf['id']]); - logger("Mail: Connected to " . $mailconf['user']); + Logger::log("Mail: Connected to " . $mailconf['user']); } else { - logger("Mail: Connection error ".$mailconf['user']." ".print_r(imap_errors(), true)); + Logger::log("Mail: Connection error ".$mailconf['user']." ".print_r(imap_errors(), true)); } } @@ -384,17 +385,17 @@ class OnePoll $msgs = Email::poll($mbox, $contact['addr']); if (count($msgs)) { - logger("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG); + Logger::log("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG); $metas = Email::messageMeta($mbox, implode(',', $msgs)); if (count($metas) != count($msgs)) { - logger("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG); + Logger::log("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG); } else { $msgs = array_combine($msgs, $metas); foreach ($msgs as $msg_uid => $meta) { - logger("Mail: Parsing mail ".$msg_uid, LOGGER_DATA); + Logger::log("Mail: Parsing mail ".$msg_uid, LOGGER_DATA); $datarray = []; $datarray['verb'] = ACTIVITY_POST; @@ -409,7 +410,7 @@ class OnePoll $condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']]; $item = Item::selectFirst($fields, $condition); if (DBA::isResult($item)) { - logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG); + Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG); // Only delete when mails aren't automatically moved or deleted if (($mailconf['action'] != 1) && ($mailconf['action'] != 3)) @@ -420,18 +421,18 @@ class OnePoll switch ($mailconf['action']) { case 0: - logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG); + Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG); break; case 1: - logger("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); + Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); imap_delete($mbox, $msg_uid, FT_UID); break; case 2: - logger("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); + Logger::log("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); break; case 3: - logger("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); + Logger::log("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); if ($mailconf['movetofolder'] != "") { imap_mail_move($mbox, $msg_uid, $mailconf['movetofolder'], FT_UID); @@ -502,13 +503,13 @@ class OnePoll $r = Email::getMessage($mbox, $msg_uid, $reply); if (!$r) { - logger("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']); + Logger::log("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']); continue; } $datarray['body'] = escape_tags($r['body']); $datarray['body'] = BBCode::limitBodySize($datarray['body']); - logger("Mail: Importing ".$msg_uid." for ".$mailconf['user']); + Logger::log("Mail: Importing ".$msg_uid." for ".$mailconf['user']); /// @TODO Adding a gravatar for the original author would be cool @@ -554,18 +555,18 @@ class OnePoll switch ($mailconf['action']) { case 0: - logger("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG); + Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG); break; case 1: - logger("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); + Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); imap_delete($mbox, $msg_uid, FT_UID); break; case 2: - logger("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); + Logger::log("Mail: Mark as seen ".$msg_uid." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); break; case 3: - logger("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); + Logger::log("Mail: Moving ".$msg_uid." to ".$mailconf['movetofolder']." for ".$mailconf['user']); imap_setflag_full($mbox, $msg_uid, "\\Seen", ST_UID); if ($mailconf['movetofolder'] != "") { imap_mail_move($mbox, $msg_uid, $mailconf['movetofolder'], FT_UID); @@ -575,18 +576,18 @@ class OnePoll } } } else { - logger("Mail: no mails for ".$mailconf['user']); + Logger::log("Mail: no mails for ".$mailconf['user']); } - logger("Mail: closing connection for ".$mailconf['user']); + Logger::log("Mail: closing connection for ".$mailconf['user']); imap_close($mbox); } } if ($xml) { - logger('received xml : ' . $xml, LOGGER_DATA); + Logger::log('received xml : ' . $xml, LOGGER_DATA); if (!strstr($xml, '<')) { - logger('post_handshake: response from ' . $url . ' did not contain XML.'); + Logger::log('post_handshake: response from ' . $url . ' did not contain XML.'); $fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()]; self::updateContact($contact, $fields); @@ -595,7 +596,7 @@ class OnePoll } - logger("Consume feed of contact ".$contact['id']); + Logger::log("Consume feed of contact ".$contact['id']); consume_feed($xml, $importer, $contact, $hub); @@ -617,10 +618,10 @@ class OnePoll $hub_update = true; } - logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update); + Logger::log("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update); if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == Protocol::FEED)) { - logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']); + Logger::log('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']); $hubs = explode(',', $hub); if (count($hubs)) { diff --git a/src/Worker/ProfileUpdate.php b/src/Worker/ProfileUpdate.php index cebc27ca5..98952658a 100644 --- a/src/Worker/ProfileUpdate.php +++ b/src/Worker/ProfileUpdate.php @@ -7,9 +7,10 @@ namespace Friendica\Worker; use Friendica\BaseObject; +use Friendica\Core\Logger; +use Friendica\Core\Worker; use Friendica\Protocol\Diaspora; use Friendica\Protocol\ActivityPub; -use Friendica\Core\Worker; class ProfileUpdate { public static function execute($uid = 0) { @@ -22,7 +23,7 @@ class ProfileUpdate { $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($uid); foreach ($inboxes as $inbox) { - logger('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + Logger::log('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'APDelivery', Delivery::PROFILEUPDATE, '', $inbox, $uid); } diff --git a/src/Worker/PubSubPublish.php b/src/Worker/PubSubPublish.php index 38d9c0786..bc9233d55 100644 --- a/src/Worker/PubSubPublish.php +++ b/src/Worker/PubSubPublish.php @@ -6,6 +6,7 @@ namespace Friendica\Worker; use Friendica\BaseObject; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\PushSubscriber; @@ -37,7 +38,7 @@ class PubSubPublish /// @todo Check server status with PortableContact::checkServer() // Before this can be done we need a way to safely detect the server url. - logger("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update'], LOGGER_DEBUG); + Logger::log("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update'], LOGGER_DEBUG); $last_update = $subscriber['last_update']; $params = OStatus::feed($subscriber['nickname'], $last_update); @@ -54,7 +55,7 @@ class PubSubPublish $subscriber['topic']), "X-Hub-Signature: sha1=" . $hmac_sig]; - logger('POST ' . print_r($headers, true) . "\n" . $params, LOGGER_DATA); + Logger::log('POST ' . print_r($headers, true) . "\n" . $params, LOGGER_DATA); $postResult = Network::post($subscriber['callback_url'], $params, $headers); $ret = $postResult->getReturnCode(); @@ -62,11 +63,11 @@ class PubSubPublish $condition = ['id' => $subscriber['id']]; if ($ret >= 200 && $ret <= 299) { - logger('Successfully pushed to ' . $subscriber['callback_url']); + Logger::log('Successfully pushed to ' . $subscriber['callback_url']); PushSubscriber::reset($subscriber['id'], $last_update); } else { - logger('Delivery error when pushing to ' . $subscriber['callback_url'] . ' HTTP: ' . $ret); + Logger::log('Delivery error when pushing to ' . $subscriber['callback_url'] . ' HTTP: ' . $ret); PushSubscriber::delay($subscriber['id']); } diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php index 6cad9ac53..8dc34a594 100644 --- a/src/Worker/Queue.php +++ b/src/Worker/Queue.php @@ -7,6 +7,7 @@ namespace Friendica\Worker; use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Worker; use Friendica\Database\DBA; @@ -32,7 +33,7 @@ class Queue $no_dead_check = Config::get('system', 'queue_no_dead_check', false); if (!$queue_id) { - logger('filling queue jobs - start'); + Logger::log('filling queue jobs - start'); // Handling the pubsubhubbub requests PushSubscriber::requeue(); @@ -43,11 +44,11 @@ class Queue if (DBA::isResult($r)) { foreach ($r as $q_item) { - logger('Call queue for id ' . $q_item['id']); + Logger::log('Call queue for id ' . $q_item['id']); Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "Queue", (int) $q_item['id']); } } - logger('filling queue jobs - end'); + Logger::log('filling queue jobs - end'); return; } @@ -72,7 +73,7 @@ class Queue $dead = Cache::get($cachekey_deadguy . $contact['notify']); if (!is_null($dead) && $dead && !$no_dead_check) { - logger('queue: skipping known dead url: ' . $contact['notify']); + Logger::log('queue: skipping known dead url: ' . $contact['notify']); QueueModel::updateTime($q_item['id']); return; } @@ -84,14 +85,14 @@ class Queue $vital = Cache::get($cachekey_server . $server); if (is_null($vital)) { - logger("Check server " . $server . " (" . $contact["network"] . ")"); + Logger::log("Check server " . $server . " (" . $contact["network"] . ")"); $vital = PortableContact::checkServer($server, $contact["network"], true); Cache::set($cachekey_server . $server, $vital, Cache::MINUTE); } if (!is_null($vital) && !$vital) { - logger('queue: skipping dead server: ' . $server); + Logger::log('queue: skipping dead server: ' . $server); QueueModel::updateTime($q_item['id']); return; } @@ -112,7 +113,7 @@ class Queue switch ($contact['network']) { case Protocol::DFRN: - logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); + Logger::log('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); $deliver_status = DFRN::deliver($owner, $contact, $data); if (($deliver_status >= 200) && ($deliver_status <= 299)) { @@ -124,7 +125,7 @@ class Queue break; case Protocol::OSTATUS: - logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); + Logger::log('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); $deliver_status = Salmon::slapper($owner, $contact['notify'], $data); if ($deliver_status == -1) { @@ -136,7 +137,7 @@ class Queue break; case Protocol::DIASPORA: - logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); + Logger::log('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); $deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true); if ((($deliver_status >= 200) && ($deliver_status <= 299)) || @@ -159,7 +160,7 @@ class Queue } break; } - logger('Deliver status ' . (int)$deliver_status . ' for item ' . $q_item['id'] . ' to ' . $contact['name'] . ' <' . $contact['url'] . '>'); + Logger::log('Deliver status ' . (int)$deliver_status . ' for item ' . $q_item['id'] . ' to ' . $contact['name'] . ' <' . $contact['url'] . '>'); return; } diff --git a/src/Worker/SpoolPost.php b/src/Worker/SpoolPost.php index 31474abfb..ca26a2f63 100644 --- a/src/Worker/SpoolPost.php +++ b/src/Worker/SpoolPost.php @@ -5,10 +5,11 @@ */ namespace Friendica\Worker; -use Friendica\Model\Item; use Friendica\Core\Config; +use Friendica\Core\Logger; +use Friendica\Model\Item; -require_once("include/items.php"); +require_once "include/items.php"; class SpoolPost { public static function execute() { @@ -49,7 +50,7 @@ class SpoolPost { $result = Item::insert($arr); - logger("Spool file ".$file." stored: ".$result, LOGGER_DEBUG); + Logger::log("Spool file ".$file." stored: ".$result, LOGGER_DEBUG); unlink($fullfile); } closedir($dh); diff --git a/src/Worker/TagUpdate.php b/src/Worker/TagUpdate.php index 3dac20b6c..cccaed8e2 100644 --- a/src/Worker/TagUpdate.php +++ b/src/Worker/TagUpdate.php @@ -2,6 +2,7 @@ namespace Friendica\Worker; +use Friendica\Core\Logger; use Friendica\Database\DBA; class TagUpdate @@ -10,7 +11,7 @@ class TagUpdate { $messages = DBA::p("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''"); - logger('fetched messages: ' . DBA::numRows($messages)); + Logger::log('fetched messages: ' . DBA::numRows($messages)); while ($message = DBA::fetch($messages)) { if ($message['uid'] == 0) { $global = true; @@ -29,7 +30,7 @@ class TagUpdate $messages = DBA::select('item', ['guid'], ['uid' => 0]); - logger('fetched messages: ' . DBA::numRows($messages)); + Logger::log('fetched messages: ' . DBA::numRows($messages)); while ($message = DBA::fetch(messages)) { DBA::update('item', ['global' => true], ['guid' => $message['guid']]); } diff --git a/src/Worker/UpdateGContact.php b/src/Worker/UpdateGContact.php index 67362917c..b7a78b51f 100644 --- a/src/Worker/UpdateGContact.php +++ b/src/Worker/UpdateGContact.php @@ -6,6 +6,7 @@ namespace Friendica\Worker; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Network\Probe; @@ -16,10 +17,10 @@ class UpdateGContact { public static function execute($contact_id) { - logger('update_gcontact: start'); + Logger::log('update_gcontact: start'); if (empty($contact_id)) { - logger('update_gcontact: no contact'); + Logger::log('update_gcontact: no contact'); return; } diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index f46b42788..8cb4c3429 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -13,6 +13,7 @@ use Friendica\Content\Widget; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBA; @@ -63,7 +64,7 @@ function frio_install() Addon::registerHook('acl_lookup_end', 'view/theme/frio/theme.php', 'frio_acl_lookup'); Addon::registerHook('display_item', 'view/theme/frio/theme.php', 'frio_display_item'); - logger('installed theme frio'); + Logger::log('installed theme frio'); } function frio_uninstall() @@ -75,7 +76,7 @@ function frio_uninstall() Addon::unregisterHook('acl_lookup_end', 'view/theme/frio/theme.php', 'frio_acl_lookup'); Addon::unregisterHook('display_item', 'view/theme/frio/theme.php', 'frio_display_item'); - logger('uninstalled theme frio'); + Logger::log('uninstalled theme frio'); } /** diff --git a/view/theme/vier/style.php b/view/theme/vier/style.php index d77786482..9b528a14b 100644 --- a/view/theme/vier/style.php +++ b/view/theme/vier/style.php @@ -2,6 +2,7 @@ /** * @file view/theme/vier/style.php */ +use Friendica\Core\Logger; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Model\Profile; @@ -31,7 +32,7 @@ foreach (['style', $style] as $file) { } } else { //TODO: use LOGGER_ERROR? - logger('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')'); + Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')'); } } $modified = gmdate('r', $modified); From 7138cc97aca3af75a4cbbb9a0db39fd08c065422 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 29 Oct 2018 17:27:28 -0400 Subject: [PATCH 10/68] Correct misspelling correct misspelled use statement --- src/Core/Logger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Logger.php b/src/Core/Logger.php index 2eae6b57e..1e7099d54 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -5,7 +5,7 @@ namespace Friendica\Core; use Friendica\Core\Config; -use Friendica\Util\DataTimeFormat; +use Friendica\Util\DateTimeFormat; class Logger { From 80367d05d8e11cd9acd5fb66968e9766dccca294 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Mon, 29 Oct 2018 19:50:40 -0400 Subject: [PATCH 11/68] Remove functions remove functions that were moved to Logger class --- include/text.php | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/include/text.php b/include/text.php index 48351f59e..aae739312 100644 --- a/include/text.php +++ b/include/text.php @@ -381,51 +381,6 @@ function attribute_contains($attr, $s) { return (count($a) && in_array($s,$a)); } - -/** - * @brief Logs the given message at the given log level - * - * log levels: - * LOGGER_WARNING - * LOGGER_INFO (default) - * LOGGER_TRACE - * LOGGER_DEBUG - * LOGGER_DATA - * LOGGER_ALL - * - * @global array $LOGGER_LEVELS - * @param string $msg - * @param int $level - */ -function logger($msg, $level = LOGGER_INFO) -{ - Logger::log($msg, $level); -} - -/** - * @brief An alternative logger for development. - * Works largely as logger() but allows developers - * to isolate particular elements they are targetting - * personally without background noise - * - * log levels: - * LOGGER_WARNING - * LOGGER_INFO (default) - * LOGGER_TRACE - * LOGGER_DEBUG - * LOGGER_DATA - * LOGGER_ALL - * - * @global array $LOGGER_LEVELS - * @param string $msg - * @param int $level - */ -function dlogger($msg, $level = LOGGER_INFO) -{ - Logger::devLog($msg, $level); -} - - /** * Compare activity uri. Knows about activity namespace. * @@ -1267,7 +1222,7 @@ function base64url_encode($s, $strip_padding = false) { function base64url_decode($s) { if (is_array($s)) { - logger('base64url_decode: illegal input: ' . print_r(debug_backtrace(), true)); + Logger::log('base64url_decode: illegal input: ' . print_r(debug_backtrace(), true)); return $s; } From 26fbe8dfba2eff823fc17157e8f917c3f8f8f42e Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 07:59:45 -0400 Subject: [PATCH 12/68] Review Modifications make changes based on review. --- boot.php | 14 ------- src/Core/Logger.php | 99 ++++++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 60 deletions(-) diff --git a/boot.php b/boot.php index 6b66625c6..3efd065f3 100644 --- a/boot.php +++ b/boot.php @@ -106,20 +106,6 @@ define('SSL_POLICY_FULL', 1); define('SSL_POLICY_SELFSIGN', 2); /* @}*/ -/** - * @name Logger - * - * log levels - * @{ - */ -define('LOGGER_WARNING', 0); -define('LOGGER_INFO', 1); -define('LOGGER_TRACE', 2); -define('LOGGER_DEBUG', 3); -define('LOGGER_DATA', 4); -define('LOGGER_ALL', 5); -/* @}*/ - /** * @name Register * diff --git a/src/Core/Logger.php b/src/Core/Logger.php index 1e7099d54..ad814042d 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -7,28 +7,39 @@ namespace Friendica\Core; use Friendica\Core\Config; use Friendica\Util\DateTimeFormat; -class Logger +/** + * @brief Logger functions + */ +class Logger extends BaseObject { + // Log levels: + const WARNING = 0; + const INFO = 1; + const TRACE = 2; + const DEBUG = 3; + const DATA = 4; + const ALL = 5; + + public static $levels = []; + + /** + * @brief Get class constants, and avoid using substring. + */ + public function getConstants() + { + $reflectionClass = new ReflectionClass($this); + return $reflectionClass->getConstants(); + } + /** * @brief Logs the given message at the given log level * - * log levels: - * LOGGER_WARNING - * LOGGER_INFO (default) - * LOGGER_TRACE - * LOGGER_DEBUG - * LOGGER_DATA - * LOGGER_ALL - * - * @global array $LOGGER_LEVELS * @param string $msg * @param int $level */ - public static function log($msg, $level = LOGGER_INFO) + public static function log($msg, $level = INFO) { - $a = get_app(); - global $LOGGER_LEVELS; - $LOGGER_LEVELS = []; + $a = self::getApp(); $debugging = Config::get('system', 'debugging'); $logfile = Config::get('system', 'logfile'); @@ -42,18 +53,19 @@ class Logger return; } - if (count($LOGGER_LEVELS) == 0) { - foreach (get_defined_constants() as $k => $v) { - if (substr($k, 0, 7) == "LOGGER_") { - $LOGGER_LEVELS[$v] = substr($k, 7, 7); - } + if (count($levels) == 0) + { + foreach (self::getConstants() as $k => $v) + { + $levels[$v] = $k; } } - $process_id = session_id(); + $processId = session_id(); - if ($process_id == '') { - $process_id = get_app()->process_id; + if ($processId == '') + { + $processId = $a->process_id; } $callers = debug_backtrace(); @@ -66,8 +78,8 @@ class Logger $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", DateTimeFormat::utcNow(DateTimeFormat::ATOM), - $process_id, - $LOGGER_LEVELS[$level], + $processId, + $levels[$level], basename($callers[0]['file']), $callers[0]['line'], $function, @@ -85,50 +97,45 @@ class Logger * to isolate particular elements they are targetting * personally without background noise * - * log levels: - * LOGGER_WARNING - * LOGGER_INFO (default) - * LOGGER_TRACE - * LOGGER_DEBUG - * LOGGER_DATA - * LOGGER_ALL - * - * @global array $LOGGER_LEVELS * @param string $msg * @param int $level */ - public static function devLog($msg, $level = LOGGER_INFO) + public static function devLog($msg, $level = INFO) { - $a = get_app(); + $a = self::getApp(); $logfile = Config::get('system', 'dlogfile'); + if (!$logfile) { return; } $dlogip = Config::get('system', 'dlogip'); - if (!is_null($dlogip) && $_SERVER['REMOTE_ADDR'] != $dlogip) { + + if (!is_null($dlogip) && $_SERVER['REMOTE_ADDR'] != $dlogip) + { return; } - if (count($LOGGER_LEVELS) == 0) { - foreach (get_defined_constants() as $k => $v) { - if (substr($k, 0, 7) == "LOGGER_") { - $LOGGER_LEVELS[$v] = substr($k, 7, 7); - } + if (count($levels) == 0) + { + foreach (self::getConstants() as $k => $v) + { + $levels[$v] = $k; } } - $process_id = session_id(); + $processId = session_id(); - if ($process_id == '') { - $process_id = $a->process_id; + if ($processId == '') + { + $processId = $a->process_id; } $callers = debug_backtrace(); $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n", DateTimeFormat::utcNow(), - $process_id, + $processId, basename($callers[0]['file']), $callers[0]['line'], $callers[1]['function'], @@ -139,4 +146,4 @@ class Logger @file_put_contents($logfile, $logline, FILE_APPEND); $a->saveTimestamp($stamp1, "file"); } -} \ No newline at end of file +} From 91ef9f238cd79f1546d03a557753eec2c7d09327 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 09:56:41 -0400 Subject: [PATCH 13/68] missing use and self add use and self statements --- src/Core/Logger.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Core/Logger.php b/src/Core/Logger.php index ad814042d..e6d4f6118 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -6,6 +6,7 @@ namespace Friendica\Core; use Friendica\Core\Config; use Friendica\Util\DateTimeFormat; +use ReflectionClass; /** * @brief Logger functions @@ -25,9 +26,9 @@ class Logger extends BaseObject /** * @brief Get class constants, and avoid using substring. */ - public function getConstants() + public static function getConstants() { - $reflectionClass = new ReflectionClass($this); + $reflectionClass = new ReflectionClass(__CLASS__); return $reflectionClass->getConstants(); } @@ -37,7 +38,7 @@ class Logger extends BaseObject * @param string $msg * @param int $level */ - public static function log($msg, $level = INFO) + public static function log($msg, $level = self::INFO) { $a = self::getApp(); @@ -53,7 +54,7 @@ class Logger extends BaseObject return; } - if (count($levels) == 0) + if (count(self::$levels) == 0) { foreach (self::getConstants() as $k => $v) { @@ -100,7 +101,7 @@ class Logger extends BaseObject * @param string $msg * @param int $level */ - public static function devLog($msg, $level = INFO) + public static function devLog($msg, $level = self::INFO) { $a = self::getApp(); @@ -117,7 +118,7 @@ class Logger extends BaseObject return; } - if (count($levels) == 0) + if (count(self::$levels) == 0) { foreach (self::getConstants() as $k => $v) { From 50da89d861dce3b648c8f9e5c1e4c480ee320a43 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 09:58:45 -0400 Subject: [PATCH 14/68] Logger Levels update logger levels in calls --- bin/daemon.php | 12 +- include/api.php | 58 ++++---- include/conversation.php | 2 +- include/enotify.php | 10 +- include/items.php | 12 +- mod/acl.php | 2 +- mod/admin.php | 16 +-- mod/dfrn_confirm.php | 6 +- mod/dfrn_notify.php | 20 +-- mod/dfrn_poll.php | 12 +- mod/dfrn_request.php | 2 +- mod/display.php | 2 +- mod/events.php | 2 +- mod/item.php | 8 +- mod/nodeinfo.php | 10 +- mod/openid.php | 2 +- mod/photos.php | 16 +-- mod/poco.php | 10 +- mod/poke.php | 2 +- mod/profile.php | 2 +- mod/pubsub.php | 4 +- mod/receive.php | 14 +- mod/redir.php | 8 +- mod/salmon.php | 4 +- mod/search.php | 8 +- mod/statistics_json.php | 2 +- mod/wall_upload.php | 10 +- src/App.php | 22 +-- src/BaseModule.php | 4 +- src/Content/Text/BBCode.php | 14 +- src/Core/Authentication.php | 4 +- src/Core/Cache/MemcachedCacheDriver.php | 4 +- src/Core/NotificationsManager.php | 2 +- src/Core/Session/CacheSessionHandler.php | 2 +- src/Core/Session/DatabaseSessionHandler.php | 2 +- src/Core/UserImport.php | 18 +-- src/Core/Worker.php | 64 ++++----- src/Database/DBA.php | 6 +- src/Database/DBStructure.php | 6 +- src/Database/PostUpdate.php | 34 ++--- src/Model/APContact.php | 2 +- src/Model/Contact.php | 4 +- src/Model/Conversation.php | 4 +- src/Model/Event.php | 2 +- src/Model/GContact.php | 24 ++-- src/Model/Item.php | 76 +++++------ src/Model/Profile.php | 18 +-- src/Model/PushSubscriber.php | 10 +- src/Model/User.php | 2 +- src/Module/Magic.php | 8 +- src/Module/Owa.php | 8 +- src/Network/CurlResult.php | 6 +- src/Network/FKOAuth1.php | 2 +- src/Network/Probe.php | 44 +++--- src/Object/Image.php | 18 +-- src/Object/Post.php | 10 +- src/Object/Thread.php | 12 +- src/Protocol/ActivityPub/Processor.php | 30 ++--- src/Protocol/ActivityPub/Receiver.php | 64 ++++----- src/Protocol/ActivityPub/Transmitter.php | 14 +- src/Protocol/DFRN.php | 80 +++++------ src/Protocol/Diaspora.php | 140 ++++++++++---------- src/Protocol/Email.php | 6 +- src/Protocol/Feed.php | 12 +- src/Protocol/OStatus.php | 68 +++++----- src/Protocol/PortableContact.php | 66 ++++----- src/Util/Emailer.php | 4 +- src/Util/HTTPSignature.php | 6 +- src/Util/JsonLD.php | 4 +- src/Util/Network.php | 10 +- src/Util/ParseUrl.php | 6 +- src/Util/XML.php | 8 +- src/Worker/APDelivery.php | 2 +- src/Worker/CheckVersion.php | 4 +- src/Worker/CronJobs.php | 10 +- src/Worker/Delivery.php | 6 +- src/Worker/Directory.php | 2 +- src/Worker/DiscoverPoCo.php | 20 +-- src/Worker/Expire.php | 22 +-- src/Worker/GProbe.php | 6 +- src/Worker/Notifier.php | 34 ++--- src/Worker/OnePoll.php | 24 ++-- src/Worker/ProfileUpdate.php | 2 +- src/Worker/PubSubPublish.php | 4 +- src/Worker/SpoolPost.php | 2 +- view/theme/vier/style.php | 2 +- 86 files changed, 673 insertions(+), 673 deletions(-) diff --git a/bin/daemon.php b/bin/daemon.php index 1ae55be78..f628031c3 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -98,7 +98,7 @@ if ($mode == "stop") { unlink($pidfile); - Logger::log("Worker daemon process $pid was killed.", LOGGER_DEBUG); + Logger::log("Worker daemon process $pid was killed.", Logger::DEBUG); Config::set('system', 'worker_daemon_mode', false); die("Worker daemon process $pid was killed.\n"); @@ -108,7 +108,7 @@ if (!empty($pid) && posix_kill($pid, 0)) { die("Daemon process $pid is already running.\n"); } -Logger::log('Starting worker daemon.', LOGGER_DEBUG); +Logger::log('Starting worker daemon.', Logger::DEBUG); if (!$foreground) { echo "Starting worker daemon.\n"; @@ -156,7 +156,7 @@ $last_cron = 0; // Now running as a daemon. while (true) { if (!$do_cron && ($last_cron + $wait_interval) < time()) { - Logger::log('Forcing cron worker call.', LOGGER_DEBUG); + Logger::log('Forcing cron worker call.', Logger::DEBUG); $do_cron = true; } @@ -170,7 +170,7 @@ while (true) { $last_cron = time(); } - Logger::log("Sleeping", LOGGER_DEBUG); + Logger::log("Sleeping", Logger::DEBUG); $start = time(); do { $seconds = (time() - $start); @@ -187,10 +187,10 @@ while (true) { if ($timeout) { $do_cron = true; - Logger::log("Woke up after $wait_interval seconds.", LOGGER_DEBUG); + Logger::log("Woke up after $wait_interval seconds.", Logger::DEBUG); } else { $do_cron = false; - Logger::log("Worker jobs are calling to be forked.", LOGGER_DEBUG); + Logger::log("Worker jobs are calling to be forked.", Logger::DEBUG); } } diff --git a/include/api.php b/include/api.php index b2a91097d..246a716fa 100644 --- a/include/api.php +++ b/include/api.php @@ -97,9 +97,9 @@ function api_source() return "Twidere"; } - Logger::log("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], LOGGER_DEBUG); + Logger::log("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], Logger::DEBUG); } else { - Logger::log("Empty user-agent", LOGGER_DEBUG); + Logger::log("Empty user-agent", Logger::DEBUG); } return "api"; @@ -195,7 +195,7 @@ function api_login(App $a) } if (!x($_SERVER, 'PHP_AUTH_USER')) { - Logger::log('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('API_login: ' . print_r($_SERVER, true), Logger::DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); throw new UnauthorizedException("This API requires login"); } @@ -236,7 +236,7 @@ function api_login(App $a) } if (!DBA::isResult($record)) { - Logger::log('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('API_login failure: ' . print_r($_SERVER, true), Logger::DEBUG); header('WWW-Authenticate: Basic realm="Friendica"'); //header('HTTP/1.0 401 Unauthorized'); //die('This api requires login'); @@ -315,7 +315,7 @@ function api_call(App $a) $stamp = microtime(true); $return = call_user_func($info['func'], $type); $duration = (float) (microtime(true) - $stamp); - Logger::log("API call duration: " . round($duration, 2) . "\t" . $a->query_string, LOGGER_DEBUG); + Logger::log("API call duration: " . round($duration, 2) . "\t" . $a->query_string, Logger::DEBUG); if (Config::get("system", "profiler")) { $duration = microtime(true)-$a->performance["start"]; @@ -335,7 +335,7 @@ function api_call(App $a) + $a->performance["network"] + $a->performance["file"]), 2), round($duration, 2) ), - LOGGER_DEBUG + Logger::DEBUG ); if (Config::get("rendertime", "callstack")) { @@ -376,7 +376,7 @@ function api_call(App $a) $o .= $func . ": " . $time . "\n"; } } - Logger::log($o, LOGGER_DEBUG); + Logger::log($o, Logger::DEBUG); } } @@ -522,7 +522,7 @@ function api_get_user(App $a, $contact_id = null) $extra_query = ""; $url = ""; - Logger::log("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG); + Logger::log("api_get_user: Fetching user data for user ".$contact_id, Logger::DEBUG); // Searching for contact URL if (!is_null($contact_id) && (intval($contact_id) == 0)) { @@ -606,7 +606,7 @@ function api_get_user(App $a, $contact_id = null) } } - Logger::log("api_get_user: user ".$user, LOGGER_DEBUG); + Logger::log("api_get_user: user ".$user, Logger::DEBUG); if (!$user) { if (api_user() === false) { @@ -1136,7 +1136,7 @@ function api_statuses_update($type) $posts_day = DBA::count('thread', $condition); if ($posts_day > $throttle_day) { - Logger::log('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG); + Logger::log('Daily posting limit reached for user '.api_user(), Logger::DEBUG); // die(api_error($type, L10n::t("Daily posting limit of %d posts reached. The post was rejected.", $throttle_day)); throw new TooManyRequestsException(L10n::tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day)); } @@ -1150,7 +1150,7 @@ function api_statuses_update($type) $posts_week = DBA::count('thread', $condition); if ($posts_week > $throttle_week) { - Logger::log('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG); + Logger::log('Weekly posting limit reached for user '.api_user(), Logger::DEBUG); // die(api_error($type, L10n::t("Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week))); throw new TooManyRequestsException(L10n::tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week)); } @@ -1164,7 +1164,7 @@ function api_statuses_update($type) $posts_month = DBA::count('thread', $condition); if ($posts_month > $throttle_month) { - Logger::log('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG); + Logger::log('Monthly posting limit reached for user '.api_user(), Logger::DEBUG); // die(api_error($type, L10n::t("Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month)); throw new TooManyRequestsException(L10n::t("Monthly posting limit of %d post reached. The post was rejected.", "Monthly posting limit of %d posts reached. The post was rejected.", $throttle_month)); } @@ -1249,7 +1249,7 @@ function api_media_upload() "h" => $media["height"], "image_type" => $media["type"]]; - Logger::log("Media uploaded: " . print_r($returndata, true), LOGGER_DEBUG); + Logger::log("Media uploaded: " . print_r($returndata, true), Logger::DEBUG); return ["media" => $returndata]; } @@ -1269,7 +1269,7 @@ function api_status_show($type, $item_id = 0) $user_info = api_get_user($a); - Logger::log('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG); + Logger::log('api_status_show: user_info: '.print_r($user_info, true), Logger::DEBUG); if ($type == "raw") { $privacy_sql = "AND NOT `private`"; @@ -1345,7 +1345,7 @@ function api_status_show($type, $item_id = 0) unset($status_info["user"]["uid"]); unset($status_info["user"]["self"]); - Logger::log('status_info: '.print_r($status_info, true), LOGGER_DEBUG); + Logger::log('status_info: '.print_r($status_info, true), Logger::DEBUG); if ($type == "raw") { return $status_info; @@ -2142,7 +2142,7 @@ function api_statuses_user_timeline($type) "api_statuses_user_timeline: api_user: ". api_user() . "\nuser_info: ".print_r($user_info, true) . "\n_REQUEST: ".print_r($_REQUEST, true), - LOGGER_DEBUG + Logger::DEBUG ); $since_id = x($_REQUEST, 'since_id') ? $_REQUEST['since_id'] : 0; @@ -3650,7 +3650,7 @@ function api_friendships_destroy($type) $contact_id = defaults($_REQUEST, 'user_id'); if (empty($contact_id)) { - Logger::log("No user_id specified", LOGGER_DEBUG); + Logger::log("No user_id specified", Logger::DEBUG); throw new BadRequestException("no user_id specified"); } @@ -3658,7 +3658,7 @@ function api_friendships_destroy($type) $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => 0, 'self' => false]); if(!DBA::isResult($contact)) { - Logger::log("No contact found for ID" . $contact_id, LOGGER_DEBUG); + Logger::log("No contact found for ID" . $contact_id, Logger::DEBUG); throw new NotFoundException("no contact found to given ID"); } @@ -3670,12 +3670,12 @@ function api_friendships_destroy($type) $contact = DBA::selectFirst('contact', [], $condition); if (!DBA::isResult($contact)) { - Logger::log("Not following Contact", LOGGER_DEBUG); + Logger::log("Not following Contact", Logger::DEBUG); throw new NotFoundException("Not following Contact"); } if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { - Logger::log("Not supported", LOGGER_DEBUG); + Logger::log("Not supported", Logger::DEBUG); throw new ExpectationFailedException("Not supported"); } @@ -3686,7 +3686,7 @@ function api_friendships_destroy($type) Contact::terminateFriendship($owner, $contact, $dissolve); } else { - Logger::log("No owner found", LOGGER_DEBUG); + Logger::log("No owner found", Logger::DEBUG); throw new NotFoundException("Error Processing Request"); } @@ -4489,7 +4489,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ Logger::log( "File upload src: " . $src . " - filename: " . $filename . " - size: " . $filesize . " - type: " . $filetype, - LOGGER_DEBUG + Logger::DEBUG ); // check if there was a php upload error @@ -4521,7 +4521,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ } if ($max_length > 0) { $Image->scaleDown($max_length); - Logger::log("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG); + Logger::log("File upload: Scaling picture to new size " . $max_length, Logger::DEBUG); } $width = $Image->getWidth(); $height = $Image->getHeight(); @@ -4531,7 +4531,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ if ($mediatype == "photo") { // upload normal image (scales 0, 1, 2) - Logger::log("photo upload: starting new photo upload", LOGGER_DEBUG); + Logger::log("photo upload: starting new photo upload", Logger::DEBUG); $r = Photo::store($Image, local_user(), $visitor, $hash, $filename, $album, 0, 0, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); if (!$r) { @@ -4552,10 +4552,10 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ Logger::log("photo upload: image upload with scale 2 (320x320) failed"); } } - Logger::log("photo upload: new photo upload ended", LOGGER_DEBUG); + Logger::log("photo upload: new photo upload ended", Logger::DEBUG); } elseif ($mediatype == "profileimage") { // upload profile image (scales 4, 5, 6) - Logger::log("photo upload: starting new profile image upload", LOGGER_DEBUG); + Logger::log("photo upload: starting new profile image upload", Logger::DEBUG); if ($width > 300 || $height > 300) { $Image->scaleDown(300); @@ -4581,7 +4581,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ } } $Image->__destruct(); - Logger::log("photo upload: new profile image upload ended", LOGGER_DEBUG); + Logger::log("photo upload: new profile image upload ended", Logger::DEBUG); } if (isset($r) && $r) { @@ -4808,7 +4808,7 @@ function api_friendica_remoteauth() 'sec' => $sec, 'expire' => time() + 45]; DBA::insert('profile_check', $fields); - Logger::log($contact['name'] . ' ' . $sec, LOGGER_DEBUG); + Logger::log($contact['name'] . ' ' . $sec, Logger::DEBUG); $dest = ($url ? '&destination_url=' . $url : ''); System::externalRedirect( @@ -5056,7 +5056,7 @@ function api_in_reply_to($item) // https://github.com/friendica/friendica/issues/1010 // This is a bugfix for that. if (intval($in_reply_to['status_id']) == intval($item['id'])) { - Logger::log('this message should never appear: id: '.$item['id'].' similar to reply-to: '.$in_reply_to['status_id'], LOGGER_DEBUG); + Logger::log('this message should never appear: id: '.$item['id'].' similar to reply-to: '.$in_reply_to['status_id'], Logger::DEBUG); $in_reply_to['status_id'] = null; $in_reply_to['user_id'] = null; $in_reply_to['status_id_str'] = null; diff --git a/include/conversation.php b/include/conversation.php index 47adfc0df..8317746dd 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -752,7 +752,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ $threads = $conv->getTemplateData($conv_responses); if (!$threads) { - Logger::log('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); + Logger::log('[ERROR] conversation : Failed to get template data.', Logger::DEBUG); $threads = []; } } diff --git a/include/enotify.php b/include/enotify.php index fe2cc1f33..bc9a7b9b0 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -134,7 +134,7 @@ function notification($params) if ($params['type'] == NOTIFY_COMMENT) { $thread = Item::selectFirstThreadForUser($params['uid'] ,['ignored'], ['iid' => $parent_id]); if (DBA::isResult($thread) && $thread["ignored"]) { - Logger::log("Thread ".$parent_id." will be ignored", LOGGER_DEBUG); + Logger::log("Thread ".$parent_id." will be ignored", Logger::DEBUG); L10n::popLang(); return; } @@ -453,7 +453,7 @@ function notification($params) $itemlink = $h['itemlink']; if ($show_in_notification_page) { - Logger::log("adding notification entry", LOGGER_DEBUG); + Logger::log("adding notification entry", Logger::DEBUG); do { $dups = false; $hash = random_string(); @@ -537,7 +537,7 @@ function notification($params) // Is this the first email notification for this parent item and user? if (!DBA::exists('notify-threads', ['master-parent-item' => $params['parent'], 'receiver-uid' => $params['uid']])) { - Logger::log("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG); + Logger::log("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), Logger::DEBUG); $fields = ['notify-id' => $notify_id, 'master-parent-item' => $params['parent'], 'receiver-uid' => $params['uid'], 'parent-item' => 0]; @@ -546,11 +546,11 @@ function notification($params) $additional_mail_header .= "Message-ID: <${id_for_parent}>\n"; $log_msg = "include/enotify: No previous notification found for this parent:\n". " parent: ${params['parent']}\n"." uid : ${params['uid']}\n"; - Logger::log($log_msg, LOGGER_DEBUG); + Logger::log($log_msg, Logger::DEBUG); } else { // If not, just "follow" the thread. $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n"; - Logger::log("There's already a notification for this parent.", LOGGER_DEBUG); + Logger::log("There's already a notification for this parent.", Logger::DEBUG); } } diff --git a/include/items.php b/include/items.php index 72ae3a8e8..104547ab8 100644 --- a/include/items.php +++ b/include/items.php @@ -110,7 +110,7 @@ function query_page_info($url, $photo = "", $keywords = false, $keyword_blacklis $data["images"][0]["src"] = $photo; } - Logger::log('fetch page info for ' . $url . ' ' . print_r($data, true), LOGGER_DEBUG); + Logger::log('fetch page info for ' . $url . ' ' . print_r($data, true), Logger::DEBUG); if (!$keywords && isset($data["keywords"])) { unset($data["keywords"]); @@ -168,7 +168,7 @@ function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, function add_page_info_to_body($body, $texturl = false, $no_photos = false) { - Logger::log('add_page_info_to_body: fetch page info for body ' . $body, LOGGER_DEBUG); + Logger::log('add_page_info_to_body: fetch page info for body ' . $body, Logger::DEBUG); $URLSearchString = "^\[\]"; @@ -252,7 +252,7 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0 // Test - remove before flight //$tempfile = tempnam(get_temppath(), "ostatus2"); //file_put_contents($tempfile, $xml); - Logger::log("Consume OStatus messages ", LOGGER_DEBUG); + Logger::log("Consume OStatus messages ", Logger::DEBUG); OStatus::import($xml, $importer, $contact, $hub); } @@ -261,7 +261,7 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0 if ($contact['network'] === Protocol::FEED) { if ($pass < 2) { - Logger::log("Consume feeds", LOGGER_DEBUG); + Logger::log("Consume feeds", Logger::DEBUG); Feed::import($xml, $importer, $contact, $hub); } @@ -269,7 +269,7 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0 } if ($contact['network'] === Protocol::DFRN) { - Logger::log("Consume DFRN messages", LOGGER_DEBUG); + Logger::log("Consume DFRN messages", Logger::DEBUG); $dfrn_importer = DFRN::getImporter($contact["id"], $importer["uid"]); if (!empty($dfrn_importer)) { Logger::log("Now import the DFRN feed"); @@ -319,7 +319,7 @@ function subscribe_to_hub($url, array $importer, array $contact, $hubmode = 'sub $postResult = Network::post($url, $params); - Logger::log('subscribe_to_hub: returns: ' . $postResult->getReturnCode(), LOGGER_DEBUG); + Logger::log('subscribe_to_hub: returns: ' . $postResult->getReturnCode(), Logger::DEBUG); return; diff --git a/mod/acl.php b/mod/acl.php index 36cfd42e7..a63cd83ae 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -35,7 +35,7 @@ function acl_content(App $a) $search = $_REQUEST['query']; } - Logger::log("Searching for ".$search." - type ".$type." conversation ".$conv_id, LOGGER_DEBUG); + Logger::log("Searching for ".$search." - type ".$type." conversation ".$conv_id, Logger::DEBUG); if ($search != '') { $sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'"; diff --git a/mod/admin.php b/mod/admin.php index 8d19f01e3..d4cbafe54 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -911,7 +911,7 @@ function admin_page_summary(App $a) $users+= $u['count']; } - Logger::log('accounts: ' . print_r($accounts, true), LOGGER_DATA); + Logger::log('accounts: ' . print_r($accounts, true), Logger::DATA); $pending = Register::getPendingCount(); @@ -2400,12 +2400,12 @@ function admin_page_logs_post(App $a) function admin_page_logs(App $a) { $log_choices = [ - LOGGER_WARNING => 'Warning', - LOGGER_INFO => 'Info', - LOGGER_TRACE => 'Trace', - LOGGER_DEBUG => 'Debug', - LOGGER_DATA => 'Data', - LOGGER_ALL => 'All' + Logger::WARNING => 'Warning', + Logger::INFO => 'Info', + Logger::TRACE => 'Trace', + Logger::DEBUG => 'Debug', + Logger::DATA => 'Data', + Logger::ALL => 'All' ]; if (ini_get('log_errors')) { @@ -2500,7 +2500,7 @@ function admin_page_features_post(App $a) { BaseModule::checkFormSecurityTokenRedirectOnError('/admin/features', 'admin_manage_features'); - Logger::log('postvars: ' . print_r($_POST, true), LOGGER_DATA); + Logger::log('postvars: ' . print_r($_POST, true), Logger::DATA); $features = Feature::get(false); diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 8c897c76d..0403085f8 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -212,7 +212,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) $params['page'] = 2; } - Logger::log('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params, true), LOGGER_DATA); + Logger::log('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params, true), Logger::DATA); /* * @@ -224,7 +224,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) $res = Network::post($dfrn_confirm, $params, null, $redirects, 120)->getBody(); - Logger::log(' Confirm: received data: ' . $res, LOGGER_DATA); + Logger::log(' Confirm: received data: ' . $res, Logger::DATA); // Now figure out what they responded. Try to be robust if the remote site is // having difficulty and throwing up errors of some kind. @@ -430,7 +430,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) Logger::log('dfrn_confirm: requestee contacted: ' . $node); - Logger::log('dfrn_confirm: request: POST=' . print_r($_POST, true), LOGGER_DATA); + Logger::log('dfrn_confirm: request: POST=' . print_r($_POST, true), Logger::DATA); // If $aes_key is set, both of these items require unpacking from the hex transport encoding. diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index a0090f492..b14c71fb8 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -18,7 +18,7 @@ use Friendica\Protocol\Diaspora; require_once 'include/items.php'; function dfrn_notify_post(App $a) { - Logger::log(__function__, LOGGER_TRACE); + Logger::log(__function__, Logger::TRACE); $postdata = file_get_contents('php://input'); @@ -118,7 +118,7 @@ function dfrn_notify_post(App $a) { $importer = Contact::updateSslPolicy($importer, $ssl_policy); - Logger::log('data: ' . $data, LOGGER_DATA); + Logger::log('data: ' . $data, Logger::DATA); if ($dissolve == 1) { // Relationship is dissolved permanently @@ -140,7 +140,7 @@ function dfrn_notify_post(App $a) { } $rawkey = hex2bin(trim($key)); - Logger::log('rino: md5 raw key: ' . md5($rawkey), LOGGER_DATA); + Logger::log('rino: md5 raw key: ' . md5($rawkey), Logger::DATA); $final_key = ''; @@ -170,10 +170,10 @@ function dfrn_notify_post(App $a) { System::xmlExit(0, "Invalid sent version '$rino_remote'"); } - Logger::log('rino: decrypted data: ' . $data, LOGGER_DATA); + Logger::log('rino: decrypted data: ' . $data, Logger::DATA); } - Logger::log('Importing post from ' . $importer['addr'] . ' to ' . $importer['nickname'] . ' with the RINO ' . $rino_remote . ' encryption.', LOGGER_DEBUG); + Logger::log('Importing post from ' . $importer['addr'] . ' to ' . $importer['nickname'] . ' with the RINO ' . $rino_remote . ' encryption.', Logger::DEBUG); $ret = DFRN::import($data, $importer); System::xmlExit($ret, 'Processed'); @@ -204,7 +204,7 @@ function dfrn_dispatch_public($postdata) System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } - Logger::log('Importing post from ' . $msg['author'] . ' with the public envelope.', LOGGER_DEBUG); + Logger::log('Importing post from ' . $msg['author'] . ' with the public envelope.', Logger::DEBUG); // Now we should be able to import it $ret = DFRN::import($msg['message'], $importer); @@ -237,7 +237,7 @@ function dfrn_dispatch_private($user, $postdata) System::xmlExit(3, 'Contact ' . $msg['author'] . ' not found'); } - Logger::log('Importing post from ' . $msg['author'] . ' to ' . $user['nickname'] . ' with the private envelope.', LOGGER_DEBUG); + Logger::log('Importing post from ' . $msg['author'] . ' to ' . $user['nickname'] . ' with the private envelope.', Logger::DEBUG); // Now we should be able to import it $ret = DFRN::import($msg['message'], $importer); @@ -277,7 +277,7 @@ function dfrn_notify_content(App $a) { 'type' => $type, 'last_update' => $last_update]; DBA::insert('challenge', $fields); - Logger::log('challenge=' . $hash, LOGGER_DATA); + Logger::log('challenge=' . $hash, Logger::DATA); $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]); if (!DBA::isResult($user)) { @@ -317,7 +317,7 @@ function dfrn_notify_content(App $a) { killme(); } - Logger::log("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DATA); + Logger::log("Remote rino version: ".$rino_remote." for ".$importer["url"], Logger::DATA); $challenge = ''; $encrypted_id = ''; @@ -345,7 +345,7 @@ function dfrn_notify_content(App $a) { $rino = Config::get('system', 'rino_encrypt'); $rino = intval($rino); - Logger::log("Local rino version: ". $rino, LOGGER_DATA); + Logger::log("Local rino version: ". $rino, Logger::DATA); // if requested rino is lower than enabled local rino, lower local rino version // if requested rino is higher than enabled local rino, reply with local rino diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 814bd555c..a961506d1 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -105,7 +105,7 @@ function dfrn_poll_init(App $a) if (DBA::isResult($r)) { $s = Network::fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check'); - Logger::log("dfrn_poll: old profile returns " . $s, LOGGER_DATA); + Logger::log("dfrn_poll: old profile returns " . $s, Logger::DATA); if (strlen($s)) { $xml = XML::parseString($s); @@ -192,7 +192,7 @@ function dfrn_poll_init(App $a) } if ($final_dfrn_id != $orig_id) { - Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); + Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, Logger::DEBUG); // did not decode properly - cannot trust this site System::xmlExit(3, 'Bad decryption'); } @@ -284,7 +284,7 @@ function dfrn_poll_post(App $a) } if ($final_dfrn_id != $orig_id) { - Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); + Logger::log('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, Logger::DEBUG); // did not decode properly - cannot trust this site System::xmlExit(3, 'Bad decryption'); } @@ -373,7 +373,7 @@ function dfrn_poll_post(App $a) // NOTREACHED } else { // Update the writable flag if it changed - Logger::log('dfrn_poll: post request feed: ' . print_r($_POST, true), LOGGER_DATA); + Logger::log('dfrn_poll: post request feed: ' . print_r($_POST, true), Logger::DATA); if ($dfrn_version >= 2.21) { if ($perm === 'rw') { $writable = 1; @@ -511,12 +511,12 @@ function dfrn_poll_content(App $a) ])->getBody(); } - Logger::log("dfrn_poll: sec profile: " . $s, LOGGER_DATA); + Logger::log("dfrn_poll: sec profile: " . $s, Logger::DATA); if (strlen($s) && strstr($s, 'challenge . ' expecting ' . $hash); Logger::log('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec); diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index d49975a1f..674248be2 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -298,7 +298,7 @@ function dfrn_request_post(App $a) $network = Protocol::DFRN; } - Logger::log('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG); + Logger::log('dfrn_request: url: ' . $url . ',network=' . $network, Logger::DEBUG); if ($network === Protocol::DFRN) { $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", diff --git a/mod/display.php b/mod/display.php index aeab0aae5..d95404a5b 100644 --- a/mod/display.php +++ b/mod/display.php @@ -75,7 +75,7 @@ function display_init(App $a) } if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) { - Logger::log('Directly serving XML for id '.$item["id"], LOGGER_DEBUG); + Logger::log('Directly serving XML for id '.$item["id"], Logger::DEBUG); displayShowFeed($item["id"], false); } diff --git a/mod/events.php b/mod/events.php index 0e582c52d..a13080a8e 100644 --- a/mod/events.php +++ b/mod/events.php @@ -48,7 +48,7 @@ function events_init(App $a) function events_post(App $a) { - Logger::log('post: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('post: ' . print_r($_REQUEST, true), Logger::DATA); if (!local_user()) { return; diff --git a/mod/item.php b/mod/item.php index ce00562a8..6e7e86fe7 100644 --- a/mod/item.php +++ b/mod/item.php @@ -57,7 +57,7 @@ function item_post(App $a) { Addon::callHooks('post_local_start', $_REQUEST); - Logger::log('postvars ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('postvars ' . print_r($_REQUEST, true), Logger::DATA); $api_source = defaults($_REQUEST, 'api_source', false); @@ -73,7 +73,7 @@ function item_post(App $a) { */ if (!$preview && !empty($_REQUEST['post_id_random'])) { if (!empty($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { - Logger::log("item post: duplicate post", LOGGER_DEBUG); + Logger::log("item post: duplicate post", Logger::DEBUG); item_post_return(System::baseUrl(), $api_source, $return_path); } else { $_SESSION['post-random'] = $_REQUEST['post_id_random']; @@ -154,7 +154,7 @@ function item_post(App $a) { // Check for multiple posts with the same message id (when the post was created via API) if (($message_id != '') && ($profile_uid != 0)) { if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) { - Logger::log("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG); + Logger::log("Message with URI ".$message_id." already exists for user ".$profile_uid, Logger::DEBUG); return 0; } } @@ -862,7 +862,7 @@ function item_post_return($baseurl, $api_source, $return_path) $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload']; } - Logger::log('post_json: ' . print_r($json, true), LOGGER_DEBUG); + Logger::log('post_json: ' . print_r($json, true), Logger::DEBUG); echo json_encode($json); killme(); diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index 7b747be21..ca4a622fb 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -204,22 +204,22 @@ function nodeinfo_cron() { Config::set('nodeinfo', 'active_users_halfyear', $active_users_halfyear); Config::set('nodeinfo', 'active_users_monthly', $active_users_monthly); - Logger::log('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, LOGGER_DEBUG); + Logger::log('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, Logger::DEBUG); } $local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]); Config::set('nodeinfo', 'local_posts', $local_posts); - Logger::log('local_posts: ' . $local_posts, LOGGER_DEBUG); + Logger::log('local_posts: ' . $local_posts, Logger::DEBUG); $local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]); Config::set('nodeinfo', 'local_comments', $local_comments); - Logger::log('local_comments: ' . $local_comments, LOGGER_DEBUG); + Logger::log('local_comments: ' . $local_comments, Logger::DEBUG); // Now trying to register $url = 'http://the-federation.info/register/'.$a->getHostName(); - Logger::log('registering url: '.$url, LOGGER_DEBUG); + Logger::log('registering url: '.$url, Logger::DEBUG); $ret = Network::fetchUrl($url); - Logger::log('registering answer: '.$ret, LOGGER_DEBUG); + Logger::log('registering answer: '.$ret, Logger::DEBUG); Logger::log('cron_end'); } diff --git a/mod/openid.php b/mod/openid.php index e97607304..d1404ba80 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -17,7 +17,7 @@ function openid_content(App $a) { if($noid) $a->internalRedirect(); - Logger::log('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA); + Logger::log('mod_openid ' . print_r($_REQUEST,true), Logger::DATA); if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) { diff --git a/mod/photos.php b/mod/photos.php index ad6922c1e..8ddb0010d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -142,9 +142,9 @@ function photos_init(App $a) { function photos_post(App $a) { - Logger::log('mod-photos: photos_post: begin' , LOGGER_DEBUG); - Logger::log('mod_photos: REQUEST ' . print_r($_REQUEST, true), LOGGER_DATA); - Logger::log('mod_photos: FILES ' . print_r($_FILES, true), LOGGER_DATA); + Logger::log('mod-photos: photos_post: begin' , Logger::DEBUG); + Logger::log('mod_photos: REQUEST ' . print_r($_REQUEST, true), Logger::DATA); + Logger::log('mod_photos: FILES ' . print_r($_FILES, true), Logger::DATA); $phototypes = Image::supportedTypes(); @@ -707,7 +707,7 @@ function photos_post(App $a) $album = !empty($_REQUEST['album']) ? notags(trim($_REQUEST['album'])) : ''; $newalbum = !empty($_REQUEST['newalbum']) ? notags(trim($_REQUEST['newalbum'])) : ''; - Logger::log('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , Logger::DEBUG); if (!strlen($album)) { if (strlen($newalbum)) { @@ -800,7 +800,7 @@ function photos_post(App $a) $type = Image::guessType($filename); } - Logger::log('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG); + Logger::log('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', Logger::DEBUG); $maximagesize = Config::get('system', 'maximagesize'); @@ -820,14 +820,14 @@ function photos_post(App $a) return; } - Logger::log('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): loading the contents of ' . $src , Logger::DEBUG); $imagedata = @file_get_contents($src); $image = new Image($imagedata, $type); if (!$image->isValid()) { - Logger::log('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): unable to process image' , Logger::DEBUG); notice(L10n::t('Unable to process image.') . EOL); @unlink($src); $foo = 0; @@ -856,7 +856,7 @@ function photos_post(App $a) $r = Photo::store($image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); if (!$r) { - Logger::log('mod/photos.php: photos_post(): image store failed', LOGGER_DEBUG); + Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG); notice(L10n::t('Image upload failed.') . EOL); killme(); } diff --git a/mod/poco.php b/mod/poco.php index 915029954..7a33a69d0 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -122,7 +122,7 @@ function poco_init(App $a) { $itemsPerPage = ((x($_GET, 'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults); if ($global) { - Logger::log("Start global query", LOGGER_DEBUG); + Logger::log("Start global query", Logger::DEBUG); $contacts = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND NOT `hide` AND `network` IN ('%s', '%s', '%s') AND `updated` > `last_failure` ORDER BY `updated` DESC LIMIT %d, %d", DBA::escape($update_limit), @@ -133,7 +133,7 @@ function poco_init(App $a) { intval($itemsPerPage) ); } elseif ($system_mode) { - Logger::log("Start system mode query", LOGGER_DEBUG); + Logger::log("Start system mode query", Logger::DEBUG); $contacts = q("SELECT `contact`.*, `profile`.`about` AS `pabout`, `profile`.`locality` AS `plocation`, `profile`.`pub_keywords`, `profile`.`gender` AS `pgender`, `profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type` @@ -145,7 +145,7 @@ function poco_init(App $a) { intval($itemsPerPage) ); } else { - Logger::log("Start query for user " . $user['nickname'], LOGGER_DEBUG); + Logger::log("Start query for user " . $user['nickname'], Logger::DEBUG); $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`) AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra LIMIT %d, %d", @@ -158,7 +158,7 @@ function poco_init(App $a) { intval($itemsPerPage) ); } - Logger::log("Query done", LOGGER_DEBUG); + Logger::log("Query done", Logger::DEBUG); $ret = []; if (x($_GET, 'sorted')) { @@ -370,7 +370,7 @@ function poco_init(App $a) { } else { System::httpExit(500); } - Logger::log("End of poco", LOGGER_DEBUG); + Logger::log("End of poco", Logger::DEBUG); if ($format === 'xml') { header('Content-type: text/xml'); diff --git a/mod/poke.php b/mod/poke.php index bf5b7e72d..3eefeb9ab 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -54,7 +54,7 @@ function poke_init(App $a) $parent = (x($_GET,'parent') ? intval($_GET['parent']) : 0); - Logger::log('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG); + Logger::log('poke: verb ' . $verb . ' contact ' . $contact_id, Logger::DEBUG); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", diff --git a/mod/profile.php b/mod/profile.php index e56f7085e..f2df82849 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -38,7 +38,7 @@ function profile_init(App $a) if (DBA::isResult($r)) { $a->internalRedirect('profile/' . $r[0]['nickname']); } else { - Logger::log('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG); + Logger::log('profile error: mod_profile ' . $a->query_string, Logger::DEBUG); notice(L10n::t('Requested profile is not available.') . EOL); $a->error = 404; return; diff --git a/mod/pubsub.php b/mod/pubsub.php index 2b3752358..e14d50086 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -41,7 +41,7 @@ function pubsub_init(App $a) $hub_verify = notags(trim(defaults($_GET, 'hub_verify_token', ''))); Logger::log('Subscription from ' . $_SERVER['REMOTE_ADDR'] . ' Mode: ' . $hub_mode . ' Nick: ' . $nick); - Logger::log('Data: ' . print_r($_GET,true), LOGGER_DATA); + Logger::log('Data: ' . print_r($_GET,true), Logger::DATA); $subscribe = (($hub_mode === 'subscribe') ? 1 : 0); @@ -89,7 +89,7 @@ function pubsub_post(App $a) $xml = file_get_contents('php://input'); Logger::log('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']); - Logger::log('Data: ' . $xml, LOGGER_DATA); + Logger::log('Data: ' . $xml, Logger::DATA); $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); diff --git a/mod/receive.php b/mod/receive.php index af90007e3..690abea15 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -42,7 +42,7 @@ function receive_post(App $a) // It is an application/x-www-form-urlencoded - Logger::log('mod-diaspora: receiving post', LOGGER_DEBUG); + Logger::log('mod-diaspora: receiving post', Logger::DEBUG); if (empty($_POST['xml'])) { $postdata = file_get_contents("php://input"); @@ -50,29 +50,29 @@ function receive_post(App $a) System::httpExit(500); } - Logger::log('mod-diaspora: message is in the new format', LOGGER_DEBUG); + Logger::log('mod-diaspora: message is in the new format', Logger::DEBUG); $msg = Diaspora::decodeRaw($importer, $postdata); } else { $xml = urldecode($_POST['xml']); - Logger::log('mod-diaspora: decode message in the old format', LOGGER_DEBUG); + Logger::log('mod-diaspora: decode message in the old format', Logger::DEBUG); $msg = Diaspora::decode($importer, $xml); if ($public && !$msg) { - Logger::log('mod-diaspora: decode message in the new format', LOGGER_DEBUG); + Logger::log('mod-diaspora: decode message in the new format', Logger::DEBUG); $msg = Diaspora::decodeRaw($importer, $xml); } } - Logger::log('mod-diaspora: decoded', LOGGER_DEBUG); + Logger::log('mod-diaspora: decoded', Logger::DEBUG); - Logger::log('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA); + Logger::log('mod-diaspora: decoded msg: ' . print_r($msg, true), Logger::DATA); if (!is_array($msg)) { System::httpExit(500); } - Logger::log('mod-diaspora: dispatching', LOGGER_DEBUG); + Logger::log('mod-diaspora: dispatching', Logger::DEBUG); $ret = true; if ($public) { diff --git a/mod/redir.php b/mod/redir.php index 6cdbc94dc..088a5f55e 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -52,7 +52,7 @@ function redir_init(App $a) { if (!empty($a->contact['id']) && $a->contact['id'] == $cid) { // Local user is already authenticated. $target_url = defaults($url, $contact_url); - Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG); + Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG); $a->redirect($target_url); } } @@ -73,7 +73,7 @@ function redir_init(App $a) { if ($v['uid'] == $_SESSION['visitor_visiting'] && $v['cid'] == $_SESSION['visitor_id']) { // Remote user is already authenticated. $target_url = defaults($url, $contact_url); - Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG); + Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG); $a->redirect($target_url); } } @@ -99,7 +99,7 @@ function redir_init(App $a) { 'sec' => $sec, 'expire' => time() + 45]; DBA::insert('profile_check', $fields); - Logger::log('mod_redir: ' . $contact['name'] . ' ' . $sec, LOGGER_DEBUG); + Logger::log('mod_redir: ' . $contact['name'] . ' ' . $sec, Logger::DEBUG); $dest = (!empty($url) ? '&destination_url=' . $url : ''); @@ -121,7 +121,7 @@ function redir_init(App $a) { $url .= $separator . 'zrl=' . urlencode($my_profile); } - Logger::log('redirecting to ' . $url, LOGGER_DEBUG); + Logger::log('redirecting to ' . $url, Logger::DEBUG); $a->redirect($url); } diff --git a/mod/salmon.php b/mod/salmon.php index bb44199dc..23e4e8884 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -21,7 +21,7 @@ function salmon_post(App $a, $xml = '') { $xml = file_get_contents('php://input'); } - Logger::log('new salmon ' . $xml, LOGGER_DATA); + Logger::log('new salmon ' . $xml, Logger::DATA); $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $mentions = (($a->argc > 2 && $a->argv[2] === 'mention') ? true : false); @@ -108,7 +108,7 @@ function salmon_post(App $a, $xml = '') { $m = base64url_decode($key_info[1]); $e = base64url_decode($key_info[2]); - Logger::log('key details: ' . print_r($key_info,true), LOGGER_DEBUG); + Logger::log('key details: ' . print_r($key_info,true), Logger::DEBUG); $pubkey = Crypto::meToPem($m, $e); diff --git a/mod/search.php b/mod/search.php index 852043f30..4be378ba9 100644 --- a/mod/search.php +++ b/mod/search.php @@ -205,7 +205,7 @@ function search_content(App $a) { $pager = new Pager($a->query_string); if ($tag) { - Logger::log("Start tag search for '".$search."'", LOGGER_DEBUG); + Logger::log("Start tag search for '".$search."'", Logger::DEBUG); $condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `otype` = ? AND `type` = ? AND `term` = ?", @@ -228,7 +228,7 @@ function search_content(App $a) { $r = []; } } else { - Logger::log("Start fulltext search for '".$search."'", LOGGER_DEBUG); + Logger::log("Start fulltext search for '".$search."'", Logger::DEBUG); $condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`)) AND `body` LIKE CONCAT('%',?,'%')", @@ -255,12 +255,12 @@ function search_content(App $a) { '$title' => $title ]); - Logger::log("Start Conversation for '".$search."'", LOGGER_DEBUG); + Logger::log("Start Conversation for '".$search."'", Logger::DEBUG); $o .= conversation($a, $r, $pager, 'search', false, false, 'commented', local_user()); $o .= $pager->renderMinimal(count($r)); - Logger::log("Done '".$search."'", LOGGER_DEBUG); + Logger::log("Done '".$search."'", Logger::DEBUG); return $o; } diff --git a/mod/statistics_json.php b/mod/statistics_json.php index 173f6db13..d1d957076 100644 --- a/mod/statistics_json.php +++ b/mod/statistics_json.php @@ -57,6 +57,6 @@ function statistics_json_init(App $a) { header("Content-Type: application/json"); echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); - Logger::log("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA); + Logger::log("statistics_init: printed " . print_r($statistics, true), Logger::DATA); killme(); } diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 63c7d8278..84e40d3b5 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -20,7 +20,7 @@ use Friendica\Object\Image; function wall_upload_post(App $a, $desktopmode = true) { - Logger::log("wall upload: starting new upload", LOGGER_DEBUG); + Logger::log("wall upload: starting new upload", Logger::DEBUG); $r_json = (x($_GET, 'response') && $_GET['response'] == 'json'); $album = (x($_GET, 'album') ? notags(trim($_GET['album'])) : ''); @@ -188,7 +188,7 @@ function wall_upload_post(App $a, $desktopmode = true) } Logger::log("File upload src: " . $src . " - filename: " . $filename . - " - size: " . $filesize . " - type: " . $filetype, LOGGER_DEBUG); + " - size: " . $filesize . " - type: " . $filetype, Logger::DEBUG); $maximagesize = Config::get('system', 'maximagesize'); @@ -226,7 +226,7 @@ function wall_upload_post(App $a, $desktopmode = true) } if ($max_length > 0) { $Image->scaleDown($max_length); - Logger::log("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG); + Logger::log("File upload: Scaling picture to new size " . $max_length, Logger::DEBUG); } $width = $Image->getWidth(); @@ -301,11 +301,11 @@ function wall_upload_post(App $a, $desktopmode = true) echo json_encode(['picture' => $picture]); killme(); } - Logger::log("upload done", LOGGER_DEBUG); + Logger::log("upload done", Logger::DEBUG); return $picture; } - Logger::log("upload done", LOGGER_DEBUG); + Logger::log("upload done", Logger::DEBUG); if ($r_json) { echo json_encode(['ok' => true]); diff --git a/src/App.php b/src/App.php index e0513be04..92eb9409c 100644 --- a/src/App.php +++ b/src/App.php @@ -1101,10 +1101,10 @@ class App $processlist = DBA::processlist(); if ($processlist['list'] != '') { - Core\Logger::log('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG); + Core\Logger::log('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], Logger::DEBUG); if ($processlist['amount'] > $max_processes) { - Core\Logger::log('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', LOGGER_DEBUG); + Core\Logger::log('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', Logger::DEBUG); return true; } } @@ -1150,7 +1150,7 @@ class App $reached = ($free < $min_memory); if ($reached) { - Core\Logger::log('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, LOGGER_DEBUG); + Core\Logger::log('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, Logger::DEBUG); } return $reached; @@ -1222,7 +1222,7 @@ class App $resource = proc_open($cmdline . ' &', [], $foo, $this->getBasePath()); } if (!is_resource($resource)) { - Core\Logger::log('We got no resource for command ' . $cmdline, LOGGER_DEBUG); + Core\Logger::log('We got no resource for command ' . $cmdline, Logger::DEBUG); return; } proc_close($resource); @@ -1253,27 +1253,27 @@ class App public static function isDirectoryUsable($directory, $check_writable = true) { if ($directory == '') { - Core\Logger::log('Directory is empty. This shouldn\'t happen.', LOGGER_DEBUG); + Core\Logger::log('Directory is empty. This shouldn\'t happen.', Logger::DEBUG); return false; } if (!file_exists($directory)) { - Core\Logger::log('Path "' . $directory . '" does not exist for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" does not exist for user ' . self::getSystemUser(), Logger::DEBUG); return false; } if (is_file($directory)) { - Core\Logger::log('Path "' . $directory . '" is a file for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" is a file for user ' . self::getSystemUser(), Logger::DEBUG); return false; } if (!is_dir($directory)) { - Core\Logger::log('Path "' . $directory . '" is not a directory for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" is not a directory for user ' . self::getSystemUser(), Logger::DEBUG); return false; } if ($check_writable && !is_writable($directory)) { - Core\Logger::log('Path "' . $directory . '" is not writable for user ' . self::getSystemUser(), LOGGER_DEBUG); + Core\Logger::log('Path "' . $directory . '" is not writable for user ' . self::getSystemUser(), Logger::DEBUG); return false; } @@ -1646,7 +1646,7 @@ class App } else { // Someone came with an invalid parameter, maybe as a DDoS attempt // We simply stop processing here - Core\Logger::log("Invalid ZRL parameter " . $_GET['zrl'], LOGGER_DEBUG); + Core\Logger::log("Invalid ZRL parameter " . $_GET['zrl'], Logger::DEBUG); Core\System::httpExit(403, ['title' => '403 Forbidden']); } } @@ -1789,7 +1789,7 @@ class App $this->internalRedirect($_SERVER['REQUEST_URI']); } - Core\Logger::log('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); + Core\Logger::log('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], Logger::DEBUG); header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . Core\L10n::t('Not Found')); $tpl = get_markup_template("404.tpl"); diff --git a/src/BaseModule.php b/src/BaseModule.php index 2f46883ed..fe09693b3 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -138,7 +138,7 @@ abstract class BaseModule extends BaseObject if (!self::checkFormSecurityToken($typename, $formname)) { $a = get_app(); Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); - Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA); notice(self::getFormSecurityStandardErrorMessage()); $a->internalRedirect($err_redirect); } @@ -149,7 +149,7 @@ abstract class BaseModule extends BaseObject if (!self::checkFormSecurityToken($typename, $formname)) { $a = get_app(); Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename); - Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA); header('HTTP/1.1 403 Forbidden'); killme(); } diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 9426677c2..22ce4ea3a 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -415,7 +415,7 @@ class BBCode extends BaseObject $Image->scaleDown(640); $new_width = $Image->getWidth(); $new_height = $Image->getHeight(); - Logger::log('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG); + Logger::log('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], Logger::DEBUG); $s = str_replace( $mtch[0], '[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]' @@ -424,7 +424,7 @@ class BBCode extends BaseObject : ''), $s ); - Logger::log('scale_external_images: new string: ' . $s, LOGGER_DEBUG); + Logger::log('scale_external_images: new string: ' . $s, Logger::DEBUG); } } } @@ -452,7 +452,7 @@ class BBCode extends BaseObject // than the maximum, then don't waste time looking for the images if ($maxlen && (strlen($body) > $maxlen)) { - Logger::log('the total body length exceeds the limit', LOGGER_DEBUG); + Logger::log('the total body length exceeds the limit', Logger::DEBUG); $orig_body = $body; $new_body = ''; @@ -472,7 +472,7 @@ class BBCode extends BaseObject if (($textlen + $img_start) > $maxlen) { if ($textlen < $maxlen) { - Logger::log('the limit happens before an embedded image', LOGGER_DEBUG); + Logger::log('the limit happens before an embedded image', Logger::DEBUG); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); $textlen = $maxlen; } @@ -486,7 +486,7 @@ class BBCode extends BaseObject if (($textlen + $img_end) > $maxlen) { if ($textlen < $maxlen) { - Logger::log('the limit happens before the end of a non-embedded image', LOGGER_DEBUG); + Logger::log('the limit happens before the end of a non-embedded image', Logger::DEBUG); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); $textlen = $maxlen; } @@ -509,11 +509,11 @@ class BBCode extends BaseObject if (($textlen + strlen($orig_body)) > $maxlen) { if ($textlen < $maxlen) { - Logger::log('the limit happens after the end of the last image', LOGGER_DEBUG); + Logger::log('the limit happens after the end of the last image', Logger::DEBUG); $new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen); } } else { - Logger::log('the text size with embedded images extracted did not violate the limit', LOGGER_DEBUG); + Logger::log('the text size with embedded images extracted did not violate the limit', Logger::DEBUG); $new_body = $new_body . $orig_body; } diff --git a/src/Core/Authentication.php b/src/Core/Authentication.php index 83effcb01..4d227c271 100644 --- a/src/Core/Authentication.php +++ b/src/Core/Authentication.php @@ -154,10 +154,10 @@ class Authentication extends BaseObject } if ($login_initial) { - Logger::log('auth_identities: ' . print_r($a->identities, true), LOGGER_DEBUG); + Logger::log('auth_identities: ' . print_r($a->identities, true), Logger::DEBUG); } if ($login_refresh) { - Logger::log('auth_identities refresh: ' . print_r($a->identities, true), LOGGER_DEBUG); + Logger::log('auth_identities refresh: ' . print_r($a->identities, true), Logger::DEBUG); } $contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]); diff --git a/src/Core/Cache/MemcachedCacheDriver.php b/src/Core/Cache/MemcachedCacheDriver.php index 5f2556deb..6453c307c 100644 --- a/src/Core/Cache/MemcachedCacheDriver.php +++ b/src/Core/Cache/MemcachedCacheDriver.php @@ -65,7 +65,7 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr if ($this->memcached->getResultCode() == Memcached::RES_SUCCESS) { return $this->filterArrayKeysByPrefix($keys, $prefix); } else { - Logger::log('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL); + Logger::log('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), Logger::ALL); return []; } } @@ -84,7 +84,7 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr if ($this->memcached->getResultCode() === Memcached::RES_SUCCESS) { $return = $value; } else { - Logger::log('Memcached \'get\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL); + Logger::log('Memcached \'get\' failed with ' . $this->memcached->getResultMessage(), Logger::ALL); } return $return; diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index d75dd18d9..19aae2b82 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -359,7 +359,7 @@ class NotificationsManager extends BaseObject break; } /// @todo Check if this part here is used at all - Logger::log('Complete data: ' . json_encode($it) . ' - ' . System::callstack(20), LOGGER_DEBUG); + Logger::log('Complete data: ' . json_encode($it) . ' - ' . System::callstack(20), Logger::DEBUG); $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = XML::parseString($xmlhead . $it['object']); diff --git a/src/Core/Session/CacheSessionHandler.php b/src/Core/Session/CacheSessionHandler.php index a819702b3..1baf111e9 100644 --- a/src/Core/Session/CacheSessionHandler.php +++ b/src/Core/Session/CacheSessionHandler.php @@ -34,7 +34,7 @@ class CacheSessionHandler extends BaseObject implements SessionHandlerInterface Session::$exists = true; return $data; } - Logger::log("no data for session $session_id", LOGGER_TRACE); + Logger::log("no data for session $session_id", Logger::TRACE); return ''; } diff --git a/src/Core/Session/DatabaseSessionHandler.php b/src/Core/Session/DatabaseSessionHandler.php index ba01dddd9..91788588f 100644 --- a/src/Core/Session/DatabaseSessionHandler.php +++ b/src/Core/Session/DatabaseSessionHandler.php @@ -35,7 +35,7 @@ class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterfa Session::$exists = true; return $session['data']; } - Logger::log("no data for session $session_id", LOGGER_TRACE); + Logger::log("no data for session $session_id", Logger::TRACE); return ''; } diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index fa9f05e2d..7ccb6f80c 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -38,7 +38,7 @@ class UserImport private static function checkCols($table, &$arr) { $query = sprintf("SHOW COLUMNS IN `%s`", DBA::escape($table)); - Logger::log("uimport: $query", LOGGER_DEBUG); + Logger::log("uimport: $query", Logger::DEBUG); $r = q($query); $tcols = []; // get a plain array of column names @@ -69,7 +69,7 @@ class UserImport $cols = implode("`,`", array_map(['Friendica\Database\DBA', 'escape'], array_keys($arr))); $vals = implode("','", array_map(['Friendica\Database\DBA', 'escape'], array_values($arr))); $query = "INSERT INTO `$table` (`$cols`) VALUES ('$vals')"; - Logger::log("uimport: $query", LOGGER_TRACE); + Logger::log("uimport: $query", Logger::TRACE); if (self::IMPORT_DEBUG) { return true; @@ -144,7 +144,7 @@ class UserImport // import user $r = self::dbImportAssoc('user', $account['user']); if ($r === false) { - Logger::log("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert user : ERROR : " . DBA::errorMessage(), Logger::INFO); notice(L10n::t("User creation error")); return; } @@ -162,7 +162,7 @@ class UserImport $profile['uid'] = $newuid; $r = self::dbImportAssoc('profile', $profile); if ($r === false) { - Logger::log("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); info(L10n::t("User profile creation error")); DBA::delete('user', ['uid' => $newuid]); return; @@ -200,7 +200,7 @@ class UserImport $contact['uid'] = $newuid; $r = self::dbImportAssoc('contact', $contact); if ($r === false) { - Logger::log("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); $errorcount++; } else { $contact['newid'] = self::lastInsertId(); @@ -214,7 +214,7 @@ class UserImport $group['uid'] = $newuid; $r = self::dbImportAssoc('group', $group); if ($r === false) { - Logger::log("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); } else { $group['newid'] = self::lastInsertId(); } @@ -239,7 +239,7 @@ class UserImport if ($import == 2) { $r = self::dbImportAssoc('group_member', $group_member); if ($r === false) { - Logger::log("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); } } } @@ -257,7 +257,7 @@ class UserImport ); if ($r === false) { - Logger::log("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); } } @@ -265,7 +265,7 @@ class UserImport $pconfig['uid'] = $newuid; $r = self::dbImportAssoc('pconfig', $pconfig); if ($r === false) { - Logger::log("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_INFO); + Logger::log("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO); } } diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 77e38532c..c053e32bc 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -43,7 +43,7 @@ class Worker // At first check the maximum load. We shouldn't continue with a high load if ($a->isMaxLoadReached()) { - Logger::log('Pre check: maximum load reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: maximum load reached, quitting.', Logger::DEBUG); return; } @@ -59,25 +59,25 @@ class Worker // Count active workers and compare them with a maximum value that depends on the load if (self::tooMuchWorkers()) { - Logger::log('Pre check: Active worker limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: Active worker limit reached, quitting.', Logger::DEBUG); return; } // Do we have too few memory? if ($a->isMinMemoryReached()) { - Logger::log('Pre check: Memory limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: Memory limit reached, quitting.', Logger::DEBUG); return; } // Possibly there are too much database connections if (self::maxConnectionsReached()) { - Logger::log('Pre check: maximum connections reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: maximum connections reached, quitting.', Logger::DEBUG); return; } // Possibly there are too much database processes that block the system if ($a->isMaxProcessesReached()) { - Logger::log('Pre check: maximum processes reached, quitting.', LOGGER_DEBUG); + Logger::log('Pre check: maximum processes reached, quitting.', Logger::DEBUG); return; } @@ -100,7 +100,7 @@ class Worker // The work will be done if (!self::execute($entry)) { - Logger::log('Process execution failed, quitting.', LOGGER_DEBUG); + Logger::log('Process execution failed, quitting.', Logger::DEBUG); return; } @@ -118,14 +118,14 @@ class Worker $stamp = (float)microtime(true); // Count active workers and compare them with a maximum value that depends on the load if (self::tooMuchWorkers()) { - Logger::log('Active worker limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Active worker limit reached, quitting.', Logger::DEBUG); Lock::release('worker'); return; } // Check free memory if ($a->isMinMemoryReached()) { - Logger::log('Memory limit reached, quitting.', LOGGER_DEBUG); + Logger::log('Memory limit reached, quitting.', Logger::DEBUG); Lock::release('worker'); return; } @@ -135,7 +135,7 @@ class Worker // Quit the worker once every 5 minutes if (time() > ($starttime + 300)) { - Logger::log('Process lifetime reached, quitting.', LOGGER_DEBUG); + Logger::log('Process lifetime reached, quitting.', Logger::DEBUG); return; } } @@ -144,7 +144,7 @@ class Worker if (Config::get('system', 'worker_daemon_mode', false)) { self::IPCSetJobState(false); } - Logger::log("Couldn't select a workerqueue entry, quitting process " . getmypid() . ".", LOGGER_DEBUG); + Logger::log("Couldn't select a workerqueue entry, quitting process " . getmypid() . ".", Logger::DEBUG); } /** @@ -214,19 +214,19 @@ class Worker // Quit when in maintenance if (Config::get('system', 'maintenance', false, true)) { - Logger::log("Maintenance mode - quit process ".$mypid, LOGGER_DEBUG); + Logger::log("Maintenance mode - quit process ".$mypid, Logger::DEBUG); return false; } // Constantly check the number of parallel database processes if ($a->isMaxProcessesReached()) { - Logger::log("Max processes reached for process ".$mypid, LOGGER_DEBUG); + Logger::log("Max processes reached for process ".$mypid, Logger::DEBUG); return false; } // Constantly check the number of available database connections to let the frontend be accessible at any time if (self::maxConnectionsReached()) { - Logger::log("Max connection reached for process ".$mypid, LOGGER_DEBUG); + Logger::log("Max connection reached for process ".$mypid, Logger::DEBUG); return false; } @@ -384,19 +384,19 @@ class Worker ' - Lock: '.number_format(self::$lock_duration, 2). ' - Rest: '.number_format($up_duration - self::$db_duration - self::$lock_duration, 2). ' - Execution: '.number_format($duration, 2), - LOGGER_DEBUG + Logger::DEBUG ); self::$lock_duration = 0; if ($duration > 3600) { - Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 1 hour (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 1 hour (".round($duration/60, 3).")", Logger::DEBUG); } elseif ($duration > 600) { - Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 10 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 10 minutes (".round($duration/60, 3).")", Logger::DEBUG); } elseif ($duration > 300) { - Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 5 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 5 minutes (".round($duration/60, 3).")", Logger::DEBUG); } elseif ($duration > 120) { - Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 2 minutes (".round($duration/60, 3).")", LOGGER_DEBUG); + Logger::log("Prio ".$queue["priority"].": ".$queue["parameter"]." - longer than 2 minutes (".round($duration/60, 3).")", Logger::DEBUG); } Logger::log("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - done in ".$duration." seconds. Process PID: ".$new_process_id); @@ -468,7 +468,7 @@ class Worker + $a->performance["network"] + $a->performance["file"]), 2), number_format($duration, 2) ), - LOGGER_DEBUG + Logger::DEBUG ); } @@ -519,7 +519,7 @@ class Worker $used = DBA::numRows($r); DBA::close($r); - Logger::log("Connection usage (user values): ".$used."/".$max, LOGGER_DEBUG); + Logger::log("Connection usage (user values): ".$used."/".$max, Logger::DEBUG); $level = ($used / $max) * 100; @@ -547,7 +547,7 @@ class Worker if ($used == 0) { return false; } - Logger::log("Connection usage (system values): ".$used."/".$max, LOGGER_DEBUG); + Logger::log("Connection usage (system values): ".$used."/".$max, Logger::DEBUG); $level = $used / $max * 100; @@ -615,7 +615,7 @@ class Worker ['id' => $entry["id"]] ); } else { - Logger::log("Worker process ".$entry["pid"]." (".substr(json_encode($argv), 0, 50).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG); + Logger::log("Worker process ".$entry["pid"]." (".substr(json_encode($argv), 0, 50).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", Logger::DEBUG); } } } @@ -698,16 +698,16 @@ class Worker $high_running = self::processWithPriorityActive($top_priority); if (!$high_running && ($top_priority > PRIORITY_UNDEFINED) && ($top_priority < PRIORITY_NEGLIGIBLE)) { - Logger::log("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG); + Logger::log("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", Logger::DEBUG); $queues = $active + 1; } } - Logger::log("Load: " . $load ."/" . $maxsysload . " - processes: " . $deferred . "/" . $active . "/" . $entries . $processlist . " - maximum: " . $queues . "/" . $maxqueues, LOGGER_DEBUG); + Logger::log("Load: " . $load ."/" . $maxsysload . " - processes: " . $deferred . "/" . $active . "/" . $entries . $processlist . " - maximum: " . $queues . "/" . $maxqueues, Logger::DEBUG); // Are there fewer workers running as possible? Then fork a new one. if (!Config::get("system", "worker_dont_fork", false) && ($queues > ($active + 1)) && ($entries > 1)) { - Logger::log("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG); + Logger::log("Active workers: ".$active."/".$queues." Fork a new worker.", Logger::DEBUG); if (Config::get('system', 'worker_daemon_mode', false)) { self::IPCSetJobState(true); } else { @@ -780,11 +780,11 @@ class Worker ++$high; } } - Logger::log("Highest priority: ".$highest_priority." Total processes: ".count($priorities)." Count high priority processes: ".$high, LOGGER_DEBUG); + Logger::log("Highest priority: ".$highest_priority." Total processes: ".count($priorities)." Count high priority processes: ".$high, Logger::DEBUG); $passing_slow = (($high/count($priorities)) > (2/3)); if ($passing_slow) { - Logger::log("Passing slower processes than priority ".$highest_priority, LOGGER_DEBUG); + Logger::log("Passing slower processes than priority ".$highest_priority, Logger::DEBUG); } return $passing_slow; } @@ -817,7 +817,7 @@ class Worker $slope = $queue_length / pow($lower_job_limit, $exponent); $limit = min($queue_length, ceil($slope * pow($jobs, $exponent))); - Logger::log('Deferred: ' . $deferred . ' - Total: ' . $jobs . ' - Maximum: ' . $queue_length . ' - jobs per queue: ' . $limit, LOGGER_DEBUG); + Logger::log('Deferred: ' . $deferred . ' - Total: ' . $jobs . ' - Maximum: ' . $queue_length . ' - jobs per queue: ' . $limit, Logger::DEBUG); $ids = []; if (self::passingSlow($highest_priority)) { // Are there waiting processes with a higher priority than the currently highest? @@ -976,7 +976,7 @@ class Worker self::runCron(); - Logger::log('Call worker', LOGGER_DEBUG); + Logger::log('Call worker', Logger::DEBUG); self::spawnWorker(); return; } @@ -1015,7 +1015,7 @@ class Worker */ private static function runCron() { - Logger::log('Add cron entries', LOGGER_DEBUG); + Logger::log('Add cron entries', Logger::DEBUG); // Check for spooled items self::add(PRIORITY_HIGH, "SpoolPost"); @@ -1153,7 +1153,7 @@ class Worker $id = $queue['id']; if ($retrial > 14) { - Logger::log('Id ' . $id . ' had been tried 14 times. We stop now.', LOGGER_DEBUG); + Logger::log('Id ' . $id . ' had been tried 14 times. We stop now.', Logger::DEBUG); return; } @@ -1161,7 +1161,7 @@ class Worker $delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1)); $next = DateTimeFormat::utc('now + ' . $delay . ' seconds'); - Logger::log('Defer execution ' . $retrial . ' of id ' . $id . ' to ' . $next, LOGGER_DEBUG); + Logger::log('Defer execution ' . $retrial . ' of id ' . $id . ' to ' . $next, Logger::DEBUG); $fields = ['retrial' => $retrial + 1, 'next_try' => $next, 'executed' => DBA::NULL_DATETIME, 'pid' => 0]; DBA::update('workerqueue', $fields, ['id' => $id]); diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 618415142..bf3004ead 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -413,7 +413,7 @@ class DBA if ((substr_count($sql, '?') != count($args)) && (count($args) > 0)) { // Question: Should we continue or stop the query here? - Logger::log('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true), LOGGER_DEBUG); + Logger::log('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true), Logger::DEBUG); } $sql = self::cleanQuery($sql); @@ -1143,7 +1143,7 @@ class DBA if ((count($command['conditions']) > 1) || is_int($first_key)) { $sql = "DELETE FROM `" . $command['table'] . "`" . $condition_string; - Logger::log(self::replaceParameters($sql, $conditions), LOGGER_DATA); + Logger::log(self::replaceParameters($sql, $conditions), Logger::DATA); if (!self::e($sql, $conditions)) { if ($do_transaction) { @@ -1173,7 +1173,7 @@ class DBA $sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" . substr(str_repeat("?, ", count($field_values)), 0, -2) . ");"; - Logger::log(self::replaceParameters($sql, $field_values), LOGGER_DATA); + Logger::log(self::replaceParameters($sql, $field_values), Logger::DATA); if (!self::e($sql, $field_values)) { if ($do_transaction) { diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 1297979ea..9a14114de 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -70,7 +70,7 @@ class DBStructure // No valid result? if (!DBA::isResult($adminlist)) { - Logger::log(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_INFO); + Logger::log(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), Logger::INFO); // Don't continue return; @@ -222,7 +222,7 @@ class DBStructure $errors = ''; - Logger::log('updating structure', LOGGER_DEBUG); + Logger::log('updating structure', Logger::DEBUG); // Get the current structure $database = []; @@ -235,7 +235,7 @@ class DBStructure foreach ($tables AS $table) { $table = current($table); - Logger::log(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG); + Logger::log(sprintf('updating structure for table %s ...', $table), Logger::DEBUG); $database[$table] = self::tableStructure($table); } } diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 00e95fa2f..94c02013e 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -53,7 +53,7 @@ class PostUpdate return true; } - Logger::log("Start", LOGGER_DEBUG); + Logger::log("Start", Logger::DEBUG); $end_id = Config::get("system", "post_update_1194_end"); if (!$end_id) { @@ -64,7 +64,7 @@ class PostUpdate } } - Logger::log("End ID: ".$end_id, LOGGER_DEBUG); + Logger::log("End ID: ".$end_id, Logger::DEBUG); $start_id = Config::get("system", "post_update_1194_start"); @@ -83,14 +83,14 @@ class PostUpdate DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA), DBA::escape(Protocol::OSTATUS)); if (!$r) { Config::set("system", "post_update_version", 1194); - Logger::log("Update is done", LOGGER_DEBUG); + Logger::log("Update is done", Logger::DEBUG); return true; } else { Config::set("system", "post_update_1194_start", $r[0]["id"]); $start_id = Config::get("system", "post_update_1194_start"); } - Logger::log("Start ID: ".$start_id, LOGGER_DEBUG); + Logger::log("Start ID: ".$start_id, Logger::DEBUG); $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1", intval($start_id), intval($end_id), @@ -100,13 +100,13 @@ class PostUpdate } else { $pos_id = $end_id; } - Logger::log("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG); + Logger::log("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, Logger::DEBUG); q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3, intval($start_id), intval($pos_id), DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA), DBA::escape(Protocol::OSTATUS)); - Logger::log("Done", LOGGER_DEBUG); + Logger::log("Done", Logger::DEBUG); } /** @@ -123,7 +123,7 @@ class PostUpdate return true; } - Logger::log("Start", LOGGER_DEBUG); + Logger::log("Start", Logger::DEBUG); $r = q("SELECT `contact`.`id`, `contact`.`last-item`, (SELECT MAX(`changed`) FROM `item` USE INDEX (`uid_wall_changed`) WHERE `wall` AND `uid` = `user`.`uid`) AS `lastitem_date` FROM `user` @@ -139,7 +139,7 @@ class PostUpdate } Config::set("system", "post_update_version", 1206); - Logger::log("Done", LOGGER_DEBUG); + Logger::log("Done", Logger::DEBUG); return true; } @@ -157,7 +157,7 @@ class PostUpdate $id = Config::get("system", "post_update_version_1279_id", 0); - Logger::log("Start from item " . $id, LOGGER_DEBUG); + Logger::log("Start from item " . $id, Logger::DEBUG); $fields = array_merge(Item::MIXED_CONTENT_FIELDLIST, ['network', 'author-id', 'owner-id', 'tag', 'file', 'author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link', 'id', @@ -226,7 +226,7 @@ class PostUpdate Config::set("system", "post_update_version_1279_id", $id); - Logger::log("Processed rows: " . $rows . " - last processed item: " . $id, LOGGER_DEBUG); + Logger::log("Processed rows: " . $rows . " - last processed item: " . $id, Logger::DEBUG); if ($start_id == $id) { // Set all deprecated fields to "null" if they contain an empty string @@ -238,13 +238,13 @@ class PostUpdate foreach ($nullfields as $field) { $fields = [$field => null]; $condition = [$field => '']; - Logger::log("Setting '" . $field . "' to null if empty.", LOGGER_DEBUG); + Logger::log("Setting '" . $field . "' to null if empty.", Logger::DEBUG); // Important: This has to be a "DBA::update", not a "Item::update" DBA::update('item', $fields, $condition); } Config::set("system", "post_update_version", 1279); - Logger::log("Done", LOGGER_DEBUG); + Logger::log("Done", Logger::DEBUG); return true; } @@ -307,7 +307,7 @@ class PostUpdate $id = Config::get("system", "post_update_version_1281_id", 0); - Logger::log("Start from item " . $id, LOGGER_DEBUG); + Logger::log("Start from item " . $id, Logger::DEBUG); $fields = ['id', 'guid', 'uri', 'uri-id', 'parent-uri', 'parent-uri-id', 'thr-parent', 'thr-parent-id']; @@ -359,17 +359,17 @@ class PostUpdate Config::set("system", "post_update_version_1281_id", $id); - Logger::log("Processed rows: " . $rows . " - last processed item: " . $id, LOGGER_DEBUG); + Logger::log("Processed rows: " . $rows . " - last processed item: " . $id, Logger::DEBUG); if ($start_id == $id) { - Logger::log("Updating item-uri in item-activity", LOGGER_DEBUG); + Logger::log("Updating item-uri in item-activity", Logger::DEBUG); DBA::e("UPDATE `item-activity` INNER JOIN `item-uri` ON `item-uri`.`uri` = `item-activity`.`uri` SET `item-activity`.`uri-id` = `item-uri`.`id` WHERE `item-activity`.`uri-id` IS NULL"); - Logger::log("Updating item-uri in item-content", LOGGER_DEBUG); + Logger::log("Updating item-uri in item-content", Logger::DEBUG); DBA::e("UPDATE `item-content` INNER JOIN `item-uri` ON `item-uri`.`uri` = `item-content`.`uri` SET `item-content`.`uri-id` = `item-uri`.`id` WHERE `item-content`.`uri-id` IS NULL"); Config::set("system", "post_update_version", 1281); - Logger::log("Done", LOGGER_DEBUG); + Logger::log("Done", Logger::DEBUG); return true; } diff --git a/src/Model/APContact.php b/src/Model/APContact.php index e5dd27e0e..c7cf54b72 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -193,7 +193,7 @@ class APContact extends BaseObject // Update the gcontact table DBA::update('gcontact', $contact_fields, ['nurl' => normalise_link($url)]); - Logger::log('Updated profile for ' . $url, LOGGER_DEBUG); + Logger::log('Updated profile for ' . $url, Logger::DEBUG); return $apcontact; } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 155b304ab..5d571e30e 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -587,7 +587,7 @@ class Contact extends BaseObject return; } } elseif (!isset($contact['url'])) { - Logger::log('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), LOGGER_DEBUG); + Logger::log('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), Logger::DEBUG); } // Contact already archived or "self" contact? => nothing to do @@ -1028,7 +1028,7 @@ class Contact extends BaseObject */ public static function getIdForURL($url, $uid = 0, $no_update = false, $default = [], $in_loop = false) { - Logger::log("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), LOGGER_DEBUG); + Logger::log("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), Logger::DEBUG); $contact_id = 0; diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index 3332d93e0..159cd2f20 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -84,12 +84,12 @@ class Conversation } if (!DBA::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) { Logger::log('Conversation: update for ' . $conversation['item-uri'] . ' from ' . $old_conv['protocol'] . ' to ' . $conversation['protocol'] . ' failed', - LOGGER_DEBUG); + Logger::DEBUG); } } else { if (!DBA::insert('conversation', $conversation, true)) { Logger::log('Conversation: insert for ' . $conversation['item-uri'] . ' (protocol ' . $conversation['protocol'] . ') failed', - LOGGER_DEBUG); + Logger::DEBUG); } } } diff --git a/src/Model/Event.php b/src/Model/Event.php index 3ec6fb1a8..e6ed20f72 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -225,7 +225,7 @@ class Event extends BaseObject } DBA::delete('event', ['id' => $event_id]); - Logger::log("Deleted event ".$event_id, LOGGER_DEBUG); + Logger::log("Deleted event ".$event_id, Logger::DEBUG); } /** diff --git a/src/Model/GContact.php b/src/Model/GContact.php index a220a5921..398fc7758 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -589,7 +589,7 @@ class GContact } if ($new_url != $url) { - Logger::log("Cleaned contact url ".$url." to ".$new_url." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Cleaned contact url ".$url." to ".$new_url." - Called by: ".System::callstack(), Logger::DEBUG); } return $new_url; @@ -606,7 +606,7 @@ class GContact if (($contact["network"] == Protocol::OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) { $data = Probe::uri($contact["url"]); if ($contact["network"] == Protocol::OSTATUS) { - Logger::log("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), Logger::DEBUG); $contact["url"] = $data["url"]; $contact["addr"] = $data["addr"]; $contact["alias"] = $data["alias"]; @@ -630,12 +630,12 @@ class GContact $last_contact_str = ''; if (empty($contact["network"])) { - Logger::log("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), Logger::DEBUG); return false; } if (in_array($contact["network"], [Protocol::PHANTOM])) { - Logger::log("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), Logger::DEBUG); return false; } @@ -703,7 +703,7 @@ class GContact DBA::unlock(); if ($doprobing) { - Logger::log("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG); + Logger::log("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], Logger::DEBUG); Worker::add(PRIORITY_LOW, 'GProbe', $contact["url"]); } @@ -808,19 +808,19 @@ class GContact if ((($contact["generation"] > 0) && ($contact["generation"] <= $public_contact[0]["generation"])) || ($public_contact[0]["generation"] == 0)) { foreach ($fields as $field => $data) { if ($contact[$field] != $public_contact[0][$field]) { - Logger::log("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$public_contact[0][$field]."'", LOGGER_DEBUG); + Logger::log("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$public_contact[0][$field]."'", Logger::DEBUG); $update = true; } } if ($contact["generation"] < $public_contact[0]["generation"]) { - Logger::log("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$public_contact[0]["generation"]."'", LOGGER_DEBUG); + Logger::log("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$public_contact[0]["generation"]."'", Logger::DEBUG); $update = true; } } if ($update) { - Logger::log("Update gcontact for ".$contact["url"], LOGGER_DEBUG); + Logger::log("Update gcontact for ".$contact["url"], Logger::DEBUG); $condition = ['`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)', normalise_link($contact["url"]), $contact["generation"]]; $contact["updated"] = DateTimeFormat::utc($contact["updated"]); @@ -844,7 +844,7 @@ class GContact // The quality of the gcontact table is mostly lower than the public contact $public_contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]); if (DBA::isResult($public_contact)) { - Logger::log("Update public contact ".$public_contact["id"], LOGGER_DEBUG); + Logger::log("Update public contact ".$public_contact["id"], Logger::DEBUG); Contact::updateAvatar($contact["photo"], 0, $public_contact["id"]); @@ -886,7 +886,7 @@ class GContact $data = Probe::uri($url); if (in_array($data["network"], [Protocol::PHANTOM])) { - Logger::log("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); + Logger::log("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), Logger::DEBUG); return; } @@ -917,7 +917,7 @@ class GContact ); if (!DBA::isResult($r)) { - Logger::log('Cannot find user with uid=' . $uid, LOGGER_INFO); + Logger::log('Cannot find user with uid=' . $uid, Logger::INFO); return false; } @@ -954,7 +954,7 @@ class GContact */ public static function fetchGsUsers($server) { - Logger::log("Fetching users from GNU Social server ".$server, LOGGER_DEBUG); + Logger::log("Fetching users from GNU Social server ".$server, Logger::DEBUG); $url = $server."/main/statistics"; diff --git a/src/Model/Item.php b/src/Model/Item.php index 7f70dc9bc..4e854e45c 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -984,12 +984,12 @@ class Item extends BaseObject 'icid', 'iaid', 'psid']; $item = self::selectFirst($fields, ['id' => $item_id]); if (!DBA::isResult($item)) { - Logger::log('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG); + Logger::log('Item with ID ' . $item_id . " hasn't been found.", Logger::DEBUG); return false; } if ($item['deleted']) { - Logger::log('Item with ID ' . $item_id . ' has already been deleted.', LOGGER_DEBUG); + Logger::log('Item with ID ' . $item_id . ' has already been deleted.', Logger::DEBUG); return false; } @@ -1090,7 +1090,7 @@ class Item extends BaseObject } } - Logger::log('Item with ID ' . $item_id . " has been deleted.", LOGGER_DEBUG); + Logger::log('Item with ID ' . $item_id . " has been deleted.", Logger::DEBUG); return true; } @@ -1193,7 +1193,7 @@ class Item extends BaseObject if (!empty($contact_id)) { return $contact_id; } - Logger::log('Missing contact-id. Called by: '.System::callstack(), LOGGER_DEBUG); + Logger::log('Missing contact-id. Called by: '.System::callstack(), Logger::DEBUG); /* * First we are looking for a suitable contact that matches with the author of the post * This is done only for comments @@ -1214,7 +1214,7 @@ class Item extends BaseObject $contact_id = $self["id"]; } } - Logger::log("Contact-id was missing for post ".$item['guid']." from user id ".$item['uid']." - now set to ".$contact_id, LOGGER_DEBUG); + Logger::log("Contact-id was missing for post ".$item['guid']." from user id ".$item['uid']." - now set to ".$contact_id, Logger::DEBUG); return $contact_id; } @@ -1299,7 +1299,7 @@ class Item extends BaseObject $item['gravity'] = GRAVITY_COMMENT; } else { $item['gravity'] = GRAVITY_UNKNOWN; // Should not happen - Logger::log('Unknown gravity for verb: ' . $item['verb'], LOGGER_DEBUG); + Logger::log('Unknown gravity for verb: ' . $item['verb'], Logger::DEBUG); } $uid = intval($item['uid']); @@ -1316,7 +1316,7 @@ class Item extends BaseObject $expire_date = time() - ($expire_interval * 86400); $created_date = strtotime($item['created']); if ($created_date < $expire_date) { - Logger::log('item-store: item created ('.date('c', $created_date).') before expiration time ('.date('c', $expire_date).'). ignored. ' . print_r($item,true), LOGGER_DEBUG); + Logger::log('item-store: item created ('.date('c', $created_date).') before expiration time ('.date('c', $expire_date).'). ignored. ' . print_r($item,true), Logger::DEBUG); return 0; } } @@ -1427,17 +1427,17 @@ class Item extends BaseObject } if ($item['network'] == Protocol::PHANTOM) { - Logger::log('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG); + Logger::log('Missing network. Called by: '.System::callstack(), Logger::DEBUG); $item['network'] = Protocol::DFRN; - Logger::log("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG); + Logger::log("Set network to " . $item["network"] . " for " . $item["uri"], Logger::DEBUG); } // Checking if there is already an item with the same guid - Logger::log('Checking for an item for user '.$item['uid'].' on network '.$item['network'].' with the guid '.$item['guid'], LOGGER_DEBUG); + Logger::log('Checking for an item for user '.$item['uid'].' on network '.$item['network'].' with the guid '.$item['guid'], Logger::DEBUG); $condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']]; if (self::exists($condition)) { - Logger::log('found item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network'], LOGGER_DEBUG); + Logger::log('found item with guid '.$item['guid'].' for user '.$item['uid'].' on network '.$item['network'], Logger::DEBUG); return 0; } @@ -1518,15 +1518,15 @@ class Item extends BaseObject } // If its a post from myself then tag the thread as "mention" - Logger::log("Checking if parent ".$parent_id." has to be tagged as mention for user ".$item['uid'], LOGGER_DEBUG); + Logger::log("Checking if parent ".$parent_id." has to be tagged as mention for user ".$item['uid'], Logger::DEBUG); $user = DBA::selectFirst('user', ['nickname'], ['uid' => $item['uid']]); if (DBA::isResult($user)) { $self = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']); $self_id = Contact::getIdForURL($self, 0, true); - Logger::log("'myself' is ".$self_id." for parent ".$parent_id." checking against ".$item['author-id']." and ".$item['owner-id'], LOGGER_DEBUG); + Logger::log("'myself' is ".$self_id." for parent ".$parent_id." checking against ".$item['author-id']." and ".$item['owner-id'], Logger::DEBUG); if (($item['author-id'] == $self_id) || ($item['owner-id'] == $self_id)) { DBA::update('thread', ['mention' => true], ['iid' => $parent_id]); - Logger::log("tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG); + Logger::log("tagged thread ".$parent_id." as mention for user ".$self, Logger::DEBUG); } } } else { @@ -1628,12 +1628,12 @@ class Item extends BaseObject */ if ($item["uid"] == 0) { if (self::exists(['uri' => trim($item['uri']), 'uid' => 0])) { - Logger::log('Global item already stored. URI: '.$item['uri'].' on network '.$item['network'], LOGGER_DEBUG); + Logger::log('Global item already stored. URI: '.$item['uri'].' on network '.$item['network'], Logger::DEBUG); return 0; } } - Logger::log('' . print_r($item,true), LOGGER_DATA); + Logger::log('' . print_r($item,true), Logger::DATA); if (array_key_exists('tag', $item)) { $tags = $item['tag']; @@ -1701,7 +1701,7 @@ class Item extends BaseObject $item = array_merge($item, $delivery_data); file_put_contents($spool, json_encode($item)); - Logger::log("Item wasn't stored - Item was spooled into file ".$file, LOGGER_DEBUG); + Logger::log("Item wasn't stored - Item was spooled into file ".$file, Logger::DEBUG); } return 0; } @@ -1760,7 +1760,7 @@ class Item extends BaseObject */ if (base64_encode(base64_decode(base64_decode($dsprsig->signature))) == base64_decode($dsprsig->signature)) { $dsprsig->signature = base64_decode($dsprsig->signature); - Logger::log("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG); + Logger::log("Repaired double encoded signature from handle ".$dsprsig->signer, Logger::DEBUG); } if (!empty($dsprsig->signed_text) && empty($dsprsig->signature) && empty($dsprsig->signer)) { @@ -2145,9 +2145,9 @@ class Item extends BaseObject $distributed = self::insert($item, false, $notify, true); if (!$distributed) { - Logger::log("Distributed public item " . $itemid . " for user " . $uid . " wasn't stored", LOGGER_DEBUG); + Logger::log("Distributed public item " . $itemid . " for user " . $uid . " wasn't stored", Logger::DEBUG); } else { - Logger::log("Distributed public item " . $itemid . " for user " . $uid . " with id " . $distributed, LOGGER_DEBUG); + Logger::log("Distributed public item " . $itemid . " for user " . $uid . " with id " . $distributed, Logger::DEBUG); } } @@ -2210,7 +2210,7 @@ class Item extends BaseObject $public_shadow = self::insert($item, false, false, true); - Logger::log("Stored public shadow for thread ".$itemid." under id ".$public_shadow, LOGGER_DEBUG); + Logger::log("Stored public shadow for thread ".$itemid." under id ".$public_shadow, Logger::DEBUG); } } @@ -2267,7 +2267,7 @@ class Item extends BaseObject $public_shadow = self::insert($item, false, false, true); - Logger::log("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG); + Logger::log("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, Logger::DEBUG); // If this was a comment to a Diaspora post we don't get our comment back. // This means that we have to distribute the comment by ourselves. @@ -2613,29 +2613,29 @@ class Item extends BaseObject // Prevent the forwarding of posts that are forwarded if (!empty($datarray["extid"]) && ($datarray["extid"] == Protocol::DFRN)) { - Logger::log('Already forwarded', LOGGER_DEBUG); + Logger::log('Already forwarded', Logger::DEBUG); return false; } // Prevent to forward already forwarded posts if ($datarray["app"] == $a->getHostName()) { - Logger::log('Already forwarded (second test)', LOGGER_DEBUG); + Logger::log('Already forwarded (second test)', Logger::DEBUG); return false; } // Only forward posts if ($datarray["verb"] != ACTIVITY_POST) { - Logger::log('No post', LOGGER_DEBUG); + Logger::log('No post', Logger::DEBUG); return false; } if (($contact['network'] != Protocol::FEED) && $datarray['private']) { - Logger::log('Not public', LOGGER_DEBUG); + Logger::log('Not public', Logger::DEBUG); return false; } $datarray2 = $datarray; - Logger::log('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG); + Logger::log('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), Logger::DEBUG); if ($contact['remote_self'] == 2) { $self = DBA::selectFirst('contact', ['id', 'name', 'url', 'thumb'], ['uid' => $contact['uid'], 'self' => true]); @@ -2675,7 +2675,7 @@ class Item extends BaseObject if ($contact['network'] != Protocol::FEED) { // Store the original post $result = self::insert($datarray2, false, false); - Logger::log('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), LOGGER_DEBUG); + Logger::log('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), Logger::DEBUG); } else { $datarray["app"] = "Feed"; $result = true; @@ -2705,7 +2705,7 @@ class Item extends BaseObject return $s; } - Logger::log('check for photos', LOGGER_DEBUG); + Logger::log('check for photos', Logger::DEBUG); $site = substr(System::baseUrl(), strpos(System::baseUrl(), '://')); $orig_body = $s; @@ -2719,7 +2719,7 @@ class Item extends BaseObject $img_st_close++; // make it point to AFTER the closing bracket $image = substr($orig_body, $img_start + $img_st_close, $img_len); - Logger::log('found photo ' . $image, LOGGER_DEBUG); + Logger::log('found photo ' . $image, Logger::DEBUG); if (stristr($image, $site . '/photo/')) { // Only embed locally hosted photos @@ -2761,7 +2761,7 @@ class Item extends BaseObject // If a custom width and height were specified, apply before embedding if (preg_match("/\[img\=([0-9]*)x([0-9]*)\]/is", substr($orig_body, $img_start, $img_st_close), $match)) { - Logger::log('scaling photo', LOGGER_DEBUG); + Logger::log('scaling photo', Logger::DEBUG); $width = intval($match[1]); $height = intval($match[2]); @@ -2774,9 +2774,9 @@ class Item extends BaseObject } } - Logger::log('replacing photo', LOGGER_DEBUG); + Logger::log('replacing photo', Logger::DEBUG); $image = 'data:' . $type . ';base64,' . base64_encode($data); - Logger::log('replaced: ' . $image, LOGGER_DATA); + Logger::log('replaced: ' . $image, Logger::DATA); } } } @@ -3148,7 +3148,7 @@ class Item extends BaseObject if (!$onlyshadow) { $result = DBA::insert('thread', $item); - Logger::log("Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); + Logger::log("Add thread for item ".$itemid." - ".print_r($result, true), Logger::DEBUG); } } @@ -3180,26 +3180,26 @@ class Item extends BaseObject $result = DBA::update('thread', $fields, ['iid' => $itemid]); - Logger::log("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result, LOGGER_DEBUG); + Logger::log("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result, Logger::DEBUG); } private static function deleteThread($itemid, $itemuri = "") { $item = DBA::selectFirst('thread', ['uid'], ['iid' => $itemid]); if (!DBA::isResult($item)) { - Logger::log('No thread found for id '.$itemid, LOGGER_DEBUG); + Logger::log('No thread found for id '.$itemid, Logger::DEBUG); return; } $result = DBA::delete('thread', ['iid' => $itemid], ['cascade' => false]); - Logger::log("deleteThread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); + Logger::log("deleteThread: Deleted thread for item ".$itemid." - ".print_r($result, true), Logger::DEBUG); if ($itemuri != "") { $condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]]; if (!self::exists($condition)) { DBA::delete('item', ['uri' => $itemuri, 'uid' => 0]); - Logger::log("deleteThread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG); + Logger::log("deleteThread: Deleted shadow for item ".$itemuri, Logger::DEBUG); } } } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 92e27f175..fba675945 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -107,7 +107,7 @@ class Profile $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]); if (!DBA::isResult($user) && empty($profiledata)) { - Logger::log('profile error: ' . $a->query_string, LOGGER_DEBUG); + Logger::log('profile error: ' . $a->query_string, Logger::DEBUG); notice(L10n::t('Requested account is not available.') . EOL); $a->error = 404; return; @@ -125,7 +125,7 @@ class Profile $pdata = self::getByNickname($nickname, $user['uid'], $profile); if (empty($pdata) && empty($profiledata)) { - Logger::log('profile error: ' . $a->query_string, LOGGER_DEBUG); + Logger::log('profile error: ' . $a->query_string, Logger::DEBUG); notice(L10n::t('Requested profile is not available.') . EOL); $a->error = 404; return; @@ -1021,27 +1021,27 @@ class Profile // Try to find the public contact entry of the visitor. $cid = Contact::getIdForURL($my_url); if (!$cid) { - Logger::log('No contact record found for ' . $my_url, LOGGER_DEBUG); + Logger::log('No contact record found for ' . $my_url, Logger::DEBUG); return; } $contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]); if (DBA::isResult($contact) && remote_user() && remote_user() == $contact['id']) { - Logger::log('The visitor ' . $my_url . ' is already authenticated', LOGGER_DEBUG); + Logger::log('The visitor ' . $my_url . ' is already authenticated', Logger::DEBUG); return; } // Avoid endless loops $cachekey = 'zrlInit:' . $my_url; if (Cache::get($cachekey)) { - Logger::log('URL ' . $my_url . ' already tried to authenticate.', LOGGER_DEBUG); + Logger::log('URL ' . $my_url . ' already tried to authenticate.', Logger::DEBUG); return; } else { Cache::set($cachekey, true, Cache::MINUTE); } - Logger::log('Not authenticated. Invoking reverse magic-auth for ' . $my_url, LOGGER_DEBUG); + Logger::log('Not authenticated. Invoking reverse magic-auth for ' . $my_url, Logger::DEBUG); Worker::add(PRIORITY_LOW, 'GProbe', $my_url); @@ -1062,7 +1062,7 @@ class Profile // We have to check if the remote server does understand /magic without invoking something $serverret = Network::curl($basepath . '/magic'); if ($serverret->isSuccess()) { - Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, LOGGER_DEBUG); + Logger::log('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path, Logger::DEBUG); System::externalRedirect($magic_path); } } @@ -1093,7 +1093,7 @@ class Profile // Try to find the public contact entry of the visitor. $cid = Contact::getIdForURL($visitor_handle); if(!$cid) { - Logger::log('owt: unable to finger ' . $visitor_handle, LOGGER_DEBUG); + Logger::log('owt: unable to finger ' . $visitor_handle, Logger::DEBUG); return; } @@ -1122,7 +1122,7 @@ class Profile info(L10n::t('OpenWebAuth: %1$s welcomes %2$s', $a->getHostName(), $visitor['name'])); - Logger::log('OpenWebAuth: auth success from ' . $visitor['addr'], LOGGER_DEBUG); + Logger::log('OpenWebAuth: auth success from ' . $visitor['addr'], Logger::DEBUG); } public static function zrl($s, $force = false) diff --git a/src/Model/PushSubscriber.php b/src/Model/PushSubscriber.php index 4f85ffba5..44495daee 100644 --- a/src/Model/PushSubscriber.php +++ b/src/Model/PushSubscriber.php @@ -46,7 +46,7 @@ class PushSubscriber $priority = $default_priority; } - Logger::log('Publish feed to ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' with priority ' . $priority, LOGGER_DEBUG); + Logger::log('Publish feed to ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' with priority ' . $priority, Logger::DEBUG); Worker::add($priority, 'PubSubPublish', (int)$subscriber['id']); } @@ -116,10 +116,10 @@ class PushSubscriber if ($days > 60) { DBA::update('push_subscriber', ['push' => -1, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]); - Logger::log('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', LOGGER_DEBUG); + Logger::log('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', Logger::DEBUG); } else { DBA::update('push_subscriber', ['push' => 0, 'next_try' => DBA::NULL_DATETIME], ['id' => $id]); - Logger::log('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', LOGGER_DEBUG); + Logger::log('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', Logger::DEBUG); } } else { // Calculate the delay until the next trial @@ -129,7 +129,7 @@ class PushSubscriber $retrial = $retrial + 1; DBA::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], ['id' => $id]); - Logger::log('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next, LOGGER_DEBUG); + Logger::log('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next, Logger::DEBUG); } } @@ -149,6 +149,6 @@ class PushSubscriber // set last_update to the 'created' date of the last item, and reset push=0 $fields = ['push' => 0, 'next_try' => DBA::NULL_DATETIME, 'last_update' => $last_update]; DBA::update('push_subscriber', $fields, ['id' => $id]); - Logger::log('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', LOGGER_DEBUG); + Logger::log('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', Logger::DEBUG); } } diff --git a/src/Model/User.php b/src/Model/User.php index 29809b2cd..43992cc5f 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -471,7 +471,7 @@ class User $username_max_length = max(1, min(64, intval(Config::get('system', 'username_max_length', 48)))); if ($username_min_length > $username_max_length) { - Logger::log(L10n::t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length), LOGGER_WARNING); + Logger::log(L10n::t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length), Logger::WARNING); $tmp = $username_min_length; $username_min_length = $username_max_length; $username_max_length = $tmp; diff --git a/src/Module/Magic.php b/src/Module/Magic.php index 08836a7b9..b8af1f961 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -23,9 +23,9 @@ class Magic extends BaseModule { $a = self::getApp(); $ret = ['success' => false, 'url' => '', 'message' => '']; - Logger::log('magic mdule: invoked', LOGGER_DEBUG); + Logger::log('magic mdule: invoked', Logger::DEBUG); - Logger::log('args: ' . print_r($_REQUEST, true), LOGGER_DATA); + Logger::log('args: ' . print_r($_REQUEST, true), Logger::DATA); $addr = ((x($_REQUEST, 'addr')) ? $_REQUEST['addr'] : ''); $dest = ((x($_REQUEST, 'dest')) ? $_REQUEST['dest'] : ''); @@ -42,7 +42,7 @@ class Magic extends BaseModule } if (!$cid) { - Logger::log('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG); + Logger::log('No contact record found: ' . print_r($_REQUEST, true), Logger::DEBUG); // @TODO Finding a more elegant possibility to redirect to either internal or external URL $a->redirect($dest); } @@ -56,7 +56,7 @@ class Magic extends BaseModule return $ret; } - Logger::log('Contact is already authenticated', LOGGER_DEBUG); + Logger::log('Contact is already authenticated', Logger::DEBUG); System::externalRedirect($dest); } diff --git a/src/Module/Owa.php b/src/Module/Owa.php index a1d11e947..a1dbfa2f3 100644 --- a/src/Module/Owa.php +++ b/src/Module/Owa.php @@ -58,8 +58,8 @@ class Owa extends BaseModule $verified = HTTPSignature::verifyMagic($contact['pubkey']); if ($verified && $verified['header_signed'] && $verified['header_valid']) { - Logger::log('OWA header: ' . print_r($verified, true), LOGGER_DATA); - Logger::log('OWA success: ' . $contact['addr'], LOGGER_DATA); + Logger::log('OWA header: ' . print_r($verified, true), Logger::DATA); + Logger::log('OWA success: ' . $contact['addr'], Logger::DATA); $ret['success'] = true; $token = random_string(32); @@ -76,10 +76,10 @@ class Owa extends BaseModule openssl_public_encrypt($token, $result, $contact['pubkey']); $ret['encrypted_token'] = base64url_encode($result); } else { - Logger::log('OWA fail: ' . $contact['id'] . ' ' . $contact['addr'] . ' ' . $contact['url'], LOGGER_DEBUG); + Logger::log('OWA fail: ' . $contact['id'] . ' ' . $contact['addr'] . ' ' . $contact['url'], Logger::DEBUG); } } else { - Logger::log('Contact not found: ' . $handle, LOGGER_DEBUG); + Logger::log('Contact not found: ' . $handle, Logger::DEBUG); } } } diff --git a/src/Network/CurlResult.php b/src/Network/CurlResult.php index aef719300..bbae881b8 100644 --- a/src/Network/CurlResult.php +++ b/src/Network/CurlResult.php @@ -104,7 +104,7 @@ class CurlResult $this->errorNumber = $errorNumber; $this->error = $error; - Logger::log($url . ': ' . $this->returnCode . " " . $result, LOGGER_DATA); + Logger::log($url . ': ' . $this->returnCode . " " . $result, Logger::DATA); $this->parseBodyHeader($result); $this->checkSuccess(); @@ -134,8 +134,8 @@ class CurlResult $this->isSuccess = ($this->returnCode >= 200 && $this->returnCode <= 299) || $this->errorNumber == 0; if (!$this->isSuccess) { - Logger::log('error: ' . $this->url . ': ' . $this->returnCode . ' - ' . $this->error, LOGGER_INFO); - Logger::log('debug: ' . print_r($this->info, true), LOGGER_DATA); + Logger::log('error: ' . $this->url . ': ' . $this->returnCode . ' - ' . $this->error, Logger::INFO); + Logger::log('debug: ' . print_r($this->info, true), Logger::DATA); } if (!$this->isSuccess && $this->errorNumber == CURLE_OPERATION_TIMEDOUT) { diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php index 97c5bccc9..51a558942 100644 --- a/src/Network/FKOAuth1.php +++ b/src/Network/FKOAuth1.php @@ -40,7 +40,7 @@ class FKOAuth1 extends OAuthServer $record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]); if (!DBA::isResult($record)) { - Logger::log('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), Logger::DEBUG); header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 894d9abe5..fc93524bf 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -110,7 +110,7 @@ class Probe $xrd_timeout = Config::get('system', 'xrd_timeout', 20); $redirects = 0; - Logger::log("Probing for ".$host, LOGGER_DEBUG); + Logger::log("Probing for ".$host, Logger::DEBUG); $xrd = null; $curlResult = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']); @@ -123,7 +123,7 @@ class Probe if (!is_object($xrd)) { $curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']); if ($curlResult->isTimeout()) { - Logger::log("Probing timeout for " . $url, LOGGER_DEBUG); + Logger::log("Probing timeout for " . $url, Logger::DEBUG); return false; } $xml = $curlResult->getBody(); @@ -131,13 +131,13 @@ class Probe $host_url = 'http://'.$host; } if (!is_object($xrd)) { - Logger::log("No xrd object found for ".$host, LOGGER_DEBUG); + Logger::log("No xrd object found for ".$host, Logger::DEBUG); return []; } $links = XML::elementToArray($xrd); if (!isset($links["xrd"]["link"])) { - Logger::log("No xrd data found for ".$host, LOGGER_DEBUG); + Logger::log("No xrd data found for ".$host, Logger::DEBUG); return []; } @@ -165,7 +165,7 @@ class Probe self::$baseurl = "http://".$host; - Logger::log("Probing successful for ".$host, LOGGER_DEBUG); + Logger::log("Probing successful for ".$host, Logger::DEBUG); return $lrdd; } @@ -195,7 +195,7 @@ class Probe $profile_link = ''; $links = self::lrdd($webbie); - Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), LOGGER_DATA); + Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), Logger::DATA); if (count($links)) { foreach ($links as $link) { if ($link['@attributes']['rel'] === NAMESPACE_DFRN) { @@ -254,7 +254,7 @@ class Probe } if (!$lrdd) { - Logger::log("No lrdd data found for ".$uri, LOGGER_DEBUG); + Logger::log("No lrdd data found for ".$uri, Logger::DEBUG); return []; } @@ -286,7 +286,7 @@ class Probe } if (!is_array($webfinger["links"])) { - Logger::log("No webfinger links found for ".$uri, LOGGER_DEBUG); + Logger::log("No webfinger links found for ".$uri, Logger::DEBUG); return false; } @@ -596,7 +596,7 @@ class Probe $lrdd = self::hostMeta($host); } if (!$lrdd) { - Logger::log('No XRD data was found for '.$uri, LOGGER_DEBUG); + Logger::log('No XRD data was found for '.$uri, Logger::DEBUG); return self::feed($uri); } $nick = array_pop($path_parts); @@ -631,12 +631,12 @@ class Probe } if (!$lrdd) { - Logger::log('No XRD data was found for '.$uri, LOGGER_DEBUG); + Logger::log('No XRD data was found for '.$uri, Logger::DEBUG); return self::mail($uri, $uid); } $addr = $uri; } else { - Logger::log("Uri ".$uri." was not detectable", LOGGER_DEBUG); + Logger::log("Uri ".$uri." was not detectable", Logger::DEBUG); return false; } @@ -681,7 +681,7 @@ class Probe $result = false; - Logger::log("Probing ".$uri, LOGGER_DEBUG); + Logger::log("Probing ".$uri, Logger::DEBUG); if (in_array($network, ["", Protocol::DFRN])) { $result = self::dfrn($webfinger); @@ -717,7 +717,7 @@ class Probe $result["url"] = $uri; } - Logger::log($uri." is ".$result["network"], LOGGER_DEBUG); + Logger::log($uri." is ".$result["network"], Logger::DEBUG); if (empty($result["baseurl"])) { $pos = strpos($result["url"], $host); @@ -752,7 +752,7 @@ class Probe $webfinger = json_decode($data, true); if (is_array($webfinger)) { if (!isset($webfinger["links"])) { - Logger::log("No json webfinger links for ".$url, LOGGER_DEBUG); + Logger::log("No json webfinger links for ".$url, Logger::DEBUG); return false; } return $webfinger; @@ -761,13 +761,13 @@ class Probe // If it is not JSON, maybe it is XML $xrd = XML::parseString($data, false); if (!is_object($xrd)) { - Logger::log("No webfinger data retrievable for ".$url, LOGGER_DEBUG); + Logger::log("No webfinger data retrievable for ".$url, Logger::DEBUG); return false; } $xrd_arr = XML::elementToArray($xrd); if (!isset($xrd_arr["xrd"]["link"])) { - Logger::log("No XML webfinger links for ".$url, LOGGER_DEBUG); + Logger::log("No XML webfinger links for ".$url, Logger::DEBUG); return false; } @@ -816,13 +816,13 @@ class Probe } $content = $curlResult->getBody(); if (!$content) { - Logger::log("Empty body for ".$noscrape_url, LOGGER_DEBUG); + Logger::log("Empty body for ".$noscrape_url, Logger::DEBUG); return false; } $json = json_decode($content, true); if (!is_array($json)) { - Logger::log("No json data for ".$noscrape_url, LOGGER_DEBUG); + Logger::log("No json data for ".$noscrape_url, Logger::DEBUG); return false; } @@ -928,7 +928,7 @@ class Probe { $data = []; - Logger::log("Check profile ".$profile_link, LOGGER_DEBUG); + Logger::log("Check profile ".$profile_link, Logger::DEBUG); // Fetch data via noscrape - this is faster $noscrape_url = str_replace(["/hcard/", "/profile/"], "/noscrape/", $profile_link); @@ -962,7 +962,7 @@ class Probe $prof_data["fn"] = defaults($data, 'name' , null); $prof_data["key"] = defaults($data, 'pubkey' , null); - Logger::log("Result for profile ".$profile_link.": ".print_r($prof_data, true), LOGGER_DEBUG); + Logger::log("Result for profile ".$profile_link.": ".print_r($prof_data, true), Logger::DEBUG); return $prof_data; } @@ -1633,7 +1633,7 @@ class Probe } $msgs = Email::poll($mbox, $uri); - Logger::log('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG); + Logger::log('searching '.$uri.', '.count($msgs).' messages found.', Logger::DEBUG); if (!count($msgs)) { return false; @@ -1715,7 +1715,7 @@ class Probe $fixed = $scheme.$host.$port.$path.$query.$fragment; - Logger::log('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, LOGGER_DATA); + Logger::log('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, Logger::DATA); return $fixed; } diff --git a/src/Object/Image.php b/src/Object/Image.php index 6449bf09a..abce69a1c 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -727,7 +727,7 @@ class Image */ public static function guessType($filename, $fromcurl = false, $header = '') { - Logger::log('Image: guessType: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG); + Logger::log('Image: guessType: '.$filename . ($fromcurl?' from curl headers':''), Logger::DEBUG); $type = null; if ($fromcurl) { $a = get_app(); @@ -765,7 +765,7 @@ class Image } } } - Logger::log('Image: guessType: type='.$type, LOGGER_DEBUG); + Logger::log('Image: guessType: type='.$type, Logger::DEBUG); return $type; } @@ -891,7 +891,7 @@ class Image ); if (!DBA::isResult($r)) { - Logger::log("Can't detect user data for uid ".$uid, LOGGER_DEBUG); + Logger::log("Can't detect user data for uid ".$uid, Logger::DEBUG); return([]); } @@ -902,10 +902,10 @@ class Image /// $community_page = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false); if ((strlen($imagedata) == 0) && ($url == "")) { - Logger::log("No image data and no url provided", LOGGER_DEBUG); + Logger::log("No image data and no url provided", Logger::DEBUG); return([]); } elseif (strlen($imagedata) == 0) { - Logger::log("Uploading picture from ".$url, LOGGER_DEBUG); + Logger::log("Uploading picture from ".$url, Logger::DEBUG); $stamp1 = microtime(true); $imagedata = @file_get_contents($url); @@ -915,7 +915,7 @@ class Image $maximagesize = Config::get('system', 'maximagesize'); if (($maximagesize) && (strlen($imagedata) > $maximagesize)) { - Logger::log("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG); + Logger::log("Image exceeds size limit of ".$maximagesize, Logger::DEBUG); return([]); } @@ -929,7 +929,7 @@ class Image if (!isset($data["mime"])) { unlink($tempfile); - Logger::log("File is no picture", LOGGER_DEBUG); + Logger::log("File is no picture", Logger::DEBUG); return([]); } @@ -937,7 +937,7 @@ class Image if (!$Image->isValid()) { unlink($tempfile); - Logger::log("Picture is no valid picture", LOGGER_DEBUG); + Logger::log("Picture is no valid picture", Logger::DEBUG); return([]); } @@ -968,7 +968,7 @@ class Image $r = Photo::store($Image, $uid, $visitor, $hash, $tempfile, L10n::t('Wall Photos'), 0, 0, $defperm); if (!$r) { - Logger::log("Picture couldn't be stored", LOGGER_DEBUG); + Logger::log("Picture couldn't be stored", Logger::DEBUG); return([]); } diff --git a/src/Object/Post.php b/src/Object/Post.php index 08e0fbaa3..bb1b81c2c 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -488,10 +488,10 @@ class Post extends BaseObject { $item_id = $item->getId(); if (!$item_id) { - Logger::log('[ERROR] Post::addChild : Item has no ID!!', LOGGER_DEBUG); + Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG); return false; } elseif ($this->getChild($item->getId())) { - Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', LOGGER_DEBUG); + Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG); return false; } /* @@ -585,7 +585,7 @@ class Post extends BaseObject return true; } } - Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', LOGGER_DEBUG); + Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG); return false; } @@ -651,7 +651,7 @@ class Post extends BaseObject public function getDataValue($name) { if (!isset($this->data[$name])) { - // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', LOGGER_DEBUG); + // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG); return false; } @@ -668,7 +668,7 @@ class Post extends BaseObject private function setTemplate($name) { if (!x($this->available_templates, $name)) { - Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', LOGGER_DEBUG); + Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG); return false; } diff --git a/src/Object/Thread.php b/src/Object/Thread.php index e9a2a0638..b6d92e743 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -78,7 +78,7 @@ class Thread extends BaseObject $this->writable = $writable; break; default: - Logger::log('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', LOGGER_DEBUG); + Logger::log('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', Logger::DEBUG); return false; break; } @@ -138,12 +138,12 @@ class Thread extends BaseObject $item_id = $item->getId(); if (!$item_id) { - Logger::log('[ERROR] Conversation::addThread : Item has no ID!!', LOGGER_DEBUG); + Logger::log('[ERROR] Conversation::addThread : Item has no ID!!', Logger::DEBUG); return false; } if ($this->getParent($item->getId())) { - Logger::log('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', Logger::DEBUG); return false; } @@ -151,12 +151,12 @@ class Thread extends BaseObject * Only add will be displayed */ if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) { - Logger::log('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', Logger::DEBUG); return false; } if ($item->getDataValue('verb') === ACTIVITY_LIKE || $item->getDataValue('verb') === ACTIVITY_DISLIKE) { - Logger::log('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', Logger::DEBUG); return false; } @@ -190,7 +190,7 @@ class Thread extends BaseObject $item_data = $item->getTemplateData($conv_responses); if (!$item_data) { - Logger::log('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').', LOGGER_DEBUG); + Logger::log('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').', Logger::DEBUG); return false; } $result[] = $item_data; diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index df1ba7dbd..7d970c003 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -159,7 +159,7 @@ class Processor { $owner = Contact::getIdForURL($activity['actor']); - Logger::log('Deleting item ' . $activity['object_id'] . ' from ' . $owner, LOGGER_DEBUG); + Logger::log('Deleting item ' . $activity['object_id'] . ' from ' . $owner, Logger::DEBUG); Item::delete(['uri' => $activity['object_id'], 'owner-id' => $owner]); } @@ -212,7 +212,7 @@ class Processor } $event_id = Event::store($event); - Logger::log('Event '.$event_id.' was stored', LOGGER_DEBUG); + Logger::log('Event '.$event_id.' was stored', Logger::DEBUG); } /** @@ -226,7 +226,7 @@ class Processor /// @todo What to do with $activity['context']? if (($item['gravity'] != GRAVITY_PARENT) && !Item::exists(['uri' => $item['parent-uri']])) { - Logger::log('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', LOGGER_DEBUG); + Logger::log('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', Logger::DEBUG); return; } @@ -239,7 +239,7 @@ class Processor $item['owner-link'] = $activity['actor']; $item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true); } else { - Logger::log('Ignoring actor because of thread completion.', LOGGER_DEBUG); + Logger::log('Ignoring actor because of thread completion.', Logger::DEBUG); $item['owner-link'] = $item['author-link']; $item['owner-id'] = $item['author-id']; } @@ -375,7 +375,7 @@ class Processor return; } - Logger::log('Updating profile for ' . $activity['object_id'], LOGGER_DEBUG); + Logger::log('Updating profile for ' . $activity['object_id'], Logger::DEBUG); APContact::getByURL($activity['object_id'], true); } @@ -387,12 +387,12 @@ class Processor public static function deletePerson($activity) { if (empty($activity['object_id']) || empty($activity['actor'])) { - Logger::log('Empty object id or actor.', LOGGER_DEBUG); + Logger::log('Empty object id or actor.', Logger::DEBUG); return; } if ($activity['object_id'] != $activity['actor']) { - Logger::log('Object id does not match actor.', LOGGER_DEBUG); + Logger::log('Object id does not match actor.', Logger::DEBUG); return; } @@ -402,7 +402,7 @@ class Processor } DBA::close($contacts); - Logger::log('Deleted contact ' . $activity['object_id'], LOGGER_DEBUG); + Logger::log('Deleted contact ' . $activity['object_id'], Logger::DEBUG); } /** @@ -421,7 +421,7 @@ class Processor $cid = Contact::getIdForURL($activity['actor'], $uid); if (empty($cid)) { - Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG); + Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG); return; } @@ -436,7 +436,7 @@ class Processor $condition = ['id' => $cid]; DBA::update('contact', $fields, $condition); - Logger::log('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Accept contact request from contact ' . $cid . ' for user ' . $uid, Logger::DEBUG); } /** @@ -455,7 +455,7 @@ class Processor $cid = Contact::getIdForURL($activity['actor'], $uid); if (empty($cid)) { - Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG); + Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG); return; } @@ -463,9 +463,9 @@ class Processor if (DBA::exists('contact', ['id' => $cid, 'rel' => Contact::SHARING, 'pending' => true])) { Contact::remove($cid); - Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', LOGGER_DEBUG); + Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', Logger::DEBUG); } else { - Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', LOGGER_DEBUG); + Logger::log('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', Logger::DEBUG); } } @@ -508,7 +508,7 @@ class Processor $cid = Contact::getIdForURL($activity['actor'], $uid); if (empty($cid)) { - Logger::log('No contact found for ' . $activity['actor'], LOGGER_DEBUG); + Logger::log('No contact found for ' . $activity['actor'], Logger::DEBUG); return; } @@ -520,7 +520,7 @@ class Processor } Contact::removeFollower($owner, $contact); - Logger::log('Undo following request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Undo following request from contact ' . $cid . ' for user ' . $uid, Logger::DEBUG); } /** diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 707d0308a..80c2a5f08 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -60,16 +60,16 @@ class Receiver { $http_signer = HTTPSignature::getSigner($body, $header); if (empty($http_signer)) { - Logger::log('Invalid HTTP signature, message will be discarded.', LOGGER_DEBUG); + Logger::log('Invalid HTTP signature, message will be discarded.', Logger::DEBUG); return; } else { - Logger::log('HTTP signature is signed by ' . $http_signer, LOGGER_DEBUG); + Logger::log('HTTP signature is signed by ' . $http_signer, Logger::DEBUG); } $activity = json_decode($body, true); if (empty($activity)) { - Logger::log('Invalid body.', LOGGER_DEBUG); + Logger::log('Invalid body.', Logger::DEBUG); return; } @@ -77,31 +77,31 @@ class Receiver $actor = JsonLD::fetchElement($ldactivity, 'as:actor'); - Logger::log('Message for user ' . $uid . ' is from actor ' . $actor, LOGGER_DEBUG); + Logger::log('Message for user ' . $uid . ' is from actor ' . $actor, Logger::DEBUG); if (LDSignature::isSigned($activity)) { $ld_signer = LDSignature::getSigner($activity); if (empty($ld_signer)) { - Logger::log('Invalid JSON-LD signature from ' . $actor, LOGGER_DEBUG); + Logger::log('Invalid JSON-LD signature from ' . $actor, Logger::DEBUG); } if (!empty($ld_signer && ($actor == $http_signer))) { - Logger::log('The HTTP and the JSON-LD signature belong to ' . $ld_signer, LOGGER_DEBUG); + Logger::log('The HTTP and the JSON-LD signature belong to ' . $ld_signer, Logger::DEBUG); $trust_source = true; } elseif (!empty($ld_signer)) { - Logger::log('JSON-LD signature is signed by ' . $ld_signer, LOGGER_DEBUG); + Logger::log('JSON-LD signature is signed by ' . $ld_signer, Logger::DEBUG); $trust_source = true; } elseif ($actor == $http_signer) { - Logger::log('Bad JSON-LD signature, but HTTP signer fits the actor.', LOGGER_DEBUG); + Logger::log('Bad JSON-LD signature, but HTTP signer fits the actor.', Logger::DEBUG); $trust_source = true; } else { - Logger::log('Invalid JSON-LD signature and the HTTP signer is different.', LOGGER_DEBUG); + Logger::log('Invalid JSON-LD signature and the HTTP signer is different.', Logger::DEBUG); $trust_source = false; } } elseif ($actor == $http_signer) { - Logger::log('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', LOGGER_DEBUG); + Logger::log('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', Logger::DEBUG); $trust_source = true; } else { - Logger::log('No JSON-LD signature, different actor.', LOGGER_DEBUG); + Logger::log('No JSON-LD signature, different actor.', Logger::DEBUG); $trust_source = false; } @@ -160,7 +160,7 @@ class Receiver { $actor = JsonLD::fetchElement($activity, 'as:actor'); if (empty($actor)) { - Logger::log('Empty actor', LOGGER_DEBUG); + Logger::log('Empty actor', Logger::DEBUG); return []; } @@ -176,11 +176,11 @@ class Receiver $receivers = array_merge($receivers, $additional); } - Logger::log('Receivers: ' . json_encode($receivers), LOGGER_DEBUG); + Logger::log('Receivers: ' . json_encode($receivers), Logger::DEBUG); $object_id = JsonLD::fetchElement($activity, 'as:object'); if (empty($object_id)) { - Logger::log('No object found', LOGGER_DEBUG); + Logger::log('No object found', Logger::DEBUG); return []; } @@ -193,7 +193,7 @@ class Receiver } $object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source); if (empty($object_data)) { - Logger::log("Object data couldn't be processed", LOGGER_DEBUG); + Logger::log("Object data couldn't be processed", Logger::DEBUG); return []; } // We had been able to retrieve the object data - so we can trust the source @@ -230,7 +230,7 @@ class Receiver $object_data['actor'] = $actor; $object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers); - Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], LOGGER_DEBUG); + Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG); return $object_data; } @@ -273,17 +273,17 @@ class Receiver { $type = JsonLD::fetchElement($activity, '@type'); if (!$type) { - Logger::log('Empty type', LOGGER_DEBUG); + Logger::log('Empty type', Logger::DEBUG); return; } if (!JsonLD::fetchElement($activity, 'as:object')) { - Logger::log('Empty object', LOGGER_DEBUG); + Logger::log('Empty object', Logger::DEBUG); return; } if (!JsonLD::fetchElement($activity, 'as:actor')) { - Logger::log('Empty actor', LOGGER_DEBUG); + Logger::log('Empty actor', Logger::DEBUG); return; } @@ -291,12 +291,12 @@ class Receiver // $trust_source is called by reference and is set to true if the content was retrieved successfully $object_data = self::prepareObjectData($activity, $uid, $trust_source); if (empty($object_data)) { - Logger::log('No object data found', LOGGER_DEBUG); + Logger::log('No object data found', Logger::DEBUG); return; } if (!$trust_source) { - Logger::log('No trust for activity type "' . $type . '", so we quit now.', LOGGER_DEBUG); + Logger::log('No trust for activity type "' . $type . '", so we quit now.', Logger::DEBUG); return; } @@ -385,7 +385,7 @@ class Receiver break; default: - Logger::log('Unknown activity: ' . $type . ' ' . $object_data['object_type'], LOGGER_DEBUG); + Logger::log('Unknown activity: ' . $type . ' ' . $object_data['object_type'], Logger::DEBUG); break; } } @@ -415,9 +415,9 @@ class Receiver $profile = APContact::getByURL($actor); $followers = defaults($profile, 'followers', ''); - Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, LOGGER_DEBUG); + Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, Logger::DEBUG); } else { - Logger::log('Empty actor', LOGGER_DEBUG); + Logger::log('Empty actor', Logger::DEBUG); $followers = ''; } @@ -501,7 +501,7 @@ class Receiver // Send a new follow request to be sure that the connection still exists if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) { ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid); - Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, Logger::DEBUG); } } @@ -571,27 +571,27 @@ class Receiver $data = ActivityPub::fetchContent($object_id); if (!empty($data)) { $object = JsonLD::compact($data); - Logger::log('Fetched content for ' . $object_id, LOGGER_DEBUG); + Logger::log('Fetched content for ' . $object_id, Logger::DEBUG); } else { - Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', LOGGER_DEBUG); + Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', Logger::DEBUG); $item = Item::selectFirst([], ['uri' => $object_id]); if (!DBA::isResult($item)) { - Logger::log('Object with url ' . $object_id . ' was not found locally.', LOGGER_DEBUG); + Logger::log('Object with url ' . $object_id . ' was not found locally.', Logger::DEBUG); return false; } - Logger::log('Using already stored item for url ' . $object_id, LOGGER_DEBUG); + Logger::log('Using already stored item for url ' . $object_id, Logger::DEBUG); $data = ActivityPub\Transmitter::createNote($item); $object = JsonLD::compact($data); } } else { - Logger::log('Using original object for url ' . $object_id, LOGGER_DEBUG); + Logger::log('Using original object for url ' . $object_id, Logger::DEBUG); } $type = JsonLD::fetchElement($object, '@type'); if (empty($type)) { - Logger::log('Empty type', LOGGER_DEBUG); + Logger::log('Empty type', Logger::DEBUG); return false; } @@ -607,7 +607,7 @@ class Receiver return self::fetchObject($object_id); } - Logger::log('Unhandled object type: ' . $type, LOGGER_DEBUG); + Logger::log('Unhandled object type: ' . $type, Logger::DEBUG); } /** diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index d9535f0b6..d3043c530 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1016,7 +1016,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1045,7 +1045,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1074,7 +1074,7 @@ class Transmitter $signed = LDSignature::sign($data, $owner); - Logger::log('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', Logger::DEBUG); return HTTPSignature::transmit($signed, $inbox, $uid); } @@ -1099,7 +1099,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, LOGGER_DEBUG); + Logger::log('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, Logger::DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -1127,7 +1127,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); + Logger::log('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -1155,7 +1155,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); + Logger::log('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); @@ -1184,7 +1184,7 @@ class Transmitter 'instrument' => ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()], 'to' => $profile['url']]; - Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG); + Logger::log('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, Logger::DEBUG); $signed = LDSignature::sign($data, $owner); HTTPSignature::transmit($signed, $profile['inbox'], $uid); diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 95921eecb..b48dc0a8d 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -176,7 +176,7 @@ class DFRN ); if (! DBA::isResult($r)) { - Logger::log(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_WARNING); + Logger::log(sprintf('No contact found for nickname=%d', $owner_nick), Logger::WARNING); killme(); } @@ -212,7 +212,7 @@ class DFRN ); if (! DBA::isResult($r)) { - Logger::log(sprintf('No contact found for uid=%d', $owner_id), LOGGER_WARNING); + Logger::log(sprintf('No contact found for uid=%d', $owner_id), Logger::WARNING); killme(); } @@ -1189,7 +1189,7 @@ class DFRN $rino = Config::get('system', 'rino_encrypt'); $rino = intval($rino); - Logger::log("Local rino version: ". $rino, LOGGER_DEBUG); + Logger::log("Local rino version: ". $rino, Logger::DEBUG); $ssl_val = intval(Config::get('system', 'ssl_policy')); $ssl_policy = ''; @@ -1226,7 +1226,7 @@ class DFRN return -3; // timed out } - Logger::log('dfrn_deliver: ' . $xml, LOGGER_DATA); + Logger::log('dfrn_deliver: ' . $xml, Logger::DATA); if (empty($xml)) { Contact::markForArchival($contact); @@ -1235,7 +1235,7 @@ class DFRN if (strpos($xml, 'rino); $page = (($owner['page-flags'] == Contact::PAGE_COMMUNITY) ? 1 : 0); - Logger::log("Remote rino version: ".$rino_remote_version." for ".$contact["url"], LOGGER_DEBUG); + Logger::log("Remote rino version: ".$rino_remote_version." for ".$contact["url"], Logger::DEBUG); if ($owner['page-flags'] == Contact::PAGE_PRVGROUP) { $page = 2; @@ -1366,13 +1366,13 @@ class DFRN } - Logger::log('dfrn_deliver: ' . "SENDING: " . print_r($postvars, true), LOGGER_DATA); + Logger::log('dfrn_deliver: ' . "SENDING: " . print_r($postvars, true), Logger::DATA); $postResult = Network::post($contact['notify'], $postvars); $xml = $postResult->getBody(); - Logger::log('dfrn_deliver: ' . "RECEIVED: " . $xml, LOGGER_DATA); + Logger::log('dfrn_deliver: ' . "RECEIVED: " . $xml, Logger::DATA); $curl_stat = $postResult->getReturnCode(); if (empty($curl_stat) || empty($xml)) { @@ -1387,7 +1387,7 @@ class DFRN if (strpos($xml, 'message)) { - Logger::log('Delivery returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG); + Logger::log('Delivery returned status '.$res->status.' - '.$res->message, Logger::DEBUG); } if (($res->status >= 200) && ($res->status <= 299)) { @@ -1486,7 +1486,7 @@ class DFRN if (strpos($xml, 'message)) { - Logger::log('Transmit to ' . $dest_url . ' returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG); + Logger::log('Transmit to ' . $dest_url . ' returned status '.$res->status.' - '.$res->message, Logger::DEBUG); } if (($res->status >= 200) && ($res->status <= 299)) { @@ -1576,7 +1576,7 @@ class DFRN $author["network"] = $contact_old["network"]; } else { if (!$onlyfetch) { - Logger::log("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, LOGGER_DEBUG); + Logger::log("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, Logger::DEBUG); } $author["contact-unknown"] = true; @@ -1629,7 +1629,7 @@ class DFRN } if (DBA::isResult($contact_old) && !$onlyfetch) { - Logger::log("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", LOGGER_DEBUG); + Logger::log("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", Logger::DEBUG); $poco = ["url" => $contact_old["url"]]; @@ -1690,7 +1690,7 @@ class DFRN // If the "hide" element is present then the profile isn't searchable. $hide = intval(XML::getFirstNodeValue($xpath, $element . "/dfrn:hide/text()", $context) == "true"); - Logger::log("Hidden status for contact " . $contact_old["url"] . ": " . $hide, LOGGER_DEBUG); + Logger::log("Hidden status for contact " . $contact_old["url"] . ": " . $hide, Logger::DEBUG); // If the contact isn't searchable then set the contact to "hidden". // Problem: This can be manually overridden by the user. @@ -1762,20 +1762,20 @@ class DFRN $contact[$field] = DateTimeFormat::utc($contact[$field]); if (strtotime($contact[$field]) > strtotime($contact_old[$field])) { - Logger::log("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG); + Logger::log("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", Logger::DEBUG); $update = true; } } foreach ($fields as $field => $data) { if ($contact[$field] != $contact_old[$field]) { - Logger::log("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", LOGGER_DEBUG); + Logger::log("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $contact_old[$field] . "'", Logger::DEBUG); $update = true; } } if ($update) { - Logger::log("Update contact data for contact " . $contact["id"] . " (" . $contact["nick"] . ")", LOGGER_DEBUG); + Logger::log("Update contact data for contact " . $contact["id"] . " (" . $contact["nick"] . ")", Logger::DEBUG); q( "UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', @@ -2299,7 +2299,7 @@ class DFRN */ private static function processVerbs($entrytype, $importer, &$item, &$is_like) { - Logger::log("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, LOGGER_DEBUG); + Logger::log("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, Logger::DEBUG); if (($entrytype == DFRN::TOP_LEVEL)) { // The filling of the the "contact" variable is done for legcy reasons @@ -2464,7 +2464,7 @@ class DFRN ); // Is there an existing item? if (DBA::isResult($current) && !self::isEditedTimestampNewer($current, $item)) { - Logger::log("Item ".$item["uri"]." (".$item['edited'].") already existed.", LOGGER_DEBUG); + Logger::log("Item ".$item["uri"]." (".$item['edited'].") already existed.", Logger::DEBUG); return; } @@ -2672,10 +2672,10 @@ class DFRN // Is it an event? if (($item["object-type"] == ACTIVITY_OBJ_EVENT) && !$owner_unknown) { - Logger::log("Item ".$item["uri"]." seems to contain an event.", LOGGER_DEBUG); + Logger::log("Item ".$item["uri"]." seems to contain an event.", Logger::DEBUG); $ev = Event::fromBBCode($item["body"]); if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) { - Logger::log("Event in item ".$item["uri"]." was found.", LOGGER_DEBUG); + Logger::log("Event in item ".$item["uri"]." was found.", Logger::DEBUG); $ev["cid"] = $importer["id"]; $ev["uid"] = $importer["importer_uid"]; $ev["uri"] = $item["uri"]; @@ -2691,20 +2691,20 @@ class DFRN } $event_id = Event::store($ev); - Logger::log("Event ".$event_id." was stored", LOGGER_DEBUG); + Logger::log("Event ".$event_id." was stored", Logger::DEBUG); return; } } } if (!self::processVerbs($entrytype, $importer, $item, $is_like)) { - Logger::log("Exiting because 'processVerbs' told us so", LOGGER_DEBUG); + Logger::log("Exiting because 'processVerbs' told us so", Logger::DEBUG); return; } // This check is done here to be able to receive connection requests in "processVerbs" if (($entrytype == DFRN::TOP_LEVEL) && $owner_unknown) { - Logger::log("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . ".", LOGGER_DEBUG); + Logger::log("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . ".", Logger::DEBUG); return; } @@ -2712,9 +2712,9 @@ class DFRN // Update content if 'updated' changes if (DBA::isResult($current)) { if (self::updateContent($current, $item, $importer, $entrytype)) { - Logger::log("Item ".$item["uri"]." was updated.", LOGGER_DEBUG); + Logger::log("Item ".$item["uri"]." was updated.", Logger::DEBUG); } else { - Logger::log("Item " . $item["uri"] . " already existed.", LOGGER_DEBUG); + Logger::log("Item " . $item["uri"] . " already existed.", Logger::DEBUG); } return; } @@ -2724,7 +2724,7 @@ class DFRN $parent = 0; if ($posted_id) { - Logger::log("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, LOGGER_DEBUG); + Logger::log("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, Logger::DEBUG); if ($item['uid'] == 0) { Item::distribute($posted_id); @@ -2734,7 +2734,7 @@ class DFRN } } else { // $entrytype == DFRN::TOP_LEVEL if (($importer["uid"] == 0) && ($importer["importer_uid"] != 0)) { - Logger::log("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored.", LOGGER_DEBUG); + Logger::log("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored.", Logger::DEBUG); return; } if (!link_compare($item["owner-link"], $importer["url"])) { @@ -2744,13 +2744,13 @@ class DFRN * the tgroup delivery code called from Item::insert will correct it if it's a forum, * but we're going to unconditionally correct it here so that the post will always be owned by our contact. */ - Logger::log('Correcting item owner.', LOGGER_DEBUG); + Logger::log('Correcting item owner.', Logger::DEBUG); $item["owner-link"] = $importer["url"]; $item["owner-id"] = Contact::getIdForURL($importer["url"], 0); } if (($importer["rel"] == Contact::FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) { - Logger::log("Contact ".$importer["id"]." is only follower and tgroup check was negative.", LOGGER_DEBUG); + Logger::log("Contact ".$importer["id"]." is only follower and tgroup check was negative.", Logger::DEBUG); return; } @@ -2764,7 +2764,7 @@ class DFRN $posted_id = $notify; } - Logger::log("Item was stored with id ".$posted_id, LOGGER_DEBUG); + Logger::log("Item was stored with id ".$posted_id, Logger::DEBUG); if ($item['uid'] == 0) { Item::distribute($posted_id); @@ -2803,18 +2803,18 @@ class DFRN $condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]]; $item = Item::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted'], $condition); if (!DBA::isResult($item)) { - Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", Logger::DEBUG); return; } if (strstr($item['file'], '[')) { - Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " is filed. So it won't be deleted.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " is filed. So it won't be deleted.", Logger::DEBUG); return; } // When it is a starting post it has to belong to the person that wants to delete it if (($item['id'] == $item['parent']) && ($item['contact-id'] != $importer["id"])) { - Logger::log("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", Logger::DEBUG); return; } @@ -2822,7 +2822,7 @@ class DFRN if (($item['id'] != $item['parent']) && ($item['contact-id'] != $importer["id"])) { $condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]]; if (!Item::exists($condition)) { - Logger::log("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG); + Logger::log("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", Logger::DEBUG); return; } } @@ -2831,7 +2831,7 @@ class DFRN return; } - Logger::log('deleting item '.$item['id'].' uri='.$uri, LOGGER_DEBUG); + Logger::log('deleting item '.$item['id'].' uri='.$uri, Logger::DEBUG); Item::delete(['id' => $item['id']]); } @@ -2885,7 +2885,7 @@ class DFRN self::fetchauthor($xpath, $doc->firstChild, $importer, "dfrn:owner", false, $xml); } - Logger::log("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG); + Logger::log("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG); // is it a public forum? Private forums aren't exposed with this method $forum = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:community/text()")); @@ -2951,7 +2951,7 @@ class DFRN self::processEntry($header, $xpath, $entry, $importer, $xml); } } - Logger::log("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG); + Logger::log("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG); return 200; } @@ -3036,7 +3036,7 @@ class DFRN $url = curPageURL(); - Logger::log('auto_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); + Logger::log('auto_redir: ' . $r[0]['name'] . ' ' . $sec, Logger::DEBUG); $dest = (($url) ? '&destination_url=' . $url : ''); System::externalRedirect($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 516e7c63d..66a19d839 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -261,7 +261,7 @@ class Diaspora if (base64_encode(base64_decode(base64_decode($signature))) == base64_decode($signature)) { $signature = base64_decode($signature); - Logger::log("Repaired double encoded signature from Diaspora/Hubzilla handle ".$handle." - level ".$level, LOGGER_DEBUG); + Logger::log("Repaired double encoded signature from Diaspora/Hubzilla handle ".$handle." - level ".$level, Logger::DEBUG); // Do a recursive call to be able to fix even multiple levels if ($level < 10) { @@ -498,7 +498,7 @@ class Diaspora } else { // This happens with posts from a relais if (!$importer) { - Logger::log("This is no private post in the old format", LOGGER_DEBUG); + Logger::log("This is no private post in the old format", Logger::DEBUG); return false; } @@ -517,7 +517,7 @@ class Diaspora $decrypted = self::aesDecrypt($outer_key, $outer_iv, $ciphertext); - Logger::log('decrypted: '.$decrypted, LOGGER_DEBUG); + Logger::log('decrypted: '.$decrypted, Logger::DEBUG); $idom = XML::parseString($decrypted); $inner_iv = base64_decode($idom->iv); @@ -662,7 +662,7 @@ class Diaspora $type = $fields->getName(); - Logger::log("Received message type ".$type." from ".$sender." for user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Received message type ".$type." from ".$sender." for user ".$importer["uid"], Logger::DEBUG); switch ($type) { case "account_migration": @@ -754,7 +754,7 @@ class Diaspora $data = XML::parseString($msg["message"]); if (!is_object($data)) { - Logger::log("No valid XML ".$msg["message"], LOGGER_DEBUG); + Logger::log("No valid XML ".$msg["message"], Logger::DEBUG); return false; } @@ -772,7 +772,7 @@ class Diaspora $type = $element->getName(); $orig_type = $type; - Logger::log("Got message type ".$type.": ".$msg["message"], LOGGER_DATA); + Logger::log("Got message type ".$type.": ".$msg["message"], Logger::DATA); // All retractions are handled identically from now on. // In the new version there will only be "retraction". @@ -859,31 +859,31 @@ class Diaspora } // No author_signature? This is a must, so we quit. if (!isset($author_signature)) { - Logger::log("No author signature for type ".$type." - Message: ".$msg["message"], LOGGER_DEBUG); + Logger::log("No author signature for type ".$type." - Message: ".$msg["message"], Logger::DEBUG); return false; } if (isset($parent_author_signature)) { $key = self::key($msg["author"]); if (empty($key)) { - Logger::log("No key found for parent author ".$msg["author"], LOGGER_DEBUG); + Logger::log("No key found for parent author ".$msg["author"], Logger::DEBUG); return false; } if (!Crypto::rsaVerify($signed_data, $parent_author_signature, $key, "sha256")) { - Logger::log("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, LOGGER_DEBUG); + Logger::log("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, Logger::DEBUG); return false; } } $key = self::key($fields->author); if (empty($key)) { - Logger::log("No key found for author ".$fields->author, LOGGER_DEBUG); + Logger::log("No key found for author ".$fields->author, Logger::DEBUG); return false; } if (!Crypto::rsaVerify($signed_data, $author_signature, $key, "sha256")) { - Logger::log("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG); + Logger::log("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, Logger::DEBUG); return false; } else { return $fields; @@ -924,7 +924,7 @@ class Diaspora $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]); if (DBA::isResult($person)) { - Logger::log("In cache " . print_r($person, true), LOGGER_DEBUG); + Logger::log("In cache " . print_r($person, true), Logger::DEBUG); // update record occasionally so it doesn't get stale $d = strtotime($person["updated"]." +00:00"); @@ -938,7 +938,7 @@ class Diaspora } if (!DBA::isResult($person) || $update) { - Logger::log("create or refresh", LOGGER_DEBUG); + Logger::log("create or refresh", Logger::DEBUG); $r = Probe::uri($handle, Protocol::DIASPORA); // Note that Friendica contacts will return a "Diaspora person" @@ -990,7 +990,7 @@ class Diaspora { $handle = false; - Logger::log("contact id is ".$contact_id." - pcontact id is ".$pcontact_id, LOGGER_DEBUG); + Logger::log("contact id is ".$contact_id." - pcontact id is ".$pcontact_id, Logger::DEBUG); if ($pcontact_id != 0) { $contact = DBA::selectFirst('contact', ['addr'], ['id' => $pcontact_id]); @@ -1008,7 +1008,7 @@ class Diaspora if (DBA::isResult($r)) { $contact = $r[0]; - Logger::log("contact 'self' = ".$contact['self']." 'url' = ".$contact['url'], LOGGER_DEBUG); + Logger::log("contact 'self' = ".$contact['self']." 'url' = ".$contact['url'], Logger::DEBUG); if ($contact['addr'] != "") { $handle = $contact['addr']; @@ -1034,7 +1034,7 @@ class Diaspora */ public static function urlFromContactGuid($fcontact_guid) { - Logger::log("fcontact guid is ".$fcontact_guid, LOGGER_DEBUG); + Logger::log("fcontact guid is ".$fcontact_guid, Logger::DEBUG); $r = q( "SELECT `url` FROM `fcontact` WHERE `url` != '' AND `network` = '%s' AND `guid` = '%s'", @@ -1069,14 +1069,14 @@ class Diaspora } if (!$cid) { - Logger::log("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG); + Logger::log("Haven't found a contact for user " . $uid . " and handle " . $handle, Logger::DEBUG); return false; } $contact = DBA::selectFirst('contact', [], ['id' => $cid]); if (!DBA::isResult($contact)) { // This here shouldn't happen at all - Logger::log("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG); + Logger::log("Haven't found a contact for user " . $uid . " and handle " . $handle, Logger::DEBUG); return false; } @@ -1278,7 +1278,7 @@ class Diaspora $server = $serverparts["scheme"]."://".$serverparts["host"]; - Logger::log("Trying to fetch item ".$guid." from ".$server, LOGGER_DEBUG); + Logger::log("Trying to fetch item ".$guid." from ".$server, Logger::DEBUG); $msg = self::message($guid, $server); @@ -1286,7 +1286,7 @@ class Diaspora return false; } - Logger::log("Successfully fetched item ".$guid." from ".$server, LOGGER_DEBUG); + Logger::log("Successfully fetched item ".$guid." from ".$server, Logger::DEBUG); // Now call the dispatcher return self::dispatchPublic($msg); @@ -1313,16 +1313,16 @@ class Diaspora // This will work for new Diaspora servers and Friendica servers from 3.5 $source_url = $server."/fetch/post/".urlencode($guid); - Logger::log("Fetch post from ".$source_url, LOGGER_DEBUG); + Logger::log("Fetch post from ".$source_url, Logger::DEBUG); $envelope = Network::fetchUrl($source_url); if ($envelope) { - Logger::log("Envelope was fetched.", LOGGER_DEBUG); + Logger::log("Envelope was fetched.", Logger::DEBUG); $x = self::verifyMagicEnvelope($envelope); if (!$x) { - Logger::log("Envelope could not be verified.", LOGGER_DEBUG); + Logger::log("Envelope could not be verified.", Logger::DEBUG); } else { - Logger::log("Envelope was verified.", LOGGER_DEBUG); + Logger::log("Envelope was verified.", Logger::DEBUG); } } else { $x = false; @@ -1331,7 +1331,7 @@ class Diaspora // This will work for older Diaspora and Friendica servers if (!$x) { $source_url = $server."/p/".urlencode($guid).".xml"; - Logger::log("Fetch post from ".$source_url, LOGGER_DEBUG); + Logger::log("Fetch post from ".$source_url, Logger::DEBUG); $x = Network::fetchUrl($source_url); if (!$x) { @@ -1347,11 +1347,11 @@ class Diaspora if ($source_xml->post->reshare) { // Reshare of a reshare - old Diaspora version - Logger::log("Message is a reshare", LOGGER_DEBUG); + Logger::log("Message is a reshare", Logger::DEBUG); return self::message($source_xml->post->reshare->root_guid, $server, ++$level); } elseif ($source_xml->getName() == "reshare") { // Reshare of a reshare - new Diaspora version - Logger::log("Message is a new reshare", LOGGER_DEBUG); + Logger::log("Message is a new reshare", Logger::DEBUG); return self::message($source_xml->root_guid, $server, ++$level); } @@ -1366,7 +1366,7 @@ class Diaspora // If this isn't a "status_message" then quit if (!$author) { - Logger::log("Message doesn't seem to be a status message", LOGGER_DEBUG); + Logger::log("Message doesn't seem to be a status message", Logger::DEBUG); return false; } @@ -1405,7 +1405,7 @@ class Diaspora } if ($result) { - Logger::log("Fetched missing item ".$guid." - result: ".$result, LOGGER_DEBUG); + Logger::log("Fetched missing item ".$guid." - result: ".$result, Logger::DEBUG); $item = Item::selectFirst($fields, $condition); } @@ -1635,7 +1635,7 @@ class Diaspora { $item = Item::selectFirst(['uid'], ['origin' => true, 'guid' => $guid]); if (DBA::isResult($item)) { - Logger::log("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG); + Logger::log("Found user ".$item['uid']." as owner of item ".$guid, Logger::DEBUG); $contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]); if (DBA::isResult($contact)) { return $contact; @@ -1750,7 +1750,7 @@ class Diaspora } if ($message_id) { - Logger::log("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored comment ".$datarray["guid"]." with message id ".$message_id, Logger::DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id, json_encode($data)); } @@ -1805,7 +1805,7 @@ class Diaspora DBA::lock('mail'); if (DBA::exists('mail', ['guid' => $msg_guid, 'uid' => $importer["uid"]])) { - Logger::log("duplicate message already delivered.", LOGGER_DEBUG); + Logger::log("duplicate message already delivered.", Logger::DEBUG); return false; } @@ -2009,7 +2009,7 @@ class Diaspora } if ($message_id) { - Logger::log("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored like ".$datarray["guid"]." with message id ".$message_id, Logger::DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id, json_encode($data)); } @@ -2064,7 +2064,7 @@ class Diaspora DBA::lock('mail'); if (DBA::exists('mail', ['guid' => $guid, 'uid' => $importer["uid"]])) { - Logger::log("duplicate message already delivered.", LOGGER_DEBUG); + Logger::log("duplicate message already delivered.", Logger::DEBUG); return false; } @@ -2132,7 +2132,7 @@ class Diaspora $server = $author; } - Logger::log('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG); + Logger::log('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, Logger::DEBUG); if (!DBA::exists('participation', ['iid' => $item['id'], 'server' => $server])) { DBA::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]); @@ -2149,7 +2149,7 @@ class Diaspora } else { $cmd = $comment['self'] ? 'like' : 'comment-import'; } - Logger::log("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, LOGGER_DEBUG); + Logger::log("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, Logger::DEBUG); Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id); } DBA::close($comments); @@ -2275,7 +2275,7 @@ class Diaspora GContact::link($gcid, $importer["uid"], $contact["id"]); - Logger::log("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], Logger::DEBUG); return true; } @@ -2337,7 +2337,7 @@ class Diaspora // That makes us friends. if ($contact) { if ($following) { - Logger::log("Author ".$author." (Contact ".$contact["id"].") wants to follow us.", LOGGER_DEBUG); + Logger::log("Author ".$author." (Contact ".$contact["id"].") wants to follow us.", Logger::DEBUG); self::receiveRequestMakeFriend($importer, $contact); // refetch the contact array @@ -2348,30 +2348,30 @@ class Diaspora if (in_array($contact["rel"], [Contact::FRIEND])) { $user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]); if (DBA::isResult($user)) { - Logger::log("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], Logger::DEBUG); $ret = self::sendShare($user, $contact); } } return true; } else { - Logger::log("Author ".$author." doesn't want to follow us anymore.", LOGGER_DEBUG); + Logger::log("Author ".$author." doesn't want to follow us anymore.", Logger::DEBUG); Contact::removeFollower($importer, $contact); return true; } } if (!$following && $sharing && in_array($importer["page-flags"], [Contact::PAGE_SOAPBOX, Contact::PAGE_NORMAL])) { - Logger::log("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", Logger::DEBUG); return false; } elseif (!$following && !$sharing) { - Logger::log("Author ".$author." doesn't want anything - and we don't know the author. Request is ignored.", LOGGER_DEBUG); + Logger::log("Author ".$author." doesn't want anything - and we don't know the author. Request is ignored.", Logger::DEBUG); return false; } elseif (!$following && $sharing) { - Logger::log("Author ".$author." wants to share with us.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to share with us.", Logger::DEBUG); } elseif ($following && $sharing) { - Logger::log("Author ".$author." wants to have a bidirectional conection.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to have a bidirectional conection.", Logger::DEBUG); } elseif ($following && !$sharing) { - Logger::log("Author ".$author." wants to listen to us.", LOGGER_DEBUG); + Logger::log("Author ".$author." wants to listen to us.", Logger::DEBUG); } $ret = self::personByHandle($author); @@ -2412,14 +2412,14 @@ class Diaspora return; } - Logger::log("Author ".$author." was added as contact number ".$contact_record["id"].".", LOGGER_DEBUG); + Logger::log("Author ".$author." was added as contact number ".$contact_record["id"].".", Logger::DEBUG); Group::addMember(User::getDefaultGroup($importer['uid'], $ret["network"]), $contact_record['id']); Contact::updateAvatar($ret["photo"], $importer['uid'], $contact_record["id"], true); if (in_array($importer["page-flags"], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP])) { - Logger::log("Sending intra message for author ".$author.".", LOGGER_DEBUG); + Logger::log("Sending intra message for author ".$author.".", Logger::DEBUG); $hash = random_string().(string)time(); // Generate a confirm_key @@ -2437,7 +2437,7 @@ class Diaspora } else { // automatic friend approval - Logger::log("Does an automatic friend approval for author ".$author.".", LOGGER_DEBUG); + Logger::log("Does an automatic friend approval for author ".$author.".", Logger::DEBUG); Contact::updateAvatar($contact_record["photo"], $importer["uid"], $contact_record["id"]); @@ -2471,7 +2471,7 @@ class Diaspora $user = DBA::selectFirst('user', [], ['uid' => $importer["uid"]]); if (DBA::isResult($user)) { - Logger::log("Sending share message (Relation: ".$new_relation.") to author ".$author." - Contact: ".$contact_record["id"]." - User: ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Sending share message (Relation: ".$new_relation.") to author ".$author." - Contact: ".$contact_record["id"]." - User: ".$importer["uid"], Logger::DEBUG); $ret = self::sendShare($user, $contact_record); // Send the profile data, maybe it weren't transmitted before @@ -2644,7 +2644,7 @@ class Diaspora self::sendParticipation($contact, $datarray); if ($message_id) { - Logger::log("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored reshare ".$datarray["guid"]." with message id ".$message_id, Logger::DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id); } @@ -2697,7 +2697,7 @@ class Diaspora while ($item = Item::fetch($r)) { if (strstr($item['file'], '[')) { - Logger::log("Target guid " . $target_guid . " for user " . $item['uid'] . " is filed. So it won't be deleted.", LOGGER_DEBUG); + Logger::log("Target guid " . $target_guid . " for user " . $item['uid'] . " is filed. So it won't be deleted.", Logger::DEBUG); continue; } @@ -2706,13 +2706,13 @@ class Diaspora // Only delete it if the parent author really fits if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) { - Logger::log("Thread author ".$parent["author-link"]." and item author ".$item["author-link"]." don't fit to expected contact ".$contact["url"], LOGGER_DEBUG); + Logger::log("Thread author ".$parent["author-link"]." and item author ".$item["author-link"]." don't fit to expected contact ".$contact["url"], Logger::DEBUG); continue; } Item::delete(['id' => $item['id']]); - Logger::log("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], LOGGER_DEBUG); + Logger::log("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], Logger::DEBUG); } return true; @@ -2741,7 +2741,7 @@ class Diaspora $contact = []; } - Logger::log("Got retraction for ".$target_type.", sender ".$sender." and user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Got retraction for ".$target_type.", sender ".$sender." and user ".$importer["uid"], Logger::DEBUG); switch ($target_type) { case "Comment": @@ -2871,7 +2871,7 @@ class Diaspora self::sendParticipation($contact, $datarray); if ($message_id) { - Logger::log("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + Logger::log("Stored item ".$datarray["guid"]." with message id ".$message_id, Logger::DEBUG); if ($datarray['uid'] == 0) { Item::distribute($message_id); } @@ -2923,7 +2923,7 @@ class Diaspora */ public static function encodePrivateData($msg, array $user, array $contact, $prvkey, $pubkey) { - Logger::log("Message: ".$msg, LOGGER_DATA); + Logger::log("Message: ".$msg, Logger::DATA); // without a public key nothing will work if (!$pubkey) { @@ -3141,8 +3141,8 @@ class Diaspora { $msg = self::buildPostXml($type, $message); - Logger::log('message: '.$msg, LOGGER_DATA); - Logger::log('send guid '.$guid, LOGGER_DEBUG); + Logger::log('message: '.$msg, Logger::DATA); + Logger::log('send guid '.$guid, Logger::DEBUG); // Fallback if the private key wasn't transmitted in the expected field if (empty($owner['uprvkey'])) { @@ -3158,7 +3158,7 @@ class Diaspora $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid); } - Logger::log("guid: ".$guid." result ".$return_code, LOGGER_DEBUG); + Logger::log("guid: ".$guid." result ".$return_code, Logger::DEBUG); return $return_code; } @@ -3203,7 +3203,7 @@ class Diaspora "parent_type" => "Post", "parent_guid" => $item["guid"]]; - Logger::log("Send participation for ".$item["guid"]." by ".$author, LOGGER_DEBUG); + Logger::log("Send participation for ".$item["guid"]." by ".$author, Logger::DEBUG); // It doesn't matter what we store, we only want to avoid sending repeated notifications for the same item Cache::set($cachekey, $item["guid"], Cache::QUARTER_HOUR); @@ -3232,7 +3232,7 @@ class Diaspora "profile" => $profile, "signature" => $signature]; - Logger::log("Send account migration ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Send account migration ".print_r($message, true), Logger::DEBUG); return self::buildAndTransmit($owner, $contact, "account_migration", $message); } @@ -3275,7 +3275,7 @@ class Diaspora "following" => "true", "sharing" => "true"]; - Logger::log("Send share ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Send share ".print_r($message, true), Logger::DEBUG); return self::buildAndTransmit($owner, $contact, "contact", $message); } @@ -3295,7 +3295,7 @@ class Diaspora "following" => "false", "sharing" => "false"]; - Logger::log("Send unshare ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Send unshare ".print_r($message, true), Logger::DEBUG); return self::buildAndTransmit($owner, $contact, "contact", $message); } @@ -3808,7 +3808,7 @@ class Diaspora $type = "comment"; } - Logger::log("Got relayable data ".$type." for item ".$item["guid"]." (".$item["id"].")", LOGGER_DEBUG); + Logger::log("Got relayable data ".$type." for item ".$item["guid"]." (".$item["id"].")", Logger::DEBUG); // Old way - is used by the internal Friendica functions /// @todo Change all signatur storing functions to the new format @@ -3832,13 +3832,13 @@ class Diaspora $message[$field] = $data; } } else { - Logger::log("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$item['signed_text'], LOGGER_DEBUG); + Logger::log("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$item['signed_text'], Logger::DEBUG); } } $message["parent_author_signature"] = self::signature($owner, $message); - Logger::log("Relayed data ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Relayed data ".print_r($message, true), Logger::DEBUG); return self::buildAndTransmit($owner, $contact, $type, $message, $public_batch, $item["guid"]); } @@ -3872,7 +3872,7 @@ class Diaspora "target_guid" => $item['guid'], "target_type" => $target_type]; - Logger::log("Got message ".print_r($message, true), LOGGER_DEBUG); + Logger::log("Got message ".print_r($message, true), Logger::DEBUG); return self::buildAndTransmit($owner, $contact, $msg_type, $message, $public_batch, $item["guid"]); } @@ -4108,7 +4108,7 @@ class Diaspora $message = self::createProfileData($uid); foreach ($recips as $recip) { - Logger::log("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG); + Logger::log("Send updated profile data for user ".$uid." to contact ".$recip["id"], Logger::DEBUG); self::buildAndTransmit($owner, $recip, "profile", $message, false, "", false); } } @@ -4125,7 +4125,7 @@ class Diaspora { $owner = User::getOwnerDataById($uid); if (empty($owner)) { - Logger::log("No owner post, so not storing signature", LOGGER_DEBUG); + Logger::log("No owner post, so not storing signature", Logger::DEBUG); return false; } @@ -4155,7 +4155,7 @@ class Diaspora { $owner = User::getOwnerDataById($uid); if (empty($owner)) { - Logger::log("No owner post, so not storing signature", LOGGER_DEBUG); + Logger::log("No owner post, so not storing signature", Logger::DEBUG); return false; } diff --git a/src/Protocol/Email.php b/src/Protocol/Email.php index 5dba94ee5..bb70972b0 100644 --- a/src/Protocol/Email.php +++ b/src/Protocol/Email.php @@ -55,21 +55,21 @@ class Email if (!$search1) { $search1 = []; } else { - Logger::log("Found mails from ".$email_addr, LOGGER_DEBUG); + Logger::log("Found mails from ".$email_addr, Logger::DEBUG); } $search2 = @imap_search($mbox, 'TO "' . $email_addr . '"', SE_UID); if (!$search2) { $search2 = []; } else { - Logger::log("Found mails to ".$email_addr, LOGGER_DEBUG); + Logger::log("Found mails to ".$email_addr, Logger::DEBUG); } $search3 = @imap_search($mbox, 'CC "' . $email_addr . '"', SE_UID); if (!$search3) { $search3 = []; } else { - Logger::log("Found mails cc ".$email_addr, LOGGER_DEBUG); + Logger::log("Found mails cc ".$email_addr, Logger::DEBUG); } $res = array_unique(array_merge($search1, $search2, $search3)); diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 32ff61756..71ebe5506 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -41,12 +41,12 @@ class Feed { $a = get_app(); if (!$simulate) { - Logger::log("Import Atom/RSS feed '".$contact["name"]."' (Contact ".$contact["id"].") for user ".$importer["uid"], LOGGER_DEBUG); + Logger::log("Import Atom/RSS feed '".$contact["name"]."' (Contact ".$contact["id"].") for user ".$importer["uid"], Logger::DEBUG); } else { - Logger::log("Test Atom/RSS feed", LOGGER_DEBUG); + Logger::log("Test Atom/RSS feed", Logger::DEBUG); } if (empty($xml)) { - Logger::log('XML is empty.', LOGGER_DEBUG); + Logger::log('XML is empty.', Logger::DEBUG); return; } @@ -200,7 +200,7 @@ class Feed { $header["contact-id"] = $contact["id"]; if (!is_object($entries)) { - Logger::log("There are no entries in this feed.", LOGGER_DEBUG); + Logger::log("There are no entries in this feed.", Logger::DEBUG); return; } @@ -249,7 +249,7 @@ class Feed { $importer["uid"], $item["uri"], Protocol::FEED, Protocol::DFRN]; $previous = Item::selectFirst(['id'], $condition); if (DBA::isResult($previous)) { - Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG); + Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], Logger::DEBUG); continue; } } @@ -424,7 +424,7 @@ class Feed { } if (!$simulate) { - Logger::log("Stored feed: ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Stored feed: ".print_r($item, true), Logger::DEBUG); $notify = Item::isRemoteSelf($contact, $item); diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index e7be6325b..a1857c5db 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -196,7 +196,7 @@ class OStatus DBA::update('contact', $contact, ['id' => $contact["id"]], $current); if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) { - Logger::log("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG); + Logger::log("Update profile picture for contact ".$contact["id"], Logger::DEBUG); Contact::updateAvatar($author["author-avatar"], $importer["uid"], $contact["id"]); } @@ -323,7 +323,7 @@ class OStatus self::$conv_list = []; } - Logger::log('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG); + Logger::log('Import OStatus message for user ' . $importer['uid'], Logger::DEBUG); if ($xml == "") { return false; @@ -349,7 +349,7 @@ class OStatus foreach ($hub_attributes as $hub_attribute) { if ($hub_attribute->name == "href") { $hub = $hub_attribute->textContent; - Logger::log("Found hub ".$hub, LOGGER_DEBUG); + Logger::log("Found hub ".$hub, Logger::DEBUG); } } } @@ -434,27 +434,27 @@ class OStatus if (in_array($item["verb"], [NAMESPACE_OSTATUS."/unfavorite", ACTIVITY_UNFAVORITE])) { // Ignore "Unfavorite" message - Logger::log("Ignore unfavorite message ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG); continue; } // Deletions come with the same uri, so we check for duplicates after processing deletions if (Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]])) { - Logger::log('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG); continue; } else { - Logger::log('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.', Logger::DEBUG); } if ($item["verb"] == ACTIVITY_JOIN) { // ignore "Join" messages - Logger::log("Ignore join message ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Ignore join message ".print_r($item, true), Logger::DEBUG); continue; } if ($item["verb"] == "http://mastodon.social/schema/1.0/block") { // ignore mastodon "block" messages - Logger::log("Ignore block message ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Ignore block message ".print_r($item, true), Logger::DEBUG); continue; } @@ -481,7 +481,7 @@ class OStatus // http://activitystrea.ms/schema/1.0/rsvp-yes if (!in_array($item["verb"], [ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE])) { - Logger::log("Unhandled verb ".$item["verb"]." ".print_r($item, true), LOGGER_DEBUG); + Logger::log("Unhandled verb ".$item["verb"]." ".print_r($item, true), Logger::DEBUG); } self::processPost($xpath, $entry, $item, $importer); @@ -494,10 +494,10 @@ class OStatus // If not, then it depends on this setting $valid = !Config::get('system', 'ostatus_full_threads'); if ($valid) { - Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.", Logger::DEBUG); } } else { - Logger::log("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported.", Logger::DEBUG); } if ($valid) { // Never post a thread when the only interaction by our contact was a like @@ -509,14 +509,14 @@ class OStatus } } if ($valid) { - Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported since the thread contains posts or shares.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported since the thread contains posts or shares.", Logger::DEBUG); } } } else { // But we will only import complete threads $valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]); if ($valid) { - Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", LOGGER_DEBUG); + Logger::log("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", Logger::DEBUG); } } @@ -533,9 +533,9 @@ class OStatus foreach (self::$itemlist as $item) { $found = Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]]); if ($found) { - Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG); + Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", Logger::DEBUG); } elseif ($item['contact-id'] < 0) { - Logger::log("Item with uri ".$item["uri"]." is from a blocked contact.", LOGGER_DEBUG); + Logger::log("Item with uri ".$item["uri"]." is from a blocked contact.", Logger::DEBUG); } else { // We are having duplicated entries. Hopefully this solves it. if (Lock::acquire('ostatus_process_item_insert')) { @@ -551,7 +551,7 @@ class OStatus } self::$itemlist = []; } - Logger::log('Processing done for post with URI '.$item["uri"].' for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Processing done for post with URI '.$item["uri"].' for user '.$importer["uid"].'.', Logger::DEBUG); } return true; } @@ -707,7 +707,7 @@ class OStatus self::fetchRelated($related, $item["parent-uri"], $importer); } } else { - Logger::log('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG); + Logger::log('Reply with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', Logger::DEBUG); } } else { $item["parent-uri"] = $item["uri"]; @@ -853,11 +853,11 @@ class OStatus $condition = ['item-uri' => $conv_data['uri'],'protocol' => Conversation::PARCEL_FEED]; if (DBA::exists('conversation', $condition)) { - Logger::log('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG); + Logger::log('Delete deprecated entry for URI '.$conv_data['uri'], Logger::DEBUG); DBA::delete('conversation', ['item-uri' => $conv_data['uri']]); } - Logger::log('Store conversation data for uri '.$conv_data['uri'], LOGGER_DEBUG); + Logger::log('Store conversation data for uri '.$conv_data['uri'], Logger::DEBUG); Conversation::insert($conv_data); } } @@ -877,7 +877,7 @@ class OStatus { $condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $self, Conversation::PARCEL_DFRN, Conversation::PARCEL_SALMON]; if (DBA::exists('conversation', $condition)) { - Logger::log('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG); + Logger::log('Conversation '.$item['uri'].' is already stored.', Logger::DEBUG); return; } @@ -897,7 +897,7 @@ class OStatus $item["protocol"] = Conversation::PARCEL_SALMON; $item["source"] = $xml; - Logger::log('Conversation '.$item['uri'].' is now fetched.', LOGGER_DEBUG); + Logger::log('Conversation '.$item['uri'].' is now fetched.', Logger::DEBUG); } /** @@ -916,11 +916,11 @@ class OStatus $stored = true; $xml = $conversation['source']; if (self::process($xml, $importer, $contact, $hub, $stored, false)) { - Logger::log('Got valid cached XML for URI '.$related_uri, LOGGER_DEBUG); + Logger::log('Got valid cached XML for URI '.$related_uri, Logger::DEBUG); return; } if ($conversation['protocol'] == Conversation::PARCEL_SALMON) { - Logger::log('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG); + Logger::log('Delete invalid cached XML for URI '.$related_uri, Logger::DEBUG); DBA::delete('conversation', ['item-uri' => $related_uri]); } } @@ -935,7 +935,7 @@ class OStatus $xml = ''; if (stristr($curlResult->getHeader(), 'Content-Type: application/atom+xml')) { - Logger::log('Directly fetched XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('Directly fetched XML for URI ' . $related_uri, Logger::DEBUG); $xml = $curlResult->getBody(); } @@ -960,7 +960,7 @@ class OStatus $curlResult = Network::curl($atom_file); if ($curlResult->isSuccess()) { - Logger::log('Fetched XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('Fetched XML for URI ' . $related_uri, Logger::DEBUG); $xml = $curlResult->getBody(); } } @@ -972,7 +972,7 @@ class OStatus $curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related).'.atom'); if ($curlResult->isSuccess()) { - Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, Logger::DEBUG); $xml = $curlResult->getBody(); } } @@ -983,7 +983,7 @@ class OStatus $curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom'); if ($curlResult->isSuccess()) { - Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, LOGGER_DEBUG); + Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, Logger::DEBUG); $xml = $curlResult->getBody(); } } @@ -994,7 +994,7 @@ class OStatus $conversation = DBA::selectFirst('conversation', ['source'], $condition); if (DBA::isResult($conversation)) { $stored = true; - Logger::log('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG); + Logger::log('Got cached XML from conversation for URI '.$related_uri, Logger::DEBUG); $xml = $conversation['source']; } } @@ -1002,7 +1002,7 @@ class OStatus if ($xml != '') { self::process($xml, $importer, $contact, $hub, $stored, false); } else { - Logger::log("XML couldn't be fetched for URI: ".$related_uri." - href: ".$related, LOGGER_DEBUG); + Logger::log("XML couldn't be fetched for URI: ".$related_uri." - href: ".$related, Logger::DEBUG); } return; } @@ -1652,7 +1652,7 @@ class OStatus private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { - Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); + Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG); } $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel); @@ -1715,7 +1715,7 @@ class OStatus private static function likeEntry(DOMDocument $doc, array $item, array $owner, $toplevel) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { - Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); + Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG); } $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel); @@ -1862,7 +1862,7 @@ class OStatus private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel) { if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) { - Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", LOGGER_DEBUG); + Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG); } $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel); @@ -2153,7 +2153,7 @@ class OStatus if ((time() - strtotime($owner['last-item'])) < 15*60) { $result = Cache::get($cachekey); if (!$nocache && !is_null($result)) { - Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', LOGGER_DEBUG); + Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', Logger::DEBUG); $last_update = $result['last_update']; return $result['feed']; } @@ -2213,7 +2213,7 @@ class OStatus $msg = ['feed' => $feeddata, 'last_update' => $last_update]; Cache::set($cachekey, $msg, Cache::QUARTER_HOUR); - Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG); + Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, Logger::DEBUG); return $feeddata; } diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 1cd566336..fb8b48d7c 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -85,14 +85,14 @@ class PortableContact $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation') ; - Logger::log('load: ' . $url, LOGGER_DEBUG); + Logger::log('load: ' . $url, Logger::DEBUG); $fetchresult = Network::fetchUrlFull($url); $s = $fetchresult->getBody(); - Logger::log('load: returns ' . $s, LOGGER_DATA); + Logger::log('load: returns ' . $s, Logger::DATA); - Logger::log('load: return code: ' . $fetchresult->getReturnCode(), LOGGER_DEBUG); + Logger::log('load: return code: ' . $fetchresult->getReturnCode(), Logger::DEBUG); if (($fetchresult->getReturnCode() > 299) || (! $s)) { return; @@ -100,7 +100,7 @@ class PortableContact $j = json_decode($s, true); - Logger::log('load: json: ' . print_r($j, true), LOGGER_DATA); + Logger::log('load: json: ' . print_r($j, true), Logger::DATA); if (!isset($j['entry'])) { return; @@ -200,10 +200,10 @@ class PortableContact GContact::link($gcid, $uid, $cid, $zcid); } catch (Exception $e) { - Logger::log($e->getMessage(), LOGGER_DEBUG); + Logger::log($e->getMessage(), Logger::DEBUG); } } - Logger::log("load: loaded $total entries", LOGGER_DEBUG); + Logger::log("load: loaded $total entries", Logger::DEBUG); $condition = ["`cid` = ? AND `uid` = ? AND `zcid` = ? AND `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", $cid, $uid, $zcid]; DBA::delete('glink', $condition); @@ -336,7 +336,7 @@ class PortableContact } if (!in_array($gcontacts[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) { - Logger::log("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG); + Logger::log("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", Logger::DEBUG); return false; } @@ -347,7 +347,7 @@ class PortableContact DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); } - Logger::log("Profile ".$profile.": Server ".$server_url." wasn't reachable.", LOGGER_DEBUG); + Logger::log("Profile ".$profile.": Server ".$server_url." wasn't reachable.", Logger::DEBUG); return false; } $contact['server_url'] = $server_url; @@ -427,7 +427,7 @@ class PortableContact $fields = ['last_contact' => DateTimeFormat::utcNow()]; DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); - Logger::log("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", Logger::DEBUG); return $noscrape["updated"]; } @@ -438,7 +438,7 @@ class PortableContact // If we only can poll the feed, then we only do this once a while if (!$force && !self::updateNeeded($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"])) { - Logger::log("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", Logger::DEBUG); GContact::update($contact); return $gcontacts[0]["updated"]; @@ -465,10 +465,10 @@ class PortableContact self::lastUpdated($data["url"], $force); } catch (Exception $e) { - Logger::log($e->getMessage(), LOGGER_DEBUG); + Logger::log($e->getMessage(), Logger::DEBUG); } - Logger::log("Profile ".$profile." was deleted", LOGGER_DEBUG); + Logger::log("Profile ".$profile." was deleted", Logger::DEBUG); return false; } @@ -476,7 +476,7 @@ class PortableContact $fields = ['last_failure' => DateTimeFormat::utcNow()]; DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); - Logger::log("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." wasn't reachable (profile)", Logger::DEBUG); return false; } @@ -492,7 +492,7 @@ class PortableContact $fields = ['last_failure' => DateTimeFormat::utcNow()]; DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); - Logger::log("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG); + Logger::log("Profile ".$profile." wasn't reachable (no feed)", Logger::DEBUG); return false; } @@ -540,7 +540,7 @@ class PortableContact DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); } - Logger::log("Profile ".$profile." was last updated at ".$last_updated, LOGGER_DEBUG); + Logger::log("Profile ".$profile." was last updated at ".$last_updated, Logger::DEBUG); return $last_updated; } @@ -663,7 +663,7 @@ class PortableContact foreach ($nodeinfo['links'] as $link) { if (!is_array($link) || empty($link['rel'])) { - Logger::log('Invalid nodeinfo format for ' . $server_url, LOGGER_DEBUG); + Logger::log('Invalid nodeinfo format for ' . $server_url, Logger::DEBUG); continue; } if ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/1.0') { @@ -964,7 +964,7 @@ class PortableContact } if (!$force && !self::updateNeeded($gserver["created"], "", $last_failure, $last_contact)) { - Logger::log("Use cached data for server ".$server_url, LOGGER_DEBUG); + Logger::log("Use cached data for server ".$server_url, Logger::DEBUG); return ($last_contact >= $last_failure); } } else { @@ -980,7 +980,7 @@ class PortableContact $last_contact = DBA::NULL_DATETIME; $last_failure = DBA::NULL_DATETIME; } - Logger::log("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG); + Logger::log("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$gserver["created"]." Failure: ".$last_failure." Contact: ".$last_contact, Logger::DEBUG); $failure = false; $possible_failure = false; @@ -1005,7 +1005,7 @@ class PortableContact // But we want to make sure to only quit if we are mostly sure that this server url fits. if (DBA::isResult($gserver) && ($orig_server_url == $server_url) && ($curlResult->isTimeout())) { - Logger::log("Connection to server ".$server_url." timed out.", LOGGER_DEBUG); + Logger::log("Connection to server ".$server_url." timed out.", Logger::DEBUG); DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]); return false; } @@ -1020,7 +1020,7 @@ class PortableContact // Quit if there is a timeout if ($curlResult->isTimeout()) { - Logger::log("Connection to server " . $server_url . " timed out.", LOGGER_DEBUG); + Logger::log("Connection to server " . $server_url . " timed out.", Logger::DEBUG); DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]); return false; } @@ -1399,9 +1399,9 @@ class PortableContact } if (($last_contact <= $last_failure) && !$failure) { - Logger::log("Server ".$server_url." seems to be alive, but last contact wasn't set - could be a bug", LOGGER_DEBUG); + Logger::log("Server ".$server_url." seems to be alive, but last contact wasn't set - could be a bug", Logger::DEBUG); } elseif (($last_contact >= $last_failure) && $failure) { - Logger::log("Server ".$server_url." seems to be dead, but last failure wasn't set - could be a bug", LOGGER_DEBUG); + Logger::log("Server ".$server_url." seems to be dead, but last failure wasn't set - could be a bug", Logger::DEBUG); } // Check again if the server exists @@ -1430,7 +1430,7 @@ class PortableContact self::discoverRelay($server_url); } - Logger::log("End discovery for server " . $server_url, LOGGER_DEBUG); + Logger::log("End discovery for server " . $server_url, Logger::DEBUG); return !$failure; } @@ -1442,7 +1442,7 @@ class PortableContact */ private static function discoverRelay($server_url) { - Logger::log("Discover relay data for server " . $server_url, LOGGER_DEBUG); + Logger::log("Discover relay data for server " . $server_url, Logger::DEBUG); $curlResult = Network::curl($server_url . "/.well-known/x-social-relay"); @@ -1558,7 +1558,7 @@ class PortableContact $r = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", DBA::escape(normalise_link($server_url))); if (!DBA::isResult($r)) { - Logger::log("Call server check for server ".$server_url, LOGGER_DEBUG); + Logger::log("Call server check for server ".$server_url, Logger::DEBUG); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $server_url); } } @@ -1643,7 +1643,7 @@ class PortableContact // Fetch all users from the other server $url = $server["poco"] . "/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; - Logger::log("Fetch all users from the server " . $server["url"], LOGGER_DEBUG); + Logger::log("Fetch all users from the server " . $server["url"], Logger::DEBUG); $curlResult = Network::curl($url); @@ -1671,7 +1671,7 @@ class PortableContact $curlResult = Network::curl($url); if ($curlResult->isSuccess() && !empty($curlResult->getBody())) { - Logger::log("Fetch all global contacts from the server " . $server["nurl"], LOGGER_DEBUG); + Logger::log("Fetch all global contacts from the server " . $server["nurl"], Logger::DEBUG); $data = json_decode($curlResult->getBody(), true); if (!empty($data)) { @@ -1680,7 +1680,7 @@ class PortableContact } if (!$success && (Config::get('system', 'poco_discovery') > 2)) { - Logger::log("Fetch contacts from users of the server " . $server["nurl"], LOGGER_DEBUG); + Logger::log("Fetch contacts from users of the server " . $server["nurl"], Logger::DEBUG); self::discoverServerUsers($data, $server); } } @@ -1733,7 +1733,7 @@ class PortableContact continue; } - Logger::log('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], LOGGER_DEBUG); + Logger::log('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], Logger::DEBUG); Worker::add(PRIORITY_LOW, 'DiscoverPoCo', 'update_server_directory', (int) $gserver['id']); if (!$complete && ( --$no_of_queries == 0)) { @@ -1763,7 +1763,7 @@ class PortableContact } if ($username != '') { - Logger::log('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], LOGGER_DEBUG); + Logger::log('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], Logger::DEBUG); // Fetch all contacts from a given user from the other server $url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation'; @@ -1866,7 +1866,7 @@ class PortableContact if ($generation > 0) { $success = true; - Logger::log("Store profile ".$profile_url, LOGGER_DEBUG); + Logger::log("Store profile ".$profile_url, Logger::DEBUG); $gcontact = ["url" => $profile_url, "name" => $name, @@ -1885,10 +1885,10 @@ class PortableContact $gcontact = GContact::sanitize($gcontact); GContact::update($gcontact); } catch (Exception $e) { - Logger::log($e->getMessage(), LOGGER_DEBUG); + Logger::log($e->getMessage(), Logger::DEBUG); } - Logger::log("Done for profile ".$profile_url, LOGGER_DEBUG); + Logger::log("Done for profile ".$profile_url, Logger::DEBUG); } } return $success; diff --git a/src/Util/Emailer.php b/src/Util/Emailer.php index b69ceda51..42aab8f5f 100644 --- a/src/Util/Emailer.php +++ b/src/Util/Emailer.php @@ -97,8 +97,8 @@ class Emailer $hookdata['headers'], $hookdata['parameters'] ); - Logger::log("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); - Logger::log("return value " . (($res)?"true":"false"), LOGGER_DEBUG); + Logger::log("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, Logger::DEBUG); + Logger::log("return value " . (($res)?"true":"false"), Logger::DEBUG); return $res; } } diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index cecfe8c26..408f4d978 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -98,7 +98,7 @@ class HTTPSignature $x = Crypto::rsaVerify($signed_data, $sig_block['signature'], $key, $algorithm); - Logger::log('verified: ' . $x, LOGGER_DEBUG); + Logger::log('verified: ' . $x, Logger::DEBUG); if (!$x) { return $result; @@ -433,12 +433,12 @@ class HTTPSignature $profile = APContact::getByURL($url); if (!empty($profile)) { - Logger::log('Taking key from id ' . $id, LOGGER_DEBUG); + Logger::log('Taking key from id ' . $id, Logger::DEBUG); return ['url' => $url, 'pubkey' => $profile['pubkey']]; } elseif ($url != $actor) { $profile = APContact::getByURL($actor); if (!empty($profile)) { - Logger::log('Taking key from actor ' . $actor, LOGGER_DEBUG); + Logger::log('Taking key from actor ' . $actor, Logger::DEBUG); return ['url' => $actor, 'pubkey' => $profile['pubkey']]; } } diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index 2d16172b7..feaf3e62f 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -66,7 +66,7 @@ class JsonLD } catch (Exception $e) { $normalized = false; - Logger::log('normalise error:' . print_r($e, true), LOGGER_DEBUG); + Logger::log('normalise error:' . print_r($e, true), Logger::DEBUG); } return $normalized; @@ -99,7 +99,7 @@ class JsonLD } catch (Exception $e) { $compacted = false; - Logger::log('compacting error:' . print_r($e, true), LOGGER_DEBUG); + Logger::log('compacting error:' . print_r($e, true), Logger::DEBUG); } return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true); diff --git a/src/Util/Network.php b/src/Util/Network.php index 0a36f47f5..255b3c8c4 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -107,7 +107,7 @@ class Network $url = self::unparseURL($parts); if (self::isUrlBlocked($url)) { - Logger::log('domain of ' . $url . ' is blocked', LOGGER_DATA); + Logger::log('domain of ' . $url . ' is blocked', Logger::DATA); return CurlResult::createErrorCurl($url); } @@ -241,7 +241,7 @@ class Network $stamp1 = microtime(true); if (self::isUrlBlocked($url)) { - Logger::log('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA); + Logger::log('post_url: domain of ' . $url . ' is blocked', Logger::DATA); return CurlResult::createErrorCurl($url); } @@ -252,7 +252,7 @@ class Network return CurlResult::createErrorCurl($url); } - Logger::log('post_url: start ' . $url, LOGGER_DATA); + Logger::log('post_url: start ' . $url, Logger::DATA); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -324,7 +324,7 @@ class Network $a->saveTimestamp($stamp1, 'network'); - Logger::log('post_url: end ' . $url, LOGGER_DATA); + Logger::log('post_url: end ' . $url, Logger::DATA); return $curlResponse; } @@ -528,7 +528,7 @@ class Network $avatar['url'] = System::baseUrl() . '/images/person-300.jpg'; } - Logger::log('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG); + Logger::log('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], Logger::DEBUG); return $avatar['url']; } diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 0475eda5a..6530959f2 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -124,7 +124,7 @@ class ParseUrl } if ($count > 10) { - Logger::log('Endless loop detected for ' . $url, LOGGER_DEBUG); + Logger::log('Endless loop detected for ' . $url, Logger::DEBUG); return $siteinfo; } @@ -188,7 +188,7 @@ class ParseUrl } if (($charset != '') && (strtoupper($charset) != 'UTF-8')) { - Logger::log('detected charset ' . $charset, LOGGER_DEBUG); + Logger::log('detected charset ' . $charset, Logger::DEBUG); $body = iconv($charset, 'UTF-8//TRANSLIT', $body); } @@ -422,7 +422,7 @@ class ParseUrl } } - Logger::log('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), LOGGER_DEBUG); + Logger::log('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), Logger::DEBUG); Addon::callHooks('getsiteinfo', $siteinfo); diff --git a/src/Util/XML.php b/src/Util/XML.php index 5abafec00..865c60406 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -276,9 +276,9 @@ class XML @xml_parser_free($parser); if (! $xml_values) { - Logger::log('Xml::toArray: libxml: parse error: ' . $contents, LOGGER_DATA); + Logger::log('Xml::toArray: libxml: parse error: ' . $contents, Logger::DATA); foreach (libxml_get_errors() as $err) { - Logger::log('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message, LOGGER_DATA); + Logger::log('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message, Logger::DATA); } libxml_clear_errors(); return; @@ -424,9 +424,9 @@ class XML $x = @simplexml_load_string($s); if (!$x) { - Logger::log('libxml: parse: error: ' . $s, LOGGER_DATA); + Logger::log('libxml: parse: error: ' . $s, Logger::DATA); foreach (libxml_get_errors() as $err) { - Logger::log('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA); + Logger::log('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, Logger::DATA); } libxml_clear_errors(); } diff --git a/src/Worker/APDelivery.php b/src/Worker/APDelivery.php index c800ee02d..ce82db249 100644 --- a/src/Worker/APDelivery.php +++ b/src/Worker/APDelivery.php @@ -23,7 +23,7 @@ class APDelivery extends BaseObject */ public static function execute($cmd, $item_id, $inbox, $uid) { - Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG); + Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, Logger::DEBUG); $success = true; diff --git a/src/Worker/CheckVersion.php b/src/Worker/CheckVersion.php index 0d87bb982..f67fb21c8 100644 --- a/src/Worker/CheckVersion.php +++ b/src/Worker/CheckVersion.php @@ -37,11 +37,11 @@ class CheckVersion // don't check return; } - Logger::log("Checking VERSION from: ".$checked_url, LOGGER_DEBUG); + Logger::log("Checking VERSION from: ".$checked_url, Logger::DEBUG); // fetch the VERSION file $gitversion = DBA::escape(trim(Network::fetchUrl($checked_url))); - Logger::log("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG); + Logger::log("Upstream VERSION is: ".$gitversion, Logger::DEBUG); Config::set('system', 'git_friendica_version', $gitversion); diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index ae3f48617..0c565daa7 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -34,7 +34,7 @@ class CronJobs return; } - Logger::log("Starting cronjob " . $command, LOGGER_DEBUG); + Logger::log("Starting cronjob " . $command, Logger::DEBUG); // Call possible post update functions // see src/Database/PostUpdate.php for more details @@ -83,7 +83,7 @@ class CronJobs return; } - Logger::log("Xronjob " . $command . " is unknown.", LOGGER_DEBUG); + Logger::log("Xronjob " . $command . " is unknown.", Logger::DEBUG); return; } @@ -212,7 +212,7 @@ class CronJobs // Calculate fragmentation $fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]); - Logger::log("Table " . $table["Name"] . " - Fragmentation level: " . round($fragmentation * 100, 2), LOGGER_DEBUG); + Logger::log("Table " . $table["Name"] . " - Fragmentation level: " . round($fragmentation * 100, 2), Logger::DEBUG); // Don't optimize tables that needn't to be optimized if ($fragmentation < $fragmentation_level) { @@ -220,7 +220,7 @@ class CronJobs } // So optimize it - Logger::log("Optimize Table " . $table["Name"], LOGGER_DEBUG); + Logger::log("Optimize Table " . $table["Name"], Logger::DEBUG); q("OPTIMIZE TABLE `%s`", DBA::escape($table["Name"])); } } @@ -259,7 +259,7 @@ class CronJobs continue; } - Logger::log("Repair contact " . $contact["id"] . " " . $contact["url"], LOGGER_DEBUG); + Logger::log("Repair contact " . $contact["id"] . " " . $contact["url"], Logger::DEBUG); q("UPDATE `contact` SET `batch` = '%s', `notify` = '%s', `poll` = '%s', pubkey = '%s' WHERE `id` = %d", DBA::escape($data["batch"]), DBA::escape($data["notify"]), DBA::escape($data["poll"]), DBA::escape($data["pubkey"]), intval($contact["id"])); diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index b539de5e2..59d506af3 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -34,7 +34,7 @@ class Delivery extends BaseObject public static function execute($cmd, $item_id, $contact_id) { - Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $contact_id, LOGGER_DEBUG); + Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $contact_id, Logger::DEBUG); $top_level = false; $followup = false; @@ -126,7 +126,7 @@ class Delivery extends BaseObject */ if (!$top_level && ($parent['wall'] == 0) && stristr($target_item['uri'], $localhost)) { - Logger::log('Followup ' . $target_item["guid"], LOGGER_DEBUG); + Logger::log('Followup ' . $target_item["guid"], Logger::DEBUG); // local followup to remote post $followup = true; } @@ -241,7 +241,7 @@ class Delivery extends BaseObject $atom = DFRN::entries($msgitems, $owner); } - Logger::log('Notifier entry: ' . $contact["url"] . ' ' . $target_item["guid"] . ' entry: ' . $atom, LOGGER_DATA); + Logger::log('Notifier entry: ' . $contact["url"] . ' ' . $target_item["guid"] . ' entry: ' . $atom, Logger::DATA); $basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3)); diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php index 33e724ce4..b4b86e344 100644 --- a/src/Worker/Directory.php +++ b/src/Worker/Directory.php @@ -34,7 +34,7 @@ class Directory Addon::callHooks('globaldir_update', $arr); - Logger::log('Updating directory: ' . $arr['url'], LOGGER_DEBUG); + Logger::log('Updating directory: ' . $arr['url'], Logger::DEBUG); if (strlen($arr['url'])) { Network::fetchUrl($dir . '?url=' . bin2hex($arr['url'])); } diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php index da9142e7d..72df3420e 100644 --- a/src/Worker/DiscoverPoCo.php +++ b/src/Worker/DiscoverPoCo.php @@ -90,7 +90,7 @@ class DiscoverPoCo } else { $result .= "failed"; } - Logger::log($result, LOGGER_DEBUG); + Logger::log($result, Logger::DEBUG); } elseif ($mode == 3) { GContact::updateSuggestions(); } elseif (($mode == 2) && Config::get('system', 'poco_completion')) { @@ -130,7 +130,7 @@ class DiscoverPoCo if (!PortableContact::updateNeeded($server["created"], "", $server["last_failure"], $server["last_contact"])) { continue; } - Logger::log('Update server status for server '.$server["url"], LOGGER_DEBUG); + Logger::log('Update server status for server '.$server["url"], Logger::DEBUG); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $server["url"]); @@ -141,7 +141,7 @@ class DiscoverPoCo } private static function discoverUsers() { - Logger::log("Discover users", LOGGER_DEBUG); + Logger::log("Discover users", Logger::DEBUG); $starttime = time(); @@ -209,7 +209,7 @@ class DiscoverPoCo if (!is_null($data)) { // Only search for the same item every 24 hours if (time() < $data + (60 * 60 * 24)) { - Logger::log("Already searched for ".$search." in the last 24 hours", LOGGER_DEBUG); + Logger::log("Already searched for ".$search." in the last 24 hours", Logger::DEBUG); return; } } @@ -222,7 +222,7 @@ class DiscoverPoCo // Check if the contact already exists $exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url)); if (DBA::isResult($exists)) { - Logger::log("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG); + Logger::log("Profile ".$jj->url." already exists (".$search.")", Logger::DEBUG); if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) && ($exists[0]["updated"] < $exists[0]["last_failure"])) { @@ -236,16 +236,16 @@ class DiscoverPoCo $server_url = PortableContact::detectServer($jj->url); if ($server_url != '') { if (!PortableContact::checkServer($server_url)) { - Logger::log("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG); + Logger::log("Friendica server ".$server_url." doesn't answer.", Logger::DEBUG); continue; } - Logger::log("Friendica server ".$server_url." seems to be okay.", LOGGER_DEBUG); + Logger::log("Friendica server ".$server_url." seems to be okay.", Logger::DEBUG); } $data = Probe::uri($jj->url); if ($data["network"] == Protocol::DFRN) { - Logger::log("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG); - Logger::log("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG); + Logger::log("Profile ".$jj->url." is reachable (".$search.")", Logger::DEBUG); + Logger::log("Add profile ".$jj->url." to local directory (".$search.")", Logger::DEBUG); if ($jj->tags != "") { $data["keywords"] = $jj->tags; @@ -255,7 +255,7 @@ class DiscoverPoCo GContact::update($data); } else { - Logger::log("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], LOGGER_DEBUG); + Logger::log("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], Logger::DEBUG); } } } diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 9ff523a12..21e873502 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -27,7 +27,7 @@ class Expire Hook::loadHooks(); if ($param == 'delete') { - Logger::log('Delete expired items', LOGGER_DEBUG); + Logger::log('Delete expired items', Logger::DEBUG); // physically remove anything that has been deleted for more than two months $condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"]; $rows = DBA::select('item', ['id'], $condition); @@ -38,35 +38,35 @@ class Expire // Normally we shouldn't have orphaned data at all. // If we do have some, then we have to check why. - Logger::log('Deleting orphaned item activities - start', LOGGER_DEBUG); + Logger::log('Deleting orphaned item activities - start', Logger::DEBUG); $condition = ["NOT EXISTS (SELECT `iaid` FROM `item` WHERE `item`.`iaid` = `item-activity`.`id`)"]; DBA::delete('item-activity', $condition); - Logger::log('Orphaned item activities deleted: ' . DBA::affectedRows(), LOGGER_DEBUG); + Logger::log('Orphaned item activities deleted: ' . DBA::affectedRows(), Logger::DEBUG); - Logger::log('Deleting orphaned item content - start', LOGGER_DEBUG); + Logger::log('Deleting orphaned item content - start', Logger::DEBUG); $condition = ["NOT EXISTS (SELECT `icid` FROM `item` WHERE `item`.`icid` = `item-content`.`id`)"]; DBA::delete('item-content', $condition); - Logger::log('Orphaned item content deleted: ' . DBA::affectedRows(), LOGGER_DEBUG); + Logger::log('Orphaned item content deleted: ' . DBA::affectedRows(), Logger::DEBUG); // make this optional as it could have a performance impact on large sites if (intval(Config::get('system', 'optimize_items'))) { DBA::e("OPTIMIZE TABLE `item`"); } - Logger::log('Delete expired items - done', LOGGER_DEBUG); + Logger::log('Delete expired items - done', Logger::DEBUG); return; } elseif (intval($param) > 0) { $user = DBA::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]); if (DBA::isResult($user)) { - Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG); + Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], Logger::DEBUG); Item::expire($user['uid'], $user['expire']); - Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG); + Logger::log('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', Logger::DEBUG); } return; } elseif ($param == 'hook' && !empty($hook_function)) { foreach (Hook::getByName('expire') as $hook) { if ($hook[1] == $hook_function) { - Logger::log("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG); + Logger::log("Calling expire hook '" . $hook[1] . "'", Logger::DEBUG); Hook::callSingle($a, 'expire', $hook, $data); } } @@ -80,7 +80,7 @@ class Expire $r = DBA::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0"); while ($row = DBA::fetch($r)) { - Logger::log('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', LOGGER_DEBUG); + Logger::log('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', Logger::DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Expire', (int)$row['uid']); } @@ -88,7 +88,7 @@ class Expire Logger::log('expire: calling hooks'); foreach (Hook::getByName('expire') as $hook) { - Logger::log("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG); + Logger::log("Calling expire hook for '" . $hook[1] . "'", Logger::DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Expire', 'hook', $hook[1]); } diff --git a/src/Worker/GProbe.php b/src/Worker/GProbe.php index 2f80e1e51..55da28f91 100644 --- a/src/Worker/GProbe.php +++ b/src/Worker/GProbe.php @@ -25,7 +25,7 @@ class GProbe { DBA::escape(normalise_link($url)) ); - Logger::log("gprobe start for ".normalise_link($url), LOGGER_DEBUG); + Logger::log("gprobe start for ".normalise_link($url), Logger::DEBUG); if (!DBA::isResult($r)) { // Is it a DDoS attempt? @@ -34,7 +34,7 @@ class GProbe { $result = Cache::get("gprobe:".$urlparts["host"]); if (!is_null($result)) { if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) { - Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG); + Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), Logger::DEBUG); return; } } @@ -61,7 +61,7 @@ class GProbe { } } - Logger::log("gprobe end for ".normalise_link($url), LOGGER_DEBUG); + Logger::log("gprobe end for ".normalise_link($url), Logger::DEBUG); return; } } diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index a6e862e7a..2d0140c17 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -58,7 +58,7 @@ class Notifier { $a = BaseObject::getApp(); - Logger::log('notifier: invoked: '.$cmd.': '.$item_id, LOGGER_DEBUG); + Logger::log('notifier: invoked: '.$cmd.': '.$item_id, Logger::DEBUG); $top_level = false; $recipients = []; @@ -105,7 +105,7 @@ class Notifier $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser(0); foreach ($inboxes as $inbox) { - Logger::log('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + Logger::log('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', Logger::DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'APDelivery', Delivery::REMOVAL, '', $inbox, $item_id); } @@ -185,7 +185,7 @@ class Notifier $condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]]; $thr_parent = Item::selectFirst($fields, $condition); - Logger::log('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG); + Logger::log('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], Logger::DEBUG); // This is IMPORTANT!!!! @@ -249,7 +249,7 @@ class Notifier $recipients = [$parent['contact-id']]; $recipients_followup = [$parent['contact-id']]; - Logger::log('notifier: followup '.$target_item["guid"].' to '.$conversant_str, LOGGER_DEBUG); + Logger::log('notifier: followup '.$target_item["guid"].' to '.$conversant_str, Logger::DEBUG); //if (!$target_item['private'] && $target_item['wall'] && if (!$target_item['private'] && @@ -279,11 +279,11 @@ class Notifier $push_notify = false; } - Logger::log("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), LOGGER_DEBUG); + Logger::log("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), Logger::DEBUG); } else { $followup = false; - Logger::log('Distributing directly '.$target_item["guid"], LOGGER_DEBUG); + Logger::log('Distributing directly '.$target_item["guid"], Logger::DEBUG); // don't send deletions onward for other people's stuff @@ -346,7 +346,7 @@ class Notifier if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) { $diaspora_delivery = false; - Logger::log('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG); + Logger::log('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], Logger::DEBUG); // Send a salmon to the parent author $probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['author-id']]); @@ -365,7 +365,7 @@ class Notifier // Send a salmon notification to every person we mentioned in the post $arr = explode(',',$target_item['tag']); foreach ($arr as $x) { - //Logger::log('Checking tag '.$x, LOGGER_DEBUG); + //Logger::log('Checking tag '.$x, Logger::DEBUG); $matches = null; if (preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) { $probed_contact = Probe::uri($matches[1]); @@ -420,7 +420,7 @@ class Notifier // delivery loop if (DBA::isResult($r)) { foreach ($r as $contact) { - Logger::log("Deliver ".$item_id." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG); + Logger::log("Deliver ".$item_id." to ".$contact['url']." via network ".$contact['network'], Logger::DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'Delivery', $cmd, $item_id, (int)$contact['id']); @@ -470,7 +470,7 @@ class Notifier $r = array_merge($r2, $r1); if (DBA::isResult($r)) { - Logger::log('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG); + Logger::log('pubdeliver '.$target_item["guid"].': '.print_r($r,true), Logger::DEBUG); foreach ($r as $rr) { // except for Diaspora batch jobs @@ -494,13 +494,13 @@ class Notifier // Notify PuSH subscribers (Used for OStatus distribution of regular posts) if ($push_notify) { - Logger::log('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG); + Logger::log('Activating internal PuSH for item '.$item_id, Logger::DEBUG); // Handling the pubsubhubbub requests PushSubscriber::publishFeed($owner['uid'], $a->queue['priority']); } - Logger::log('notifier: calling hooks for ' . $cmd . ' ' . $item_id, LOGGER_DEBUG); + Logger::log('notifier: calling hooks for ' . $cmd . ' ' . $item_id, Logger::DEBUG); if ($normal_mode) { Hook::fork($a->queue['priority'], 'notifier_normal', $target_item); @@ -518,15 +518,15 @@ class Notifier if ($target_item['origin']) { $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid); - Logger::log('Origin item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); + Logger::log('Origin item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG); } elseif (!DBA::exists('conversation', ['item-uri' => $target_item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB])) { - Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', LOGGER_DEBUG); + Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', Logger::DEBUG); return; } else { // Remote items are transmitted via the personal inboxes. // Doing so ensures that the dedicated receiver will get the message. $personal = true; - Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); + Logger::log('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG); } if ($parent['origin']) { @@ -535,7 +535,7 @@ class Notifier } if (empty($inboxes)) { - Logger::log('No inboxes found for item ' . $item_id . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', LOGGER_DEBUG); + Logger::log('No inboxes found for item ' . $item_id . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', Logger::DEBUG); return; } @@ -543,7 +543,7 @@ class Notifier ActivityPub\Transmitter::createCachedActivityFromItem($item_id, true); foreach ($inboxes as $inbox) { - Logger::log('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + Logger::log('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', Logger::DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'APDelivery', $cmd, $item_id, $inbox, $uid); diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 6628115f0..77745b807 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -87,7 +87,7 @@ class OnePoll $updated = DateTimeFormat::utcNow(); if ($last_updated) { - Logger::log('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG); + Logger::log('Contact '.$contact['id'].' had last update on '.$last_updated, Logger::DEBUG); // The last public item can be older than the last item we got if ($last_updated < $contact['last-item']) { @@ -100,7 +100,7 @@ class OnePoll } else { self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]); Contact::markForArchival($contact); - Logger::log('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG); + Logger::log('Contact '.$contact['id'].' is marked for archival', Logger::DEBUG); } return; @@ -214,7 +214,7 @@ class OnePoll $handshake_xml = $curlResult->getBody(); $html_code = $curlResult->getReturnCode(); - Logger::log('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA); + Logger::log('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, Logger::DATA); if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) { Logger::log("$url appears to be dead - marking for death "); @@ -348,7 +348,7 @@ class OnePoll $xml = $curlResult->getBody(); } elseif ($contact['network'] === Protocol::MAIL) { - Logger::log("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG); + Logger::log("Mail: Fetching for ".$contact['addr'], Logger::DEBUG); $mail_disabled = ((function_exists('imap_open') && !Config::get('system', 'imap_disabled')) ? 0 : 1); if ($mail_disabled) { @@ -358,7 +358,7 @@ class OnePoll return; } - Logger::log("Mail: Enabled", LOGGER_DEBUG); + Logger::log("Mail: Enabled", Logger::DEBUG); $mbox = null; $user = DBA::selectFirst('user', ['prvkey'], ['uid' => $importer_uid]); @@ -385,17 +385,17 @@ class OnePoll $msgs = Email::poll($mbox, $contact['addr']); if (count($msgs)) { - Logger::log("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG); + Logger::log("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], Logger::DEBUG); $metas = Email::messageMeta($mbox, implode(',', $msgs)); if (count($metas) != count($msgs)) { - Logger::log("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG); + Logger::log("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", Logger::DEBUG); } else { $msgs = array_combine($msgs, $metas); foreach ($msgs as $msg_uid => $meta) { - Logger::log("Mail: Parsing mail ".$msg_uid, LOGGER_DATA); + Logger::log("Mail: Parsing mail ".$msg_uid, Logger::DATA); $datarray = []; $datarray['verb'] = ACTIVITY_POST; @@ -410,7 +410,7 @@ class OnePoll $condition = ['uid' => $importer_uid, 'uri' => $datarray['uri']]; $item = Item::selectFirst($fields, $condition); if (DBA::isResult($item)) { - Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG); + Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],Logger::DEBUG); // Only delete when mails aren't automatically moved or deleted if (($mailconf['action'] != 1) && ($mailconf['action'] != 3)) @@ -421,7 +421,7 @@ class OnePoll switch ($mailconf['action']) { case 0: - Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG); + Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", Logger::DEBUG); break; case 1: Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); @@ -555,7 +555,7 @@ class OnePoll switch ($mailconf['action']) { case 0: - Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", LOGGER_DEBUG); + Logger::log("Mail: Seen before ".$msg_uid." for ".$mailconf['user'].". Doing nothing.", Logger::DEBUG); break; case 1: Logger::log("Mail: Deleting ".$msg_uid." for ".$mailconf['user']); @@ -585,7 +585,7 @@ class OnePoll } if ($xml) { - Logger::log('received xml : ' . $xml, LOGGER_DATA); + Logger::log('received xml : ' . $xml, Logger::DATA); if (!strstr($xml, '<')) { Logger::log('post_handshake: response from ' . $url . ' did not contain XML.'); diff --git a/src/Worker/ProfileUpdate.php b/src/Worker/ProfileUpdate.php index 98952658a..808d47299 100644 --- a/src/Worker/ProfileUpdate.php +++ b/src/Worker/ProfileUpdate.php @@ -23,7 +23,7 @@ class ProfileUpdate { $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($uid); foreach ($inboxes as $inbox) { - Logger::log('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + Logger::log('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', Logger::DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], 'APDelivery', Delivery::PROFILEUPDATE, '', $inbox, $uid); } diff --git a/src/Worker/PubSubPublish.php b/src/Worker/PubSubPublish.php index bc9233d55..801bdc888 100644 --- a/src/Worker/PubSubPublish.php +++ b/src/Worker/PubSubPublish.php @@ -38,7 +38,7 @@ class PubSubPublish /// @todo Check server status with PortableContact::checkServer() // Before this can be done we need a way to safely detect the server url. - Logger::log("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update'], LOGGER_DEBUG); + Logger::log("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update'], Logger::DEBUG); $last_update = $subscriber['last_update']; $params = OStatus::feed($subscriber['nickname'], $last_update); @@ -55,7 +55,7 @@ class PubSubPublish $subscriber['topic']), "X-Hub-Signature: sha1=" . $hmac_sig]; - Logger::log('POST ' . print_r($headers, true) . "\n" . $params, LOGGER_DATA); + Logger::log('POST ' . print_r($headers, true) . "\n" . $params, Logger::DATA); $postResult = Network::post($subscriber['callback_url'], $params, $headers); $ret = $postResult->getReturnCode(); diff --git a/src/Worker/SpoolPost.php b/src/Worker/SpoolPost.php index ca26a2f63..2efd77d55 100644 --- a/src/Worker/SpoolPost.php +++ b/src/Worker/SpoolPost.php @@ -50,7 +50,7 @@ class SpoolPost { $result = Item::insert($arr); - Logger::log("Spool file ".$file." stored: ".$result, LOGGER_DEBUG); + Logger::log("Spool file ".$file." stored: ".$result, Logger::DEBUG); unlink($fullfile); } closedir($dh); diff --git a/view/theme/vier/style.php b/view/theme/vier/style.php index 9b528a14b..196d37765 100644 --- a/view/theme/vier/style.php +++ b/view/theme/vier/style.php @@ -31,7 +31,7 @@ foreach (['style', $style] as $file) { $modified = $stylemodified; } } else { - //TODO: use LOGGER_ERROR? + //TODO: use Logger::ERROR? Logger::log('Error: missing file: "' . $stylecssfile .'" (userid: '. $uid .')'); } } From 342e48453387145640acd16f013fc071598106ac Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 10:02:52 -0400 Subject: [PATCH 15/68] Missing BaseObject add use BaseObject --- src/Core/Logger.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Core/Logger.php b/src/Core/Logger.php index e6d4f6118..0a6e56020 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -4,6 +4,7 @@ */ namespace Friendica\Core; +use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Util\DateTimeFormat; use ReflectionClass; From 17ae53c9d7c3e1a4ccddb0c99769df8e2835d4ce Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 11:40:11 -0400 Subject: [PATCH 16/68] Review Updates create array, remove getConstants function, add self references. --- src/Core/Logger.php | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/src/Core/Logger.php b/src/Core/Logger.php index 0a6e56020..c9253a83e 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -22,16 +22,14 @@ class Logger extends BaseObject const DATA = 4; const ALL = 5; - public static $levels = []; - - /** - * @brief Get class constants, and avoid using substring. - */ - public static function getConstants() - { - $reflectionClass = new ReflectionClass(__CLASS__); - return $reflectionClass->getConstants(); - } + public static $levels = [ + self::WARNING => 'Warning', + self::INFO => 'Info', + self::TRACE => 'Trace', + self::DEBUG => 'Debug', + self::DATA => 'Data', + self::ALL => 'All', + ]; /** * @brief Logs the given message at the given log level @@ -55,14 +53,6 @@ class Logger extends BaseObject return; } - if (count(self::$levels) == 0) - { - foreach (self::getConstants() as $k => $v) - { - $levels[$v] = $k; - } - } - $processId = session_id(); if ($processId == '') @@ -81,7 +71,7 @@ class Logger extends BaseObject $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", DateTimeFormat::utcNow(DateTimeFormat::ATOM), $processId, - $levels[$level], + self::$levels[$level], basename($callers[0]['file']), $callers[0]['line'], $function, @@ -100,9 +90,8 @@ class Logger extends BaseObject * personally without background noise * * @param string $msg - * @param int $level */ - public static function devLog($msg, $level = self::INFO) + public static function devLog($msg) { $a = self::getApp(); @@ -119,14 +108,6 @@ class Logger extends BaseObject return; } - if (count(self::$levels) == 0) - { - foreach (self::getConstants() as $k => $v) - { - $levels[$v] = $k; - } - } - $processId = session_id(); if ($processId == '') From c3ee9afa595c7b7d7070ff38fcda236a6f8f979d Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 11:43:27 -0400 Subject: [PATCH 17/68] Bug fix update Logger::DEBUG to Core\Logger:: --- src/App.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/App.php b/src/App.php index 92eb9409c..781faf1a5 100644 --- a/src/App.php +++ b/src/App.php @@ -1101,10 +1101,10 @@ class App $processlist = DBA::processlist(); if ($processlist['list'] != '') { - Core\Logger::log('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], Logger::DEBUG); + Core\Logger::log('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], Core\Logger::DEBUG); if ($processlist['amount'] > $max_processes) { - Core\Logger::log('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', Logger::DEBUG); + Core\Logger::log('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', Core\Logger::DEBUG); return true; } } @@ -1150,7 +1150,7 @@ class App $reached = ($free < $min_memory); if ($reached) { - Core\Logger::log('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, Logger::DEBUG); + Core\Logger::log('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, Core\Logger::DEBUG); } return $reached; @@ -1222,7 +1222,7 @@ class App $resource = proc_open($cmdline . ' &', [], $foo, $this->getBasePath()); } if (!is_resource($resource)) { - Core\Logger::log('We got no resource for command ' . $cmdline, Logger::DEBUG); + Core\Logger::log('We got no resource for command ' . $cmdline, Core\Logger::DEBUG); return; } proc_close($resource); @@ -1253,27 +1253,27 @@ class App public static function isDirectoryUsable($directory, $check_writable = true) { if ($directory == '') { - Core\Logger::log('Directory is empty. This shouldn\'t happen.', Logger::DEBUG); + Core\Logger::log('Directory is empty. This shouldn\'t happen.', Core\Logger::DEBUG); return false; } if (!file_exists($directory)) { - Core\Logger::log('Path "' . $directory . '" does not exist for user ' . self::getSystemUser(), Logger::DEBUG); + Core\Logger::log('Path "' . $directory . '" does not exist for user ' . self::getSystemUser(), Core\Logger::DEBUG); return false; } if (is_file($directory)) { - Core\Logger::log('Path "' . $directory . '" is a file for user ' . self::getSystemUser(), Logger::DEBUG); + Core\Logger::log('Path "' . $directory . '" is a file for user ' . self::getSystemUser(), Core\Logger::DEBUG); return false; } if (!is_dir($directory)) { - Core\Logger::log('Path "' . $directory . '" is not a directory for user ' . self::getSystemUser(), Logger::DEBUG); + Core\Logger::log('Path "' . $directory . '" is not a directory for user ' . self::getSystemUser(), Core\Logger::DEBUG); return false; } if ($check_writable && !is_writable($directory)) { - Core\Logger::log('Path "' . $directory . '" is not writable for user ' . self::getSystemUser(), Logger::DEBUG); + Core\Logger::log('Path "' . $directory . '" is not writable for user ' . self::getSystemUser(), Core\Logger::DEBUG); return false; } @@ -1646,7 +1646,7 @@ class App } else { // Someone came with an invalid parameter, maybe as a DDoS attempt // We simply stop processing here - Core\Logger::log("Invalid ZRL parameter " . $_GET['zrl'], Logger::DEBUG); + Core\Logger::log("Invalid ZRL parameter " . $_GET['zrl'], Core\Logger::DEBUG); Core\System::httpExit(403, ['title' => '403 Forbidden']); } } @@ -1789,7 +1789,7 @@ class App $this->internalRedirect($_SERVER['REQUEST_URI']); } - Core\Logger::log('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], Logger::DEBUG); + Core\Logger::log('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], Core\Logger::DEBUG); header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . Core\L10n::t('Not Found')); $tpl = get_markup_template("404.tpl"); From 3a604029eb741519cb4f79b850900e8cb70f10ec Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 14:51:21 -0400 Subject: [PATCH 18/68] Create FileTag class create class and move functions --- include/text.php | 202 +------------------------------- src/Model/FileTag.php | 266 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 271 insertions(+), 197 deletions(-) create mode 100644 src/Model/FileTag.php diff --git a/include/text.php b/include/text.php index aae739312..aa4b2c8db 100644 --- a/include/text.php +++ b/include/text.php @@ -24,6 +24,7 @@ use Friendica\Util\Map; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Core\Logger; +use Friendica\Model\FileTag; require_once "include/conversation.php"; @@ -1099,9 +1100,9 @@ function get_cats_and_terms($item) if ($cnt) { foreach ($matches as $mtch) { $categories[] = [ - 'name' => xmlify(file_tag_decode($mtch[1])), + 'name' => xmlify(FileTag::decode($mtch[1])), 'url' => "#", - 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""), + 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(FileTag::decode($mtch[1])):""), 'first' => $first, 'last' => false ]; @@ -1120,9 +1121,9 @@ function get_cats_and_terms($item) if ($cnt) { foreach ($matches as $mtch) { $folders[] = [ - 'name' => xmlify(file_tag_decode($mtch[1])), + 'name' => xmlify(FileTag::decode($mtch[1])), 'url' => "#", - 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) : ""), + 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(FileTag::decode($mtch[1])) : ""), 'first' => $first, 'last' => false ]; @@ -1360,199 +1361,6 @@ function item_post_type($item) { return L10n::t('post'); } -// post categories and "save to file" use the same item.file table for storage. -// We will differentiate the different uses by wrapping categories in angle brackets -// and save to file categories in square brackets. -// To do this we need to escape these characters if they appear in our tag. - -function file_tag_encode($s) { - return str_replace(['<','>','[',']'],['%3c','%3e','%5b','%5d'],$s); -} - -function file_tag_decode($s) { - return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s); -} - -function file_tag_file_query($table,$s,$type = 'file') { - - if ($type == 'file') { - $str = preg_quote('[' . str_replace('%', '%%', file_tag_encode($s)) . ']'); - } else { - $str = preg_quote('<' . str_replace('%', '%%', file_tag_encode($s)) . '>'); - } - return " AND " . (($table) ? DBA::escape($table) . '.' : '') . "file regexp '" . DBA::escape($str) . "' "; -} - -// ex. given music,video return