From 9bfb4ec07ff8494f97597b6ef95d386b0bf9795d Mon Sep 17 00:00:00 2001
From: mhsdesign <85400359+mhsdesign@users.noreply.github.com>
Date: Sun, 16 Jun 2024 22:22:16 +0200
Subject: [PATCH 1/3] FEATURE: Check `cr:status` in health check
---
.../Healthcheck/CrHealthcheck.php | 38 +++++++------------
1 file changed, 14 insertions(+), 24 deletions(-)
diff --git a/Classes/Infrastructure/Healthcheck/CrHealthcheck.php b/Classes/Infrastructure/Healthcheck/CrHealthcheck.php
index 6223b67..cc4991d 100644
--- a/Classes/Infrastructure/Healthcheck/CrHealthcheck.php
+++ b/Classes/Infrastructure/Healthcheck/CrHealthcheck.php
@@ -4,8 +4,8 @@
namespace Neos\Neos\Setup\Infrastructure\Healthcheck;
-use Doctrine\DBAL\Connection;
-use Doctrine\DBAL\Schema\AbstractSchemaManager;
+use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
+use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Configuration\ConfigurationManager;
use Neos\Setup\Domain\Health;
use Neos\Setup\Domain\HealthcheckEnvironment;
@@ -15,8 +15,8 @@
class CrHealthcheck implements HealthcheckInterface
{
public function __construct(
- private Connection $dbalConnection,
- private ConfigurationManager $configurationManager
+ private ConfigurationManager $configurationManager,
+ private ContentRepositoryRegistry $contentRepositoryRegistry
) {
}
@@ -27,8 +27,7 @@ public function getTitle(): string
public function execute(HealthcheckEnvironment $environment): Health
{
- // TODO: Implement execute() method.
-
+ // todo add contentRepositoryRegistry::getIds() ?
$crIdentifiers = array_keys(
$this->configurationManager
->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.ContentRepositoryRegistry.contentRepositories') ?? []
@@ -41,19 +40,12 @@ public function execute(HealthcheckEnvironment $environment): Health
);
}
- $schemaManager = $this->dbalConnection->getSchemaManager();
- if (!$schemaManager instanceof AbstractSchemaManager) {
- throw new \RuntimeException('Failed to retrieve Schema Manager', 1691250062732);
- }
-
- $existingTableNames = $schemaManager->listTableNames();
-
$unSetupContentRepositories = [];
foreach ($crIdentifiers as $crIdentifier) {
- $eventTableName = sprintf('cr_%s_events', $crIdentifier);
+ $cr = $this->contentRepositoryRegistry->get(ContentRepositoryId::fromString($crIdentifier));
- $isCrSetup = in_array($eventTableName, $existingTableNames, true);
- if (!$isCrSetup) {
+ $crStatus = $cr->status();
+ if (!$crStatus->isOk()) {
$unSetupContentRepositories[] = $crIdentifier;
}
}
@@ -61,13 +53,13 @@ public function execute(HealthcheckEnvironment $environment): Health
if (count($crIdentifiers) === count($unSetupContentRepositories)) {
$rest = $unSetupContentRepositories;
$first = array_shift($rest);
- $additionalNote = sprintf(' or setup %s.', join(' or ', $rest));
+ $additionalNote = count($rest) ? sprintf(' or with %s.', join(' or ', $rest)) : '';
return new Health(
sprintf(
- 'No content repository is setup. Please run {{flowCommand}} cr:setup%s
%s',
+ '{{flowCommand}} cr:status
reported a problem. Please run {{flowCommand}} cr:setup%s
%s',
$environment->isSafeToLeakTechnicalDetails() ? ' --content-repository ' . $first : '',
- $environment->isSafeToLeakTechnicalDetails() && count($rest) ? $additionalNote : ''
+ $environment->isSafeToLeakTechnicalDetails() ? $additionalNote : ''
),
Status::ERROR(),
);
@@ -76,21 +68,19 @@ public function execute(HealthcheckEnvironment $environment): Health
if (count($unSetupContentRepositories)) {
$rest = $unSetupContentRepositories;
$first = array_shift($rest);
- $additionalNote = sprintf(' or setup %s.', join(' or ', $rest));
+ $additionalNote = count($rest) ? sprintf(' or with %s.', join(' or ', $rest)) : '';
return new Health(
sprintf(
'%s Please run {{flowCommand}} cr:setup%s
%s',
- count($unSetupContentRepositories) > 1 ? 'Some content repositories are not setup.' : 'A content repository is not setup.',
+ '{{flowCommand}} cr:status
reported a problem.',
$environment->isSafeToLeakTechnicalDetails() ? ' --content-repository ' . $first : '',
- $environment->isSafeToLeakTechnicalDetails() && count($rest) ? $additionalNote : ''
+ $environment->isSafeToLeakTechnicalDetails() ? $additionalNote : ''
),
Status::WARNING(),
);
}
- // TODO check if `cr:setup` needs to be rerun, to "migrate" projections?
-
if (count($crIdentifiers) === 1) {
return new Health(
sprintf('Content repository %sis setup.', $environment->isSafeToLeakTechnicalDetails() ? sprintf('"%s" ', $crIdentifiers[0]) : ''),
From fcb1fe0103015b6f31691dcb4acb9c24bc9d83e1 Mon Sep 17 00:00:00 2001
From: mhsdesign <85400359+mhsdesign@users.noreply.github.com>
Date: Fri, 13 Dec 2024 08:52:55 +0100
Subject: [PATCH 2/3] TASK: Adjust to use `getContentRepositoryIds`
---
.../Healthcheck/CrHealthcheck.php | 20 ++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/Classes/Infrastructure/Healthcheck/CrHealthcheck.php b/Classes/Infrastructure/Healthcheck/CrHealthcheck.php
index cc4991d..fd7a846 100644
--- a/Classes/Infrastructure/Healthcheck/CrHealthcheck.php
+++ b/Classes/Infrastructure/Healthcheck/CrHealthcheck.php
@@ -4,9 +4,8 @@
namespace Neos\Neos\Setup\Infrastructure\Healthcheck;
-use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
-use Neos\Flow\Configuration\ConfigurationManager;
+use Neos\ContentRepositoryRegistry\Exception\InvalidConfigurationException;
use Neos\Setup\Domain\Health;
use Neos\Setup\Domain\HealthcheckEnvironment;
use Neos\Setup\Domain\HealthcheckInterface;
@@ -15,7 +14,6 @@
class CrHealthcheck implements HealthcheckInterface
{
public function __construct(
- private ConfigurationManager $configurationManager,
private ContentRepositoryRegistry $contentRepositoryRegistry
) {
}
@@ -27,10 +25,8 @@ public function getTitle(): string
public function execute(HealthcheckEnvironment $environment): Health
{
- // todo add contentRepositoryRegistry::getIds() ?
- $crIdentifiers = array_keys(
- $this->configurationManager
- ->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.ContentRepositoryRegistry.contentRepositories') ?? []
+ $crIdentifiers = iterator_to_array(
+ $this->contentRepositoryRegistry->getContentRepositoryIds()
);
if (count($crIdentifiers) === 0) {
@@ -42,8 +38,14 @@ public function execute(HealthcheckEnvironment $environment): Health
$unSetupContentRepositories = [];
foreach ($crIdentifiers as $crIdentifier) {
- $cr = $this->contentRepositoryRegistry->get(ContentRepositoryId::fromString($crIdentifier));
-
+ try {
+ $cr = $this->contentRepositoryRegistry->get($crIdentifier);
+ } catch (InvalidConfigurationException $e) {
+ return new Health(
+ sprintf('Content repository %s is invalid configured%s', $crIdentifier->value, $environment->isSafeToLeakTechnicalDetails() ? ': ' . $e->getMessage() : ''),
+ Status::ERROR(),
+ );
+ }
$crStatus = $cr->status();
if (!$crStatus->isOk()) {
$unSetupContentRepositories[] = $crIdentifier;
From 76e6a055c1dc4673e97ddda2c565992ff0b662e4 Mon Sep 17 00:00:00 2001
From: mhsdesign <85400359+mhsdesign@users.noreply.github.com>
Date: Fri, 13 Dec 2024 09:17:27 +0100
Subject: [PATCH 3/3] TASK: Adjust to use `site:importall`
Fixes: https://github.com/neos/neos-setup/issues/14
see https://github.com/neos/neos-development-collection/pull/5307
---
.../Healthcheck/SiteHealthcheck.php | 29 +++++++------------
.../ImageHandler/ImageHandlerService.php | 1 +
2 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/Classes/Infrastructure/Healthcheck/SiteHealthcheck.php b/Classes/Infrastructure/Healthcheck/SiteHealthcheck.php
index 36761e1..4fbb133 100644
--- a/Classes/Infrastructure/Healthcheck/SiteHealthcheck.php
+++ b/Classes/Infrastructure/Healthcheck/SiteHealthcheck.php
@@ -43,13 +43,12 @@ public function execute(HealthcheckEnvironment $environment): Health
}
if (!$environment->isSafeToLeakTechnicalDetails()) {
- // TODO adjust to 9.0
- return new Health('No Neos site was created. Please visit the documentation how setup a site.', Status::WARNING());
+ return new Health('No Neos site was created. Please look into {{flowCommand}} site:importall
or {{flowCommand}} site:create
.', Status::WARNING());
}
$availableSitePackagesToBeImported = [];
foreach ($this->packageManager->getFilteredPackages('available', 'neos-site') as $sitePackage) {
- $possibleSiteContentToImport = sprintf('resource://%s/Private/Content/events.jsonl', $sitePackage->getPackageKey());
+ $possibleSiteContentToImport = sprintf('resource://%s/Private/Content', $sitePackage->getPackageKey());
if (file_exists($possibleSiteContentToImport)) {
$availableSitePackagesToBeImported[] = $sitePackage->getPackageKey();
}
@@ -57,7 +56,6 @@ public function execute(HealthcheckEnvironment $environment): Health
if (count($availableSitePackagesToBeImported) === 0) {
if (!$this->packageManager->isPackageAvailable('Neos.SiteKickstarter')) {
- // TODO adjust to 9.0
return new Health(<<composer require neos/site-kickstarter.
Or you can create a new site package completely from scratch via {{flowCommand}} package:create My.Site --package-type=neos-site
.
@@ -66,24 +64,17 @@ public function execute(HealthcheckEnvironment $environment): Health
MSG, Status::WARNING());
}
- // TODO adjust to 9.0
return new Health(<<{{flowCommand}} kickstart:site My.Site my-site
- and import it via {{flowCommand}} site:import --package-key My.Site
+ No Neos site was created. You can kickstart a new site package via {{flowCommand}} kickstart:site My.Site
+ and use it to create a site via {{flowCommand}} site:create my-site My.Site My.Site:Document.Homepage
MSG, Status::WARNING());
}
- if (count($availableSitePackagesToBeImported) === 1 && $availableSitePackagesToBeImported[0] === 'Neos.Demo') {
- // TODO adjust to 9.0 (make less specific to neos demo)
- return new Health(<<{{flowCommand}} site:create neosdemo Neos.Demo Neos.Demo:Document.Homepage and {{flowCommand}} cr:prune
and {{flowCommand}} cr:import resource://Neos.Demo/Private/Content
- MSG, Status::WARNING());
- }
-
- // TODO adjust to 9.0
- $availableSitePackages = join(', ', $availableSitePackagesToBeImported);
- return new Health(<<{{flowCommand}} site:importall --package-key %1$s.%2$s',
+ $firstAvailableSitePackageKey,
+ $availableSitePackagesToBeImported === [] ? '' : sprintf(' Or import one of the other available site packages: %s', join(', ', $availableSitePackagesToBeImported))
+ ), Status::WARNING());
}
}
diff --git a/Classes/Infrastructure/ImageHandler/ImageHandlerService.php b/Classes/Infrastructure/ImageHandler/ImageHandlerService.php
index f846242..8a71190 100644
--- a/Classes/Infrastructure/ImageHandler/ImageHandlerService.php
+++ b/Classes/Infrastructure/ImageHandler/ImageHandlerService.php
@@ -49,6 +49,7 @@ class ImageHandlerService
public function __construct()
{
//
+ // FIXME: It seems there is this hack and in the image factory there is a hack too now (: https://github.com/neos/imagine/pull/11
// Hack. We instantiate the unproxied class without injected settings.
// This is to allow to still reconfigure the image driver, even if it is disabled.
// The "driver" Gd for Imagine must be enabled by settings, check Neos.Imagine.enabledDrivers. Or use ./flow setup:imagehandler