Move Config::get() to DI::config()->get()

This commit is contained in:
nupplaPhil 2020-01-19 21:21:13 +01:00
parent 5d294e8be8
commit 6c36fd9e01
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
126 changed files with 581 additions and 596 deletions

View file

@ -24,7 +24,7 @@ class CheckVersion
{
Logger::log('checkversion: start');
$checkurl = Config::get('system', 'check_new_version_url', 'none');
$checkurl = DI::config()->get('system', 'check_new_version_url', 'none');
switch ($checkurl) {
case 'master':

View file

@ -21,9 +21,9 @@ class Cron
{
$a = DI::app();
$last = Config::get('system', 'last_cron');
$last = DI::config()->get('system', 'last_cron');
$poll_interval = intval(Config::get('system', 'cron_interval'));
$poll_interval = intval(DI::config()->get('system', 'cron_interval'));
if ($last) {
$next = $last + ($poll_interval * 60);
@ -60,7 +60,7 @@ class Cron
Worker::add(PRIORITY_LOW, "CronJobs", "repair_database");
// once daily run birthday_updates and then expire in background
$d1 = Config::get('system', 'last_expire_day');
$d1 = DI::config()->get('system', 'last_expire_day');
$d2 = intval(DateTimeFormat::utcNow('d'));
// Daily cron calls
@ -90,13 +90,13 @@ class Cron
}
// Hourly cron calls
if (Config::get('system', 'last_cron_hourly', 0) + 3600 < time()) {
if (DI::config()->get('system', 'last_cron_hourly', 0) + 3600 < time()) {
// Delete all done workerqueue entries
DBA::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 1 HOUR']);
// Optimizing this table only last seconds
if (Config::get('system', 'optimize_workerqueue', false)) {
if (DI::config()->get('system', 'optimize_workerqueue', false)) {
DBA::e("OPTIMIZE TABLE `workerqueue`");
}
@ -169,7 +169,7 @@ class Cron
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function pollContacts() {
$min_poll_interval = Config::get('system', 'min_poll_interval', 1);
$min_poll_interval = DI::config()->get('system', 'min_poll_interval', 1);
Addon::reload();
@ -188,7 +188,7 @@ class Cron
// Only poll from those with suitable relationships,
// and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
$abandon_days = intval(Config::get('system', 'account_abandon_days'));
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
if ($abandon_days < 1) {
$abandon_days = 0;
}

View file

@ -139,7 +139,7 @@ class CronJobs
*/
private static function clearCache(App $a)
{
$last = Config::get('system', 'cache_last_cleared');
$last = DI::config()->get('system', 'cache_last_cleared');
if ($last) {
$next = $last + (3600); // Once per hour
@ -165,10 +165,10 @@ class CronJobs
clear_cache($a->getBasePath() . "/view/smarty3/compiled", $a->getBasePath() . "/view/smarty3/compiled");
// clear cache for image proxy
if (!Config::get("system", "proxy_disabled")) {
if (!DI::config()->get("system", "proxy_disabled")) {
clear_cache($a->getBasePath(), $a->getBasePath() . "/proxy");
$cachetime = Config::get('system', 'proxy_cache_time');
$cachetime = DI::config()->get('system', 'proxy_cache_time');
if (!$cachetime) {
$cachetime = ProxyUtils::DEFAULT_TIME;
@ -185,13 +185,13 @@ class CronJobs
DBA::delete('parsed_url', ["`created` < NOW() - INTERVAL 3 MONTH"]);
// Maximum table size in megabyte
$max_tablesize = intval(Config::get('system', 'optimize_max_tablesize')) * 1000000;
$max_tablesize = intval(DI::config()->get('system', 'optimize_max_tablesize')) * 1000000;
if ($max_tablesize == 0) {
$max_tablesize = 100 * 1000000; // Default are 100 MB
}
if ($max_tablesize > 0) {
// Minimum fragmentation level in percent
$fragmentation_level = intval(Config::get('system', 'optimize_fragmentation')) / 100;
$fragmentation_level = intval(DI::config()->get('system', 'optimize_fragmentation')) / 100;
if ($fragmentation_level == 0) {
$fragmentation_level = 0.3; // Default value is 30%
}

View file

@ -14,7 +14,7 @@ use Friendica\Database\DBA;
class DBClean {
public static function execute($stage = 0) {
if (!Config::get('system', 'dbclean', false)) {
if (!DI::config()->get('system', 'dbclean', false)) {
return;
}
@ -30,12 +30,12 @@ class DBClean {
*/
private static function forkCleanProcess() {
// Get the expire days for step 8 and 9
$days = Config::get('system', 'dbclean-expire-days', 0);
$days = DI::config()->get('system', 'dbclean-expire-days', 0);
for ($i = 1; $i <= 10; $i++) {
// Execute the background script for a step when it isn't finished.
// Execute step 8 and 9 only when $days is defined.
if (!Config::get('system', 'finished-dbclean-'.$i, false) && (($i < 8) || ($i > 9) || ($days > 0))) {
if (!DI::config()->get('system', 'finished-dbclean-'.$i, false) && (($i < 8) || ($i > 9) || ($days > 0))) {
Worker::add(PRIORITY_LOW, 'DBClean', $i);
}
}
@ -62,11 +62,11 @@ class DBClean {
*/
private static function removeOrphans($stage) {
// We split the deletion in many small tasks
$limit = Config::get('system', 'dbclean-expire-limit', 1000);
$limit = DI::config()->get('system', 'dbclean-expire-limit', 1000);
// Get the expire days for step 8 and 9
$days = Config::get('system', 'dbclean-expire-days', 0);
$days_unclaimed = Config::get('system', 'dbclean-expire-unclaimed', 90);
$days = DI::config()->get('system', 'dbclean-expire-days', 0);
$days_unclaimed = DI::config()->get('system', 'dbclean-expire-unclaimed', 90);
if ($days_unclaimed == 0) {
$days_unclaimed = $days;
@ -77,7 +77,7 @@ class DBClean {
return;
}
$last_id = Config::get('system', 'dbclean-last-id-1', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-1', 0);
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
@ -100,7 +100,7 @@ class DBClean {
Config::set('system', 'dbclean-last-id-1', $last_id);
} elseif ($stage == 2) {
$last_id = Config::get('system', 'dbclean-last-id-2', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-2', 0);
Logger::log("Deleting items without parents. Last ID: ".$last_id);
$r = DBA::p("SELECT `id` FROM `item`
@ -126,7 +126,7 @@ class DBClean {
Config::set('system', 'finished-dbclean-2', true);
}
} elseif ($stage == 3) {
$last_id = Config::get('system', 'dbclean-last-id-3', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-3', 0);
Logger::log("Deleting orphaned data from thread table. Last ID: ".$last_id);
$r = DBA::p("SELECT `iid` FROM `thread`
@ -152,7 +152,7 @@ class DBClean {
Config::set('system', 'finished-dbclean-3', true);
}
} elseif ($stage == 4) {
$last_id = Config::get('system', 'dbclean-last-id-4', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-4', 0);
Logger::log("Deleting orphaned data from notify table. Last ID: ".$last_id);
$r = DBA::p("SELECT `iid`, `id` FROM `notify`
@ -178,7 +178,7 @@ class DBClean {
Config::set('system', 'finished-dbclean-4', true);
}
} elseif ($stage == 5) {
$last_id = Config::get('system', 'dbclean-last-id-5', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-5', 0);
Logger::log("Deleting orphaned data from notify-threads table. Last ID: ".$last_id);
$r = DBA::p("SELECT `id` FROM `notify-threads`
@ -204,7 +204,7 @@ class DBClean {
Config::set('system', 'finished-dbclean-5', true);
}
} elseif ($stage == 6) {
$last_id = Config::get('system', 'dbclean-last-id-6', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-6', 0);
Logger::log("Deleting orphaned data from sign table. Last ID: ".$last_id);
$r = DBA::p("SELECT `iid`, `id` FROM `sign`
@ -230,7 +230,7 @@ class DBClean {
Config::set('system', 'finished-dbclean-6', true);
}
} elseif ($stage == 7) {
$last_id = Config::get('system', 'dbclean-last-id-7', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-7', 0);
Logger::log("Deleting orphaned data from term table. Last ID: ".$last_id);
$r = DBA::p("SELECT `oid`, `tid` FROM `term`
@ -260,7 +260,7 @@ class DBClean {
return;
}
$last_id = Config::get('system', 'dbclean-last-id-8', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-8', 0);
Logger::log("Deleting expired threads. Last ID: ".$last_id);
$r = DBA::p("SELECT `thread`.`iid` FROM `thread`
@ -295,8 +295,8 @@ class DBClean {
return;
}
$last_id = Config::get('system', 'dbclean-last-id-9', 0);
$till_id = Config::get('system', 'dbclean-last-id-8', 0);
$last_id = DI::config()->get('system', 'dbclean-last-id-9', 0);
$till_id = DI::config()->get('system', 'dbclean-last-id-8', 0);
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
@ -319,8 +319,8 @@ class DBClean {
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));
$last_id = DI::config()->get('system', 'dbclean-last-id-10', 0);
$days = intval(DI::config()->get('system', 'dbclean_expire_conversation', 90));
Logger::log("Deleting old conversations. Last created: ".$last_id);
$r = DBA::p("SELECT `received`, `item-uri` FROM `conversation`

View file

@ -14,7 +14,7 @@ class DBUpdate
public static function execute()
{
// Just in case the last update wasn't failed
if (Config::get('system', 'update', Update::SUCCESS, true) != Update::FAILED) {
if (DI::config()->get('system', 'update', Update::SUCCESS, true) != Update::FAILED) {
Update::run(DI::app()->getBasePath());
}
}

View file

@ -414,7 +414,7 @@ class Delivery
Logger::notice('Deliver via Diaspora', ['target' => $target_item['id'], 'guid' => $target_item['guid'], 'to' => $loc]);
if (Config::get('system', 'dfrn_only') || !Config::get('system', 'diaspora_enabled')) {
if (DI::config()->get('system', 'dfrn_only') || !DI::config()->get('system', 'diaspora_enabled')) {
return;
}
@ -495,7 +495,7 @@ class Delivery
*/
private static function deliverMail($cmd, $contact, $owner, $target_item, $thr_parent)
{
if (Config::get('system','dfrn_only')) {
if (DI::config()->get('system','dfrn_only')) {
return;
}

View file

@ -17,7 +17,7 @@ class Directory
{
public static function execute($url = '')
{
$dir = Config::get('system', 'directory');
$dir = DI::config()->get('system', 'directory');
if (!strlen($dir)) {
return;

View file

@ -45,7 +45,7 @@ class Expire
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'))) {
if (intval(DI::config()->get('system', 'optimize_items'))) {
DBA::e("OPTIMIZE TABLE `item`");
}

View file

@ -318,7 +318,7 @@ class Notifier
// If this is a public message and pubmail is set on the parent, include all your email contacts
if (
function_exists('imap_open')
&& !Config::get('system','imap_disabled')
&& !DI::config()->get('system','imap_disabled')
&& $public_message
&& intval($target_item['pubmail'])
) {
@ -551,7 +551,7 @@ class Notifier
$url_recipients = array_filter($url_recipients);
// send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
// They are especially used for notifications to OStatus users that don't follow us.
if (!Config::get('system', 'dfrn_only') && count($url_recipients) && ($public_message || $push_notify) && !empty($target_item)) {
if (!DI::config()->get('system', 'dfrn_only') && count($url_recipients) && ($public_message || $push_notify) && !empty($target_item)) {
$slap = OStatus::salmon($target_item, $owner);
foreach ($url_recipients as $url) {
Logger::log('Salmon delivery of item ' . $target_id . ' to ' . $url);
@ -640,7 +640,7 @@ class Notifier
}
// Skip DFRN when the item will be (forcefully) delivered via AP
if (Config::get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
if (DI::config()->get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
return true;
}

View file

@ -84,7 +84,7 @@ class OnePoll
}
// Don't poll if polling is deactivated (But we poll feeds and mails anyway)
if (!in_array($protocol, [Protocol::FEED, Protocol::MAIL]) && Config::get('system', 'disable_polling')) {
if (!in_array($protocol, [Protocol::FEED, Protocol::MAIL]) && DI::config()->get('system', 'disable_polling')) {
Logger::log('Polling is disabled');
// set the last-update so we don't keep polling
@ -115,7 +115,7 @@ class OnePoll
$xml = false;
if ($contact['subhub']) {
$poll_interval = Config::get('system', 'pushpoll_frequency', 3);
$poll_interval = DI::config()->get('system', 'pushpoll_frequency', 3);
$contact['priority'] = intval($poll_interval);
$hub_update = false;
@ -444,7 +444,7 @@ class OnePoll
{
Logger::log("Mail: Fetching for ".$contact['addr'], Logger::DEBUG);
$mail_disabled = ((function_exists('imap_open') && !Config::get('system', 'imap_disabled')) ? 0 : 1);
$mail_disabled = ((function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) ? 0 : 1);
if ($mail_disabled) {
// set the last-update so we don't keep polling
self::updateContact($contact, ['last-update' => $updated]);

View file

@ -22,7 +22,7 @@ class SearchDirectory
// <search pattern>: Searches for "search pattern" in the directory.
public static function execute($search)
{
if (!Config::get('system', 'poco_local_search')) {
if (!DI::config()->get('system', 'poco_local_search')) {
Logger::info('Local search is not enabled');
return;
}

View file

@ -21,7 +21,7 @@ class UpdateGContacts
*/
public static function execute()
{
if (!Config::get('system', 'poco_completion')) {
if (!DI::config()->get('system', 'poco_completion')) {
return;
}

View file

@ -17,7 +17,7 @@ class UpdateServerDirectories
*/
public static function execute()
{
if (Config::get('system', 'poco_discovery') == PortableContact::DISABLED) {
if (DI::config()->get('system', 'poco_discovery') == PortableContact::DISABLED) {
return;
}
@ -25,7 +25,7 @@ class UpdateServerDirectories
GServer::discover();
// Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
if (!Config::get('system', 'ostatus_disabled')) {
if (!DI::config()->get('system', 'ostatus_disabled')) {
GContact::discoverGsUsers();
}
}