Skip to content

Commit 9a6569b

Browse files
authored
Merge branch 'main' into preview-enabled
2 parents c8f3000 + c1a9054 commit 9a6569b

File tree

162 files changed

+6949
-5688
lines changed

Some content is hidden

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

162 files changed

+6949
-5688
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
*.esm.js
66
/drupal
77
/drupal-*
8+
/local-next-drupal

.github/workflows/next.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
phpunit:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-24.04
1313
strategy:
1414
matrix:
1515
# Supported PHP versions: https://www.drupal.org/docs/getting-started/system-requirements/php-requirements
@@ -22,15 +22,21 @@ jobs:
2222
- "10.0.x"
2323
- "10.1.x"
2424
- "10.2.x"
25+
- "10.3.x"
26+
- "11.0.x"
2527
exclude:
2628
- drupal: "10.0.x"
2729
php: "8.3"
2830
- drupal: "10.1.x"
2931
php: "8.3"
32+
- drupal: "11.0.x"
33+
php: "8.1"
34+
- drupal: "11.0.x"
35+
php: "8.2"
3036
name: Drupal ${{ matrix.drupal }} - PHP ${{ matrix.php }}
3137
services:
3238
mysql:
33-
image: mysql:5.7
39+
image: mysql:8.0
3440
env:
3541
MYSQL_ALLOW_EMPTY_PASSWORD: yes
3642
MYSQL_DATABASE: db

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ yarn-error.log*
4242
/drupal/web/phpunit.xml
4343
/drupal/web/sites/default/settings.local.php
4444
/drupal-*
45+
/local-next-drupal

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ yarn workspace next-drupal dev
5050

5151
You can run all the tests from the root of the repository.
5252

53+
Due to the current CI/CD setup it is not possible to run the tests locally.
54+
A running Drupal instance with a secret configuration is required to run the tests.
55+
56+
To add the required env vars to Jest run:
57+
58+
```
59+
cp packages/next-drupal/.env.example packages/next-drupal/.env
60+
```
61+
5362
### `next-drupal`
5463

5564
We use `jest` for testing the `next-drupal` package.

modules/next/.gitlab-ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ include:
5252
#
5353
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
5454
################
55-
# variables:
56-
# SKIP_ESLINT: '1'
57-
55+
variables:
56+
# SKIP_ESLINT: '1'
57+
OPT_IN_TEST_PREVIOUS_MINOR: 1
58+
OPT_IN_TEST_NEXT_MINOR: 1
59+
OPT_IN_TEST_NEXT_MAJOR: 1
5860
###################################################################################
5961
#
6062
# *

modules/next/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
"drupal/subrequests": "^3.0"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^6.0 || ^7.0 || ^8.0 || ^9.0"
20+
"phpunit/phpunit": "^9 || ^10"
2121
}
2222
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Next.js Extras (Experimental)
22
description: Adds extra (mostly experiemental) functionality to Next.js module
33
type: module
4-
core_version_requirement: ^9 || ^10
4+
core_version_requirement: ^10 || ^11
55
package: Web services
66
dependencies:
77
- next:next

modules/next/modules/next_extras/src/NextCacheInvalidator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public function invalidatePath(string $path, array $sites): void {
143143
}
144144
}
145145
catch (RequestException $exception) {
146-
watchdog_exception('next_extras', $exception);
146+
// Using logger service to log the exception.
147+
$this->logger->error($exception->getMessage());
147148
}
148149
}
149150
}

modules/next/modules/next_graphql/next_graphql.info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Next.js GraphQL'
22
type: module
33
description: 'GraphQL for Next.js'
4-
core_version_requirement: ^9 || ^10
4+
core_version_requirement: ^10 || ^11
55
package: Web services
66
dependencies:
77
- graphql:graphql

modules/next/modules/next_jsonapi/next_jsonapi.info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Next.js JSON:API'
22
type: module
33
description: 'JSON:API Helpers for Next.js'
4-
core_version_requirement: ^9 || ^10
4+
core_version_requirement: ^10 || ^11
55
package: Web services
66
dependencies:
77
- decoupled_router:decoupled_router

