You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 22afa4b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(Cache): delete hidden cache entries in the File handler
A cache key may begin with a period, so save() writes a hidden cache file.
clean() called delete_files() without $hidden, getCacheInfo() used a helper
that always skipped dot-leading names, and deleteMatching() used FNM_PERIOD.
Such an entry was not listed by getCacheInfo() nor bulk-removed by clean()
or deleteMatching(), so cache:clear left it in place permanently.
- clean(): pass $hidden = true. .htaccess, index.* and web.config stay
protected by $htdocs.
- getCacheInfo(): add an optional $hidden parameter to get_dir_file_info(),
keep its default behavior, and include hidden files.
- deleteMatching(): drop FNM_PERIOD so wildcards match dot-leading entries,
and skip the .htaccess protection file case-insensitively.
The user guide and the 4.7.7 changelog describe the new behavior.
Copy file name to clipboardExpand all lines: docs/changelogs/v4.7.7.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@ Release Date: Unreleased
22
22
23
23
-**API:** Fixed HTTP 500 errors in `ResponseTrait::paginate()` when using a Query Builder with a very large page number or `$perPage = 0`.
24
24
-**Cache:** Fixed a bug where `PredisHandler::increment()` and `PredisHandler::decrement()` updated the unused `'data'` hash field instead of `'__ci_value'`, causing `get()` to return stale values for existing counters.
25
+
-**Cache:** Fixed a bug where the File handler skipped cache entries whose key begins with a period in `clean()`, `getCacheInfo()` and `deleteMatching()`. Such entries were not listed by `getCacheInfo()` and were not removed by `clean()` or `deleteMatching()`, so `cache:clear` left them in place. `deleteMatching()` wildcard patterns now also match these entries, while the `.htaccess` protection file is still skipped.
25
26
-**CORS:** Fixed a bug where `Cors::hasResponseHeaders()` matched header substrings via `str_contains()`, causing false positives when existing exposed headers shared a prefix with configured exposed headers.
26
27
-**Database:** Fixed a bug where `BaseConnection::prepare()` did not reset pretend mode when the closure threw an exception, leaving the connection in pretend mode so that subsequent queries on it were silently discarded.
27
28
-**Database:** Fixed a bug where `Postgre`, `OCI8`, and `SQLSRV``Forge::_dropKeyAsConstraint()` interpolated table, constraint, and schema names without escaping.
-**$topLevelOnly**`bool` Whether to look only at the specified directory (excluding sub-directories)
224
+
-**$recursion**`bool` Whether to recurse into sub-directories. For internal use; do not pass it from application code.
225
+
-**$hidden**`bool` Whether to include hidden files (files beginning with a period)
226
+
227
+
> **Note:**`$recursion` is an internal parameter and should not be passed by callers. When you need hidden files, use the named argument, e.g. `get_dir_file_info($sourceDir, hidden: true)`.
224
228
225
229
-**Returns**: An array containing info on the supplied directory's contents
This is an array of settings specific to the **File** handler to determine how it should save the cache files.
72
72
73
-
Cache files whose names start with a dot are not fully supported by the File handler: `getCacheInfo()` does not report them, `deleteMatching()` wildcard patterns do not match them, and `clean()` / `cache:clear` do not delete them. Avoid keys and prefixes that produce a leading dot.
73
+
Dot-leading cache keys are supported by the File handler: they are reported by `getCacheInfo()`, matched by `deleteMatching()`, and removed by `clean()` / `cache:clear`. The `.htaccess` protection file is never deleted by `deleteMatching()`, and the protection files (`.htaccess`, `index.html`, `index.htm`, `index.php`, `web.config`) are kept by `clean()`; any other dot-leading file in the cache directory is affected. See the notes below `deleteMatching()`, `clean()` and `getCacheInfo()`.
74
74
75
75
### $memcached
76
76
@@ -201,7 +201,7 @@ This method will delete multiple items from the cache store at once by matching
201
201
This method is only implemented for the File, Redis and Predis handlers. Due to limitations, it couldn't be implemented for the Memcached and Wincache handlers.
202
202
203
203
!!! note "Note"
204
-
With the File handler, the pattern is matched against cache file names only and cannot match files in subdirectories. A pattern containing a forward slash (`/`) therefore never matches.
204
+
With the File handler, the pattern is matched against cache file names only and cannot match files in subdirectories. A pattern containing a forward slash (`/`) therefore never matches. A cache entry whose key begins with a period (a dot-leading file name) is matched by patterns like any other entry, but the `.htaccess` protection file is never deleted. Any other dot-leading file in the cache directory (for example `.gitignore` or `.env`) is matched as well.
205
205
206
206
Example:
207
207
@@ -276,6 +276,9 @@ Example:
276
276
$cache->clean();
277
277
```
278
278
279
+
!!! note "Note"
280
+
The File handler also deletes cache entries whose key begins with a period, while the `.htaccess`, `index.html`, `index.htm`, `index.php` and `web.config` files are kept. Any other dot-leading file in the cache directory or its subdirectories (for example `.gitignore`, `.env` or `.user.ini`) is deleted as well.
281
+
279
282
#### getCacheInfo()
280
283
281
284
-**Returns**: Information on the entire cache database
0 commit comments