Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
"Surfnet_": "library/"
},
"psr-4": {
"OpenConext\\": "src/OpenConext"
"OpenConext\\": "src/OpenConext",
"OpenConext\\EngineBlock\\Doctrine\\Migrations\\": "migrations/DoctrineMigrations"
},
"classmap": [
"src/Kernel.php"
Expand Down
17 changes: 15 additions & 2 deletions library/EngineBlock/ApplicationSingleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use OpenConext\EngineBlockBundle\Exception\Art;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;

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

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

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

public function hasSession(): bool
{
try {
$this->getSession();
return true;
} catch (SessionNotFoundException) {
return false;
}
}
Comment on lines +426 to +434
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution should work no problem; assuming we autostart sessions and have them enabled in the first place. Which is a requirement for EB to work..

You might have gone the isCli route, which might have been somewhat 'safer' in the department of change of behavior. I'm fine with this too, just wanted to chime in on this.


/**
* @return \EngineBlock_Application_DiContainer
*/
Expand Down
17 changes: 15 additions & 2 deletions migrations/DoctrineMigrations/Version20260224000000.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

namespace OpenConext\EngineBlock\Doctrine\Migrations;

use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Name\Identifier;
use Doctrine\DBAL\Schema\Name\OptionallyQualifiedName;
use Doctrine\DBAL\Schema\Name\UnqualifiedName;
use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding;
use Doctrine\DBAL\Schema\Schema;

/**
Expand All @@ -39,9 +44,17 @@ public function preUp(Schema $schema): void
{
parent::preUp($schema);

$indexes = $this->connection->createSchemaManager()->listTableIndexes('consent');
$indexes = $this->connection->createSchemaManager()->introspectTableIndexes(new OptionallyQualifiedName(Identifier::unquoted('consent'), null));
$deletedAtIndex = array_filter(
$indexes,
static fn(Index $index) => $index->getObjectName()->equals(
UnqualifiedName::unquoted('deleted_at'),
UnquotedIdentifierFolding::NONE
)
);

$this->skipIf(
!isset($indexes['deleted_at']),
count($deletedAtIndex) === 0,
'Index deleted_at on consent table does not exist. Skipping.'
);
}
Expand Down