From a78e9c2ebe34b628d48641dd633a7984a48a4d47 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Mon, 11 Apr 2022 10:09:15 +0200 Subject: [PATCH 1/6] rex_mediapool_saveMedia() korrigiert (#5112) --- .../src/addons/mediapool/functions/function_rex_mediapool.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redaxo/src/addons/mediapool/functions/function_rex_mediapool.php b/redaxo/src/addons/mediapool/functions/function_rex_mediapool.php index 554995206e..50f839f057 100644 --- a/redaxo/src/addons/mediapool/functions/function_rex_mediapool.php +++ b/redaxo/src/addons/mediapool/functions/function_rex_mediapool.php @@ -42,7 +42,7 @@ function rex_mediapool_saveMedia($FILE, $rexFileCategory, $FILEINFOS, $userlogin if ($FILE) { $data['file'] = $FILE; - if (!isset($data['file']['path']) && isset($FILE['name'])) { + if (!isset($data['file']['path']) && isset($FILE['name']) && !isset($FILE['tmp_name'])) { $data['file']['path'] = rex_path::media($FILE['name']); } } From d0a1d714a502ea812c71d45a30067ebaa91f3d12 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Mon, 11 Apr 2022 10:13:37 +0200 Subject: [PATCH 2/6] rex_var::quote: support null value (#5108) --- redaxo/src/core/lib/var/var.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redaxo/src/core/lib/var/var.php b/redaxo/src/core/lib/var/var.php index dae442dfc6..bc0ec38fce 100644 --- a/redaxo/src/core/lib/var/var.php +++ b/redaxo/src/core/lib/var/var.php @@ -341,12 +341,16 @@ abstract protected function getOutput(); /** * Quotes the string for php context. * - * @param string $string + * @param string|null $string * * @return string */ protected static function quote($string) { + if (null === $string) { + return 'null'; + } + $string = addcslashes($string, "\\'"); $string = preg_replace('/\v+/', '\' . "$0" . \'', $string); $string = addcslashes($string, "\r\n"); From 432d0e0470656b2ccad4c3a67062a5714307f731 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Mon, 11 Apr 2022 10:16:02 +0200 Subject: [PATCH 3/6] Command assets:sync: Core-Assets-Handling optimiert (#5110) --- redaxo/src/core/lib/console/assets_sync.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/redaxo/src/core/lib/console/assets_sync.php b/redaxo/src/core/lib/console/assets_sync.php index 3a6b95aadc..3e6d684770 100644 --- a/redaxo/src/core/lib/console/assets_sync.php +++ b/redaxo/src/core/lib/console/assets_sync.php @@ -62,7 +62,21 @@ protected function execute(InputInterface $input, OutputInterface $output) $errored += $err; } - [$ctd, $upd, $err] = $this->sync($io, rex_path::coreAssets(), rex_path::core('assets/')); + $assetsPublicPath = rex_path::coreAssets(); + $assetsSrcPath = rex_path::core('assets/'); + if (!is_dir($assetsPublicPath)) { + rex_dir::create($assetsPublicPath); + } + if (!is_dir($assetsSrcPath)) { + rex_dir::create($assetsSrcPath); + } + + [$ctd, $upd, $err] = $this->sync($io, $assetsPublicPath, $assetsSrcPath); + $created += $ctd; + $updated += $upd; + $errored += $err; + + [$ctd, $upd, $err] = $this->sync($io, $assetsSrcPath, $assetsPublicPath); $created += $ctd; $updated += $upd; $errored += $err; From eca0fd93dca084a412b7987e9d7fc0eb8900827b Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Mon, 11 Apr 2022 10:18:27 +0200 Subject: [PATCH 4/6] =?UTF-8?q?Package-Cache=20besser=20l=C3=B6schen=20(#5?= =?UTF-8?q?109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redaxo/src/core/lib/packages/manager.php | 2 ++ redaxo/src/core/lib/packages/package.php | 28 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/redaxo/src/core/lib/packages/manager.php b/redaxo/src/core/lib/packages/manager.php index 2760d715f2..ee53840a61 100644 --- a/redaxo/src/core/lib/packages/manager.php +++ b/redaxo/src/core/lib/packages/manager.php @@ -381,6 +381,8 @@ protected function _delete($ignoreState = false) $this->message = $this->i18n('deleted', $this->package->getName()); } + $this->package->clearCache(); + return true; } diff --git a/redaxo/src/core/lib/packages/package.php b/redaxo/src/core/lib/packages/package.php index 242217054c..9d2fc779b4 100644 --- a/redaxo/src/core/lib/packages/package.php +++ b/redaxo/src/core/lib/packages/package.php @@ -17,6 +17,8 @@ abstract class rex_package implements rex_package_interface public const FILE_UNINSTALL_SQL = 'uninstall.sql'; public const FILE_UPDATE = 'update.php'; + private const PROPERTIES_CACHE_FILE = 'packages.cache'; + /** * Name of the package. * @@ -298,7 +300,7 @@ public function loadProperties() static $cache = null; if (null === $cache) { - $cache = rex_file::getCache(rex_path::coreCache('packages.cache')); + $cache = rex_file::getCache(rex_path::coreCache(self::PROPERTIES_CACHE_FILE)); } $id = $this->getPackageId(); @@ -320,7 +322,7 @@ public function loadProperties() unset($cache[$package]); } } - rex_file::putCache(rex_path::coreCache('packages.cache'), $cache); + rex_file::putCache(rex_path::coreCache(self::PROPERTIES_CACHE_FILE), $cache); }); } } catch (rex_yaml_parse_exception $exception) { @@ -359,13 +361,27 @@ public function loadProperties() public function clearCache() { $cacheDir = $this->getCachePath(); - if (!is_dir($cacheDir)) { - return; + if (!rex_dir::delete($cacheDir)) { + throw new rex_functional_exception($this->i18n('cache_not_writable', $cacheDir)); } - if (rex_dir::delete($cacheDir)) { + + $cache = rex_file::getCache($path = rex_path::coreCache(self::PROPERTIES_CACHE_FILE)); + if (!$cache) { return; } - throw new rex_functional_exception($this->i18n('cache_not_writable', $cacheDir)); + + unset($cache[$this->getPackageId()]); + + if ($this instanceof rex_addon) { + $start = $this->getPackageId().'/'; + foreach ($cache as $packageId => $_) { + if (str_starts_with((string) $packageId, $start)) { + unset($cache[$packageId]); + } + } + } + + rex_file::putCache($path, $cache); } public function enlist() From 4b35b5df91ddd8ac8e4a86e007e5d6e21b2aefe9 Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Fri, 15 Apr 2022 11:39:49 +0200 Subject: [PATCH 5/6] =?UTF-8?q?rex=5Fform:=20Fieldset=20mit=20eckigen=20Kl?= =?UTF-8?q?ammern=20unterst=C3=BCtzen=20(#5111)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redaxo/src/core/lib/form/form_base.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/redaxo/src/core/lib/form/form_base.php b/redaxo/src/core/lib/form/form_base.php index b278235338..cb06b2f261 100644 --- a/redaxo/src/core/lib/form/form_base.php +++ b/redaxo/src/core/lib/form/form_base.php @@ -559,10 +559,11 @@ protected function createElement($tag, $name, $value, array $attributes = []) // Eigentlichen Feldnamen nochmals speichern $fieldName = $name; + $fieldset = rex_string::normalize($this->fieldset); if (true === $attributes['internal::useArraySyntax']) { - $name = $this->fieldset . '[' . $name . ']'; + $name = $fieldset . '[' . $name . ']'; } elseif (false === $attributes['internal::useArraySyntax']) { - $name = $this->fieldset . '_' . $name; + $name = $fieldset . '_' . $name; } unset($attributes['internal::useArraySyntax']); @@ -933,7 +934,8 @@ protected function getElement($fieldsetName, $elementName) return null; } - $normalizedName = rex_string::normalize($fieldsetName . '[' . $elementName . ']', '_', '[]'); + $normalizedName = rex_string::normalize($fieldsetName); + $normalizedName .= '['.rex_string::normalize($elementName).']'; for ($i = 0; $i < count($this->elements[$fieldsetName]); ++$i) { if ($this->elements[$fieldsetName][$i]->getAttribute('name') == $normalizedName) { @@ -1017,15 +1019,7 @@ protected function preView($fieldsetName, $fieldName, $fieldValue) */ public function fieldsetPostValues($fieldsetName) { - // Name normalisieren, da der gepostete Name auch zuvor normalisiert wurde. - // Da der Feldname als Ganzes normalisiert wurde, hier Array mit angehängtem '[' simulieren - // um das Trimmen von möglichen "_" am Ende durch die normalize-Methode zu vermeiden. - // Anschließend "[" wieder entfernen. - // https://github.com/redaxo/redaxo/issues/2710 - $normalizedFieldsetName = rex_string::normalize($fieldsetName.'[', '_', '[]'); - $normalizedFieldsetName = substr($normalizedFieldsetName, 0, -1); - - return rex_post($normalizedFieldsetName, 'array'); + return rex_post(rex_string::normalize($fieldsetName), 'array'); } /** @@ -1040,7 +1034,7 @@ public function elementPostValue($fieldsetName, $fieldName, $default = null) $fields = $this->fieldsetPostValues($fieldsetName); // name attributes are normalized - $normalizedFieldName = rex_string::normalize($fieldName, '_', '[]'); + $normalizedFieldName = rex_string::normalize($fieldName); if (isset($fields[$normalizedFieldName])) { return $fields[$normalizedFieldName]; From da96794e4b02abea76a409a7dbeb3ea09a65f1a4 Mon Sep 17 00:00:00 2001 From: Marcel Kuhmann Date: Fri, 15 Apr 2022 11:48:35 +0200 Subject: [PATCH 6/6] debug: check core config file to decide if clockwork should be turned on (#5113) --- redaxo/src/addons/debug/boot.php | 2 +- .../src/addons/debug/lib/debug_clockwork.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/redaxo/src/addons/debug/boot.php b/redaxo/src/addons/debug/boot.php index b2b53a99b3..e0751ca381 100644 --- a/redaxo/src/addons/debug/boot.php +++ b/redaxo/src/addons/debug/boot.php @@ -1,6 +1,6 @@ getCachePath('clockwork.db'); } + + /** + * We cannot rely on rex::isDebugMode() because it is always true on the console. + * So we have to check the config file itself. + */ + public static function isRexDebugEnabled(): bool + { + if (PHP_SAPI !== 'cli') { + return rex::isDebugMode(); + } + + $coreConfigCacheFile = rex_path::coreCache('config.yml.cache'); + $coreConfigCache = rex_file::getCache($coreConfigCacheFile); + /** @var bool $debugEnabled */ + $debugEnabled = $coreConfigCache['debug']['enabled'] ?? false; + + return $debugEnabled; + } }