Skip to content

Commit

Permalink
LPAL-754/LPAL-823 Upgrade service-admin and service-front to PHP 8.1 (#…
Browse files Browse the repository at this point in the history
…965)

* Add psalm as service-admin dev dependency

* Update service-admin psalm config to match other components

* First pass of level 4 psalm check

* Implement simplified LoggerTrait

The MakeLogger LoggerTrait is designed to work with laminas-mvc
apps and will not work correctly in service-admin (which is
not a laminas-mvc app).

Implement a simple alternative logger which can be used within
service-admin as a drop-in replacement for MakeLogger.

As we are not so concerned about logging trace IDs here, we can
resort to logging errors directly and not as JSON. If this is
unacceptable, we will have to consider rewriting the MakeLogger
code so we can output JSON in non-laminas-mvc apps.

The code in this commit improves things, as at the moment I would
expect logging to fail completely for service-admin due to
missing laminas-mvc dependencies.

* Second pass of pass of level 4 psalm check

* Comment out currently-unused class

Once the issue with slim-jwt-auth is fixed
(see tuupola/slim-jwt-auth#217),
we can reinstate that library as the JWT solution as follows:

* Add tuupola/slim-jwt-auth back into composer.json
* Remove tuupola/http-factory and tuupola/callable-handler
  (these are dependencies of tuupola/slim-jwt-auth
  and will be installed by that library; we no longer need to reference
  them directly once slim-jwt-auth is back in place)
* Uncomment body of App\Middleware\Session\JwtAuthenticationFactory class
* Remove App\Middleware\Session\JwtMiddleware file
* Remove App\Middleware\Session\JwtMiddlewareFactory file
* Uncomment lines 67-68 and remove lines 69-70 of ConfigProvider.php

For more context, see commit 3efaa3b in this repo.

* Update to PHP 8.1 in composer config

* Set a default form element value of '' if it is null

* Upgrade to PHP 8.1 in service-admin docker container

* Update to version 14 of opg-lpa-datamodels

* psalm scan service-admin with PHP 8.1

* Update composer dependencies

* Upgrade front-app docker image to PHP 8.1

* Passing null to DateTime is deprecated

When we get the last login time for a user, we set this to null
if they have not logged in before. This value is then passed
to new DateTime($lastLogin). However, PHP 8.1 is not happy with
passing a null to the DateTime constructor and throws a deprecation
message. Default this value to 'now' if the user has never logged
in before to fix.

* Move simplified LoggerTrait into MakeLogger shared directory
  • Loading branch information
townxelliot authored Jun 14, 2022
1 parent a283766 commit d7a1331
Show file tree
Hide file tree
Showing 24 changed files with 2,054 additions and 453 deletions.
44 changes: 3 additions & 41 deletions .github/workflows/psalm-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,7 @@ on:
- "service-front/**"
# - 'service-pdf/**' fix when more known about the error at https://github.com/vimeo/psalm/issues/6361
jobs:
psalm_admin:
name: psalm-scan
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
scan:
- name: service-admin
path: "./service-admin"
# - name: service-pdf - fix when more known about the error at https://github.com/vimeo/psalm/issues/6361
# path: './service-pdf'
defaults:
run:
working-directory: ${{ matrix.scan.path }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: path filters
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
check: '${{ matrix.scan.path }}/**'
- name: Setup PHP with tools
if: steps.filter.outputs.check == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
tools: vimeo/psalm
- name: Composer install
if: steps.filter.outputs.check == 'true'
run: composer install --prefer-dist --optimize-autoloader --no-suggest --no-interaction --no-scripts
- name: Run psalm
if: steps.filter.outputs.check == 'true'
run: psalm --output-format=github --taint-analysis --report=psalm-results.sarif
- name: Upload Security Analysis results to GitHub
if: steps.filter.outputs.check == 'true'
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ matrix.scan.path }}/psalm-results.sarif
psalm_front_and_api:
psalm_front_api_and_admin:
name: psalm-scan
runs-on: ubuntu-latest
strategy:
Expand All @@ -62,6 +22,8 @@ jobs:
path: "./service-front"
- name: service-api
path: "./service-api"
- name: service-admin
path: "./service-admin"
defaults:
run:
working-directory: ${{ matrix.scan.path }}
Expand Down
34 changes: 17 additions & 17 deletions service-admin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,34 @@
}
},
"require": {
"php": "^8.0",
"php": "^8.1",
"aws/aws-sdk-php": "^3.81",
"guzzlehttp/guzzle": "^6.3",
"ministryofjustice/opg-lpa-datamodels": "^13.3",
"php-http/guzzle6-adapter": "^2.0.2",
"slim/flash": "^0.4.0",

"firebase/php-jwt": "^6.0",
"psr/http-message": "^1.0",
"tuupola/http-factory": "^0.4.0|^1.0.2",
"tuupola/callable-handler": "^0.3.0|^0.4.0|^1.0",
"psr/http-server-middleware": "^1.0",

"guzzlehttp/guzzle": "^6.3",
"laminas/laminas-authentication": "^2.8",
"laminas/laminas-cache": "^3.1.2",
"laminas/laminas-cache-storage-adapter-memory": "2.0",
"laminas/laminas-component-installer": "^2.5.1",
"laminas/laminas-config-aggregator": "^1.7",
"laminas/laminas-diactoros": "^2.8.0",
"mezzio/mezzio": "^3.6.0",
"mezzio/mezzio-fastroute": "^3.3.0",
"mezzio/mezzio-helpers": "^5.7.0",
"mezzio/mezzio-platesrenderer": "^2.4.0",
"laminas/laminas-form": "^3.0.1",
"laminas/laminas-log": "^2.13",
"laminas/laminas-math": "^3.4",
"laminas/laminas-mvc": "^3.3",
"laminas/laminas-permissions-rbac": "^3.2.0",
"laminas/laminas-servicemanager": "^3.10.0",
"laminas/laminas-stdlib": "^3.6.1",
"laminas/laminas-log": "^2.13"
"mezzio/mezzio": "^3.6.0",
"mezzio/mezzio-fastroute": "^3.3.0",
"mezzio/mezzio-helpers": "^5.7.0",
"mezzio/mezzio-platesrenderer": "^2.4.0",
"ministryofjustice/opg-lpa-datamodels": "^14.0",
"php-http/guzzle6-adapter": "^2.0.2",
"psr/http-message": "^1.0",
"psr/http-server-middleware": "^1.0",
"slim/flash": "^0.4.0",
"tuupola/callable-handler": "^0.3.0|^0.4.0|^1.0",
"tuupola/http-factory": "^0.4.0|^1.0.2"
},
"replace": {
"laminas/laminas-cache-storage-adapter-apc": "*",
Expand All @@ -68,7 +67,8 @@
"phpspec/prophecy-phpunit": "^2.0.1",
"phpunit/phpunit": "^9.5.10",
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "^3.6.1"
"squizlabs/php_codesniffer": "^3.6.1",
"vimeo/psalm": "^4.23"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit d7a1331

Please sign in to comment.