Fixed deleting page with language code not removing the folder if it was the last language [#3305]

This commit is contained in:
Matias Griese
2021-04-09 11:13:51 +03:00
parent 74a667bbef
commit f3e4f9d311
2 changed files with 16 additions and 4 deletions

View File

@@ -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

View File

@@ -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'] ?? []);
}
/**