modules/next/modules/next_jsonapi/src/NextJsonapiServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class NextJsonapiServiceProvider extends ServiceProviderBase {
1515
*/
1616
public function alter(ContainerBuilder $container) {
1717
/** @var \Symfony\Component\DependencyInjection\Definition $definition */
18-
1918
if ($container->hasDefinition('jsonapi.entity_resource')) {
2019
$definition = $container->getDefinition('jsonapi.entity_resource');
2120
$definition->setClass('Drupal\next_jsonapi\Controller\EntityResource');

modules/next/modules/next_jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Drupal\Tests\node\Traits\NodeCreationTrait;
99
use Drupal\Tests\user\Traits\UserCreationTrait;
1010
use Drupal\user\Entity\User;
11-
use Symfony\Component\HttpFoundation\ParameterBag;
11+
use Symfony\Component\HttpFoundation\InputBag;
1212
use Symfony\Component\HttpFoundation\Request;
1313

1414
/**
@@ -45,7 +45,6 @@ protected function setUp(): void {
4545
$this->installEntitySchema('node');
4646
$this->installEntitySchema('user');
4747
$this->installConfig(['filter', 'next']);
48-
$this->installSchema('system', ['sequences']);
4948
$this->installSchema('node', ['node_access']);
5049

5150
$type = NodeType::create([
@@ -91,14 +90,14 @@ public function testPageLimit() {
9190

9291
// Default using \Drupal\jsonapi\Query\OffsetPage::SIZE_MAX.
9392
$request = Request::create('/jsonapi/node/article');
94-
$request->query = new ParameterBag();
93+
$request->query = new InputBag();
9594
$response = $entity_resource->getCollection($resource_type, $request);
9695
$data = $response->getResponseData()->getData();
9796
$this->assertSame(50, $data->count());
9897

9998
// With page limit.
10099
$request = Request::create('/jsonapi/node/article');
101-
$request->query = new ParameterBag([
100+
$request->query = new InputBag([
102101
'page' => [
103102
'limit' => 10,
104103
],
@@ -109,7 +108,7 @@ public function testPageLimit() {
109108

110109
// With page limit over size max.
111110
$request = Request::create('/jsonapi/node/article');
112-
$request->query = new ParameterBag([
111+
$request->query = new InputBag([
113112
'page' => [
114113
'limit' => 100,
115114
],
@@ -120,7 +119,7 @@ public function testPageLimit() {
120119

121120
// With page limit and offset.
122121
$request = Request::create('/jsonapi/node/article');
123-
$request->query = new ParameterBag([
122+
$request->query = new InputBag([
124123
'page' => [
125124
'offset' => 2,
126125
'limit' => 5,
@@ -132,7 +131,7 @@ public function testPageLimit() {
132131

133132
// With fields as sparse fieldset.
134133
$request = Request::create('/jsonapi/node/article');
135-
$request->query = new ParameterBag([
134+
$request->query = new InputBag([
136135
'fields' => [
137136
'node--article' => 'title',
138137
],
@@ -143,7 +142,7 @@ public function testPageLimit() {
143142

144143
// Using sparse fieldset path override.
145144
$request = Request::create('/jsonapi/node/article');
146-
$request->query = new ParameterBag([
145+
$request->query = new InputBag([
147146
'fields' => [
148147
'node--article' => 'path,title',
149148
],
@@ -154,7 +153,7 @@ public function testPageLimit() {
154153

155154
// Using sparse fieldset path override and limit.
156155
$request = Request::create('/jsonapi/node/article');
157-
$request->query = new ParameterBag([
156+
$request->query = new InputBag([
158157
'fields' => [
159158
'node--article' => 'path,title',
160159
],
@@ -168,7 +167,7 @@ public function testPageLimit() {
168167

169168
// Using sparse fieldset path override and limit.
170169
$request = Request::create('/jsonapi/node/article');
171-
$request->query = new ParameterBag([
170+
$request->query = new InputBag([
172171
'fields' => [
173172
'node--article' => 'path,title',
174173
],

modules/next/modules/next_jwt/next_jwt.info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Next.js JWT (Experimental)
22
type: module
33
description: 'Generates preview URLs using JSON Web Token'
4-
core_version_requirement: ^9 || ^10
4+
core_version_requirement: ^10 || ^11
55
package: Web services
66
dependencies:
77
- next:next

modules/next/modules/next_jwt/src/EventSubscriber/JwtEventSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(AccountInterface $current_user, NextSettingsManagerI
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public static function getSubscribedEvents() {
46+
public static function getSubscribedEvents(): array {
4747
$events[JwtAuthEvents::GENERATE][] = ['setStandardClaims', 100];
4848
$events[JwtAuthEvents::GENERATE][] = ['setDrupalClaims', 99];
4949
return $events;

modules/next/next.info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Next.js
22
description: Next.js + Drupal for Incremental Static Regeneration and Draft mode.
33
type: module
4-
core_version_requirement: ^9 || ^10
4+
core_version_requirement: ^10 || ^11
55
package: Web services
66
configure: entity.next_site.collection
77
dependencies:

modules/next/next.services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
'@config.factory',
2222
'@plugin.manager.next.site_previewer',
2323
'@plugin.manager.next.preview_url_generator',
24+
'@logger.channel.next',
2425
]
2526
next.preview_secret_generator:
2627
class: Drupal\next\PreviewSecretGenerator

modules/next/src/Entity/NextSite.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,15 @@ public function getLiveUrlForEntity(EntityInterface $entity): ?Url {
265265
/**
266266
* {@inheritdoc}
267267
*/
268-
public function getRevalidateUrlForPath(string $path): ?Url {
268+
public function buildRevalidateUrl(array $query = []): ?Url {
269269
$revalidate_url = $this->getRevalidateUrl();
270-
271270
if (!$revalidate_url) {
272271
return NULL;
273272
}
274-
275-
$query = [
276-
'path' => $path,
277-
];
278-
279273
if ($secret = $this->getRevalidateSecret()) {
280274
$query['secret'] = $secret;
281275
}
282-
283-
return Url::fromUri($this->getRevalidateUrl(), [
276+
return Url::fromUri($revalidate_url, [
284277
'query' => $query,
285278
]);
286279
}

modules/next/src/Entity/NextSiteInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ public function setRevalidateSecret(string $revalidate_secret): self;
131131
/**
132132
* Returns the revalidate url for given path.
133133
*
134-
* @param string $path
135-
* The path.
134+
* @param array $query
135+
* The revalidate URL query parameters.
136136
*
137137
* @return \Drupal\Core\Url|null
138138
* The revalidate url.
139139
*/
140-
public function getRevalidateUrlForPath(string $path): ?Url;
140+
public function buildRevalidateUrl(array $query = []): ?Url;
141141

142142
}

modules/next/src/EventSubscriber/EntityActionEventRevalidateSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EntityActionEventRevalidateSubscriber extends EntityActionEventSubscriberB
1717
/**
1818
* {@inheritdoc}
1919
*/
20-
public static function getSubscribedEvents() {
20+
public static function getSubscribedEvents(): array {
2121
$events[EntityEvents::ENTITY_ACTION] = ['onAction'];
2222
return $events;
2323
}

modules/next/src/Form/NextSettingsForm.php

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Drupal\next\Form;
44

5-
use Drupal\Core\Config\ConfigFactoryInterface;
65
use Drupal\Core\Form\ConfigFormBase;
76
use Drupal\Core\Form\FormStateInterface;
87
use Drupal\Core\Form\SubformState;
@@ -22,7 +21,7 @@ class NextSettingsForm extends ConfigFormBase {
2221
*
2322
* @var \Drupal\next\Plugin\SitePreviewerManagerInterface
2423
*/
25-
protected $sitePreviewerManager;
24+
protected SitePreviewerManagerInterface $sitePreviewerManager;
2625

2726
/**
2827
* The preview url generator manager.
@@ -31,34 +30,16 @@ class NextSettingsForm extends ConfigFormBase {
3130
*/
3231
protected PreviewUrlGeneratorManagerInterface $previewUrlGeneratorManager;
3332

34-
/**
35-
* NextSettingsForm constructor.
36-
*
37-
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
38-
* The config factory service.
39-
* @param \Drupal\next\Plugin\SitePreviewerManagerInterface $site_previewer_manager
40-
* The site previewer manager.
41-
* @param \Drupal\next\Plugin\PreviewUrlGeneratorManagerInterface $preview_url_generator_manager
42-
* The preview url generator manager.
43-
*/
44-
public function __construct(ConfigFactoryInterface $config_factory, SitePreviewerManagerInterface $site_previewer_manager, PreviewUrlGeneratorManagerInterface $preview_url_generator_manager = NULL) {
45-
if (!$preview_url_generator_manager) {
46-
@trigger_error('Calling NextSettingsForm::__construct() without the $preview_url_generator_manager argument is deprecated in next:1.3.0 and will be required in next:2.0.0. See https://www.drupal.org/node/3308330', E_USER_DEPRECATED);
47-
// @codingStandardsIgnoreStart
48-
$preview_url_generator_manager = \Drupal::service('plugin.manager.next.preview_url_generator');
49-
// @codingStandardsIgnoreEnd
50-
}
51-
52-
parent::__construct($config_factory);
53-
$this->sitePreviewerManager = $site_previewer_manager;
54-
$this->previewUrlGeneratorManager = $preview_url_generator_manager;
55-
}
56-
5733
/**
5834
* {@inheritdoc}
5935
*/
6036
public static function create(ContainerInterface $container) {
61-
return new static($container->get('config.factory'), $container->get('plugin.manager.next.site_previewer'), $container->get('plugin.manager.next.preview_url_generator'));
37+
$instance = parent::create($container);
38+
39+
$instance->sitePreviewerManager = $container->get('plugin.manager.next.site_previewer');
40+
$instance->previewUrlGeneratorManager = $container->get('plugin.manager.next.preview_url_generator');
41+
42+
return $instance;
6243
}
6344

6445
/**

0 commit comments

Comments
 (0)