Item cache related functionality removed

This commit is contained in:
Michael 2021-07-05 04:57:50 +00:00
parent 844727dc19
commit a06d699480
9 changed files with 0 additions and 136 deletions

View File

@ -444,93 +444,6 @@ function get_temppath()
return '';
}
function get_cachefile($file, $writemode = true)
{
$cache = get_itemcachepath();
if ((!$cache) || (!is_dir($cache))) {
return "";
}
$subfolder = $cache . "/" . substr($file, 0, 2);
$cachepath = $subfolder . "/" . $file;
if ($writemode) {
if (!is_dir($subfolder)) {
mkdir($subfolder);
chmod($subfolder, 0777);
}
}
return $cachepath;
}
function clear_cache($basepath = "", $path = "")
{
if ($path == "") {
$basepath = get_itemcachepath();
$path = $basepath;
}
if (($path == "") || (!is_dir($path))) {
return;
}
if (substr(realpath($path), 0, strlen($basepath)) != $basepath) {
return;
}
$cachetime = (int) DI::config()->get('system', 'itemcache_duration');
if ($cachetime == 0) {
$cachetime = 86400;
}
if (is_writable($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
$fullpath = $path . "/" . $file;
if ((filetype($fullpath) == "dir") && ($file != ".") && ($file != "..")) {
clear_cache($basepath, $fullpath);
}
if ((filetype($fullpath) == "file") && (filectime($fullpath) < (time() - $cachetime))) {
unlink($fullpath);
}
}
closedir($dh);
}
}
}
function get_itemcachepath()
{
// Checking, if the cache is deactivated
$cachetime = (int) DI::config()->get('system', 'itemcache_duration');
if ($cachetime < 0) {
return "";
}
$itemcache = DI::config()->get('system', 'itemcache');
if (($itemcache != "") && System::isDirectoryUsable($itemcache)) {
return BasePath::getRealPath($itemcache);
}
$temppath = get_temppath();
if ($temppath != "") {
$itemcache = $temppath . "/itemcache";
if (!file_exists($itemcache) && !is_dir($itemcache)) {
mkdir($itemcache);
}
if (System::isDirectoryUsable($itemcache)) {
DI::config()->set("system", "itemcache", $itemcache);
return $itemcache;
}
}
return "";
}
/**
* Returns the path where spool files are stored
*

View File

@ -329,8 +329,6 @@ class System
function info($s)
function is_site_admin()
function get_temppath()
function get_cachefile($file, $writemode = true)
function get_itemcachepath()
function get_spoolpath()
*/
}

View File

