I've been doing more testing with multiple vocabularies, where the vocab selected for weblinks navigation is not the standard one provided by the module. The following error message is shown and it was not clear where it came from:

"Invalid group requested (14)"

There are two problems here:
(a) This message text is used in three functions, so it was not clear where it was created.
(b) What situation caused the error to be shown anyway?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonathan1055’s picture

Status: Active » Needs review
FileSize
2.71 KB

(a) I have changed the error text message to show the function it is called from, which will assist future debug. In this case it was:

"Invalid group requested (14) in function weblinks_get_tree."

(b) It was called from the related block and the reason for the error being displayed was that the $ismainlinkspage value in weblinks_get_tree() was TRUE, whereas it should be FALSE if this function is called from a block.

Here's a patch which solves both of these.

GStegemann’s picture

Thanks for discovering this.

I have tested the patch and see the following notice
Notice: Undefined property: stdClass::$tid in weblinks_get_tree() (line 1185 of /var/www/html/cm7/sites/all/modules/weblinks/weblinks.module)
when I enter an URL like www.example.com/weblinks/4711.

jonathan1055’s picture

FileSize
2.81 KB

Thanks for testing, I did not try typing an incorrect url directly, so that's good. I was just checking that the message was not shown when a related block called the function.

Easy to fix - the test for $ismainlinkspage should only prevent the error message. The function still needs to return the empty array at that point, not continue on (where your errors were shown). Here's an updated patch. I also added a bit of in-code documentation.

jonathan1055’s picture

argh ... this is not right either. We need the message to be shown when trying to go to /weblinks/nn when nn is not valid. So $ismainlinkspage is not the right thing to test for anyway. All we need is for the message not to be shown when this is called from the related block.

I'll do some more investigation.

jonathan1055’s picture

I have found that the error is caused by the wrong terms being used in weblinks_blocks_block_view() and passed to _weblinks_blocks_related_block(). It happens when the weblinks standard vocabulary is added to the content type but a different vocabulary is being used for Web Links navigation. The node value $node->taxonomy_weblinks is hard-coded but it should use the field which has the current weblinks navigation vocab. Now that #2481521: Expand the information returned by _weblinks_vocabulary_field_info() is in, I can fix it properly, which was my eventual aim anyway.

  • jonathan1055 committed e3b72e9 on 7.x-1.x
    Issue #2482165 by jonathan1055: Improve error message "Invalid group...
jonathan1055’s picture

Status: Needs review » Needs work

The above is just the improvement in the error message adding the function which produced the error. I will work on the actual fix now.

  • jonathan1055 committed 22f38d9 on 7.x-1.x
    Issue #2482165 by jonathan1055: Make error message generic for "Invalid...
jonathan1055’s picture

Status: Needs work » Needs review
FileSize
4 KB

There were a couple of reasons for the error messages
(a) If the site has a 'recent' or 'popular' block for a specific term, then the weblinks navigation vocabulary is switched to a different one, the term of that block is no longer applicable. This is fixed at the top of weblinks_blocks_block_view() by checking the vocabulary id of the term associated with the block being requested.
(b) In the related block section, we cannot assume that the field taxonomy_weblinks is the field being used to group weblinks. With the expansion of data returned by _weblinks_vocabulary_field_info() we can get the actual field name and use this instead.

The attached patch fixes both of these.

GStegemann’s picture

Status: Needs review » Reviewed & tested by the community

Tested and works. Thanks.

  • jonathan1055 committed 3c94dd2 on 7.x-1.x
    Issue #2482165 by jonathan1055: Error message "Invalid group requested"...
jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for testing.

Status: Fixed » Closed (fixed)

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