Skip to content

Commit

Permalink
Merge branch '9.0' into task/4705-check-and-fix-neosnodetypes-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaeslich committed Nov 9, 2023
2 parents 562d152 + 337cef7 commit 8b33006
Show file tree
Hide file tree
Showing 23 changed files with 428 additions and 72 deletions.
3 changes: 0 additions & 3 deletions .composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"license": ["GPL-3.0-or-later"],
"type": "neos-package-collection",
"require": {
"neos/flow-development-collection": "9.0.x-dev",
"neos/neos-setup": "^2.0",
"league/flysystem-memory": "^3"
},
"replace": {
},
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ jobs:
git -C ../${{ env.NEOS_FOLDER }} checkout -b build
composer config repositories.neos '{ "type": "path", "url": "../${{ env.NEOS_FOLDER }}", "options": { "symlink": false } }'
composer require --no-update neos/neos-development-collection:"dev-build as ${{ env.NEOS_BRANCH_ALIAS }}"
# TODO workaround for not-yet-released neos/eventstore packages
composer require --no-update neos/eventstore:"dev-main"
composer require --no-update neos/eventstore-doctrineadapter:"dev-main"
- name: Cache Composer packages
id: composer-cache
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentGraph.DoctrineDbalAdapter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "GPL-3.0+",
"require": {
"neos/contentrepository-core": "self.version",
"doctrine/dbal": "*",
"doctrine/dbal": "^2.13",
"doctrine/migrations": "*"
},
"autoload": {
Expand Down
6 changes: 3 additions & 3 deletions Neos.ContentRepository.Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"GPL-3.0-or-later"
],
"require": {
"neos/eventstore": "*",
"neos/eventstore-doctrineadapter": "*",
"neos/eventstore": "~1.0.0",
"neos/eventstore-doctrineadapter": "~1.0.0",
"php": "^8.2",
"neos/error-messages": "*",
"neos/utility-objecthandling": "*",
"neos/utility-arrays": "*",
"doctrine/dbal": "^2.6",
"doctrine/dbal": "^2.13",
"symfony/serializer": "^6.3",
"psr/clock": "^1",
"behat/transliterator": "~1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ private function determineResourcesPath(): string

private static function defaultResourcesPath(): string
{
// @phpstan-ignore-next-line
return FLOW_PATH_DATA . 'Persistent/Resources';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ protected function evaluateOperator($value, $operator, $operand)
{
if ($operator === 'instanceof' && $value instanceof Node) {
if ($this->operandIsSimpleType($operand)) {
/** @phpstan-ignore-next-line Flow does not properly declare its types here */
return $this->handleSimpleTypeOperand($operand, $value);
} elseif ($operand === Node::class) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentRepository.NodeAccess/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"GPL-3.0-or-later"
],
"require": {
"neos/flow": "*",
"neos/flow": "~9.0.0",
"neos/contentrepository-core": "self.version"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentRepository.TestSuite/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"GPL-3.0-or-later"
],
"require": {
"neos/utility-arrays": "*",
"neos/utility-arrays": "~9.0.0",
"neos/contentrepository-core": "self.version",
"neos/contentrepository-structureadjustment": "self.version",
"neos/contentrepository-nodemigration": "self.version",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,34 @@ public function __construct(
* Shows the merged configuration (including supertypes) of a NodeType
*
* @param string $nodeTypeName The name of the NodeType to show
* @param ?string $path Path of the NodeType-configuration which will be shown
* @param string $path Path of the NodeType-configuration which will be shown
* @param int $level Truncate the configuration at this depth and show '...' (Usefully for only seeing the keys of the properties)
* @param string $contentRepository Identifier of the Content Repository to determine the set of NodeTypes
*/
public function showCommand(string $nodeTypeName, ?string $path = null, string $contentRepository = 'default'): void
public function showCommand(string $nodeTypeName, string $path = '', int $level = 0, string $contentRepository = 'default'): void
{
$contentRepositoryId = ContentRepositoryId::fromString($contentRepository);
$nodeTypeManager = $this->contentRepositoryRegistry->get($contentRepositoryId)->getNodeTypeManager();

if (!$nodeTypeManager->hasNodeType($nodeTypeName)) {
$this->outputLine('<b>NodeType "%s" was not found!</b>', [$nodeTypeName]);
$this->outputLine('<error>NodeType "%s" was not found!</error>', [$nodeTypeName]);
$this->quit();
}

$nodeType = $nodeTypeManager->getNodeType($nodeTypeName);
$yaml = Yaml::dump(
$path
? $nodeType->getConfiguration($path)
: [$nodeTypeName => $nodeType->getFullConfiguration()],
99
);
$this->outputLine('<b>NodeType Configuration "%s":</b>', [$nodeTypeName . ($path ? ("." . $path) : "")]);

if ($path && !$nodeType->hasConfiguration($path)) {
$this->outputLine('<b>NodeType "%s" does not have configuration "%s".</b>', [$nodeTypeName, $path]);
$this->quit();
}

$configuration = $path
? self::truncateArrayAtLevel($nodeType->getConfiguration($path), $level)
: [$nodeTypeName => self::truncateArrayAtLevel($nodeType->getFullConfiguration(), $level)];

$yaml = Yaml::dump($configuration, 99);

$this->outputLine('<b>NodeType configuration "%s":</b>', [$nodeTypeName . ($path ? ("." . $path) : "")]);
$this->outputLine();
$this->outputLine($yaml);
$this->outputLine();
Expand Down Expand Up @@ -91,4 +98,30 @@ public function listCommand(?string $filter = null, bool $includeAbstract = true
}
}
}

/**
* @param array<string, mixed> $array
* @param int $truncateLevel 0 for no truncation and 1 to only show the first keys of the array
* @param int $currentLevel 1 for the start and will be incremented recursively
* @return array<string, mixed>
*/
private static function truncateArrayAtLevel(array $array, int $truncateLevel, int $currentLevel = 1): array
{
if ($truncateLevel <= 0) {
return $array;
}
$truncatedArray = [];
foreach ($array as $key => $value) {
if ($currentLevel >= $truncateLevel) {
$truncatedArray[$key] = '...'; // truncated
continue;
}
if (!is_array($value)) {
$truncatedArray[$key] = $value;
continue;
}
$truncatedArray[$key] = self::truncateArrayAtLevel($value, $truncateLevel, $currentLevel + 1);
}
return $truncatedArray;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class NodeTypesLoader implements LoaderInterface
*/
private $configurationBasePath;

/** @phpstan-ignore-next-line FLOW_PATH_CONFIGURATION not found */
public function __construct(YamlSource $yamlSource, string $configurationBasePath = FLOW_PATH_CONFIGURATION, protected readonly ?Bootstrap $bootstrap = null)
{
$this->yamlSource = $yamlSource;
Expand Down
3 changes: 0 additions & 3 deletions Neos.ContentRepositoryRegistry/Classes/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function boot(Bootstrap $bootstrap)
$dispatcher = $bootstrap->getSignalSlotDispatcher();

$dispatcher->connect(ConfigurationManager::class, 'configurationManagerReady', function (ConfigurationManager $configurationManager) use ($bootstrap) {
/** @phpstan-ignore-next-line FLOW_* */
$configurationManager->registerConfigurationType('NodeTypes', new NodeTypesLoader(new YamlSource(), FLOW_PATH_CONFIGURATION, $bootstrap));
});

Expand All @@ -64,7 +63,6 @@ public function boot(Bootstrap $bootstrap)
}
}

/** @phpstan-ignore-next-line FLOW_* */
$nodeTypeConfigurationFileMonitor->monitorDirectory(FLOW_PATH_CONFIGURATION, 'NodeTypes(\..+)\.yaml');

$nodeTypeConfigurationFileMonitor->detectChanges();
Expand All @@ -73,7 +71,6 @@ public function boot(Bootstrap $bootstrap)
});
$dispatcher->connect(FileMonitor::class, 'filesHaveChanged', static function (string $fileMonitorIdentifier) use ($bootstrap) {
if ($fileMonitorIdentifier === 'ContentRepository_NodeTypesConfiguration') {
/** @phpstan-ignore-next-line flow's object manager needs to be a template */
$bootstrap->getObjectManager()->get(ConfigurationManager::class)->refreshConfiguration();
}
});
Expand Down
6 changes: 4 additions & 2 deletions Neos.ContentRepositoryRegistry/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"license": [
"GPL-3.0-or-later"
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"neos/flow": "*",
"neos/flow": "~9.0.0",
"neos/contentrepository-core": "self.version",
"neos/contentrepositoryregistry-storageclient": "self.version",
"symfony/property-access": "*",
"symfony/property-access": "^5.4|^6.0",
"psr/clock": "^1"
},
"autoload": {
Expand Down
15 changes: 5 additions & 10 deletions Neos.Neos/Classes/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,15 @@ public function tokenLoginAction(string $token): void
if ($newSessionId === false) {
$this->logger->warning(sprintf('Token-based login failed, non-existing or expired token %s', $token));
$this->redirect('index');
return;
}

$this->logger->debug(sprintf('Token-based login succeeded, token %s', $token));

$newSession = $this->sessionManager->getSession($newSessionId);
if ($newSession->canBeResumed()) {
if ($newSession?->canBeResumed()) {
$newSession->resume();
}
if (!$newSession->isStarted()) {
if (!$newSession?->isStarted()) {
$this->logger->error(sprintf(
'Failed resuming or starting session %s which was referred to in the login token %s.',
$newSessionId,
Expand Down Expand Up @@ -211,13 +210,11 @@ protected function onAuthenticationFailure(AuthenticationRequiredException $exce
*
* @param ActionRequest|null $originalRequest The request that was intercepted by the security framework,
* NULL if there was none
* @phpstan-ignore-next-line Flow does not properly declare its return type here
* @return void
* @throws SessionNotStartedException
* @throws StopActionException
* @throws \Neos\Flow\Mvc\Exception\NoSuchArgumentException
*/
protected function onAuthenticationSuccess(ActionRequest $originalRequest = null): void
protected function onAuthenticationSuccess(ActionRequest $originalRequest = null): null
{
if ($this->view instanceof JsonView) {
$this->view->assign(
Expand All @@ -227,6 +224,7 @@ protected function onAuthenticationSuccess(ActionRequest $originalRequest = null
'csrfToken' => $this->securityContext->getCsrfProtectionToken()
]
);
return null;
} else {
if ($originalRequest !== null) {
// Redirect to the location that redirected to the login form because the user was nog logged in
Expand Down Expand Up @@ -268,11 +266,8 @@ public function logoutAction(): void
/**
* Disable the default error flash message
*
*
* @phpstan-ignore-next-line Flow does not properly declare its types here
* @return false
*/
protected function getErrorFlashMessage(): bool
protected function getErrorFlashMessage(): false
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ public function indexAction()

/**
* Display no flash message at all on errors.
*
* @phpstan-ignore-next-line Flow does not properly declare its types here
* @return false
*/
protected function getErrorFlashMessage()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function indexAction()
$packageGroups = [];
foreach ($this->packageManager->getAvailablePackages() as $package) {
/** @var Package $package */
/** @phpstan-ignore-next-line FLOW_PATH_PACKAGES is known at this point */
$packagePath = substr($package->getPackagepath(), strlen(FLOW_PATH_PACKAGES));
$packageGroup = substr($packagePath, 0, strpos($packagePath, '/') ?: null);
$packageGroups[$packageGroup][$package->getPackageKey()] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ public function createSiteNodeAction($packageKey, $siteName, $nodeType)
1412372375
);
$this->redirect('createSiteNode');
return;
} catch (SiteNodeTypeIsInvalid $exception) {
$this->addFlashMessage(
$this->getModuleLabel(
Expand All @@ -406,7 +405,6 @@ public function createSiteNodeAction($packageKey, $siteName, $nodeType)
1412372375
);
$this->redirect('createSiteNode');
return;
} catch (SiteNodeNameIsAlreadyInUseByAnotherSite | NodeNameIsAlreadyOccupied $exception) {
$this->addFlashMessage(
$this->getModuleLabel('sites.SiteCreationError.siteWithSiteNodeNameAlreadyExists.body', [$siteName]),
Expand All @@ -416,7 +414,6 @@ public function createSiteNodeAction($packageKey, $siteName, $nodeType)
1412372375
);
$this->redirect('createSiteNode');
return;
}

$this->addFlashMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public function showAction(WorkspaceName $workspace): void
if (is_null($workspaceObj)) {
/** @todo add flash message */
$this->redirect('index');
return;
}
$this->view->assignMultiple([
'selectedWorkspace' => $workspaceObj,
Expand Down Expand Up @@ -259,7 +258,6 @@ public function editAction(WorkspaceName $workspaceName): void
if (is_null($workspace)) {
// @todo add flash message
$this->redirect('index');
return;
}
$this->view->assign('workspace', $workspace);
$this->view->assign('baseWorkspaceOptions', $this->prepareBaseWorkspaceOptions($contentRepository, $workspace));
Expand Down Expand Up @@ -304,7 +302,6 @@ public function updateAction(
Message::SEVERITY_ERROR
);
$this->redirect('index');
return;
}

if (!$workspace->workspaceTitle->equals($title) || !$workspace->workspaceDescription->equals($description)) {
Expand Down Expand Up @@ -360,12 +357,10 @@ public function deleteAction(WorkspaceName $workspaceName): void
Message::SEVERITY_ERROR
);
$this->redirect('index');
return;
}

if ($workspace->isPersonalWorkspace()) {
$this->redirect('index');
return;
}

$dependentWorkspaces = $contentRepository->getWorkspaceFinder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public function processRequest(ActionRequest $request, ActionResponse $response)
{
try {
parent::processRequest($request, $response);
/** @phpstan-ignore-next-line Although Flow does not declare it, StopActionExceptions might be thrown */
} catch (StopActionException $exception) {
throw $exception;
} catch (\Exception $exception) {
Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"neos/diff": "self.version",
"neos/flow": "~9.0.0",
"neos/media-browser": "self.version",
"neos/party": "*",
"neos/twitter-bootstrap": "*",
"neos/party": "~7.0.3",
"neos/contentrepository-core": "self.version",
"neos/contentrepositoryregistry": "self.version",
"neos/contentrepository-nodeaccess": "self.version",
"neos/contentrepository-export": "self.version",
"neos/fusion": "self.version",
"neos/fusion-afx": "self.version",
"neos/fusion-form": "^1.0 || ^2.0",
Expand Down
9 changes: 9 additions & 0 deletions bootstrap-phpstan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

/**
* This bootstrap helps phpstan to detect all available constants
*/

$_SERVER['FLOW_ROOTPATH'] = dirname(__DIR__, 2);

new \Neos\Flow\Core\Bootstrap('Testing');
Loading

0 comments on commit 8b33006

Please sign in to comment.