Merge pull request #5977 from nupplaphil/move_global_functions_3
Move Global Functions - Part 3
This commit is contained in:
commit
49c7b5481b
46
boot.php
46
boot.php
|
@ -121,24 +121,6 @@ define('LOGGER_DATA', 4);
|
||||||
define('LOGGER_ALL', 5);
|
define('LOGGER_ALL', 5);
|
||||||
/* @}*/
|
/* @}*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @name Cache
|
|
||||||
* @deprecated since version 3.6
|
|
||||||
* @see Cache
|
|
||||||
*
|
|
||||||
* Cache levels
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
define('CACHE_MONTH', Cache::MONTH);
|
|
||||||
define('CACHE_WEEK', Cache::WEEK);
|
|
||||||
define('CACHE_DAY', Cache::DAY);
|
|
||||||
define('CACHE_HOUR', Cache::HOUR);
|
|
||||||
define('CACHE_HALF_HOUR', Cache::HALF_HOUR);
|
|
||||||
define('CACHE_QUARTER_HOUR', Cache::QUARTER_HOUR);
|
|
||||||
define('CACHE_FIVE_MINUTES', Cache::FIVE_MINUTES);
|
|
||||||
define('CACHE_MINUTE', Cache::MINUTE);
|
|
||||||
/* @}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Register
|
* @name Register
|
||||||
*
|
*
|
||||||
|
@ -212,11 +194,6 @@ $netgroup_ids = [
|
||||||
*/
|
*/
|
||||||
define('MAX_LIKERS', 75);
|
define('MAX_LIKERS', 75);
|
||||||
|
|
||||||
/**
|
|
||||||
* Communication timeout
|
|
||||||
*/
|
|
||||||
define('ZCURL_TIMEOUT', (-1));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Notify
|
* @name Notify
|
||||||
*
|
*
|
||||||
|
@ -502,29 +479,6 @@ function check_db($via_worker)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the base url for use in cmdline programs which don't have
|
|
||||||
* $_SERVER variables
|
|
||||||
*
|
|
||||||
* @param object $a App
|
|
||||||
*/
|
|
||||||
function check_url(App $a)
|
|
||||||
{
|
|
||||||
$url = Config::get('system', 'url');
|
|
||||||
|
|
||||||
// if the url isn't set or the stored url is radically different
|
|
||||||
// than the currently visited url, store the current value accordingly.
|
|
||||||
// "Radically different" ignores common variations such as http vs https
|
|
||||||
// and www.example.com vs example.com.
|
|
||||||
// We will only change the url to an ip address if there is no existing setting
|
|
||||||
|
|
||||||
if (empty($url) || (!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->getHostName()))) {
|
|
||||||
Config::set('system', 'url', System::baseUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Automatic database updates
|
* @brief Automatic database updates
|
||||||
* @param object $a App
|
* @param object $a App
|
||||||
|
|
|
@ -172,7 +172,7 @@ if ($a->getMode()->isInstall() && $a->module != 'view') {
|
||||||
} elseif (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $a->module != 'view') {
|
} elseif (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $a->module != 'view') {
|
||||||
$a->module = 'maintenance';
|
$a->module = 'maintenance';
|
||||||
} else {
|
} else {
|
||||||
check_url($a);
|
$a->checkURL();
|
||||||
check_db(false);
|
check_db(false);
|
||||||
Addon::check();
|
Addon::check();
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ function ping_init(App $a)
|
||||||
DBA::escape(DateTimeFormat::utcNow())
|
DBA::escape(DateTimeFormat::utcNow())
|
||||||
);
|
);
|
||||||
if (DBA::isResult($ev)) {
|
if (DBA::isResult($ev)) {
|
||||||
Cache::set($cachekey, $ev, CACHE_HOUR);
|
Cache::set($cachekey, $ev, Cache::HOUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,9 +136,9 @@ function search_content(App $a) {
|
||||||
"description" => L10n::t("Only one search per minute is permitted for not logged in users.")]);
|
"description" => L10n::t("Only one search per minute is permitted for not logged in users.")]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), CACHE_HOUR);
|
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), Cache::HOUR);
|
||||||
} else
|
} else
|
||||||
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => 1]), CACHE_HOUR);
|
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => 1]), Cache::HOUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Nav::setSelected('search');
|
Nav::setSelected('search');
|
||||||
|
|
19
src/App.php
19
src/App.php
|
@ -1607,4 +1607,23 @@ class App
|
||||||
|
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the base url for use in cmdline programs which don't have
|
||||||
|
* $_SERVER variables
|
||||||
|
*/
|
||||||
|
public function checkURL()
|
||||||
|
{
|
||||||
|
$url = Config::get('system', 'url');
|
||||||
|
|
||||||
|
// if the url isn't set or the stored url is radically different
|
||||||
|
// than the currently visited url, store the current value accordingly.
|
||||||
|
// "Radically different" ignores common variations such as http vs https
|
||||||
|
// and www.example.com vs example.com.
|
||||||
|
// We will only change the url to an ip address if there is no existing setting
|
||||||
|
|
||||||
|
if (empty($url) || (!link_compare($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->getHostName()))) {
|
||||||
|
Config::set('system', 'url', $this->getBaseURL());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,9 +120,9 @@ class OEmbed
|
||||||
'content' => $json_string,
|
'content' => $json_string,
|
||||||
'created' => DateTimeFormat::utcNow()
|
'created' => DateTimeFormat::utcNow()
|
||||||
], true);
|
], true);
|
||||||
$cache_ttl = CACHE_DAY;
|
$cache_ttl = Cache::DAY;
|
||||||
} else {
|
} else {
|
||||||
$cache_ttl = CACHE_FIVE_MINUTES;
|
$cache_ttl = Cache::FIVE_MINUTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::set($cache_key, $json_string, $cache_ttl);
|
Cache::set($cache_key, $json_string, $cache_ttl);
|
||||||
|
|
|
@ -468,7 +468,7 @@ class GContact
|
||||||
* Uncommented because the result of the queries are to big to store it in the cache.
|
* Uncommented because the result of the queries are to big to store it in the cache.
|
||||||
* We need to decide if we want to change the db column type or if we want to delete it.
|
* We need to decide if we want to change the db column type or if we want to delete it.
|
||||||
*/
|
*/
|
||||||
//Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, CACHE_FIVE_MINUTES);
|
//Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $r, Cache::FIVE_MINUTES);
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
@ -509,7 +509,7 @@ class GContact
|
||||||
* Uncommented because the result of the queries are to big to store it in the cache.
|
* Uncommented because the result of the queries are to big to store it in the cache.
|
||||||
* We need to decide if we want to change the db column type or if we want to delete it.
|
* We need to decide if we want to change the db column type or if we want to delete it.
|
||||||
*/
|
*/
|
||||||
//Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $list, CACHE_FIVE_MINUTES);
|
//Cache::set("suggestion_query:".$uid.":".$start.":".$limit, $list, Cache::FIVE_MINUTES);
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ class Photo
|
||||||
DBA::escape(L10n::t('Contact Photos'))
|
DBA::escape(L10n::t('Contact Photos'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Cache::set($key, $albums, CACHE_DAY);
|
Cache::set($key, $albums, Cache::DAY);
|
||||||
}
|
}
|
||||||
return $albums;
|
return $albums;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ class Photo
|
||||||
public static function clearAlbumCache($uid)
|
public static function clearAlbumCache($uid)
|
||||||
{
|
{
|
||||||
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
|
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
|
||||||
Cache::set($key, null, CACHE_DAY);
|
Cache::set($key, null, Cache::DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -577,7 +577,7 @@ class Profile
|
||||||
);
|
);
|
||||||
if (DBA::isResult($s)) {
|
if (DBA::isResult($s)) {
|
||||||
$r = DBA::toArray($s);
|
$r = DBA::toArray($s);
|
||||||
Cache::set($cachekey, $r, CACHE_HOUR);
|
Cache::set($cachekey, $r, Cache::HOUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,7 +1037,7 @@ class Profile
|
||||||
logger('URL ' . $my_url . ' already tried to authenticate.', LOGGER_DEBUG);
|
logger('URL ' . $my_url . ' already tried to authenticate.', LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Cache::set($cachekey, true, CACHE_MINUTE);
|
Cache::set($cachekey, true, Cache::MINUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('Not authenticated. Invoking reverse magic-auth for ' . $my_url, LOGGER_DEBUG);
|
logger('Not authenticated. Invoking reverse magic-auth for ' . $my_url, LOGGER_DEBUG);
|
||||||
|
|
|
@ -381,7 +381,7 @@ class Probe
|
||||||
|
|
||||||
// Only store into the cache if the value seems to be valid
|
// Only store into the cache if the value seems to be valid
|
||||||
if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
|
if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
|
||||||
Cache::set("Probe::uri:".$network.":".$uri, $data, CACHE_DAY);
|
Cache::set("Probe::uri:".$network.":".$uri, $data, Cache::DAY);
|
||||||
|
|
||||||
/// @todo temporary fix - we need a real contact update function that updates only changing fields
|
/// @todo temporary fix - we need a real contact update function that updates only changing fields
|
||||||
/// The biggest problem is the avatar picture that could have a reduced image size.
|
/// The biggest problem is the avatar picture that could have a reduced image size.
|
||||||
|
|
|
@ -545,7 +545,7 @@ class Transmitter
|
||||||
|
|
||||||
$data = ActivityPub\Transmitter::createActivityFromItem($item_id);
|
$data = ActivityPub\Transmitter::createActivityFromItem($item_id);
|
||||||
|
|
||||||
Cache::set($cachekey, $data, CACHE_QUARTER_HOUR);
|
Cache::set($cachekey, $data, Cache::QUARTER_HOUR);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3205,7 +3205,7 @@ class Diaspora
|
||||||
logger("Send participation for ".$item["guid"]." by ".$author, LOGGER_DEBUG);
|
logger("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
|
// 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);
|
Cache::set($cachekey, $item["guid"], Cache::QUARTER_HOUR);
|
||||||
|
|
||||||
return self::buildAndTransmit($owner, $contact, "participation", $message);
|
return self::buildAndTransmit($owner, $contact, "participation", $message);
|
||||||
}
|
}
|
||||||
|
@ -3575,7 +3575,7 @@ class Diaspora
|
||||||
|
|
||||||
$msg = ["type" => $type, "message" => $message];
|
$msg = ["type" => $type, "message" => $message];
|
||||||
|
|
||||||
Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
|
Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
|
||||||
|
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
@ -3702,7 +3702,7 @@ class Diaspora
|
||||||
$comment['thread_parent_guid'] = self::getGuidFromUri($item['thr-parent'], $item['uid']);
|
$comment['thread_parent_guid'] = self::getGuidFromUri($item['thr-parent'], $item['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::set($cachekey, $comment, CACHE_QUARTER_HOUR);
|
Cache::set($cachekey, $comment, Cache::QUARTER_HOUR);
|
||||||
|
|
||||||
return($comment);
|
return($comment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2210,7 +2210,7 @@ class OStatus
|
||||||
$feeddata = trim($doc->saveXML());
|
$feeddata = trim($doc->saveXML());
|
||||||
|
|
||||||
$msg = ['feed' => $feeddata, 'last_update' => $last_update];
|
$msg = ['feed' => $feeddata, 'last_update' => $last_update];
|
||||||
Cache::set($cachekey, $msg, CACHE_QUARTER_HOUR);
|
Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
|
||||||
|
|
||||||
logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG);
|
logger('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, LOGGER_DEBUG);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class JsonLD
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = jsonld_default_document_loader($url);
|
$data = jsonld_default_document_loader($url);
|
||||||
Cache::set('documentLoader:' . $url, $data, CACHE_DAY);
|
Cache::set('documentLoader:' . $url, $data, Cache::DAY);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ class DiscoverPoCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cache::set("dirsearch:".$search, time(), CACHE_DAY);
|
Cache::set("dirsearch:".$search, time(), Cache::DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Queue
|
||||||
logger("Check server " . $server . " (" . $contact["network"] . ")");
|
logger("Check server " . $server . " (" . $contact["network"] . ")");
|
||||||
|
|
||||||
$vital = PortableContact::checkServer($server, $contact["network"], true);
|
$vital = PortableContact::checkServer($server, $contact["network"], true);
|
||||||
Cache::set($cachekey_server . $server, $vital, CACHE_MINUTE);
|
Cache::set($cachekey_server . $server, $vital, Cache::MINUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($vital) && !$vital) {
|
if (!is_null($vital) && !$vital) {
|
||||||
|
@ -119,7 +119,7 @@ class Queue
|
||||||
QueueModel::removeItem($q_item['id']);
|
QueueModel::removeItem($q_item['id']);
|
||||||
} else {
|
} else {
|
||||||
QueueModel::updateTime($q_item['id']);
|
QueueModel::updateTime($q_item['id']);
|
||||||
Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
|
Cache::set($cachekey_deadguy . $contact['notify'], true, Cache::MINUTE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class Queue
|
||||||
|
|
||||||
if ($deliver_status == -1) {
|
if ($deliver_status == -1) {
|
||||||
QueueModel::updateTime($q_item['id']);
|
QueueModel::updateTime($q_item['id']);
|
||||||
Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
|
Cache::set($cachekey_deadguy . $contact['notify'], true, Cache::MINUTE);
|
||||||
} else {
|
} else {
|
||||||
QueueModel::removeItem($q_item['id']);
|
QueueModel::removeItem($q_item['id']);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ class Queue
|
||||||
QueueModel::removeItem($q_item['id']);
|
QueueModel::removeItem($q_item['id']);
|
||||||
} else {
|
} else {
|
||||||
QueueModel::updateTime($q_item['id']);
|
QueueModel::updateTime($q_item['id']);
|
||||||
Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
|
Cache::set($cachekey_deadguy . $contact['notify'], true, Cache::MINUTE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user