Skip to content

Commit

Permalink
Upgrade CA dependencies: PHP 8.3, Laravel 11, PHPUnit 11 (#2842)
Browse files Browse the repository at this point in the history
* upgrade laravel, php, phpunit

* uncomment fake mix code

* Run php-cs-fixer

* update workflow

(cherry picked from commit efb250f)

* update, run php-cs-fixer

* actually update php-cs-fixer

* Unnecessary tearDown() not calling 'parent::tearDown()' causing 'PDOException: There is already an active transaction' when running tests

* Fix event assertions in tests

* fix some migrations

* Fix unittest

* Unittests: Replace removed mock function withConsecutive

* use phpunit 11, replace deprecated annotations

* make phpstan happy

* revert nullability of cerpus_contents_shares.email

---------

Co-authored-by: emmachughes <[email protected]>
Co-authored-by: Christian Einvik <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent a27a89c commit 8aa1b74
Show file tree
Hide file tree
Showing 92 changed files with 2,353 additions and 2,226 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/contentauthor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3

- name: Manage php-cs-fixer cache
uses: actions/cache@v4
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
extensions: sockets, zip
coverage: pcov

Expand Down
7 changes: 3 additions & 4 deletions sourcecode/apis/contentauthor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM php:8.2-fpm-alpine AS base
FROM php:8.3-fpm-alpine AS base

RUN apk add --no-cache \
git \
unzip

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN IPE_GD_WITHOUTAVIF=1 install-php-extensions \
RUN install-php-extensions \
bcmath \
gettext \
igbinary \
Expand All @@ -15,7 +15,6 @@ RUN IPE_GD_WITHOUTAVIF=1 install-php-extensions \
pcntl \
pdo_mysql \
redis \
sockets \
xmlrpc \
zip

Expand Down Expand Up @@ -106,7 +105,7 @@ RUN set -eux; \
chown -R www-data:www-data .


FROM prod as test
FROM prod AS test

COPY phpunit.xml .
COPY tests tests
Expand Down
6 changes: 3 additions & 3 deletions sourcecode/apis/contentauthor/app/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public function render(): string
}

/**
* @return HasMany<ArticleCollaborator>
* @return HasMany<ArticleCollaborator, $this>
*/
public function collaborators(): HasMany
{
return $this->hasMany(ArticleCollaborator::class);
}

/**
* @return HasMany<File>
* @return HasMany<File, $this>
*/
public function files(): HasMany
{
Expand All @@ -103,7 +103,7 @@ public function givesScore(): int
}

