mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 08:45:28 +02:00
Fixed deleting page with language code not removing the folder if it was the last language [#3305]
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
|
||||
1. [](#improved)
|
||||
* Better GPM detection of unauthorized installations
|
||||
* Fixed nxinx appending repeating `?url=` in some redirects
|
||||
* Fixed nxinx appending repeating `?_url=` in some redirects
|
||||
* Fixed deleting page with language code not removing the folder if it was the last language [#3305](https://github.com/getgrav/grav/issues/3305)
|
||||
|
||||
# v1.7.10
|
||||
## 04/06/2021
|
||||
|
||||
@@ -474,17 +474,28 @@ class PageStorage extends FolderStorage
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if page folder should be deleted.
|
||||
*
|
||||
* Deleting page can be done either by deleting everything or just a single language.
|
||||
* If key contains the language, delete only it, unless it is the last language.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
protected function canDeleteFolder(string $key): bool
|
||||
{
|
||||
// Return true if there's no language in the key.
|
||||
$keys = $this->extractKeysFromStorageKey($key);
|
||||
if ($keys['lang']) {
|
||||
return false;
|
||||
if (!$keys['lang']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
// Get the main key and reload meta.
|
||||
$key = $this->buildStorageKey($keys);
|
||||
$meta = $this->getObjectMeta($key, true);
|
||||
|
||||
// Return true if there aren't any markdown files left.
|
||||
return empty($meta['markdown'] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user