Rules/Trigger/Action and Views Bulk Operations support for Nodetype version 6.x-1.0
Since the .module code is the same for 6.x-1.x-dev they both can be patched.

CommentFileSizeAuthor
#15 nodetype.patch7.28 KBzeusent
#11 nodetype.patch845 byteszeusent
#3 nodetype-bulk-682272-1.patch7.22 KBAnonymous (not verified)
#1 nodetype.patch7.31 KBzeusent
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zeusent’s picture

FileSize
7.31 KB

Here is the patch for it.

kerberos’s picture

This also adds support for changing the nodetype settings to determine which node types a particular content type can be converted to.

-Daniel

Anonymous’s picture

Little change, was a problem with the patch folder "/Users/mainuser/Downloads/" etc.

No actual code changed. Thanks for the patch.

asb’s picture

The patch applies cleanly.

Thank you!

When embedding the Action into VBO, I'd prefer if the checks if the content type actually can be changed would happen before it is executed.

Other observations: When trying to change the nodetype of 112 nodes, I hade to raise the php_memory_limit from 150M to 1024M. However, the bulk operation finished fined.

Greetings,
-asb

asb’s picture

Category: feature » bug
Priority: Normal » Critical

Hi,

when appying the node type change during a normal edit of one node, I'm getting the following error:

Fatal error: Call to undefined function _trigger_get_hook_aids() in /var/www/drupal/sites/all/modules/nodetype/nodetype.module on line 132

The nodetype is configured to "Allow nodes of this type to have their content type changed."

Fatal error = priority "critical".

Thanks & greetings,
-asb

asb’s picture

