From e20e62ffd688e401b2bd95739ceb9dfe0b1df1ab Mon Sep 17 00:00:00 2001 From: utzer Date: Fri, 12 Mar 2021 09:55:55 +0100 Subject: [PATCH 1/5] Part of bugfix for storage move problem @fabrixxm is this already good to change? --- src/Core/StorageManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/StorageManager.php b/src/Core/StorageManager.php index c8385783e9..b832b20fa3 100644 --- a/src/Core/StorageManager.php +++ b/src/Core/StorageManager.php @@ -311,7 +311,7 @@ class StorageManager if ($destinationRef !== '') { $this->logger->info('update row'); - if ($this->dba->update($table, ['backend-class' => $destination, 'backend-ref' => $destinationRef, 'data' => ''], ['id' => $id])) { + if ($this->dba->update($table, ['backend-class' => $destination::getName(), 'backend-ref' => $destinationRef, 'data' => ''], ['id' => $id])) { if (!empty($source)) { $this->logger->info('Delete data from old backend.', ['oldBackend' => $source, 'oldReference' => $sourceRef]); $source->delete($sourceRef); From 225a37af9a111f3565c7ee315e14aec7866680ef Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Fri, 12 Mar 2021 18:21:50 +0100 Subject: [PATCH 2/5] Installer: install themes as last action this will register theme hooks --- src/Module/Install.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Module/Install.php b/src/Module/Install.php index 95644ae625..2a9bab81ec 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -26,6 +26,7 @@ use Friendica\BaseModule; use Friendica\Core; use Friendica\Core\Config\Cache; use Friendica\Core\Renderer; +use Friendica\Core\Theme; use Friendica\DI; use Friendica\Network\HTTPException; use Friendica\Util\BasePath; @@ -162,6 +163,16 @@ class Install extends BaseModule } self::$installer->installDatabase($configCache->get('system', 'basepath')); + + // install allowed themes to register theme hooks + // this is same as "Reload active theme" in /admin/themes + $allowed_themes = Theme::getAllowedList(); + $allowed_themes = array_unique($allowed_themes); + foreach ($allowed_themes as $theme) { + Theme::uninstall($theme); + Theme::install($theme); + } + Theme::setAllowedList($allowed_themes); break; } From a861eb65afa999a0be7e001b0d5b239623b569a6 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Fri, 12 Mar 2021 18:24:45 +0100 Subject: [PATCH 3/5] Storage: small fixes to 'storage move' - stop command if current storage backend is still "legacy" - write destination backend name in log --- src/Console/Storage.php | 5 +++++ src/Core/StorageManager.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Console/Storage.php b/src/Console/Storage.php index d0a2a66637..a048d74ff8 100644 --- a/src/Console/Storage.php +++ b/src/Console/Storage.php @@ -23,6 +23,7 @@ namespace Friendica\Console; use Asika\SimpleConsole\CommandArgsException; use Friendica\Core\StorageManager; +use Friendica\Model\Storage\StorageException; /** * tool to manage storage backend and stored data from CLI @@ -165,6 +166,10 @@ HELP; $current = $this->storageManager->getBackend(); $total = 0; + if (is_null($current)) { + throw new StorageException(sprintf("Cannot move to legacy storage. Please select a storage backend.")); + } + do { $moved = $this->storageManager->move($current, $tables, $this->getOption('n', 5000)); if ($moved) { diff --git a/src/Core/StorageManager.php b/src/Core/StorageManager.php index b832b20fa3..6fadcb52bc 100644 --- a/src/Core/StorageManager.php +++ b/src/Core/StorageManager.php @@ -305,7 +305,7 @@ class StorageManager $data = $source->get($sourceRef); } - $this->logger->info('Save data to new backend.', ['newBackend' => $destination]); + $this->logger->info('Save data to new backend.', ['newBackend' => $destination::getName()]); $destinationRef = $destination->put($data); $this->logger->info('Saved data.', ['newReference' => $destinationRef]); From 0bc1ebe5bfc9532b85e22539fdf4a24f06d1dda8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 Mar 2021 11:37:11 +0000 Subject: [PATCH 4/5] Only set file permissions when configured --- src/Module/Proxy.php | 9 +++++++-- static/defaults.config.php | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index 10ddd56334..735048a867 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -127,13 +127,16 @@ class Proxy extends BaseModule } $basepath = $a->getBasePath(); + $filepermission = DI::config()->get('system', 'proxy_file_chmod'); // Store original image if ($direct_cache) { // direct cache , store under ./proxy/ $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true); file_put_contents($filename, $image->asString()); - chmod($filename, DI::config()->get('system', 'proxy_file_chmod')); + if (!empty($filepermission)) { + chmod($filename, $filepermission); + } } elseif($cachefile !== '') { // cache file file_put_contents($cachefile, $image->asString()); @@ -153,7 +156,9 @@ class Proxy extends BaseModule if ($direct_cache && $request['sizetype'] != '') { $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true) . $request['sizetype']; file_put_contents($filename, $image->asString()); - chmod($filename, DI::config()->get('system', 'proxy_file_chmod')); + if (!empty($filepermission)) { + chmod($filename, $filepermission); + } } self::responseImageHttpCache($image); diff --git a/static/defaults.config.php b/static/defaults.config.php index b075db36a0..ce9dd477aa 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -571,9 +571,9 @@ return [ // Timeout in seconds for fetching the XRD links. 'xrd_timeout' => 20, - // proxy_file_chmod (Integer) - // Access rights for downloaded files in /proxy/ directory - 'proxy_file_chmod' => 0640, + // proxy_file_chmod (Octal Integer) + // Access rights for downloaded files in /proxy/ directory like 0640 + 'proxy_file_chmod' => 0, ], 'experimental' => [ // exp_themes (Boolean) From af874c6a1be2d4b34061dbac26ecef604d8cee41 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 13 Mar 2021 07:19:17 -0500 Subject: [PATCH 5/5] Improve description of system.proxy_file_chmod setting --- static/defaults.config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/defaults.config.php b/static/defaults.config.php index ce9dd477aa..2edb135074 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -571,8 +571,8 @@ return [ // Timeout in seconds for fetching the XRD links. 'xrd_timeout' => 20, - // proxy_file_chmod (Octal Integer) - // Access rights for downloaded files in /proxy/ directory like 0640 + // proxy_file_chmod (Octal Integer like 0640) + // If set, defines the files permissions for downloaded files in the /proxy/ directory, default is system-dependent 'proxy_file_chmod' => 0, ], 'experimental' => [