Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drupal 10 Compatibility from Upgrade Status #960

Merged
merged 14 commits into from
Jul 12, 2023
6 changes: 2 additions & 4 deletions .github/workflows/build-2.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ jobs:
strategy:
fail-fast: false
matrix:
# PHP 8.1 fails - see https://github.com/Islandora/islandora/issues/887
php-versions: ["7.4", "8.0", "8.1"]
php-versions: ["8.1"]
# test-suite functional-javascript will appear to pass but will skip tests; missing chromedriver.
test-suite: ["kernel", "functional", "functional-javascript"]
# Not yet Drupal 10 ready - see https://github.com/Islandora/islandora/issues/888
drupal-version: ["9.4.x", "9.5.x"]
drupal-version: ["9.5.x", "10.0.x", "10.1.x"]
mysql: ["8.0"]
allowed_failure: [false]

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
}
],
"require": {
"drupal/context": "^4",
"drupal/context": "^4 || ^5@RC",
"drupal/ctools": "^3.8 || ^4",
"drupal/eva" : "^3.0",
"drupal/features" : "^3.7",
"drupal/features" : "^3.13",
"drupal/file_replace": "^1.1",
"drupal/filehash": "^2",
"drupal/flysystem" : "^2.0@alpha",
Expand All @@ -29,7 +29,7 @@
"drupal/token" : "^1.3",
"islandora/chullo": "^2.0",
"islandora/fedora-entity-mapper": "^1.0",
"islandora/jsonld": "^2",
"islandora/jsonld": "^2 || ^3",
"stomp-php/stomp-php": "4.* || ^5"
},
"require-dev": {
Expand Down
37 changes: 18 additions & 19 deletions islandora.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,31 @@ name: 'islandora'
description: "Islandora Core"
type: module
package: Islandora
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
dependencies:
- context:context_ui
- ctools:ctools
- drupal:action
- drupal:basic_auth
- drupal:block
- drupal:content_translation
- drupal:link
- drupal:media
- drupal:node
- drupal:path
- drupal:text
- drupal:options
- drupal:link
- jsonld:jsonld
- search_api:search_api
- jwt:jwt
- drupal:path
- drupal:rest
- filehash:filehash
- drupal:basic_auth
- context:context_ui
- drupal:action
- eva:eva
- drupal:taxonomy
- drupal:text
- drupal:views_ui
- drupal:media
- prepopulate:prepopulate
- eva:eva
- features:features_ui
- migrate_source_csv:migrate_source_csv
- drupal:content_translation
- file_replace:file_replace
- filehash:filehash
- flysystem:flysystem
- jsonld:jsonld
- jwt:jwt
- migrate_source_csv:migrate_source_csv
- prepopulate:prepopulate
- search_api:search_api
- token:token
- file_replace:file_replace
- ctools:ctools
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: 'Islandora Advanced Search'
description: "Creates an Advanced Search block and other enhancements to search."
type: module
package: Islandora
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
dependencies:
- drupal:facets
- drupal:facets_summary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(Request $request, RouteMatchInterface $current_route
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('request_stack')->getMasterRequest(),
$container->get('request_stack')->getMainRequest(),
$container->get('current_route_match')
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_definition,
$container->get('plugin.manager.search_api.display'),
$container->get('form_builder'),
$container->get('request_stack')->getMasterRequest()
$container->get('request_stack')->getMainRequest()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function create(ContainerInterface $container, array $configuratio
$configuration,
$plugin_id,
$plugin_definition,
$container->get('request_stack')->getMasterRequest()
$container->get('request_stack')->getMainRequest()
);
}

Expand Down
3 changes: 1 addition & 2 deletions modules/islandora_audio/islandora_audio.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: 'Islandora Audio'
description: 'Islandora audio derivative actions'
type: module
package: Islandora
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
dependencies:
- drupal:islandora
3 changes: 1 addition & 2 deletions modules/islandora_breadcrumbs/islandora_breadcrumbs.info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: 'Islandora Breadcrumbs'
type: module
description: 'Builds breadcrumbs based on field_member_of relationships.'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
package: Islandora
dependencies:
- islandora:islandora
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: 'Islandora Core Feature'
description: 'Minimum configuration required for Islandora.'
type: module
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
dependencies:
- drupal:basic_auth
- drupal:content_translation
Expand Down
3 changes: 1 addition & 2 deletions modules/islandora_iiif/islandora_iiif.info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: 'Islandora IIIF'
type: module
description: 'IIIF support for Islandora'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
package: Islandora
dependencies:
- drupal:islandora
3 changes: 1 addition & 2 deletions modules/islandora_image/islandora_image.info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: 'Islandora Image'
type: module
description: 'Islandora Image derivative actions'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
package: Islandora
dependencies:
- drupal:islandora
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: 'Islandora Text Extraction'
type: module
description: 'Islandora 8 module to connect to Hypercube microservice, and to get text from PDF ingest'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
package: 'Islandora'
dependencies:
- drupal:islandora
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: 'Islandora Text Extraction Defaults'
type: module
description: 'Default config for the Islandora Text Extraction module.'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
package: Islandora
dependencies:
- drupal:field
Expand Down
3 changes: 1 addition & 2 deletions modules/islandora_video/islandora_video.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: 'Islandora Video'
description: 'Islandora video derivative actions'
type: module
package: Islandora
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
dependencies:
- drupal:islandora
1 change: 1 addition & 0 deletions src/EventGenerator/EventGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ protected function isNewRevision(EntityInterface $entity) {
protected function getRevisionIds(Media $media, EntityStorageInterface $media_storage) {
$result = $media_storage->getQuery()
->allRevisions()
->accessCheck(TRUE)
->condition($media->getEntityType()->getKey('id'), $media->id())
->sort($media->getEntityType()->getKey('revision'), 'DESC')
->execute();
Expand Down
20 changes: 3 additions & 17 deletions src/Flysystem/Adapter/FedoraAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Drupal\islandora\Flysystem\Adapter;

use GuzzleHttp\Psr7\Header;
use function GuzzleHttp\Psr7\parse_header;
use Drupal\Core\Logger\LoggerChannelInterface;
use Islandora\Chullo\IFedoraApi;
use League\Flysystem\AdapterInterface;
Expand Down Expand Up @@ -160,14 +159,8 @@ protected function getMetadataFromHeaders(Response $response) {
// NonRDFSource's are considered files. Everything else is a
// directory.
$type = 'dir';
// phpcs:disable
if (class_exists(Header::class)) {
$links = Header::parse($response->getHeader('Link'));
}
else {
$links = parse_header($response->getHeader('Link'));
}
// phpcs:enable
$links = Header::parse($response->getHeader('Link'));

foreach ($links as $link) {
if ($link['rel'] == 'type' && $link[0] == '<http://www.w3.org/ns/ldp#NonRDFSource>') {
$type = 'file';
Expand Down Expand Up @@ -403,14 +396,7 @@ private function deleteTombstone($path) {
$return = NULL;
if ($response->getStatusCode() == 410) {
$return = FALSE;
// phpcs:disable
if (class_exists(Header::class)) {
$link_headers = Header::parse($response->getHeader('Link'));
}
else {
$link_headers = parse_header($response->getHeader('Link'));
}
// phpcs:enable
$link_headers = Header::parse($response->getHeader('Link'));
if ($link_headers) {
$tombstones = array_filter($link_headers, function ($o) {
return (isset($o['rel']) && $o['rel'] == 'hasTombstone');
Expand Down
10 changes: 8 additions & 2 deletions src/Form/ConfirmDeleteMediaAndFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// Check for files.
$fields = $this->entityFieldManager->getFieldDefinitions('media', $entity->bundle());
foreach ($fields as $field) {
if ($field->getName() == 'thumbnail') {
continue;
}
$type = $field->getType();
if ($type == 'file' || $type == 'image') {
$target_id = $entity->get($field->getName())->target_id;
Expand All @@ -137,8 +140,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$inaccessible_entities[] = $file;
continue;
}
$delete_files[$file->id()] = $file;
$total_count++;
if (!array_key_exists($file->id(), $delete_files)) {
$delete_files[$file->id()] = $file;
$total_count++;
}

}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Plugin/Condition/NodeReferencedByNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ protected function evaluateEntity(EntityInterface $entity) {
$config = FieldStorageConfig::loadByName('node', $reference_field);
if ($config) {
$id_count = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition($reference_field, $entity->id())
->count()
->execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Integer weight test views'
type: module
description: 'Provides default views for integer weight views tests.'
package: Testing
core_version_requirement: ^8 || ^9
core_version_requirement: ^8 || ^9 || ^10
dependencies:
- drupal:node
- drupal:views
Expand Down
9 changes: 8 additions & 1 deletion tests/src/Functional/DeleteMediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@ class DeleteMediaTest extends IslandoraFunctionalTestBase {
public function setUp(): void {
parent::setUp();

if (version_compare(\Drupal::VERSION, '10.1', '>=')) {
$permissions = ['create media', 'delete any media', 'delete any file'];
}
else {
$permissions = ['create media', 'delete any media'];
}

// Create a test user.
$this->account = $this->createUser(['create media', 'delete any media']);
$this->account = $this->createUser($permissions);

list($this->file, $this->media) = $this->makeMediaAndFile($this->account);
}
Expand Down
14 changes: 4 additions & 10 deletions tests/src/Kernel/FedoraAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Prophecy\PhpUnit\ProphecyTrait;
use GuzzleHttp\Psr7\Utils;
use function GuzzleHttp\Psr7\stream_for;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\islandora\Flysystem\Adapter\FedoraAdapter;
use GuzzleHttp\Psr7\Response;
Expand Down Expand Up @@ -61,13 +60,8 @@ protected function createAdapterBase() {
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
// phpcs:disable
if (class_exists(Utils::class)) {
$prophecy->getBody()->willReturn(Utils::streamFor("DERP"));
} else {
$prophecy->getBody()->willReturn(stream_for("DERP"));
}
// phpcs:enable
$prophecy->getBody()->willReturn(Utils::streamFor("DERP"));

return $prophecy;
}

Expand Down Expand Up @@ -241,7 +235,7 @@ protected function createAdapterForDeleteWithTombstone() {
$head_prophecy = $this->prophesize(Response::class);
$head_prophecy->getStatusCode()->willReturn(410);
$head_prophecy->getHeader('Link')
->willReturn('<some-path-to-a-tombstone>; rel="hasTombstone"');
->willReturn(['<some-path-to-a-tombstone>; rel="hasTombstone"']);

$tombstone_prophecy = $this->prophesize(Response::class);
$tombstone_prophecy->getStatusCode()->willReturn(204);
Expand Down Expand Up @@ -269,7 +263,7 @@ protected function createAdapterForDeleteWithTombstoneFail() {
$head_prophecy = $this->prophesize(Response::class);
$head_prophecy->getStatusCode()->willReturn(410);
$head_prophecy->getHeader('Link')
->willReturn('<some-path-to-a-tombstone>; rel="hasTombstone"');
->willReturn(['<some-path-to-a-tombstone>; rel="hasTombstone"']);

$tombstone_prophecy = $this->prophesize(Response::class);
$tombstone_prophecy->getStatusCode()->willReturn(500);
Expand Down
3 changes: 3 additions & 0 deletions tests/src/Kernel/FedoraPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\islandora\Flysystem\Fedora;
use Islandora\Chullo\IFedoraApi;
use League\Flysystem\AdapterInterface;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;

Expand All @@ -17,6 +18,8 @@
*/
class FedoraPluginTest extends IslandoraKernelTestBase {

use ProphecyTrait;

/**
* Mocks up a plugin.
*/
Expand Down