When deleting a taxonomy term an error is produced:

Fatal error: Cannot use object of type stdClass as array
in /weblinks.module on line 1664

This is in weblinks_form_alter(), when trying to get the $tid from $form['#term']['tid']. During delete processing the $form['#term'] is an object not an array. We could test for this, however we do not need to do any processing in weblinks_form_alter() when a term is being deleted, so we can simply exit out if $form_state['confirm_delete'] is set.

Comments

jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new624 bytes

We have already made a similar fix in weblinks_blocks_form_alter() and need to do the same here. Patch for review.

jonathan1055’s picture

Title: Deleting a taxonomy term pduces fatal error 'Cannot use object as array' » Deleting a taxonomy term produces fatal error 'Cannot use object as array'
gstegemann’s picture

Tested and works basically. But ...

We could test for this, however we do not need to do any processing in weblinks_form_alter() when a term is being deleted,

Are you really sure? I've deleted the term while it was still assigned to a link. The link does not show up on the Web Links page. Attempting to display the link I got the following error message:
Invalid group requested (287) in function weblinks_get_tree, called from _weblinks_blocks_related_block.
I expected that an affected link will be changed to 'Unclassified'. However, that did not happen. I had to edit the link first. Then it appears on the Web Links page again.

gstegemann’s picture

Status: Needs review » Needs work
jonathan1055’s picture

Yes, but you have found a different error, not caused by my change. The problem this patch solves is allowing the term to be deleted, by not processing the unrequired modifications to the form in weblinks_form_alter() which create the fatal error.

If we need to do other processing to react to a term being deleted then there is probably a hook provided by taxonomy module. I have replicated your message, which is caused not when viewing the node with the deleted term, but when editing it. There is something else going on, because the related block is not being shown when I view the node, and no error is produced, but when I edit the node the related block is attempted and causes the error. But it should all be fixable - just need more investigation.

gstegemann’s picture

Understand.

Should I file a new issue regarding the 'related block' problem when a term was deleted?

jonathan1055’s picture

Status: Needs work » Needs review

Yes I think it is worth creating a different issue. If you are happy with the correction in the patch above I can commit this first. The other issue might take longer to resolve.

gstegemann’s picture

Status: Needs review » Reviewed & tested by the community

Yes, I'm happy with the patch and it can be commited.

  • jonathan1055 committed c2f024e on 7.x-1.x
    Issue #2495563 by jonathan1055: Deleting a taxonomy term produces fatal...
jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: +#2497229: Deleting a used taxonomy term does not change a link to 'Unclassified'

Thanks. I've linked to the new issue too.

Status: Fixed » Closed (fixed)

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