These two functions are the equivalent of:
Hey Node API, I've NFI what kind of variable I have here, can you figure it out for me?
Postponed on #617562: Remove underscore-to-dash conversion in path arguments for content types
Comment | File | Size | Author |
---|---|---|---|
#18 | drupal8.node-type-name.18.patch | 22.85 KB | sun |
#15 | drupal8.node-type-name.15.patch | 22.86 KB | sun |
#15 | interdiff.txt | 14.91 KB | sun |
#12 | node-type-name-1564832-12.patch | 22.54 KB | dcam |
#6 | node-type-name-1564832-6.patch | 18.92 KB | dcam |
Comments
Comment #1
matt2000 CreditAttribution: matt2000 commentedBlocker has been committed.
Comment #2
sunKick-starting this.
Comment #4
junedkazi CreditAttribution: junedkazi commented#2: drupal8.node-type-name.2.patch queued for re-testing.
Comment #6
dcam CreditAttribution: dcam commentedReroll of #2.
Comment #7
junedkazi CreditAttribution: junedkazi commentedI don't think this patch will work anymore. Looks like a lot of the code has been reshuffled.
Comment #8
junedkazi CreditAttribution: junedkazi commentedsorry I did not see the re-roll. Marking it as needs review again.
Comment #10
dcam CreditAttribution: dcam commented#6: node-type-name-1564832-6.patch queued for re-testing.
Comment #12
dcam CreditAttribution: dcam commentedI re-worked some parts of the patch.
Comment #13
sunThis patch now is a dependency for #111715: Convert node/content types into configuration
@dcam: Can you clarify what you reworked? At minimum, an interdiff would be helpful. :)
Comment #14
dcam CreditAttribution: dcam commentedMan, I wish I'd written this into the post two weeks ago. It was late. I think I just wanted to go to bed. I'll check the patches over again in the morning and create an interdiff, but here's the gist:
The patch in #2 originally failed because it changed the first argument of node_type_get_base(), requiring it to be a node object. Previously the first argument could be a string with the type name OR a node object. The problem is that node_type_get_base() is called by functions that don't have any node objects. They just want to know what the base is for a given type. See NodeTypeTest.php.
So node_type_get_base() has to be called with a type name string argument. The part I "reworked" between #2 and #12 was to make node_type_get_base() take a string and NOT a node object. Anywhere it's currently called with a node object, I changed that from $node to $node->type.
I also changed node_hook() in the same way for the same reasons.
Comment #15
sunAn interdiff wasn't possible, so I manually compared the latest patch to the original.
One essential change was that you renamed node_get_type_label() into node_type_get_label(). However, these are actually two different use-cases:
- In the first, you have a $node object and you want to get the label of the associated node type.
- In the second, you have a node type and you want to get its label.
The second case will essentially be eliminated/simplified with #111715: Convert node/content types into configuration, because that boils down to $type->label() then, since node types become an (config) entity themselves. :)
Therefore, I adjusted this patch and re-introduced the second function.
That said, I'll also look into making the first case more "fluid"; e.g., by allowing to call
$node->getType()->label()
or similar, but that's most likely for another, separate follow-up.Comment #17
dcam CreditAttribution: dcam commented@sun
Ok, yeah I had eliminated node_get_type_label(), the first use case mentioned in #15. It seemed redundant, given that if you have a node object, $node, then we can just call node_type_get_label() with $node->type. They're practically the same function. Is there a reason that both are necessary? Sorry for asking you to explain. I'm still a newbie.
Comment #18
sunFor now, I'd just like to have a clean separation, which doesn't require other code to pass certain properties to some functions.
Most of this clean-up will likely vanish with #111715: Convert node/content types into configuration either way. However, it's a good clean-up on its own, which I'd like to do upfront. (I already considered to merge this patch, but since it's separated already, I'd rather not.)
Attached patch removes the Node type-hint from node_get_type_label(), so Tracker module tests don't complain.
Comment #19
dcam CreditAttribution: dcam commentedOk, thank you for explaining.
Comment #21
tim.plunkett#18: drupal8.node-type-name.18.patch queued for re-testing.
Comment #22
sun#18: drupal8.node-type-name.18.patch queued for re-testing.
Comment #23
rbayliss CreditAttribution: rbayliss commentedThe only confusing thing I found was that on CRUD actions we use the friendly name for drupal_set_message(), yet log the raw node type to watchdog. But that's pre-existing behavior, and there's probably a reason for it. Patch looks good to me, and this change makes sense.
Comment #24
sunGuess you meant to RTBC? Helping you out there. ;)
Comment #25
catchIt'd be nice to get rid of hook_node_type() and all the fake node hooks altogether, but yeah in the interim this is a good cleanup. Since we're removing a public function this should have a change notice. Committed/pushed to 8.x.
Comment #26
webchickWe are now over thresholds on critical tasks, so this and other issues with outstanding change notices are blocking features in D8. Please fix.
Comment #27
andypostJust a change for function name
only a string now passed
2 new functions
And parameter changes
Comment #28
ParisLiakos CreditAttribution: ParisLiakos commentedtagging
Comment #29
andypostChange notification waiting for review http://drupal.org/node/1802786
Comment #30
webchickLooks great to me. The only thing I noticed is that node_type_get_base() is not a new API function, but rather received an API change, so I slightly adjusted the text http://drupal.org/node/1802786/revisions/view/2381780/2381852
With that this looks fixed to me. Thanks a bunch!
Comment #31.0
(not verified) CreditAttribution: commentedUpdated issue summary.