Hello,
I am testing Drupal 8.8.0-alpha1 and get the following error:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Drupal\jsonapi\ResourceType\ResourceTypeRepository::__construct(), 4 passed in /project/www/modules/contrib/jsonapi_extras/src/ResourceType/ConfigurableResourceTypeRepository.php on line 92 and exactly 5 expected in /project/www/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php:107
Stack trace:
#0 /project/www/modules/contrib/jsonapi_extras/src/ResourceType/ConfigurableResourceTypeRepository.php(92): Drupal\jsonapi\ResourceType\ResourceTypeRepository->__construct(Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Entity\EntityTypeBundleInfo), Object(Drupal\Core\Entity\EntityFieldManager), Object(Drupal\Core\Cache\BackendChain))
#1 /project/www/core/lib/Drupal/Component/DependencyInjection/Container.php(285): Drupal\jsonapi_extras\ResourceType\ConfigurableResourceTypeRepository->__construct(Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\Core\Entity\EntityTypeBundleInfo), Object(Drupal\Core\Entity\EntityFieldMan in /project/www/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php on line 107
Patch incoming.
Comment | File | Size | Author |
---|---|---|---|
#24 | 3089444-24.patch | 1.48 KB | BR0kEN |
#21 | 3089444-21.patch | 1.7 KB | Rajab Natshah |
| |||
#2 | jsonapi_extras-compatibility-8.8.x-3089444-2.patch | 1.74 KB | Grimreaper |
Comments
Comment #2
GrimreaperHere is the patch, thanks for the review.
Comment #3
damontgomery CreditAttribution: damontgomery at Palantir.net commentedI was just looking at this. The patch in #2 works for me.
I'm not sure if this is the right place for this, but I found another bug / incompatibility with 8.8.0-alpha1.
- Overwrite a node resource
- Change the Resource Type, example: `node--article` to `article`
- Save
- Clear the cache, `drush cr`
```
PHP Fatal error: 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 /var/www/my_site/docroot/core/modules/jsonapi/src/Routing/Routes.php:434
Stack trace:
#0 [internal function]: Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}(false, NULL)
#1 /var/www/my_site/docroot/core/modules/jsonapi/src/Routing/Routes.php(436): array_reduce(Array, Object(Closure), false)
#2 /var/www/my_site/docroot/core/modules/jsonapi/src/Routing/Routes.php(339): Drupal\jsonapi\Routing\Routes::hasNonInternalTargetResourceTypes(Array)
#3 /var/www/my_site/docroot/core/modules/jsonapi/src/Routing/Routes.php(183): Drupal\jsonapi\Routing\Routes::getIndividualRoutesForResourceType(Object(Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType))
#4 /var/www/my_site/docroot/core/modules/jsonapi/src/Routing/Routes.php(116): Drupal\jsonapi\Routing\Routes::getRout in /var/www/my_site/docroot/core/modules/jsonapi/src/Routing/Routes.php on line 434
```
I'm not sure what was causing that issue but it might be related to https://www.drupal.org/project/drupal/issues/2996114.
Comment #4
GrimreaperThanks @damontgomery for the feedback.
I am also writing automated tests on #3064320: Pathauto support, And I got problems with jsonapi_extras on Core 8.8.0-alpha1.
So I guess there are other places to fix.
Comment #5
dorficus CreditAttribution: dorficus as a volunteer commentedThe problem @danmontgomery mentioned is a core issue here: https://www.drupal.org/project/drupal/issues/2996114 that is causing this error.
Comment #6
damontgomery CreditAttribution: damontgomery at Palantir.net commentedThanks @dorficus and @Grimreaper.
Is it worth updating this issue to limit the scope to the issue you fixed and then having new issues for the other problems?
I've been using your patch for a few days and it seems to be working on our work-in-progress site.
Thanks.
Comment #7
dorficus CreditAttribution: dorficus at Genuine commentedI just started using the patch and it's doing what it should be. We're also developing a WIP site that is right on that cusp of 8.7.x and 8.8.x and I want to get some of the functions from 8.8.x. This is the only blocker, but the patch works for me.
@Grimreaper, what errors are you getting when testing pathauto?
Comment #8
Grimreaper@dorficus.
I was trying to reproduce my bugs with #3089850: Tests: Pathauto support. But I can't sorry.
So yes, the scope of the issue can be limited on my first patch.
Comment #9
shalikas CreditAttribution: shalikas commentedAny news Regarding this problem ?
when i'm doing get request to jsonapi endpoint, after upgrade to 8.8 alpha1 i got
Fatal error: Trait 'Shaper\DataAdaptor\DataAdaptorValidatorTrait' not found in
/public_html/modules/jsonapi_extras/src/Plugin/ResourceFieldEnhancerBase.php on line
25
Comment #10
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commented#2 works well with Drupal 8.8.0-beta1 only
Not sure if this should be in a new branch or should be handled by code
But it's not working with Drupal 8.7.x it will have the issue of
Comment #11
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedThe __construct for ResourceTypeRepository in Drupal core 8.7.x has 4 arguments
But in Drupal core 8.8.x it has 5 arguments.
Comment #12
dorficus CreditAttribution: dorficus at Genuine commented@RajabNatshah this patch is only for the 8.8.x version. There was an API change so previous versions of Drupal would require a different version of the module to function.
Comment #13
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedThank you J.
That is clear to me
I'm suggesting for a new branch
#10
Not sure if this should be in a new branch or should be handled by code
#3093428: Add the 3089444-21.patch for the [JSON:API Extras] module to fix Compatibility with Drupal 8.8.x and Drupal 8.7.x
Seems that we may need a new branch for
#3089444: Compatibility with Drupal 8.8.x
or a new branch for Varbase API too.
Comment #14
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #15
lawxen CreditAttribution: lawxen at Sparkpad commented#2
WorksMake the site can be cache cleared, thanks @Grimreaper.But the we should fix the test code.
Comment #16
lawxen CreditAttribution: lawxen at Sparkpad commentedComment #17
lawxen CreditAttribution: lawxen at Sparkpad commentedAfter read above two issues, the whole ConfigurableResourceTypeRepository.php should be removed, and use ResourceTypeBuildEvent to handle the renaming of fields.
Comment #18
lawxen CreditAttribution: lawxen at Sparkpad commentedComment #19
lawxen CreditAttribution: lawxen at Sparkpad commentedI try to add a ResourceTypeBuildEventSubscriber, but there's are so many other places needs be changed, But I don't have so much time these days.
Comment #20
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedHi Liu :)
Nice following and debugging on this issue
I think we should change the patch to work as what Jacob did for webform
#3091715: Too few arguments to function Drupal\webform\WebformThemeManager::__construct()
like the null argument !! maybe
I have noticed number argument number issues when we start to use Drupal 8.8.x and Drupal 8.7.x at the same time.
Comment #21
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #22
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedComment #23
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedStill I think a new branch could result on a faster performance by removing all conditions in the module.
any condition which related D8.8.x or D8.7.x
Comment #24
BR0kENHere's a simpler solution.
Comment #25
mglaman👍 this is much simpler. The only reason the constructor is overridden is to add additional cache tags, nothing else is injected.
---
Edit: 8.8 failed, but that looks like unrelated errors.
Comment #26
sokru CreditAttribution: sokru as a volunteer commentedRun into this problem when tried to update Drupal core to 8.8.0. Somehow the update managed to finish
system_update_8803
but so stuck onsystem_update_8804
with error[error] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.path_alias' doesn't exist: INSERT INTO {path_alias} ...
.I was able to reproduce this all time with restored database, then applied patch from #24 and all update hooks finished correctly.
Comment #27
axle_foley00 CreditAttribution: axle_foley00 commentedThe patch in #24 did fixed the issue for me when upgrading from 8.7.8 to 8.8.0.
Comment #28
brockfanning CreditAttribution: brockfanning commentedI don't understand the details, but also need to resolve this for a site. I tried re-testing the patch in #24 and it appears to have passed this time, FWIW.
Edit - Whoops, I think I was reading the test results wrong. My re-test didn't change the results, it seems.
Comment #29
drupalninja99 CreditAttribution: drupalninja99 at Mediacurrent commentedPatch #24 worked for me
Comment #30
BR0kEN#24 reveals another issues with Drupal 8.8.x however it's still needed in order to move forward.
Right now 8.x-3.x tests fail early (https://www.drupal.org/pift-ci-job/1497535) and #24 helps to overcome this but also leads to the following errors - https://www.drupal.org/pift-ci-job/1495249. The #99 of #2996114: Argument 2 passed to Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}() must be an instance of Drupal\jsonapi\ResourceType\ResourceType, NULL given allows to resolve many of those errors.
Comment #32
e0ipsoThanks to everyone that contributed to this issue!
Comment #33
e0ipsoComment #34
siva01 CreditAttribution: siva01 at Ciklum Western Europe for BurdaForward commentedAs wrote lawxen, there is still problem with renamed fields.
Error: Call to undefined method Drupal\jsonapi\ResourceType\ResourceTypeAttribute::withRelatableResourceTypes() in Drupal\jsonapi\ResourceType\ResourceType->Drupal\jsonapi\ResourceType\{closure}() (Zeile 385 in /var/www/html/docroot/core/modules/jsonapi/src/ResourceType/ResourceType.php) #0 [internal function]: Drupal\jsonapi\ResourceType\ResourceType->Drupal\jsonapi\ResourceType\{closure}(Array, 'type')
How reproduce it: try rewrite some field and use custom field name. Run drush cim, or drush updb. And you will get error. So this module still isn't compatible with Drupal 8.8
Comment #35
BR0kEN@siva01, apply #99 from #2996114: Argument 2 passed to Drupal\jsonapi\Routing\Routes::Drupal\jsonapi\Routing\{closure}() must be an instance of Drupal\jsonapi\ResourceType\ResourceType, NULL given to resolve the issue you've desribed.
Comment #37
siva01 CreditAttribution: siva01 at Ciklum Western Europe for BurdaForward commented@BR0kEN I already did it. Problem is in "type". We used alias "type" for one another field, than it is paragraph "type" (bundle) field, which is disabled, but still it make some conflict. Result is "Fatal error: Uncaught Error: Call to undefined method Drupal\jsonapi\ResourceType\ResourceTypeAttribute::withRelatableResourceTypes()". Fast solution is use different alias.
Comment #38
BR0kEN@siva01, I cannot reproduce this either using UI nor by the unit test. Can you help writing a test?
Also, feel free to open a new ticket and link it to this one.
My test that passes (
Drupal\Tests\jsonapi\Functional\JsonApiFunctionalTest
):