I just tried to save a bunch of "Janode" nodes (an abandoned D5 module which created a own nodetype) by using the VBO plugin (patch from #3); that attempt failed.

After upgrading to D6, the "Janode" node type isn't handled anymore by any module; however, through VBO I can filter out unhandled content types (hoooray!) Since the content type isn't handled, I can nowhere configure it to allow node type changes. Thus the VBO plugin fails; message:

Cannot change type of ...
Cannot change type of ...
Cannot change type of ...
Cannot change type of ...
...
40 rows processed in about 1593 ms

Thus no nodetype was changed.

It'd be really helpful to make the change nodetype setting from #2 optional to gain a little more flexibility.

Thanks & greetings, -asb

kerberos’s picture

Status: Needs review » Needs work

Hi.

Sorry, we'll take a look at the error to see what may be causing it. What version of Drupal are you using so we can test it?

As for Janode, this patch is for Drupal 6. Not sure we can support any changes for D5, particularly if we don't know if the maintainer will contribute this patch to the dev. version of this module.

asb’s picture

Hi Kerberos,

thanks for looking into this!

I'm using Drupal 6.16, and I applied the patch against Nodetype 6.x-1.0 (#4). The patch introduces some new behaviours and causes two problems:

  • appying the node type change during a normal edit of one node (no VBO operation) causes an error; the nodetype is not being changed (error message in #5)
  • the addition from #2 forces to explicitly allow a node type to be changed; if you have unhandled nodetypes, you can not allow it to be changed, thus attempting a VBO operation fails (thats the scenario I ran into when I tried to fix Janode remains; #6)

Because of this I'd suggest to change the behaviour a bit:

  • Allow node type changes by default (as before), optionally allow to disable node type changes
  • In the VBO action, the checks if the content type actually can be changed should happen before the operation is executed

The problem from #5 is a simple bug; a workaround is to execute a VBO operation on this single node and not to use the node type change pulldown on the node edit form.

However, the patch incredibly enhances this module's power and I hope it'll make it soon into the official code!

Thanks & greetings,
-asb

kerberos’s picture

Hi Asb.

We'll look at the bug in #5. Give me a few days since we are swamped with work.

We are open to making the adjustments you discuss, assuming the module maintainer is willing to accept and add patches along those lines. We don't need those changes and don't have the time to make them unless we are certain they will get contributed to the module.

I am surprised you have an unhandled node type, how did that happen? It might be easier to fix that. :)

-Daniel
Adulmec

ndame’s picture

Thanks for your work on this, subscribing

zeusent’s picture

FileSize
845 bytes

The error at #5 seems to be cause by Trigger module not being turned on. This patch makes sure to check that before trying to run the code dependent on that module. I'm still looking in finding a good way to solve your other problem though I have to admin what you suggested seems to be the best way (meaning that an user has to choose which type a node is NOT allowed to be changed to instead of choosing the ones that IS).

I'll get back on this. In the meantime please let me know if the patch solves your #5 problem.

Thanks,
Mihai Fratu

asb’s picture

Hi,

thanks for the new patch!

Appying nodetype.patch from #11 against a fresh nodetype-6.x-1.0 fails:

# patch < nodetype_2.patch
patching file nodetype.module
Hunk #1 FAILED at 129.
1 out of 1 hunk FAILED -- saving rejects to file nodetype.module.rej

Contents of nodetype.module.rej:

# cat nodetype.module.rej
*************** function nodetype_hook_info() {
*** 129,141 ****
   */
  function nodetype_nodetype($op, $node) {
    if ($op == 'changed') {
-     $aids = _trigger_get_hook_aids('nodetype', $op);
-     $context = array(
-       'hook' => 'nodetype',
-       'op' => $op,
-       'node' => $node,
-     );
-     actions_do(array_keys($aids), $node, $context);
      watchdog('nodetype', 'Node type was changed to @type', array('@type' => $node->type));
    }
    else {
--- 129,143 ----
   */
  function nodetype_nodetype($op, $node) {
    if ($op == 'changed') {
+     if (module_exists('trigger')) {
+       $aids = _trigger_get_hook_aids('nodetype', $op);
+       $context = array(
+         'hook' => 'nodetype',
+         'op' => $op,
+         'node' => $node,
+       );
+       actions_do(array_keys($aids), $node, $context);
+     }
      watchdog('nodetype', 'Node type was changed to @type', array('@type' => $node->type));
    }
    else {

Greetings, -asb

zeusent’s picture

I am new at patching... What does that mean? How can I repair it?

asb’s picture

Sorry, I'm no programmer, just a user who can apply patches ;-(

All I can say at the moment is that the patch could not be applied against a freshly downloaded nodetype-6.x-1.0. So most probably you have created the patch file from a different (already altered) code base.

The rejects file contains the code diffs which couldn't be replaced. That's as far as my limited knowledge goes.

Maybe you can simple reroll the patch against a fresh nodetype-6.x-1.0 (or simply attach the complete file; the Drupal guys don't like this, but we're not dissecting Drupal core here ;)

Thanks & greetings, -asb

zeusent’s picture

FileSize
7.28 KB

You were right. I run the patch against an already patched version of the module. Here is the patch over a clean version of the module. Please let me know if it works ok

asb’s picture

Hi,

the patch now applies cleanly an modifies nodetype.module.

If I'm trying to change the nodetype on the node editing form, I'm still getting this fatal error (like in #5):

Fatal error: Call to undefined function _trigger_get_hook_aids() in /var/www/drupal/sites/all/modules/nodetype/nodetype.module on line 132

Af you mentioned correctly in #11, I don't have trigger.module enabled. As a workaround (to avoid permanently switching between patched and unpatched versions) I simply enabled it. Now the error is gone; however, IMHO something should catch requirements like this.

Also VBO works now pretty reliably for me, even if the need to enable allowed conversions per content type can be a bit pesky...

Thanks & greetings to Romania, -asb

zeusent’s picture

I've just looked into the code of this and on line 132 you should have something like

if (module_exists('trigger')) {

and not

$aids = _trigger_get_hook_aids('nodetype', $op);

wich should be on line 133. If you don't have the first if statement it means the patch didn't apply correctly (that was the difference between the first version that generated #5 error.

rc2020’s picture

Hey,

I have applied this patch and it seems to have applied okay and the option to change node type appears in the rules action menu - but no type change seems to happen. I've tested it without any conditionals and the type doesen't seem to change.

I've also performed 'save a content' so the content is saved beforehand, and that does not help either.

Thoughts?

Thanks!