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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

matt2000’s picture

Status: Postponed » Active

Blocker has been committed.

sun’s picture

Status: Active » Needs review
FileSize
22.14 KB

Kick-starting this.

Status: Needs review » Needs work
Issue tags: -DrupalWTF, -Novice, -API change, -API clean-up

The last submitted patch, drupal8.node-type-name.2.patch, failed testing.

junedkazi’s picture

Status: Needs work » Needs review

#2: drupal8.node-type-name.2.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +DrupalWTF, +Novice, +API change, +API clean-up

The last submitted patch, drupal8.node-type-name.2.patch, failed testing.

dcam’s picture

Status: Needs work » Needs review
FileSize
18.92 KB

Reroll of #2.

junedkazi’s picture

Status: Needs review » Needs work

I don't think this patch will work anymore. Looks like a lot of the code has been reshuffled.

junedkazi’s picture

Status: Needs work » Needs review

sorry I did not see the re-roll. Marking it as needs review again.

Status: Needs review » Needs work
Issue tags: -DrupalWTF, -Novice, -API change, -API clean-up

The last submitted patch, node-type-name-1564832-6.patch, failed testing.

dcam’s picture

Status: Needs work » Needs review

#6: node-type-name-1564832-6.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +DrupalWTF, +Novice, +API change, +API clean-up

The last submitted patch, node-type-name-1564832-6.patch, failed testing.

dcam’s picture

Status: Needs work » Needs review
FileSize
22.54 KB

I re-worked some parts of the patch.

sun’s picture

This 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. :)

dcam’s picture

Man, 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.

sun’s picture

An 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.

Status: Needs review » Needs work

The last submitted patch, drupal8.node-type-name.15.patch, failed testing.

dcam’s picture

@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.

sun’s picture

Status: Needs work » Needs review
FileSize
22.85 KB

For 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.

dcam’s picture

Ok, thank you for explaining.

Status: Needs review » Needs work
Issue tags: -DrupalWTF, -Novice, -API change, -API clean-up, -Configuration system, -Configurables

The last submitted patch, drupal8.node-type-name.18.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review

#18: drupal8.node-type-name.18.patch queued for re-testing.

sun’s picture

rbayliss’s picture

The 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.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Guess you meant to RTBC? Helping you out there. ;)

catch’s picture

Title: Remove _node_extract_type() and node_type_get_name() » Change notification for: Remove _node_extract_type() and node_type_get_name()
Priority: Normal » Critical
Status: Reviewed & tested by the community » Active

It'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.

webchick’s picture

We are now over thresholds on critical tasks, so this and other issues with outstanding change notices are blocking features in D8. Please fix.

andypost’s picture

Status: Active » Needs work
+++ b/core/modules/forum/forum.moduleundefined
@@ -180,7 +180,7 @@ function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
-              'title' => t('Add new @node_type', array('@node_type' => node_type_get_name($type))),
+              'title' => t('Add new @node_type', array('@node_type' => node_type_get_label($type))),

Just a change for function name

+++ b/core/modules/node/node.moduleundefined
@@ -436,16 +423,15 @@ function node_type_get_types() {
-function node_type_get_base($node) {
-  $type = _node_extract_type($node);
+function node_type_get_base($type) {

only a string now passed

+++ b/core/modules/node/node.moduleundefined
@@ -457,25 +443,38 @@ function node_type_get_base($node) {
+function node_type_get_label($name) {
...
-function node_type_get_name($node) {
-  $type = _node_extract_type($node);
+function node_get_type_label($node) {
   $types = _node_types_build()->names;

2 new functions

+++ b/core/modules/node/node.moduleundefined
@@ -972,24 +971,24 @@ function node_rdf_mapping() {
-function node_hook($node, $hook) {
-  $base = node_type_get_base($node);
-  return module_hook($base, $hook);
+function node_hook($type, $hook) {

And parameter changes

ParisLiakos’s picture

Issue tags: +Needs change record

tagging

andypost’s picture

Status: Needs work » Needs review

Change notification waiting for review http://drupal.org/node/1802786

webchick’s picture

Title: Change notification for: Remove _node_extract_type() and node_type_get_name() » Remove _node_extract_type() and node_type_get_name()
Priority: Critical » Normal
Status: Needs review » Fixed
Issue tags: -Needs change record

Looks 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!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.