Skip to content

Commit bd60f50

Browse files
authored
refactor: deprecate redundant FileHandler cache methods (#9511)
1 parent 49a56da commit bd60f50

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

system/Cache/Handlers/FileHandler.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function __construct(Cache $config)
6363

6464
$this->mode = $config->file['mode'] ?? 0640;
6565
$this->prefix = $config->prefix;
66+
67+
helper('filesystem');
6668
}
6769

6870
/**
@@ -96,7 +98,7 @@ public function save(string $key, $value, int $ttl = 60)
9698
'data' => $value,
9799
];
98100

99-
if ($this->writeFile($this->path . $key, serialize($contents))) {
101+
if (write_file($this->path . $key, serialize($contents))) {
100102
try {
101103
chmod($this->path . $key, $this->mode);
102104

@@ -176,15 +178,15 @@ public function decrement(string $key, int $offset = 1)
176178
*/
177179
public function clean()
178180
{
179-
return $this->deleteFiles($this->path, false, true);
181+
return delete_files($this->path, false, true);
180182
}
181183

182184
/**
183185
* {@inheritDoc}
184186
*/
185187
public function getCacheInfo()
186188
{
187-
return $this->getDirFileInfo($this->path);
189+
return get_dir_file_info($this->path);
188190
}
189191

190192
/**
@@ -251,6 +253,8 @@ protected function getItem(string $filename)
251253
/**
252254
* Writes a file to disk, or returns false if not successful.
253255
*
256+
* @deprecated 4.6.1 Use `write_file()` instead.
257+
*
254258
* @param string $path
255259
* @param string $data
256260
* @param string $mode
@@ -283,6 +287,8 @@ protected function writeFile($path, $data, $mode = 'wb')
283287
* If the second parameter is set to TRUE, any directories contained
284288
* within the supplied base directory will be nuked as well.
285289
*
290+
* @deprecated 4.6.1 Use `delete_files()` instead.
291+
*
286292
* @param string $path File path
287293
* @param bool $delDir Whether to delete any directories found in the path
288294
* @param bool $htdocs Whether to skip deleting .htaccess and index page files
@@ -318,6 +324,8 @@ protected function deleteFiles(string $path, bool $delDir = false, bool $htdocs
318324
*
319325
* Any sub-folders contained within the specified path are read as well.
320326
*
327+
* @deprecated 4.6.1 Use `get_dir_file_info()` instead.
328+
*
321329
* @param string $sourceDir Path to source
322330
* @param bool $topLevelOnly Look only at the top level directory specified?
323331
* @param bool $_recursion Internal variable to determine recursion status - do not use in calls
@@ -360,6 +368,8 @@ protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true,
360368
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
361369
* Returns FALSE if the file cannot be found.
362370
*
371+
* @deprecated 4.6.1 Use `get_file_info()` instead.
372+
*
363373
* @param string $file Path to file
364374
* @param array|string $returnedValues Array or comma separated string of information returned
365375
*

user_guide_src/source/changelogs/v4.6.1.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ Changes
2626
Deprecations
2727
************
2828

29+
- **Cache:** The ``FileHandler::writeFile()`` method is deprecated. Use ``write_file()`` instead.
30+
- **Cache:** The ``FileHandler::deleteFiles()`` method is deprecated. Use ``delete_files()`` instead.
31+
- **Cache:** The ``FileHandler::getDirFileInfo()`` method is deprecated. Use ``get_dir_file_info()`` instead.
32+
- **Cache:** The ``FileHandler::getFileInfo()`` method is deprecated. Use ``get_file_info()`` instead.
33+
2934
**********
3035
Bugs Fixed
3136
**********

0 commit comments

Comments
 (0)