Skip to content

Commit 43acb8d

Browse files
committed
Merge branch 'release/1.10.54'
2 parents c6c820a + 13aa5d1 commit 43acb8d

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

2+
# v1.10.54
3+
## 08/07/2026
4+
5+
1. [](#bugfix)
6+
* Deleting a media file whose name contains a bracket or a similar character now removes its retina copies and metadata, which were previously left behind.
7+
* Deleting a media file no longer also removes files belonging to a different item whose name ends with the same text, so deleting `banner.jpg` leaves `my-banner@2x.jpg` alone.
8+
29
# v1.10.53
310
## 07/21/2026
411

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Admin Panel
22
slug: admin
33
type: plugin
4-
version: 1.10.53
4+
version: 1.10.54
55
description: Adds an advanced administration panel to manage your site
66
icon: empire
77
author:

classes/plugin/AdminBaseController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,13 @@ public function taskRemoveMedia($filename = null)
10921092

10931093
$fileParts = Utils::pathinfo($filename);
10941094

1095+
// The extension was the one part left unescaped here, and the pattern
1096+
// was unanchored, so a name could match as a suffix of a longer one.
1097+
$regex_pattern = '/^(?:' . preg_quote((string)($fileParts['filename'] ?? ''), '/')
1098+
. '@\d+x\.' . preg_quote((string)($fileParts['extension'] ?? ''), '/')
1099+
. '(?:\.meta\.yaml)?|' . preg_quote($fileParts['basename'], '/') . '\.meta\.yaml)$/';
1100+
10951101
foreach (scandir($fileParts['dirname']) as $file) {
1096-
$regex_pattern = '/' . preg_quote($fileParts['filename'], '/') . "@\d+x\." . $fileParts['extension'] . "(?:\.meta\.yaml)?$|" . preg_quote($fileParts['basename'], '/') . "\.meta\.yaml$/";
10971102
if (preg_match($regex_pattern, $file)) {
10981103
$path = $fileParts['dirname'] . '/' . $file;
10991104
@unlink($path);

classes/plugin/AdminController.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,14 +2504,29 @@ protected function taskDelmedia()
25042504
}
25052505

25062506
// Remove Extra Files
2507+
// Escape the filename before it becomes part of the pattern, otherwise a
2508+
// regex metacharacter in the name (`|`, `.`, `+`, `[`, ...) changes what
2509+
// the sweep matches: `a[b.jpg` makes the pattern invalid so the cleanup
2510+
// silently does nothing, and an alternation reaches unrelated files in the
2511+
// page folder. Anchored so a name is not matched as a suffix of a longer
2512+
// one, which is what let deleting `banner.jpg` take `my-banner@2x.jpg`.
2513+
$preg_name = preg_quote((string)($fileParts['filename'] ?? ''), '/');
2514+
$preg_ext = preg_quote((string)($fileParts['extension'] ?? ''), '/');
2515+
$preg_filename = preg_quote($filename, '/');
2516+
$regex_pattern = "/^(?:{$preg_name}@\d+x\.{$preg_ext}(?:\.meta\.yaml)?|{$preg_filename}\.meta\.yaml)$/";
2517+
25072518
foreach (scandir($media->getPath(), SCANDIR_SORT_NONE) as $file) {
2508-
if (preg_match("/{$fileParts['filename']}@\d+x\.{$fileParts['extension']}(?:\.meta\.yaml)?$|{$filename}\.meta\.yaml$/", $file)) {
2519+
if (preg_match($regex_pattern, $file)) {
25092520

25102521
$targetPath = $media->getPath() . '/' . $file;
25112522
if ($locator->isStream($targetPath)) {
25122523
$targetPath = $locator->findResource($targetPath, true, true);
25132524
}
25142525

2526+
if (!is_file($targetPath)) {
2527+
continue;
2528+
}
2529+
25152530
$result = unlink($targetPath);
25162531

25172532
if (!$result) {

0 commit comments

Comments
 (0)