When we import the exported config which has the Brightcove plugin installed, we get:
Uncaught TypeError: Argument 2 passed to
Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}() must be an instance of
Drupal\jsonapi\ResourceType\ResourceType, null given in
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php:354
Stack trace:
#0 [internal function]: Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}(false, NULL)
#1
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php(356):
array_reduce(Array, Object(Closure), false)
#2
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php(274):
Drupal\jsonapi\Routing\Routes::hasNonInternalTargetResourceTypes(Array)
#3
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php(176):
Drupal\jsonapi\Routing\Routes::getIndividualRoutesForResourceType(Object(Drupal\jsona in
drupal8/html/modules/contrib/jsonapi/src/Routing/Routes.php,
line 354In our case, this fails, because Brightcove has an entity (BrightcoveVideo) that's defined programatically, which references another entity in its baseFieldDefinitions that's declared as in yaml file in "config/install". During initial plugin installation there's no problem, because the config is imported before the video entity is created. However, when running "drush config-import", the "baseFieldDefinitions" method is executed before the configuration is imported. Given that there's no agreement whether database updates should be executed before or after the configuration is imported I decided to open an issue here.
Intuition tells me that routes should only be generated after config is imported and database updates are executed.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff_10-11.txt | 2.05 KB | immaculatexavier |
| #11 | 3033070-11.patch | 2.09 KB | immaculatexavier |
| #10 | 3033070-10.patch | 1.77 KB | ravi.shankar |
| #3 | 3033070-3-do-not-test.patch | 1.62 KB | wim leers |
Comments
Comment #2
gabesulliceI think I agree with you, but that makes this a Drupal core issue. JSON:API doesn't control when routes are generated.
Comment #3
wim leersHm, here's a thought, this might be able to solve it. But the config syncing process is so much of a black box to me, that it's really just a wild guess.
Comment #9
borisson_This patch probably did not apply for core, i'm not sure if this is actually still a problem, so we should probably start by checking if this is still an issue with the brightcove module
If it still applies, we also need tests, tagged with the CMI tag so the right people can also have a look at this to see if this is a good solution.
Comment #10
ravi.shankar commentedAdded reroll of patch #3 on Drupal 9.4.x.
Comment #11
immaculatexavier commentedRerolled patch against #10
Comment #12
borisson_Before the rerolling, it's more important to see if this is actually still needed.