Skip to content

Commit 3ad5945

Browse files
authored
Merge pull request #975 from catalyst/973-bump-symphony-version
Issue #973: Update vendor files to latest available for PHP8.1
2 parents b4e4c83 + fb07dd6 commit 3ad5945

File tree

1,259 files changed

+44672
-35287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,259 files changed

+44672
-35287
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
codechecker_max_warnings: 0 # CI should now fail on phpcs / code checker warnings.
1414
disable_behat: true
1515
disable_grunt: true
16-
min_php: 7.4
16+
min_php: 8.1
1717
extra_plugin_runners: |
1818
sudo sed -i 's/azure\.//' /etc/apt/sources.list
1919
sudo apt-get update

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM moodlehq/moodle-php-apache:8.1
2+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
3+
4+
WORKDIR /code
5+
CMD ["composer", "update", "--no-dev"]

UPGRADING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Upgrading
2+
There has been a `Dockerfile` and `docker-compose.yaml` added to allow running composer update consistently without relying on local configuration of php.
3+
4+
To run an upgrade running `docker compose up` will start the container and run `composer update --no-dev`. You can then commit the result with the updated `vendor` folder and updated `composer.lock` file.
5+

classes/local/execution/engine.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
use Monolog\Handler\BrowserConsoleHandler;
2121
use Monolog\Handler\RotatingFileHandler;
2222
use Monolog\Handler\StreamHandler;
23+
use Monolog\LogRecord;
24+
use Monolog\Logger;
25+
use Monolog\Level;
2326
use Monolog\Processor\PsrLogMessageProcessor;
24-
use Symfony\Bridge\Monolog\Logger;
2527
use tool_dataflows\dataflow;
2628
use tool_dataflows\exportable;
2729
use tool_dataflows\helper;
@@ -353,7 +355,7 @@ public function initialise() {
353355
// Register signal handler - if a signal caused the dataflow to stop.
354356
\core_shutdown_manager::register_signal_handler(function ($signo){
355357
$error = error_get_last();
356-
$this->logger->log(Logger::NOTICE, 'Engine: shutdown signal ({signo}) received', [
358+
$this->logger->log(Level::Notice, 'Engine: shutdown signal ({signo}) received', [
357359
'signo' => $signo,
358360
'lasterror' => $error,
359361
]);
@@ -362,12 +364,12 @@ public function initialise() {
362364

363365
// Register shutdown handler - if request is ended by client, abort and finalise flow.
364366
\core_shutdown_manager::register_function(function (){
365-
$this->logger->log(Logger::DEBUG, 'Engine: shutdown handler was called');
367+
$this->logger->log(Level::Debug, 'Engine: shutdown handler was called');
366368

367369
// If the script has stopped and flow is not finalised then abort.
368370
if (!in_array($this->status, [self::STATUS_FINALISED, self::STATUS_ABORTED])) {
369371
$error = error_get_last();
370-
$this->logger->log(Logger::ERROR, 'Engine: shutdown happened abruptly', ['lasterror' => $error]);
372+
$this->logger->log(Level::Error, 'Engine: shutdown happened abruptly', ['lasterror' => $error]);
371373
$this->set_status(self::STATUS_ABORTED);
372374

373375
$notifyreason = new \Exception('Shutdown handler triggered abort. Last error: ' . $error);
@@ -568,7 +570,7 @@ public function abort(?\Throwable $reason = null) {
568570
$context = [];
569571
}
570572
}
571-
$this->log('Engine: aborting steps', $message ? array_merge(['reason' => $message], $context) : [], Logger::NOTICE);
573+
$this->log('Engine: aborting steps', $message ? array_merge(['reason' => $message], $context) : [], Level::Notice);
572574
$this->exception = $reason;
573575
foreach ($this->enginesteps as $enginestep) {
574576
$status = $enginestep->status;
@@ -611,7 +613,7 @@ public function abort(?\Throwable $reason = null) {
611613
* @param mixed $context
612614
* @param mixed $level
613615
*/
614-
public function log(string $message, $context = [], $level = Logger::INFO) {
616+
public function log(string $message, $context = [], $level = Level::Info) {
615617
$this->logger->log($level, $message, $context);
616618
}
617619

@@ -683,9 +685,9 @@ public function set_status(int $status) {
683685
'status' => get_string('engine_status:'.self::STATUS_LABELS[$this->status], 'tool_dataflows'),
684686
];
685687

686-
$level = Logger::INFO;
688+
$level = Level::Info;
687689
if (in_array($status, self::STATUS_TERMINATORS, true)) {
688-
$level = Logger::NOTICE;
690+
$level = Level::Notice;
689691
$context['export'] = $this->get_export_data();
690692
}
691693
$this->logger->log($level, "Engine: dataflow '{status}'", $context);
@@ -774,6 +776,7 @@ public function set_current_step(?engine_step $step) {
774776
*/
775777
private function setup_logging() {
776778
global $CFG;
779+
777780
// Initalise a new run (only for non-dry runs). This should only be
778781
// created when the engine is executed.
779782
$channel = 'dataflow/' . $this->dataflow->id;
@@ -794,15 +797,17 @@ private function setup_logging() {
794797
$log->pushProcessor(new PsrLogMessageProcessor(null, true));
795798

796799
// Ensure step names are used if supplied.
797-
$log->pushProcessor(function ($record) {
800+
$log->pushProcessor(function (LogRecord $record): LogRecord {
801+
$context = $record->context;
802+
$message = $record->message;
798803
if (isset($this->currentstep)) {
799-
$record['context']['step'] = $this->currentstep->name;
804+
$context['step'] = $this->currentstep->name;
800805
}
801806

802-
if (isset($record['context']['step'])) {
803-
$record['message'] = '{step}: ' . $record['message'];
807+
if (isset($context['step'])) {
808+
$message = '{step}: ' . $message;
804809
}
805-
return $record;
810+
return $record->with(message: $message, context: $context);
806811
});
807812

808813
// Tweak the default datetime output to include microseconds.
@@ -835,7 +840,7 @@ private function setup_logging() {
835840
$dataflowrunlogpath = $CFG->dataroot . DIRECTORY_SEPARATOR .
836841
'tool_dataflows' . DIRECTORY_SEPARATOR .
837842
$this->dataflow->id . DIRECTORY_SEPARATOR .
838-
$rundateformat . '_' . $this->run->name . '.log';
843+
$rundateformat . '_' . ($this->run->name ?? 'dry') . '.log';
839844

840845
$streamhandler = new StreamHandler($dataflowrunlogpath, $minloglevel);
841846
$streamhandler->setFormatter($lineformatter);
@@ -878,7 +883,7 @@ public function notify_on_abort(?\Throwable $reason) {
878883
continue;
879884
}
880885

881-
$this->log('Sending abort notification email.', [], Logger::NOTICE);
886+
$this->log('Sending abort notification email.', [], Level::Notice);
882887
$context = [
883888
'flowname' => $this->dataflow->get('name'),
884889
'run' => $this->run->get('id'),

classes/local/execution/logging/mtrace_handler.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace tool_dataflows\local\execution\logging;
1818

1919
use Monolog\Handler\AbstractProcessingHandler;
20+
use Monolog\LogRecord;
2021

2122
/**
2223
* An environment for logging information about dataflow execution.
@@ -31,24 +32,24 @@ class mtrace_handler extends AbstractProcessingHandler {
3132
/**
3233
* Default handler for Moodle.
3334
*
34-
* @param array $record the log record
35+
* @param LogRecord $record the log record
3536
* @return bool
3637
**/
37-
public function handle(array $record): bool {
38+
public function handle(LogRecord $record): bool {
3839
if ($this->isHandling($record)) {
3940
$record['formatted'] = trim($this->getFormatter()->format($record));
4041
$this->write($record);
4142
return true;
4243
}
43-
return $this->handler->handle($record);
44+
return $this->handle($record);
4445
}
4546

4647
/**
4748
* Writes the record down to the log of the implementing handler
4849
*
49-
* @param array $record
50+
* @param LogRecord $record
5051
*/
51-
protected function write(array $record): void {
52+
protected function write(LogRecord $record): void {
5253
mtrace($record['formatted']);
5354
}
5455
}

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"config": {
33
"platform": {
4-
"php": "7.4"
4+
"php": "8.1"
55
}
66
},
77
"require": {
8-
"php": ">=7.4",
9-
"symfony/yaml": "^4.0",
10-
"symfony/expression-language": "^3.4",
8+
"php": ">=8.1",
9+
"symfony/yaml": "^6.0",
10+
"symfony/expression-language": "^6.0",
1111
"phpseclib/phpseclib": "~3.0",
1212
"symfony/monolog-bundle": "^3.6"
1313
}

0 commit comments

Comments
 (0)