deprecate DiskCache->touch()

This commit is contained in:
Andrew Dolgov 2022-11-24 08:16:56 +03:00
parent 9732d8fc9f
commit 3180b35807
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
5 changed files with 7 additions and 12 deletions

View File

@ -20,7 +20,6 @@ interface Cache_Adapter {
* @return int|false Bytes written or false if an error occurred.
*/
public function put(string $filename, $data);
public function touch(string $filename): bool;
public function get(string $filename): ?string;
public function get_full_path(string $filename): string;
/**

View File

@ -66,10 +66,6 @@ class Cache_Local implements Cache_Adapter {
return file_put_contents($this->get_full_path($filename), $data);
}
public function touch(string $filename): bool {
return touch($this->get_full_path($filename));
}
/**
* @return false|null|string false if detection failed, null if the file doesn't exist, string mime content type otherwise
*/

View File

@ -238,8 +238,12 @@ class DiskCache implements Cache_Adapter {
return $this->adapter->put($filename, $data);
}
/** @deprecated we can't assume cached files are local, and other storages
* might not support this operation (object metadata may be immutable) */
public function touch(string $filename): bool {
return $this->adapter->touch($filename);
user_error("DiskCache: called unsupported method touch() for $filename", E_USER_DEPRECATED);
return false;
}
public function get(string $filename): ?string {

View File

@ -1326,8 +1326,6 @@ class RSSUtils {
} else {
Debug::log("cache_enclosures: failed with ".UrlHelper::$fetch_last_error_code.": ".UrlHelper::$fetch_last_error);
}
} else if (is_writable($local_filename)) {
$cache->touch($local_filename);
}
}
}
@ -1353,8 +1351,6 @@ class RSSUtils {
} else {
Debug::log("cache_media: failed with ".UrlHelper::$fetch_last_error_code.": ".UrlHelper::$fetch_last_error);
}
} else if ($cache->is_writable($local_filename)) {
$cache->touch($local_filename);
}
}

View File

@ -31,10 +31,10 @@ class Cache_Starred_Images extends Plugin {
chmod($this->cache_status->get_dir(), 0777);
if (!$this->cache->exists(".no-auto-expiry"))
$this->cache->touch(".no-auto-expiry");
$this->cache->put(".no-auto-expiry", "");
if (!$this->cache_status->exists(".no-auto-expiry"))
$this->cache_status->touch(".no-auto-expiry");
$this->cache_status->put(".no-auto-expiry", "");
if ($this->cache->is_writable() && $this->cache_status->is_writable()) {
$host->add_hook($host::HOOK_HOUSE_KEEPING, $this);