Skip to content

Commit 0bcf392

Browse files
authored
Merge pull request #1946 from OpenConext/feature/fix-install-issues
Fix error reporting / session / migration issues
2 parents b6e4c60 + 072660d commit 0bcf392

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
"Surfnet_": "library/"
110110
},
111111
"psr-4": {
112-
"OpenConext\\": "src/OpenConext"
112+
"OpenConext\\": "src/OpenConext",
113+
"OpenConext\\EngineBlock\\Doctrine\\Migrations\\": "migrations/DoctrineMigrations"
113114
},
114115
"classmap": [
115116
"src/Kernel.php"

library/EngineBlock/ApplicationSingleton.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use OpenConext\EngineBlockBundle\Exception\Art;
2424
use Psr\Log\LoggerInterface;
2525
use Symfony\Component\DependencyInjection\ContainerInterface;
26+
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
2627

2728
define('ENGINEBLOCK_FOLDER_ROOT' , realpath(__DIR__ . '/../../') . '/');
2829
define('ENGINEBLOCK_FOLDER_LIBRARY' , ENGINEBLOCK_FOLDER_ROOT . 'library/');
@@ -235,8 +236,10 @@ public function reportError(Throwable $exception, $messageSuffix = '')
235236
$log->log($severity, $message, $logContext);
236237

237238
// Store some valuable debug info in session so it can be displayed on feedback pages
238-
@session_start();
239-
$this->getSession()->set('feedbackInfo', $this->collectFeedbackInfo($exception));
239+
if($this->hasSession()) {
240+
// In CLI context, the session is not available
241+
$this->getSession()->set('feedbackInfo', $this->collectFeedbackInfo($exception));
242+
}
240243

241244
// flush all messages in queue, something went wrong!
242245
$this->flushLog('An error was caught');
@@ -420,6 +423,16 @@ public function getSession()
420423
return $this->getDiContainer()->getSession();
421424
}
422425

426+
public function hasSession(): bool
427+
{
428+
try {
429+
$this->getSession();
430+
return true;
431+
} catch (SessionNotFoundException) {
432+
return false;
433+
}
434+
}
435+
423436
/**
424437
* @return \EngineBlock_Application_DiContainer
425438
*/

migrations/DoctrineMigrations/Version20260224000000.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020

2121
namespace OpenConext\EngineBlock\Doctrine\Migrations;
2222

23+
use Doctrine\DBAL\Schema\Index;
24+
use Doctrine\DBAL\Schema\Name\Identifier;
25+
use Doctrine\DBAL\Schema\Name\OptionallyQualifiedName;
26+
use Doctrine\DBAL\Schema\Name\UnqualifiedName;
27+
use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding;
2328
use Doctrine\DBAL\Schema\Schema;
2429

2530
/**
@@ -39,9 +44,17 @@ public function preUp(Schema $schema): void
3944
{
4045
parent::preUp($schema);
4146

42-
$indexes = $this->connection->createSchemaManager()->listTableIndexes('consent');
47+
$indexes = $this->connection->createSchemaManager()->introspectTableIndexes(new OptionallyQualifiedName(Identifier::unquoted('consent'), null));
48+
$deletedAtIndex = array_filter(
49+
$indexes,
50+
static fn(Index $index) => $index->getObjectName()->equals(
51+
UnqualifiedName::unquoted('deleted_at'),
52+
UnquotedIdentifierFolding::NONE
53+
)
54+
);
55+
4356
$this->skipIf(
44-
!isset($indexes['deleted_at']),
57+
count($deletedAtIndex) === 0,
4558
'Index deleted_at on consent table does not exist. Skipping.'
4659
);
4760
}

0 commit comments

Comments
 (0)