@ -194,8 +194,6 @@ class Site extends BaseAdmin
$dbclean_unclaimed = (!empty($_POST['dbclean_unclaimed']) ? intval($_POST['dbclean_unclaimed']) : 0);
$dbclean_expire_conv = (!empty($_POST['dbclean_expire_conv']) ? intval($_POST['dbclean_expire_conv']) : 0);
$suppress_tags = !empty($_POST['suppress_tags']);
$itemcache = (!empty($_POST['itemcache']) ? Strings::escapeTags(trim($_POST['itemcache'])) : '');
$itemcache_duration = (!empty($_POST['itemcache_duration']) ? intval($_POST['itemcache_duration']) : 0);
$max_comments = (!empty($_POST['max_comments']) ? intval($_POST['max_comments']) : 0);
$max_display_comments = (!empty($_POST['max_display_comments']) ? intval($_POST['max_display_comments']) : 0);
$temppath = (!empty($_POST['temppath']) ? Strings::escapeTags(trim($_POST['temppath'])) : '');
@ -395,12 +393,6 @@ class Site extends BaseAdmin
DI::config()->set('system', 'dbclean-expire-unclaimed', $dbclean_unclaimed);
if ($itemcache != '') {
$itemcache = BasePath::getRealPath($itemcache);
}
DI::config()->set('system', 'itemcache', $itemcache);
DI::config()->set('system', 'itemcache_duration', $itemcache_duration);
DI::config()->set('system', 'max_comments', $max_comments);
DI::config()->set('system', 'max_display_comments', $max_display_comments);
@ -506,7 +498,6 @@ class Site extends BaseAdmin
// Automatically create temporary paths
get_temppath();
get_itemcachepath();
/* Register policy */
$register_choices = [
@ -674,8 +665,6 @@ class Site extends BaseAdmin
'$dbclean_expire_days' => ['dbclean_expire_days', DI::l10n()->t('Lifespan of remote items'), DI::config()->get('system', 'dbclean-expire-days'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which remote items will be deleted. Own items, and marked or filed items are always kept. 0 disables this behaviour.')],
'$dbclean_unclaimed' => ['dbclean_unclaimed', DI::l10n()->t('Lifespan of unclaimed items'), DI::config()->get('system', 'dbclean-expire-unclaimed'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which unclaimed remote items (mostly content from the relay) will be deleted. Default value is 90 days. Defaults to the general lifespan value of remote items if set to 0.')],
'$dbclean_expire_conv' => ['dbclean_expire_conv', DI::l10n()->t('Lifespan of raw conversation data'), DI::config()->get('system', 'dbclean_expire_conversation'), DI::l10n()->t('The conversation data is used for ActivityPub and OStatus, as well as for debug purposes. It should be safe to remove it after 14 days, default is 90 days.')],
'$itemcache' => ['itemcache', DI::l10n()->t('Path to item cache'), DI::config()->get('system', 'itemcache'), DI::l10n()->t('The item caches buffers generated bbcode and external images.')],
'$itemcache_duration' => ['itemcache_duration', DI::l10n()->t('Cache duration in seconds'), DI::config()->get('system', 'itemcache_duration'), DI::l10n()->t('How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.')],
'$max_comments' => ['max_comments', DI::l10n()->t('Maximum numbers of comments per post'), DI::config()->get('system', 'max_comments'), DI::l10n()->t('How much comments should be shown for each post? Default value is 100.')],
'$max_display_comments' => ['max_display_comments', DI::l10n()->t('Maximum numbers of comments per post on the display page'), DI::config()->get('system', 'max_display_comments'), DI::l10n()->t('How many comments should be shown on the single view for each post? Default value is 1000.')],
'$temppath' => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],

View File

@ -38,29 +38,6 @@ class ClearCache
// clear old cache
DI::cache()->clear();
// clear old item cache files
clear_cache();
// clear cache for photos
clear_cache($a->getBasePath(), $a->getBasePath() . "/photo");
// clear smarty cache
clear_cache($a->getBasePath() . "/view/smarty3/compiled", $a->getBasePath() . "/view/smarty3/compiled");
// clear cache for image proxy
if (!DI::config()->get("system", "proxy_disabled")) {
clear_cache($a->getBasePath(), $a->getBasePath() . "/proxy");
$cachetime = DI::config()->get('system', 'proxy_cache_time');
if (!$cachetime) {
$cachetime = ProxyUtils::DEFAULT_TIME;
}
$condition = ['`uid` = 0 AND `resource-id` LIKE "pic:%" AND `created` < NOW() - INTERVAL ? SECOND', $cachetime];
Photo::delete($condition);
}
// Delete the cached OEmbed entries that are older than three month
DBA::delete('oembed', ["`created` < NOW() - INTERVAL 3 MONTH"]);

View File

@ -570,10 +570,6 @@ return [
// xrd_timeout (Integer)
// Timeout in seconds for fetching the XRD links.
'xrd_timeout' => 20,
// proxy_file_chmod (Octal Integer like 0640)
// If set, defines the files permissions for downloaded files in the /proxy/ directory, default is system-dependent
'proxy_file_chmod' => 0,
],
'experimental' => [
// exp_themes (Boolean)

View File

@ -51,9 +51,6 @@ class BBCodeTest extends MockedTest
$this->configMock->shouldReceive('get')
->with('system', 'allowed_link_protocols')
->andReturn(null);
$this->configMock->shouldReceive('get')
->with('system', 'itemcache_duration')
->andReturn(-1);
$this->configMock->shouldReceive('get')
->with('system', 'url')
->andReturn('friendica.local');

View File

@ -106,8 +106,6 @@
<h2>{{$performance}}</h2>
{{include file="field_checkbox.tpl" field=$only_tag_search}}
{{include file="field_input.tpl" field=$itemcache}}
{{include file="field_input.tpl" field=$itemcache_duration}}
{{include file="field_input.tpl" field=$max_comments}}
{{include file="field_input.tpl" field=$max_display_comments}}
{{include file="field_checkbox.tpl" field=$proxy_disabled}}

View File

@ -241,8 +241,6 @@
<div id="admin-settings-performance-collapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="admin-settings-performance">
<div class="panel-body">
{{include file="field_checkbox.tpl" field=$only_tag_search}}
{{include file="field_input.tpl" field=$itemcache}}
{{include file="field_input.tpl" field=$itemcache_duration}}
{{include file="field_input.tpl" field=$max_comments}}
{{include file="field_input.tpl" field=$max_display_comments}}
{{include file="field_checkbox.tpl" field=$proxy_disabled}}

View File

@ -4620,7 +4620,6 @@ div #datebrowse-sidebar.widget {
margin: 25px 0 25px 0;
}
#id_itemcache,
#id_basepath,
#id_temppath,
#id_lockpath,
@ -4633,7 +4632,6 @@ div #datebrowse-sidebar.widget {
width: 440px;
}
#id_itemcache_duration,
#id_abandon_days,
#id_maxloadavg,
#id_poll_interval,