/**
* @return BelongsTo<Article, self>
* @return BelongsTo<Article, $this>
*/
public function parent(): BelongsTo
{
Expand Down
5 changes: 2 additions & 3 deletions sourcecode/apis/contentauthor/app/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Illuminate\Support\Facades\Session;

use function htmlspecialchars_decode;

use function property_exists;

use const ENT_HTML5;
Expand Down Expand Up @@ -119,7 +118,7 @@ public function isOwner($currentUserId): bool
abstract public function getContentType(bool $withSubType = false);

/**
* @return HasOne<NdlaIdMapper>
* @return HasOne<NdlaIdMapper, $this>
*/
public function ndlaMapper(): HasOne
{
Expand All @@ -132,7 +131,7 @@ public function isCopyable(): bool
}

/**
* @return HasMany<ContentLock>
* @return HasMany<ContentLock, $this>
*/
public function locks(): HasMany
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class File extends Model
use HasFactory;

/**
* @return BelongsTo<Article, self>
* @return BelongsTo<Article, $this>
*/
public function article(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getISO6393Language(): string
}

/**
* @return BelongsTo<Gametype, self>
* @return BelongsTo<Gametype, $this>
*/
public function gameType(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/Gametype.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Gametype extends Model
];

/**
* @return HasMany<Game>
* @return HasMany<Game, $this>
*/
public function games(): HasMany
{
Expand Down
12 changes: 6 additions & 6 deletions sourcecode/apis/contentauthor/app/H5PContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,39 +69,39 @@ class H5PContent extends Content implements VersionableObject
];

/**
* @return HasMany<H5PCollaborator>
* @return HasMany<H5PCollaborator, $this>
*/
public function collaborators(): HasMany
{
return $this->hasMany(H5PCollaborator::class, 'h5p_id');
}

/**
* @return BelongsTo<H5PLibrary, self>
* @return BelongsTo<H5PLibrary, $this>
*/
public function library(): BelongsTo
{
return $this->belongsTo(H5PLibrary::class, 'library_id');
}

/**
* @return HasMany<H5PContentsUserData>
* @return HasMany<H5PContentsUserData, $this>
*/
public function contentUserData(): HasMany
{
return $this->hasMany(H5PContentsUserData::class, 'content_id');
}

/**
* @return HasMany<H5PContentLibrary>
* @return HasMany<H5PContentLibrary, $this>
*/
public function contentLibraries(): HasMany
{
return $this->hasMany(H5PContentLibrary::class, 'content_id');
}

/**
* @return HasOne<H5PContentsMetadata>
* @return HasOne<H5PContentsMetadata, $this>
*/
public function metadata(): HasOne
{
Expand Down Expand Up @@ -200,7 +200,7 @@ public function makeCopy($owner = null): self
}

/**
* @return HasMany<H5PContentsVideo>
* @return HasMany<H5PContentsVideo, $this>
*/
public function contentVideos(): HasMany
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/H5PContentsMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class H5PContentsMetadata extends Model
protected $table = 'h5p_contents_metadata';

/**
* @return BelongsTo<H5PContent, self>
* @return BelongsTo<H5PContent, $this>
*/
public function content(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/H5PContentsUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class H5PContentsUserData extends Model
protected $table = "h5p_contents_user_data";

/**
* @return BelongsTo<H5PContent, self>
* @return BelongsTo<H5PContent, $this>
*/
public function content(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/H5PContentsVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class H5PContentsVideo extends Model
];

/**
* @return BelongsTo<H5PContent, self>
* @return BelongsTo<H5PContent, $this>
*/
public function content(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/H5PLibrariesHubCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getUpdatedAtAttribute($value)
}

/**
* @return HasMany<H5PLibrary>
* @return HasMany<H5PLibrary, $this>
*/
public function libraries(): HasMany
{
Expand Down
10 changes: 5 additions & 5 deletions sourcecode/apis/contentauthor/app/H5PLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@ public function getMachineNameAttribute()
}

/**
* @return HasOne<H5PLibraryCapability>
* @return HasOne<H5PLibraryCapability, $this>
*/
public function capability(): HasOne
{
return $this->hasOne(H5PLibraryCapability::class, 'library_id');
}

/**
* @return HasOne<LibraryDescription>
* @return HasOne<LibraryDescription, $this>
*/
public function description(): HasOne
{
return $this->hasOne(LibraryDescription::class, 'library_id');
}

/**
* @return HasMany<H5PContent>
* @return HasMany<H5PContent, $this>
*/
public function contents(): HasMany
{
Expand All @@ -109,15 +109,15 @@ public function contentsWithNoScore()
}

/**
* @return HasMany<H5PLibraryLanguage>
* @return HasMany<H5PLibraryLanguage, $this>
*/
public function languages(): HasMany
{
return $this->hasMany(H5PLibraryLanguage::class, 'library_id');
}

/**
* @return HasMany<H5PLibraryLibrary>
* @return HasMany<H5PLibraryLibrary, $this>
*/
public function libraries(): HasMany
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/H5PLibraryCapability.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class H5PLibraryCapability extends Model
protected $appends = ['title', 'description'];

/**
* @return BelongsTo<H5PLibrary, self>
* @return BelongsTo<H5PLibrary, $this>
*/
public function library(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/H5PLibraryLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class H5PLibraryLanguage extends Model
public $timestamps = false;

/**
* @return BelongsTo<H5PLibrary, self>
* @return BelongsTo<H5PLibrary, $this>
*/
public function library(): BelongsTo
{
Expand Down
4 changes: 2 additions & 2 deletions sourcecode/apis/contentauthor/app/H5PLibraryLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class H5PLibraryLibrary extends Model
public $timestamps = false;

/**
* @return BelongsTo<H5PLibrary, self>
* @return BelongsTo<H5PLibrary, $this>
*/
public function library(): BelongsTo
{
return $this->belongsTo(H5PLibrary::class);
}

/**
* @return HasOne<H5PLibrary>
* @return HasOne<H5PLibrary, $this>
*/
public function requiredLibrary(): HasOne
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Created by PhpStorm.
* User: tsivert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function contentForLibrary(H5PLibrary $library, Request $request): View
->orderBy('updated_at', 'DESC')
->orderBy('id', 'DESC')
->limit($pageSize)
->offset($pageSize * ($page-1))
->offset($pageSize * ($page - 1))
->get()
->map(function (H5PContent $row) use (&$latestCount) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use Doctrine\DBAL\Driver\PDOConnection;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
Expand All @@ -20,9 +19,6 @@ public function index()
return response('cache test failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}

/**
* @var PDOConnection $connection
*/
$connection = DB::connection()->getPdo();

$query = $connection->query("SELECT '1'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function useMaxScore(): bool
public function addTrackingScripts(): ?string
{
return null;
// return <<<TRACKINGDOC
// return <<<TRACKINGDOC
//<!-- Global site tag (gtag.js) - Google Analytics -->
//<script async src="https://www.googletagmanager.com/gtag/js?id=G-R51SSMVE78"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);}gtag('js', new Date()); gtag('config', 'G-R51SSMVE78'); </script>
//TRACKINGDOC;
Expand Down
2 changes: 0 additions & 2 deletions sourcecode/apis/contentauthor/app/Libraries/H5P/H5PImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public function __construct(\H5PEditorAjax $editorAjax)
}

/**
* @param bool $isDraft
* @param bool $isPrivate
* @return H5PImportDataObject|bool
* @throws \Exception
*/
Expand Down
4 changes: 2 additions & 2 deletions sourcecode/apis/contentauthor/app/Libraries/H5P/H5PInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public function getInformation(H5PContent $content): array
'name' => $content->library->name,
'majorVersion' => $content->library->major_version,
'minorVersion' => $content->library->minor_version,
'latestMajorVersion' =>$libraryInfo->major_version,
'latestMinorVersion' =>$libraryInfo->minor_version,
'latestMajorVersion' => $libraryInfo->major_version,
'latestMinorVersion' => $libraryInfo->minor_version,
'upgradable' => $content->library->isUpgradable(),
],
'published' => $content['is_published'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Libraries\H5P\Traits;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Support\Facades\Log;
use Exception;
use App\H5PFile;
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/LibraryDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LibraryDescription extends Model
protected $appends = ['capability_id'];

/**
* @return BelongsTo<H5PLibrary, self>
* @return BelongsTo<H5PLibrary, $this>
*/
public function library(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function givesScore(): int
}

/**
* @return HasMany<ArticleCollaborator>
* @return HasMany<ArticleCollaborator, $this>
*/
public function collaborators(): HasMany
{
Expand Down
2 changes: 1 addition & 1 deletion sourcecode/apis/contentauthor/app/NdlaArticleId.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setJsonAttribute($value): void
}

/**
* @return HasMany<NdlaArticleImportStatus>
* @return HasMany<NdlaArticleImportStatus, $this>
*/
public function messages(): HasMany
{
Expand Down
Loading

0 comments on commit 8aa1b74

Please sign in to comment.