Problem/Motivation
rest module's default settings reference the entity:node entity type, but rest.info.yml doesn't require node module.
Snippet from the default coGonfig:
resources:
entity:node:
GET:
supported_formats:
- hal_json
supported_auth:
- basic_auth
POST:
supported_formats:
- hal_json
supported_auth:
- basic_auth
PATCH:
supported_formats:
- hal_json
supported_auth:
- basic_auth
DELETE:
supported_formats:
- hal_json
supported_auth:
- basic_auth
Proposed resolution
Utilize a configuration entity type for configuring REST endpoints and provide an optional configuration entity that configures a REST endpoint for nodes. Tis makes it possible
Remaining tasks
Switch to config entities for REST endpoint configurationFix HEAD testsIncorporate test changes from earlier patchesUse PluginCollections for easy dependency generation and plugin instantiationTry to move some methods from the Rescource Plugin onto the Configuration entityDecide whether to use the elaborate dependency generation code from #2308745-103: Remove rest.settings.yml, use rest_resource config entities or to rely only on resource plugin dependencies or maybe find another solutionDecide what endpoints should be shipped with the REST module as optional configuration or maybe even moved to their respective modules
Tasks after the comment:
- Adapt the existing documentation, like https://www.drupal.org/developing/api/8/rest
Beta phase evaluation
Issue category | Bug because with the current design in HEAD configuration installation for rest.settings fails if the node module ins not enabled. It also fails if an install profile provides a custom rest.settings.yml which contains configuration for entity endpoints that are provided by contrib modules (see #2397271: REST configuration fails if it contains a plugin reference that does not exist). |
---|---|
Issue priority | Major because it does not happen in general but only if the rest module is used and a custom rest.settings.yml is provided. |
Disruption | Disruptive for contributed and custom modules/install-profiles ond for other REST focused core issues because the API for managing REST endpoits changes. |
User interface changes
None
API changes
Removed the simple configuration rest.settings.yml
.
REST endpoints are now managed via a config entity.
E.g. creating an endpoint:
// if plugin id is for a derivative plugin replace with : because those are not valid in config entity id's
endpoint_id = str_replace(':', '__', $resource_plugin_id);
// get entity by id
/** @var \Drupal\rest\RestEndpointInterface $endpoint */
$endpoint = $this->endpoint_storage->create(['id' => $endpoint_id]);
$endpoint->addSupportedFormat('GET', 'hal_json');
$endpoint->addSupportedAuthenticationProvider('GET', 'basic_auth');
$endpoint->addSupportedFormat('POST', 'hal_json');
$endpoint->addSupportedAuthenticationProvider('POST', 'basic_auth');
$endpoint->addSupportedFormat('PATCH', 'hal_json');
$endpoint->addSupportedAuthenticationProvider('PATCH', 'basic_auth');
$endpoint->addSupportedFormat('DELETE', 'hal_json');
$endpoint->addSupportedAuthenticationProvider('DELETE', 'basic_auth');
$endpoint->save();
Also resource plugins can implement DependentPluginInterface
, which make those dependencies appear on the config entity.
Comment | File | Size | Author |
---|---|---|---|
#248 | 2308745-248.patch | 85.78 KB | alexpott |
#248 | 243-248-interdiff.txt | 4.74 KB | alexpott |
#243 | 2308745-243.patch | 84.94 KB | alexpott |
#243 | 241-243-interdiff.txt | 3.78 KB | alexpott |
#241 | 238-241-interdiff.txt | 12.35 KB | alexpott |
Comments
Comment #1
larowlantests/site blow up in spectacular format so figure this is major
Comment #2
BerdirThis currently serves as documentation I guess, so we should probably move it somewhere?
Also, having a single config file for this is likely going to cause trouble and for example makes it harder to deploy default service configuration with a module, but I doubt we're able to change that now.
Comment #3
clemens.tolboom+1 for committing this patch.
Maybe comment the node settings instead to have an in code example?
Comment #4
klausiWe already have docs at https://www.drupal.org/node/2096019 .
I agree with clemens, I think we should comment out the example config since it is surely useful.
Comment #5
larowlanUnlike with php, there is a performance hit in large comments in yml.
I think better option would be comment pointing to online documentation.
In reality most people are going to use Rest UI module.
Comment #6
dawehnerIn case this is really helpful, we could just go with an "example." file put in some directory
Comment #7
clemens.tolboom@larowlan how often is the config file scanned? In the past it was copied over to the config/active once.
OTOH using REST UI makes it's content unimportant.
Comment #8
larowlan@clemens, yeah fair point.
Moved the config to comment.
No interdiff, new patch.
Comment #9
jibranComment #10
BerdirYep, comments don't survive an import into active, so it should only affect the initial import, I don't think that makes a measurable difference.
Comment #11
klausiCool, so the only remaining thing to do is a test case that demonstrates the spectacular site blow up that this patch fixes :-)
Comment #12
larowlanok coming right up, cause a test in one of my contrib modules is how I found this :)
Comment #13
larowlanComment #14
larowlanComment #17
klausiOk, looks good to me!
Comment #18
alexpottAdding a web test solely for this purpose seems odd. How about we remove node from the list of modules to enable in
RESTTestBase
. Which is a doubly good thing since faster tests!Comment #19
BerdirKernel tests don't install default config, so that will not make it fail unless we'd also force it to import the config.
Comment #20
alexpott@Berdir but
abstract class RESTTestBase extends WebTestBase
Comment #21
larowlansure - tries #18, fingers crossed
Comment #24
R.Muilwijk CreditAttribution: R.Muilwijk commentedTests failed because RESTTestBase was using self:: in the setUp()
Comment #25
R.Muilwijk CreditAttribution: R.Muilwijk commentedComment #26
moshe weitzman CreditAttribution: moshe weitzman commentedLooks proper to me.
Comment #29
ArlaIn the off chance that ATest has
'node'
in $modules, and BTest extends ATest, I guess BTest will not have the content type created, but it should? Better change thein_array()
check to\Drupal::moduleHandler()->moduleExists('node')
?Comment #30
larowlanComment #31
larowlanComment #32
larowlanback to rtbc?
Comment #33
dawehnerIt is a bit sad, because this makes it harder for people to enable REST support for nodes. It no longer is simple :(
Comment #34
larowlanSo that's a vote for option 1 - make REST.module depend on node.module?
Comment #35
dawehnerNo, I think that would be worse, but meh, we seem to have to go with #31
Comment #36
penyaskitoAs berdir mentioned at #2, a single file for providing all entities config causes troubles like this (I faced this in a profile, where I had to set the settings in hook_install() because providing a config file failed.
It could also help with dawehner concerns at #33, as we could provide a rest_node module in core only with the proper config, and it would be simple again.
Is this feasible at this stage?
Comment #37
penyaskitoComment #38
alexpottI think the least disruptive solution is to fix it like this #2397271: REST configuration fails if it contains a plugin reference that does not exist
But the correct solution is to have a configuration entity
rest.settings.node
so that it is deployable.Comment #39
larowlanSo is that a postponed or a duplicate?
Comment #40
alexpott@larowlan well the fix in #2397271: REST configuration fails if it contains a plugin reference that does not exist removes the dependency on the node module since with that change wherever rest.settings is used we check that we have a plugin for it. So that's the quick fix.
I think this issue should be repurposed to consider changing the rest module to use config entities. It makes little sense that ...
We're checking if the route is enabled in the configuration... the plugin should only return configured routes.
Comment #41
Alumei CreditAttribution: Alumei commentedIs the following assumption true:
If rest would use config entities for the endpoint configuration then the node module could provide such a configuration entity as optional configuration?
Comment #42
ArlaOh, yes, optional configuration should make this easier. But it seems to me like rest should better ship with that optional configuration for all relevant core modules. (Although possibly "all relevant core modules" really means only "node".)
Comment #43
Alumei CreditAttribution: Alumei commentedHow about something like this to get started?
Comment #44
ArlaI don't see any problems with this. The RestEndpointRepository seems like a slightly unnecessary layer on top of the storage, and the actual endpoint config is missing. Also the changes to RestTestBase from the earlier patches should be applied. Let's add it and see some test runs?
Comment #45
clemens.tolboomPlease fix issue summary as per #40
May I assume we now will #2300677: JSON:API POST/PATCH support for fully validatable config entities? If so please close that set of issues preferably with a motivation.
No newline
No newline
Whitespace
No newline
No newline
Comment #46
BerdirNo, those two issues have nothing in common. This is about using config entities to store rest.module's configuration.
Comment #47
clemens.tolboom@Berdir thanks. Fixing
Comment #48
Alumei CreditAttribution: Alumei commentedUpdates issue summary.
I'll work on this now.
I first wanted to get the config entity done first. Now i will work on the feedback and start working down the remaining tasks as state in the IS:
Switch to config entities for REST endpoint configurationComment #49
Alumei CreditAttribution: Alumei commentedLet's see if HEAD tests work now.
@44: Removed EndpointRepository
@45: Fixed those stupid ones ...
Comment #50
Alumei CreditAttribution: Alumei commentedAdded Task to IS:
Node should probably be be only one as the current design would would automatically enable an endpoint if it was shipped as optional configuration if all dependencies are met.
We could also add an active flag to denote whether an endpoint is enabled. In that case it might be better to for each/some core module/s to provide a default configuration instead of the REST module providing one for each of them.
Comment #52
Alumei CreditAttribution: Alumei commentedThis should fix those test's & also @44: This should contain all relevant changes from #31.
Comment #54
Alumei CreditAttribution: Alumei commentedThis will hopefully fix the "Invalid character in Config object name" Exceptions.
I changed the the resource plugin ids generated by the EntityDeriver to look like 'entity__*' instead of 'entity:*'.
Comment #56
Alumei CreditAttribution: Alumei commentedFixed lines missed in refactoring of
RESTTestBase
.Comment #58
Alumei CreditAttribution: Alumei commentedREST endpoint entities now have an correctly working
id()
....Comment #60
Alumei CreditAttribution: Alumei commentedThis should only have the page cache test's failing.
Comment #62
Alumei CreditAttribution: Alumei commentedApparently neither
.
nor:
are valid as part of a config entity name, switched back to__
.Added optional configuration for the node module as the failing page cache test expects an enabled node rest endpoint after REST module installation.
The plugin id is generated automatically on entity creation.
Comment #64
Alumei CreditAttribution: Alumei commentedFixed cache tag assertion in REST module's PageCacheTest.
Fixed permission generation.
Comment #66
Alumei CreditAttribution: Alumei commentedThis should remove the last fatal error. Still no idea why id is not set ...
Comment #68
Alumei CreditAttribution: Alumei commentedThis should fix all fails except the ones in
Drupal\page_cache\Tests\PageCacheTest
.Comment #70
Alumei CreditAttribution: Alumei commentedThis is a long shot but i think that fails because in the REST endpoint for node I hard coded the module dependencies which it should have:
Comment #71
Alumei CreditAttribution: Alumei commentedAdded interdiff against the patch from #31.
This patch also removes the rest.settings.yml and its schema now.
Updated IS to reflect the current progress.
Comment #72
Alumei CreditAttribution: Alumei commentedUpdated IS with API changes.
Comment #73
alexpottThe
These dependencies must be calculable and atm I don't see how they are. Also I think that this might belong in node/config/optional
This should implement EntityWithPluginCollectionInterface
Comment #74
tim.plunkettComment #75
Alumei CreditAttribution: Alumei commented@73: That's on the todo list ;-)
@73.1: I thought about that as well, whether to put the endpoint into the REST module or node. ++ for node from me
Comment #76
Alumei CreditAttribution: Alumei commentedAdded methods to manage the configuration array of the config entity & removed the getter & setter.
Comment #77
Alumei CreditAttribution: Alumei commentedThe config entity now implements
EntityWithPluginCollectionInterface
which should calculate the additional dependencies for the resource plugin.I also wanted to calculate additional dependencies based on the supported formats and authentication provider but those are not identified easily. Apparently both formats and authentication provider are registered via tagged services but there seems to be no way of identifying which module provides that service.
The module could probably be identified by the namespace used for the service class but is there an easier way that i may have overlooked?
Comment #80
BerdirNot reviewed yet, just cross-referencing with #2472321: Move rest.module routes to /api, which will conflict a lot I guess.
Comment #81
Alumei CreditAttribution: Alumei commentedAdded code to ensure that the request method is upper case and throw an exception if a not matching method is passed.
I could not find an error in the API but maybe there is an error in the usage of the API in tests?
Comment #82
Alumei CreditAttribution: Alumei commentedRealized there is a tag for that ;-)
Comment #84
Alumei CreditAttribution: Alumei commentedWell this should fix that ...
Apparently did not see that in
protected function enableService($resource_type, $method = 'GET', $format = NULL, $auth = NULL) {
the$auth
parameter is expected to be an array -_-Added an
array
type hint with this patch.Comment #86
Alumei CreditAttribution: Alumei commentedWell this showed that i missed something during refactoring ...
Should be green now.
Comment #87
dawehnerJust some quick drive by review.
Why do you have to care about this here, given that the entity itself seems to have stored that information?
Nitpick: Missing @file Contains bit.
Do we want to use the "injected" value?
Comment #89
Alumei CreditAttribution: Alumei commented#87.1: That is in there for the first time the entity is created. The plugin id is generated at that time and stored after that. On each subsequent load, the plugin id will be loaded from storage and won't be generated again.
I will fix #87.2 & #87.3 in a subsequent patch hopefully along with the test failures.
Comment #90
Alumei CreditAttribution: Alumei commentedThat single missing
!
-_-Comment #91
Alumei CreditAttribution: Alumei commentedFor the test bot.
Comment #94
Alumei CreditAttribution: Alumei commentedGrasping for straws now ...
Trying to backtrack to find out what is causing those changes.
Comment #95
alexpottTo evaluate whether we should make this change during the beta, we need to update the issue summary according to https://www.drupal.org/core/beta-changes to explain what improvements it makes and what the disruption of the change would be. Can someone add Drupal 8 beta phase evaluation template to the issue summary.
Comment #97
Alumei CreditAttribution: Alumei commentedI tried my best to fill out the template appropriately.
Comment #98
Alumei CreditAttribution: Alumei commentedHow could I ever have expected that the last patch would be green -_-
Maybe this one.
Comment #100
Alumei CreditAttribution: Alumei commentedUpdated IS example with the new methods.
Comment #101
Alumei CreditAttribution: Alumei commentedDefaultSingleLazyPluginCollection
as we are dealing with only 1 plugin.EntityResource
to implementDependentPluginInterface
& identify the entity type provider as module dependency.This should include into the dependencies: the resource plugin provider & in case of an
EntityResource
derived plugin, the entity type providerComment #102
Alumei CreditAttribution: Alumei commentedRenamed <
hasSupportedAuthenticationProviders($method)
tosupportsAuthenticationProviders($method)
.Also in lack of any other proposal, implemented my idea from #77:
This works as follows:
RestServiceProvider
along the idea of #77rest.dependencies.auth
&rest.dependencies.format
calculateDependencies()
, those parameters are accessed via theContainerAwareTrait
onDependencyRemoval(array $dependencies)
Comment #103
Alumei CreditAttribution: Alumei commentedI would probably want to cache the affected authentication provider & formats from
onDependencyRemoval(array $dependencies)
in a static property on the class to improve performance if multiple endpoints are affected.But before that:
Comment #106
Alumei CreditAttribution: Alumei commentedTackled "Try to move some methods from the Rescource Plugin onto the Configuration entity".
The patch contains:
getBaseRoute($canonical_path, $method)
public so it can be accessed insideRestEndpoint
.ResourceBase
to the config entity type.I only moved the route generation part, because it explicitly depends on configuration.
Once this is green we only have to
Comment #107
Alumei CreditAttribution: Alumei commentedThat should be it for now ;-)
Comment #108
Alumei CreditAttribution: Alumei commentedAttempted reroll.
Tried to incorporate changes changes from other since the last patch:
Let's see what breaks ;-)
Comment #110
Alumei CreditAttribution: Alumei commentedThis should fix the failure by enabling the missing `basic_auth` module. The rest endpoint that this patch ships with the rest module as optional dependency depends on:
Comment #112
Alumei CreditAttribution: Alumei commentedWrong patch .....
Comment #115
ArlaReroll.
Also, I guess this is unfortunately not welcome in 8.0.x anymore? :)
Comment #117
catchYes this could only happen in a minor release.
Also we're going to have to look at a backwards compatibility layer for this somehow, not sure what that looks like though.
Comment #118
catchOne possible option
- when saving a config entity, convert the old config key to config entities and strip them out of the config object itself.
- when loading a config entity, convert the config entities back to the old config format on the config object
This would cover modules loading and saving the old config object, including default configuration.
When we load, we'd have to add some kind of identifier to indicate that the items are 'fake' to avoid doing the work on save.
Could put this into its own event listener so it's out of the way of everything else, and then potentially could be disabled too. And that event listener is then a place we could trigger E_USER_DEPRECATED in a later release if modules haven't been ported.
If that's actually enough to provide bc, it could be quite a small thing to add.
Comment #119
Crell CreditAttribution: Crell as a volunteer commentedPedantic point: There is no such thing as a "rest endpoint". This should be called "rest resource". Endpoints only exist in RPC.
Ibid.
Ibid. (Will not repeat further.)
It's a plugin. Just inject properly with the create() static method. No ContainerAware.
Is there a reason PUT isn't whitelisted? We're not using it for Entities but in concept there's no reason for us to not support it.
While there's a lot of new code here, from an API perspective we're just changing the configuration storage format, no? The API for defining a new REST resource is the same, unless you need dependencies and then it's just an addition. So why do we need a BC layer? I'd think all we need is an upgrade hook to convert the old config file to the new config entities and call it a day.
Comment #120
catch@Crell per my previous comment, modules can provide default configuration.
Comment #121
andypost@catch modules can only change the config via
hook_install()
now, because otherwise you will get config import error about the configrest.settings
exists (installed with rest module)That's the second point to get that fixed - provide a way to import rest settings for each resource without affecting a whole config object. The same was done for
content_translation.settings
andlanguage.settings
for scalability & performance reasons already.So maybe better to re-use third party settings like #2363155: content_translation.settings config is not scalable
EDIT: language settings was changed to config entity #2355909: language.settings config is not scalable
Comment #122
Arla#119: "I'd think all we need is an upgrade hook to convert the old config file to the new config entities and call it a day."
Did this, and it fixes some fails. Some other fails are caused by what I think is a bug in system_update_8004(), so I'm suggesting a fix there as well. Also suggesting some helpful fail() messages to UpdatePathTestBase.
#121: "modules can only change the config via hook_install() now"
Not sure what you mean by this, @andypost? The update hook seems to work fine. And if we were to use third_party_settings, what entity type would we hang them on to?
Ignored all of the code/naming review points in #119 for now, I want to make the test greener first (and get someone's confirmation on the changes in this patch).
Comment #123
catchIt means that currently, modules can implement hook_install() to modify the rest configuration object - this is what we need a bc layer for per #118. Similarly with install profile configuration overrides.
The rest update should be numbered 8100 since this will go into 8.1.x
Comment #124
MattA CreditAttribution: MattA commentedJust browsing through the patch file...
Missing documentation.
Punctuation and formatting.
More punctuation and formatting all throughout this method...
Doesn't this break existing plugins that override the method and keep the old visibility?
...or is it ok to be changing ResourceBase and ResourceInterface?
Periods and stuff.
AS => as
Comment #125
AlxVallejo CreditAttribution: AlxVallejo as a volunteer and commentedComment #126
AlxVallejo CreditAttribution: AlxVallejo as a volunteer and commentedComment #127
g.oechsler CreditAttribution: g.oechsler at Wunder commentedReroll.
Comment #128
g.oechsler CreditAttribution: g.oechsler at Wunder commentedComment #129
g.oechsler CreditAttribution: g.oechsler at Wunder commentedNow that it applies again let's put some love in it.
It addresses the formatting issues, adds missing doc blocks (#124) and renames the update hook to rest_update_8100 (#123).
Comment #130
dawehnerAt least inject the parameters directly instead.
IMHO this should stay on the plugin somehow. This kind of method is something people really might want to override on the plugin level. The config entity is just about storage for me, so it should not contain that kind of logic.
nitpick: use remove the space after "["
A, let's use $this->entityType and $entity_type_manager instead.
Comment #131
MattA CreditAttribution: MattA commentedLet's especially not forget to consider 124.4 and 124.5 either.
Comment #132
dawehnerI'll work a bit on this
Comment #133
ArlaFixed nitpicks. Big issues remain though:
#119.4: EntityInterface::create() ≠ ContainerFactoryPluginInterface::create()... right?
Setting to Needs review to trigger bots although it needs work as per above.
Comment #134
dawehnerSome changed on top of #133
Yeah :( I'm thinking that it would actually make sense to add this big amount of logic into its own service
Comment #135
Wim LeersI was sent the following feedback by Edward Faulkner of Ember.js:
I too have been frustrated/surprised by this.
Technically this is off-topic for this issue. But, this issue is completely changing (well, removing)
rest.settings.yml
. So, if we ever have a chance of changing this, it's in this issue.Thoughts? An explanation justifying the current design would be welcome too, of course.
Comment #136
dawehnerWell, we end to support everything what we supported before, otherwise we have an API break, so I don't see how we can change this here.
This though sounds like a discussion for D9. As far as I understand the rest module it tries to be quite flexible in its configuration, so it can fit into more usecases than a normal simple REST integration.
Comment #137
Wim LeersChanging title to clarify what this issue actually does.
Comment #138
Wim LeersWouldn't
rest_resource
config entities make more sense thanrest_endpoint
config entities?That'd also be consistent with the plugin interface name (https://api.drupal.org/api/drupal/core%21modules%21rest%21src%21Plugin%2...) and the annotation (https://api.drupal.org/api/drupal/core%21modules%21rest%21src%21Annotati...).
Comment #139
dawehnerRe #135
@Wim Leers
While I understand your points here, we need to take into account two things
a) We want to make progress on this issue itself. It solves a ton of problems rest has at the moment
b) People might have setup crazy things, so let's not try to break things.
IMHO We should split up rest though in two parts:
1. The generic code, usable by probably all REST implementations
2. The concrete rest implementation using the plugin system to register recourses. The second part could then be over time replaced by another module doing something more sane
Comment #140
Wim LeersYep, I understand that, and I agree. I split off #135 into #2664780: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources.
My comments #137 and #138 are on-topic/do not make out-of-scope requests, and are just trying to move this issue forward.
Comment #141
neclimdulYeah, this would be pretty nice. Having everything in rest.settings can be a pain in testing as well because you pull along all the other endpoint requirements when testing an individual endpoint. This would allow more targeted, less error prone units of testing for site developers.
Comment #142
Crell CreditAttribution: Crell as a volunteer commentedSwitching REST configuration to config entities makes a ton of sense for a myriad of reasons, so +1 on that. However, "endpoint" is the completely wrong terminology here. :-) There is no such thing as a "REST endpoint". REST has resources.
I'm a little unclear from the patch what the scope of the new config entity is. Is it one entity per content entity being exposed (ie, one for node, one for user, one for term, etc.) or one per piece of the content entity being exposed (GET node, POST node, DELETE node, GET user, POST user, DELETE user, etc.)? That will help determine the proper name. (REST Resource is already taken by the main plugin of REST module.)
Comment #143
dawehnerThe patch uses one per entity type / rest plugin.
Comment #144
BerdirSo the config entity is the configuration for a rest resource plugin.
Agreed that Resource is a better name for it than Endpoint. Leaves the naming overlap.
A pattern that I quite like for that is a Config suffix. Like FieldConfig for example. Classname would be RestResourceConfig, entity type could be rest_resource or rest_resource_config, and the config prefix either way just rest_resource I think.
Comment #145
Wim LeersPer #138, #142 and #144.
I don't see why the naming overlap needs to be a problem per se, because one is an annotation, this is a config entity. Confusion seems unlikely. Consistency with
FieldConfig
is a good argument though.Comment #146
Crell CreditAttribution: Crell as a volunteer commented#144 sounds good to me.
Comment #147
ArlaRename.
Comment #149
ArlaRemoved the test added in #2397271: REST configuration fails if it contains a plugin reference that does not exist. The other fail I cannot find the cause of.
Comment #150
Wim Leers+1 to #149. Now the patch removes everything that #2397271: REST configuration fails if it contains a plugin reference that does not exist added.
If you run
Drupal\Tests\rest\Kernel\RequestHandlerTest
locally, does it pass?Comment #152
ArlaNo, locally I get the same message "test runner returned a non-zero error code (2) " but cannot find out how to get more information. Nothing in error_log, tried commenting out the two methods one at a time but both give the error.
Comment #153
xjmComment #155
Wim LeersPatch still applies. I can reproduce the failures locally. Do we still want this in 8.1.x, or do we really move this to 8.2.x? (#154 moved it automatically.)
Moving back to 8.1.x-dev for discussing that.
Comment #156
Wim LeersA BC layer that doesn't exist yet is obviously a showstopper.
Comment #158
dawehnerOpened up a follow up, see #2721595: Simplify REST configuration
Comment #159
dawehnerJust a reroll
Comment #161
dawehnerReroll + bugfix
Comment #163
dawehnerNo comment ....
Comment #165
dawehnerSo much random failure ...
Comment #166
Wim LeersOverall, I really really like this patch! I reviewed architecture, not details.
Per our recent discussion at DrupalCon, which involved many REST stakeholders, I'm wondering if we can't simplify this further:
What do you think?
This is where what I proposed above becomes more complex.
But… I'd be willing to wager that 99% of sites using REST would actually be able to convert just fine. We could show a warning for the remaining 1% that more things are allowed than before (more formats, more authentication mechanisms).
Because in upgrading, we'd just take the superset of formats and authentication mechanisms and allow them on all methods.
IMO that'd be a totally sane upgrade process, with very very minimal disruption.
Especially if we document it well.
Can we do better than this, i.e. can we not inject them? If not, let's document why.
Hurray!
I wonder if this allows for an inconsistent state/race condition?
I've never seen a
calculateDependencies()
implementation be tied to data in the container.Happy to be wrong though! Just want to be careful wrt dependency metadata, to prevent a state where the user is stuck.
Nit: This is British English, not American English :) And it's inconsistent with Symfony's
Serializer::normalize()
Why these API changes?
AFAICT it's because of the changes in
RestResources
: it bears the full responsibility for creating routes, rather than the individual resource plugins. So these changes allow@RestResource
plugins to actually be declarative: the only non-declarative things they have are the implementations for each of the HTTP methods they support.(Those are non-declarative, but also
getBaseRoute()
implementation they inherit. But that's a good thing: it allows specific REST resources to have more advanced route options, and opt out from the default permissions we also require, or provide a BC layer for existing sites for them, when we land #2664780: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources.)Is this interpretation correct?
Nit: these all belong on a separate line. Occurs in many places.
s/where/whether/
Comment #167
dawehnerThanks for this great review! It triggered a couple of changes. I hope these are okay, they have explanations below.
Well sure, the current format is too verbose, but I also disagree with changing this in this issue. We have a dedicated issue for that already: #2664780: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources
As we now have an interface changing the internal configuration structure is much easier.
Oh you mean proper english ;)
Great question. Sadly I cannot find the issue where we tried this last time. It failed horrible. While I tried to inject, what was needed, I realized that actually one should not put too much logic into an entity and extracted the dependency logic into its own service. This also helps to not initialize those services outside of the scope of config dependencies, make the configuration not container aware etc.
I've seen one: #1996130: REST views: not adding dependencies on Serializer providers. I believe that there is no race condition possible: On a full config import, every module installation / uninstallation always fires before other config changes, which then trigger any recalculation of dependencies.
See
\Drupal\Core\Config\ConfigImporter::initialize
The first time I had a look at this patch even more things changed. For example the routes have been entirely defined by the config entities. I think your feeling here is right, we are changing something here we should not change. For me the logic should mostly live in the plugin, as this is what you can override. The config entity itself is just an alternative way to store data, every other change doesn't belong here. This triggered quite some changes all over the place, but I'm quite sure this reduces the patch size quite a bit (spoiler: its just 3 KB less, but it should be easier to review now).
I hope these changes don't cause drama.
Fixed that together with some more minor changes
Comment #169
dawehnerI hope that's it.
Comment #170
Wim LeersI knew you were going to say this :) And I actually agree with you!
The main (well, sole) reason that I propose to do it here is because I think doing this sort of change in two steps will be considered too invasive. And because it will mean breaking newly introduced APIs. All of these interface methods are AFAICT tightly coupled to the current configuration structure, because all of them are tied to a particular method:
… it is precisely this interface we would have to change again AFAICT. See the examples of tight coupling I just gave. If you can demonstrate we would not need to change that newly added interface in #2664780: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources, then that'd be great, and in that case, ignore what I said in my first point!
This sounds sensible. I see you already did that, yay!
I'm not sure it's actually better by going back to the way it is in HEAD. But it means fewer changes are introduced. And that I think is a good thing, because it is simply not necessary for this patch to change that, it is not in any way related to how REST resources are configured.
So +1 for reverting to the old logic/behavior/structure/responsibilities.
Interdiff review:
I wonder if
ConfigDependencies(Handler|Calculator)
or justDependencies(Handler|Calculator)
would be a better name?Right now when you read the code, especially the code in
RestResourceConfig
, it looks like you're interacting with dependencies, but you're not, you're only interacting with the logic that calculates/handles dependencies.These are the only changes in
ResourceBase
in this patch (yay, less BC break), and I think this change can be reverted?Is the fact that this plugin now implements this interface actually enough for this plugin's
calculateDependencies()
to be called and to be taken into account?AFAICT this is pointless, because you can already do
getResourcePlugin()->getPluginId()
.I guess that's not entirely true, because we also have
\Drupal\block\Entity\Block::getPluginId()
. But none of the other\Drupal\Core\Entity\EntityWithPluginCollectionInterface
classes actually have such a method. So I don't this should either.If we want our implementation (
RestResourceConfig
) to have this, then let's let it implement\Drupal\Component\Plugin\PluginInspectionInterface
.Why not just
getSupportedRequestMethods()
?Why these 3? Why not just the first?
These two cause tight coupling to the current configuration system. Also, they're only used in tests. I'd prefer to not have these nice helpers to keep the freedom to change the underlying configuration structure. Tests can just specify the expected array structure instead IMO.
Same story here.
That: A) removes the (AFAICT) useless "has" and "supports" methods, B) is overall far more compact, C) avoids tight coupling to the current configuration structure, and is therefore forward compatible with #2664780: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources.
Comment #172
dawehnerThe more I think about it, the more I think we should really just go with it. Let's do that here then. I totally agree that this interface is again simply a c&p of every possible method rather than a designed interface. Thank you wim for insisting on it!
@Wim Leers Do you want to give it a try?
Well yeah, the question is whether we want to keep it a property which is not used anymore, but sure we can keep it.
Agreed!
What else could the entity plugin depend on?
Comment #173
Wim Leers:)
If I do so, I can't RTBC this patch anymore. So I'll let you do so, if you don't mind.
Oh, right, never mind that!
Sorry, I explained myself poorly! I didn't mean that it would depend on something else. I meant that I didn't understand how this
calculateDependencies()
method would ever be called, how its results would make its way back into theResourceConfigEntity
.Comment #174
dawehnerSo yeah, if we really want to change the support configuration we should first discuss that with other people. For example I'm not sure whether requiring the less verbose configuration is possible in D8 itself.
You know, there are other problems too have, so yeah I personally wait until we actually know what we want to do.
We can simplify your configuration even more by skipping the top level 'configuration key':
Comment #176
Wim LeersAha, so this part was missing!
Now I understand how this works :) Thanks!
+1!
Agreed. Assigning to @klausi for feedback. And pinged @catch and @alexpott for feedback also.
Comment #177
alexpottWe can't skip the top level configuration key because the top level has to be a mapping and not a sequence :( There are issues out there discussing this... eg. #2248709: The root type of a configuration object can not be a sequence
Comment #178
dawehnerWell this is status quo, but with the simplified configuration syntax you have just 'formats', 'auth' and 'methods' there, which are all sequences.
Comment #179
dawehnerThis just fixes some test failures.
From the discussion with alexpott yesterday it seemed to be that we cannot just drop the verbosity of the old configuration.
Comment #180
Wim LeersWell…
I started doing the archeology, but in doing so I ended up finding the full answer to #2664780: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources's problems, so I wrote that up in #2664780-11: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources and managed to finish that patch mostly. Now finishing up my archeological digging…
We already talked about exactly that, see the earlier chat transcript. I agree we don't have consensus yet, but moving to config entities first doesn't help, because then we end up with three formats we have to support:
rest.settings
as it exists todayrest.settings
intorest_resource
config entitiesrest_resource
config entitiesThat's the part that is untenable as far as I can tell.
That is why I wrote what I wrote in #166.1 and #166.2.
Comment #181
Wim LeersI did some archeology, to find out why exactly we ended up with the current
rest.settings
design, which configured supported formats and supported authenticated mechanisms per method per resource, instead of only per resource, or even configuring those for all resources.rest
as a configuration object, and it only had'resources'
as the key. It did not have the ability to configure formats or formats, you couldn't even enable/disable methoids.rest
torest.settings
and introducedrest.settings.yml
: it ensured we have a default config YAML file.So, much like the way the permission handling in REST was done with barely any critical review, as I described at #2664780-11: Remove REST's resource- and verb-specific permissions for EntityResource, but provide BC and document why it's necessary for other resources, the same is true here. Times have changed; this would never have been able to land in the past few years.
Comment #182
dawehnerThank you for your dirty diving. Ancient information are there.
In general no question, in general people tend to nick without thinking, when there are too many changes at the same time, which is actually a contra point to any major short time change. Just small evolutionary steps can really provide a good end result.
Are we sure we cannot remove support for the old format, as we provide a clear 1to1 update path?
In general I doubt there is too much overhead connected with providing a BC layer, but well, let's first simplify the interface, so at least supporting that might be actually easier.
If @alexpott kinda thinks about a BC layer, and well, let's be honest, he is one of the more liberal core committers, I cannot imagine how other would react to it.
Comment #184
Wim LeersOh!!! You're saying it's 100% guaranteed we can provide a complete upgrade path from
rest.settings
'sresources
key torest_resource
config entities? That's totally true, that's what this patch basically does.So then we end up with two types of config entities, or two versions/levels. I almost wonder if it makes sense to call the config entity we're introducing here the
rest_resource_verbose
config entities? And then the simplified ones could be calledrest_resource
?+100, I was hoping you'd do that :)
This review basically reviews the #182 interdiff.
In #172, you agreed to also remove this one.
I'm still concerned that these are here, I think these may still tie the interface too closely to the current configuration structure (everything per-method).
Comment #185
dawehnerNo idea how this sneaked in again.
That could be a great solution to the problem. The interface would then just have methods for the non verbose case maybe?
Just rerolled the patch due to recent great improvements!
Comment #187
Wim LeersGlad you like the idea.
What do klausi & Alex Pott think?
Exactly!
Comment #188
klausiCan we support specifying the format on the resource level and on the method level at the same time in one config entity? We could throw an exception if someone mixes those 2 variants and specifies the format on both levels. Or not, then the method level format would override the resource level format. Same for authentication.
Comment #189
Wim Leers#138: I don't see how we can do that with config schema.
Comment #190
Wim LeersFYI: I'm trying to prove myself wrong: I'm trying to make this happen with config schema. I think it may actually be possible.
Comment #191
Wim LeersHURRAY! I was able to prove myself wrong :) :)
I found a way to make it possible to:
type: granular
.type: simple
.Attached is a patch that updates REST's config schema to support this. And another patch that provides an example
rest.settings.yml
to use it. Apply both, and verify using https://www.drupal.org/project/config_inspector that it is indeed working.I am not saying we must add support for this simple variant here, although I personally think that may actually be better. But, if we agree that this is what we want
rest_resource
config entities do use by default (thetype: simple
) variant, then this can inform what theRestResourceConfigInterface
must look like for both types to be supported.Finally, for completeness, the relevant IRC transcript from last Friday, where this was discussed among @klausi, @dawehner and I, where we were in full agreement to proceed with this approach:
Comment #192
MattA CreditAttribution: MattA commentedI like where this is headed, but I have a quick suggestion. Can we make the type names a bit more descriptive and/or related to the config property's purpose?
Ex:
type: granular --> type: per_method
type: simple --> type: per_resource
Comment #193
Wim Leers#192: ooh, perhaps
granularity: resource
andgranularity: method
? There's no need to call the keytype
, it can be anything.Comment #194
Wim LeersTalked to @dawehner in IRC.
We're now swapping roles. He's going to review, I'm going to reroll, since he's not going to have the bandwidth to reroll this patch.
Comment #195
Wim Leers#2631774: Impossible to update Comment entity with REST (HTTP PATCH): bundle field not allowed to be updated, but EntityNormalizer::denormalize() requires it landed and caused a conflict, and also required a change in
UpdateTest
, because as of #2631774,node
isn't being installed by default anymore inRESTTestBase
.So, this is still a straight reroll. This doesn't fix any of the test failures. Doing that next.
Comment #196
Wim LeersOne tiny thing was overlooked in #182, that's what the first hunk of this interdiff fixes. That's what causes all of the failures here, except for those in
PageCacheTest
. Those I still need to fix.The rest in this patch is to address a small bug that has existed for longer in this patch, but is only exposed/causing failing tests since #2626298: REST module must cache only responses to GET requests, which was committed after #182/#185. Otherwise, there would be many more failures.
So, this should bring it down to far fewer failures.
Comment #197
Wim LeersThis unnecessary change is what causing the fails in
PageCacheTest
: the$entity
object here does not have an ID, hence no URL can be generated.Comment #200
Wim LeersGiven the broad agreement for #188–#193, to have two granularities with which you can configure REST resources, which allows us to keep BC easily, I'm addressing that first. That's the biggest remaining obstacle.
This patch then introduces
granularity: method
, but does NOT introducegranularity: resource
. That's for #2721595: Simplify REST configuration to do, but #191's attachments contain everything that is necessary to be able to do that, config-schema-wise.Comment #201
Wim LeersAlright, we now have a green patch again, that has a solution for how to deal with first doing this, and then simplifying the configuration (in #2721595: Simplify REST configuration). It'd be great to hear from @dawehner, @klausi and others whether they're still +1.
Note that a consequence of this is that in several places, we'll need forked logic: "if granularity is method, do X, if granularity is resource, do Y". However, that is of course the cost of BC, and that's something we cannot avoid.
Next step: look into simplifying the interface further, like I said in #184.2.
Also, #200 made me notice we don't yet have upgrade path tests.
Comment #202
dawehner+1
Comment #203
Wim Leers#202: yay!
Small step forward in simplifying
RestResourceConfig(Interface)
: per #87.3 and #170.3, we can get rid ofgetResourcePluginID()
.Comment #204
MattA CreditAttribution: MattA commented80-char limit
Optional: This could probably be shortened into calculateDependenciesByMethod()?
Could probably use a comma after "deleted."
Might have been looking for the possessive form of dependency instead of the plural form. Rephrase?
Is "supported" really necessary in these method names? I might have glossed over some stuff, but I'm not seeing a use-case for getting all the installed providers/formats at the config entity level.
Comment #205
dawehnerGood point!
Comment #206
Wim LeersPer myself in #170.8:
and @dawhener's confirmation of that in #171:
I started doing this. Each of these points has a corresponding interdiff. Consider each a commit. This makes reviewing easier, but avoids me posting a gazillion separate patches.
getMethods()
(I know I saidgetSupportedRequestMethods()
, but that seems overly verbose and obvious). I removedisRequestMethodEnabled()
. I already made it easy for #2721595 to add its code for resource-level granularity — also because that makes it more clear what the end result will look like. Which is important for determining how maintainable the end result will be.16 LoC less, and simpler interface.
$this->get('configuration')['granularity']
quickly got annoying. So I moved it outside ofconfiguration
, into the top level.getSupportedAuthenticationProviders()
togetAuthenticationProviders()
, removedaddSupportedAuthenticationProvider()
andremoveSupportedAuthenticationProvider()
.40 LoC less, and simpler interface.
getSupportedFormats()
togetFormats()
, removedaddSupportedFormat()
andremoveSupportedFormat()
.54 LoC less, and simpler interface.
Related to interdiff 2: @dawehner already alluded to this in #178. But there, he wanted to go further: the resource-level granularity doesn't need the top-level
'configuration'
key, he says. This is true. But if we remove that key, then we can no longer choose either method- or resource-level granularity within the same config entity.However… we totally can if we make
GET
,POST
etc into a mapping rather than a sequence. Every key in a mapping is optional anyway. (Everything is optional in config.)#204.1–4: Thanks for the nits! Will address later.
#204.5 + #205: hah, that's exactly what I already did :)
Next step: roll a sister patch for #2721595: Simplify REST configuration, to prove that this can indeed work.
Comment #207
Wim LeersBefore rolling that sister patch I mentioned at the end of #206, it's more practical to first have upgrade test coverage, because that other issue will need its own upgrade path test, relative to this one.
So, here's upgrade path test coverage.
Comment #208
Wim LeersWhile I started working on the sister patch, I noticed many more places weren't yet making the granularity-based distinction that they will need to. This introduces that distinction in all necessary places.
This also clearly visualized the cost of this approach: every
RestResourceConfigInterface
method implementation forks into two distinct implementations: one for either granularity. The same goes for thecalculateDependencies()
andonDependencyRemoval()
methods: we need two distinct implementations, one for each granularity.I think this is the true cost of BC. This is why I originally argued for removing this capability of configuring up to a per-method granularity: is it really a BC break to suddenly have the union/superset of all formats and authentication mechanisms be available for all methods on a resource? I'm not convinced it is.
I'll now stop working on this patch. Only remaining todos: address nitpicks, including those in #204.1–4.
I'm now working on a sister patch for #2721595: Simplify REST configuration that builds on top of this one, and hence provides a picture of what the overall end result would look like, if we continue to support both configuration granularities.
Comment #209
Wim LeersAnd voila,
granularity: resource
is now implemented at #2721595-7: Simplify REST configuration, with a patch that includes upgrade path test coverage, and with an actual testable patch that stacks on top of patch #208 here. It should come back green.That leaves this patch at a point where it's more feasible than before to properly evaluate the consequences.
IMO this is now blocked on review from at least:
Comment #210
dawehnerWell, it all comes down to our definition of BC. When we define just our formats as the officially supported ones I would agree with your point. On the other hand there might be crazy custom formats which exposes some data you should normally not see on a GET request. I would rather be defensive than exposing anything to the world. There is a reason we support BC, and well of course we need a price to pay for it. There is also a reason why D9 will be released at some point.
Yeah entity interfaces are a lie anyway. There will always be just one implementation of it. You know as long the complexity is just within the entity, this seems totally reasonable for me. We added an abstraction which makes it possible to implement some custom behaviour underneath it, which is some form of success, at least for me. When we are afraid of the if statements you could implement a plugin type for the granularity but I'm really not sure its worth the effort.
Nice interface!
Its conceptually better to put that information into a compiler pass, as we derive information from existing registered classes. Note:
\Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass
and\Drupal\serialization\RegisterSerializationClassesCompilerPass
are both implemented as path.For me authentication is something provided by core itself, so this data should be added by core. Authentication is orthogonal to rest. #2228141: Add authentication support to REST views would like to use it as well.
Formats are conceptually not an idea of the rest module but rather an idea of the serialization module. Also, isn't rest.dependencies.format exactly the same as serializer.format_providers at the moment?
Comment #211
Wim LeersAgreed.
Fair! And we should definitely not forget that. I forgot that for a moment there. But you're totally right, and that's the reason we're willing to do this.
Agreed!
Agreed :)
Comment #212
Wim LeersAddressed #210.2–4.
Comment #213
Wim LeersOops :)
Comment #216
Wim LeersHah, this uncovered another nice bug:
\Drupal\Tests\rest\Kernel\RestLinkManagerTest
doesn't installserialization
module, but it should.This will be green again.
Comment #217
dawehnerI think this looks really great. Just fixing two small nitpicks. Also wrote some change record in the meantime.
Comment #218
Wim LeersGreat, thanks!
Comment #219
alexpottThis seems weird to have on the same level as methods then. Why do we have that? I guess config schema parsing - it's not necessary we can use something like %parent.granularity... hmmm that's what you've done... is this necessary?
I think this should be a
.
to be more like how fields handles this.Why can't we inject the authentication_collector here and not create the authentication_provider container param?
This looks necessary for both levels - looks like it could move to
ConfigDependencies::calculateDependencies()
. Actually thinking about this maybe we want to implementEntityWithPluginCollectionInterface
on the config entity. Since this gives as a lot for free. @timplunkett is the expert on these. But doing this should make this code redundant AND keep plugin and config in sync. See ConfigEntityBase::set().I think this can be reduced to two lines using array_intersect - it preserves keys... so:
This code looks odd because it's setting $rest_config which is the config entity - and using array access... not sure whats going on here.
As above
I don't think we should be using the word config. Maybe just
Rest resource
or change config to configuration.Need documenting.
I think we should throw an exception on the unsupported code path for now.
return $this;
- this changed in Drupal 8 beta. Yes it is tricky because plugin's version does something different - sorry.Should have a separate issue - looks extremely sensible.
Comment #220
Wim LeersComment #221
alexpottRe point 4 well using
EntityWithPluginCollectionInterface
is nothing to do with granularity.Comment #222
alexpottI also think that this issue highlights the need for #2628144: Ensure that ConfigImport is taking place against the same code base to prevent people re-importing configuration in the old rest.settings config.
[Edit: fixed the issue link]
Comment #223
dawehnerGood point, yeah this is indeed no longer necessary.
Well, having the actual instances of the providers is nice, but they don't really want us to tell anything about their modules providing them, even if you ask really friendly.
OH yeah, that might indeed help quite a bit, I'll explore that.
Its certainly in the interest of array to have some kind of union.
I think it helps to distinct the rest resource plugins from the actual configurations.
Well, actually they need removal. All three aren't used.
Good idea!
Oh yeah totally, let's see
Comment #224
dawehnerOpened the followup in #2747789: Improve UpdatePathTestBase debuggablity
Comment #225
alexpottOops... array_interest() = array_intersect()
Comment #226
dawehnerWhich issue do you actually talk about here?
Comment #228
dawehnerWe already implement that interface ...
Comment #230
alexpottIf you already implement the interface - I think this code is unnecessary.
Comment #231
dawehnerLet's see, this could fix a couple of the issues.
Comment #233
dawehnerComment #234
dawehner.
Comment #235
Wim LeersLooks great! This addressed all of @alexpott's remarks AFAICT.
This makes so much sense! I'm happy @alexpott asked for that.
Why this rename?
No longer public: totally makes sense.
I think just renaming this would've been good enough — I think that's all that @alexpott was asking.
Comment #236
alexpott#230 is still to be addressed...
Not needed (i think)
Comment #237
Wim LeersFor #235 + #236.
Comment #238
dawehnerYeah let's revert those changes.
Comment #239
Wim Leers#238 addressed #235 + #236. No more remarks.
Hurray!
Comment #240
dawehnerThank you!
Comment #241
alexpottPatched attached replaces the hard coding everywhere of
'method'
with a constant because it's better. And fixes a few coding standards issues. Leaving at RTBC because I don't think these changes warrant going back to needs review - but I wanted a test run before committing and a +1 from @Wim Leers or @dawehner.Comment #242
alexpottDiscussed with @dawehner in IRC and we discussed whether the constant should be on
RestResourceConfig
orRestResourceConfigInterface
. At first it seemed that moving to the concrete class was correct because it felt an implementation detail of RestResourceConfig but it is also used extensively by the service this patch adds so I think the interface is better.Comment #243
alexpottDiscussed this with @dawehner - it's not really a service - he considered it a private service but as we're using \Drupal::service() it can't be private. We decided to remove it from the container and use the class resolver to inject its dependencies. The results in a separation of concerns whilst not making it a swappable service.
Comment #244
dawehnerWorks for me. Thank you!
Comment #245
alexpottAre we sure that using the config entity API is alright in a hook_update_N? I'm not sure. I think we probably should do a little dance. Ie. I think we need to fix rest.settings here but then create the config entities in a post update. So we set it in state or something and go from there?
Comment #246
dawehnerWell, in this case its just create ... in general though I don't see a reason this could not be post update. There is nothing to repair.
Comment #247
Wim Leers+1 for everything said here.
Comment #248
alexpottSo discussed a bit more with @dawehner - we agreed that we shouldn't be using the full config entity API in hook_update_N(). So in the hook_update_N() I save the current resources to state...
\Drupal::state()->set('rest_update_8201_resources', \Drupal::config('rest.settings')->get('resources'));
. At the moment the patch leaves this in state. I think this is good idea - just in case we need to do something with this information cause we missed something with the post update.Comment #249
Wim LeersLooks great.
Comment #251
alexpottCommitted 871da5e and pushed to 8.2.x. Thanks!
Comment #252
Wim LeersWhew! OMG! Yes!
So glad this is in. A few months ago, I thought it'd be impossible :)
This unblocked #2721595: Simplify REST configuration.
The IS also mentioned this:
Did that too (changes: https://www.drupal.org/node/2667736/revisions/view/9764057/9794157), and updated the CR for that too. Also clarified the CR to explain why this was necessary.
Comment #253
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedI tried the update path from 8.1.3 to 8.2.x via drush. I got the
Failed: The "rest_resource_config" entity type does not exist.
on the first try. I think we have to rebuild the entity type registry? The update worked flawless on the seconddrush updb
. I did not calldrush cr
before the firstdrush updb
. Worth a follow-up?Comment #254
dawehnerThank you for your testing @webflo
You are just so right!
This line is the problematic line. Conceptually we should NOT get the definition from the entity type manager, but rather hardcode the definition in the update function which was available at the point in time we wrote the code.
So we better fix the update function I guess. Practically it doesn't matter than much because this is a config entity anyway, which doesn't deal with all that.
Comment #255
Wim Leers#253 reported again, at #2721595-61: Simplify REST configuration.
Comment #257
Wim Leers#253: now being fixed at #2803179-8: [regression] rest_update_8201() can fail and break things.
Comment #258
skyredwangI am trying to test D8.2.2 with Drupal Commerce 2-beta3.
REST UI recognizes commerce_order's endpoint as
/admin/commerce/orders/{commerce_order}
. I couldn't get this endpoint working neither/commerce_order/{commerce_order}
, or/entity/commerce_order/{commerce_order}
On the other hand, I was trying to declare endpoints, using code. But, I am not sure what this paragraph mean exactly?
Does this mean each module has to write a little code to support REST?
By the way, I also tried
/entity/rest_resource_config/{rest_resource_config}
, I see WSOD.Can someone write a short tutorial to get a not-too-easy entity working? (Not node, taxonomy, etc)
Comment #259
R.Muilwijk CreditAttribution: R.Muilwijk at Trinoco commented