Full message:
Undefined property: stdClass::$multiple in similarterms_block_info() line 65 of sites/all/modules/similarterms/similarterms.module

Had to disable similarterm module to have something stable.

Module Similar By Terms 7.x-1.0-alpha2

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Project: Drupal core » Similar By Terms
Version: 7.0 » 7.x-1.x-dev
Component: other » Code

Then report it there, not for Drupal core :)

inolen’s picture

FileSize
5.19 KB

The D7 build was completely broken for me. This is my first Drupal patch, so let's hope it works. Added some misc. changes to make this work with D7's theming changes, also updated the database queries to work with D7's new schema, the old code referenced the table "term_node" and my new code references "field_data_field_tags" which appears to be proper. I also removed one of the query conditions (node.moderate = 0) because the column no longer existed, I'm not sure if a new condition should be added to replace it. This got me up and running, hopefully it's helpful.

Is this the proper way to post this patch? And is it now up to the maintainers to review and possibly commit it, or is there something more obvious that I am missing?

Berdir’s picture

Status: Active » Needs work

Yes, what you are doing is correct. Not the maintainer, but I can give your patch a short review....

First, always set issues to needs review when you upload a patch. For projects that have automated testing enabled (this one doesn't), it will automatically get test and even when not, users can see that there is a patch which can be tested.

+++ contributions/modules/similarterms/similarterms.info	4 Aug 2010 00:17:39 -0000
@@ -5,3 +5,10 @@
 files[] = similarterms.module
 files[] = similarterms.install

The rather new rule is to only add files to this definition that contain classes. Typically, these are for texample .test files.

+++ contributions/modules/similarterms/similarterms.info	4 Aug 2010 00:17:39 -0000
@@ -5,3 +5,10 @@
 files[] = similarterms.install
+
+; Information added by drupal.org packaging script on 2010-08-04
+version = "7.x-1.x-dev"
+core = "7.x"
+project = "similarterms"
+datestamp = "1280881059"
+

Looks like you used a -dev download to port it. You should remove this part from the info file because it' automatically added by the bild script.

+++ contributions/modules/similarterms/similarterms.module	9 Feb 2011 22:54:42 -0000
@@ -79,7 +79,10 @@
+    'content' => theme('similarterms', array (
+		'display_options' => variable_get('similarterms_display_options', 'title_only'),
+		'items' => similarterms_list($delta)
+	))

You should use 2 spaces instead of tabs.

+++ contributions/modules/similarterms/similarterms.module	9 Feb 2011 22:54:42 -0000
@@ -218,15 +221,16 @@
-      $query = db_select('node', 'n', $options)
-        ->addField('n', 'nid')
-        ->addField('n', 'title')
-        ->addExpression('COUNT(nid)', 'ncount')
-        ->innerJoin('term_node', 'tn', 'n.vid = tn.vid')
-        ->condition('tn.tid', $terms, 'IN');
+      $query = db_select('node', 'n');
+
+      $query->addField('n', 'nid');
+      $query->addField('n', 'title');
+      $query->addExpression('COUNT(nid)', 'ncount');
+      $query->innerJoin('field_data_field_tags', 'tn', 'n.vid = tn.revision_id');
+      $query->condition('tn.field_tags_tid', $terms, 'IN');

What you did works, but it should be possible to do it with fewer lines.

Untested:

$query = db_select('node', 'n')
  ->fields('n', array('nid', 'title'))
  ->condition('tn.field_tags_tid', $terms);
$query->addExpression('COUNT(nid)', 'ncount');
$query->innerJoin('field_data_field_tags', 'tn', 'n.vid = tn.revision_id');

- fields and condition are chainable, add* and join calls not (This is a mess a know, one of the things I want to change in D8)
- I think you want to use the 'taxonomy_term_node (or similar) table to join, the field table is just for the default tags field and might or might not exist.

+++ contributions/modules/similarterms/similarterms.module	9 Feb 2011 22:54:42 -0000
@@ -258,9 +260,9 @@
       $result = $query->execute();
+
       foreach ($result as $record) {
-        $r = $record->fetchObject();
-        $nodes[] = node_load($r->nid);
+        $nodes[] = node_load($record->nid);
       }

This can be written in two lines :)

$nids = $query->fetchCol();
$nodes = node_load_multiple($nids);

ok, a few more lines, you want to add a check if there were any nid's returned.

Also, it looks like the query selects and groups by n.title but it doesn't seem to be used, so that could maybe be removed.

+++ contributions/modules/similarterms/similarterms.module	9 Feb 2011 22:54:42 -0000
@@ -535,8 +538,7 @@
   );
-}
-
+}
\ No newline at end of file

diff doesn't like it when there is no empty newline at the end of file, so you should leave that.

Powered by Dreditor.

inolen’s picture

Thanks a lot for the detailed review! I'll fix up the issues you brought up and post a more proper patch later tonight.

HaloFX’s picture

subscribe

worldandworld’s picture

Hi, I have patched the module as per the instructions. but still i am getting the error messages. have anybody get this similarterms working with Drupal 7???

Fatal error: Call to undefined function taxonomy_node_get_terms() in /home/content/w/o/r/worldandworld/html/ReadMalayalam/sites/all/modules/similarterms/similarterms.module on line 204

gmopinillosv’s picture

Hello gays

I setted Similar terms 7.x-1.x-dev on drupal 7.2 and I got the same error. Also, are there a patch update for this issue?
On he other hand, how I set an patch? Sorry I am new in this. Thanks

Gerben Zaagsma’s picture

subscribe

Sutharsan’s picture

Status: Needs work » Needs review
FileSize
7.88 KB

I did not look at this issue before I stared working a number of hours ago. So I got an unrelated patch which tries do the same, get the module working.
Fixes various problems:
- Wrong path for admin page
- Admin page is empty
- Fixes the mising taxonomy_node_get_terms_by_vocabulary() and taxonomy_node_get_terms() functions
- Move complex php code to preprocess (more todo here).
The original issue is not yet fixed, but a todo with a solution suggestion is added.

Sutharsan’s picture

I've tried to find out how to determine in D7 the type of taxonomy input (multiselect, tagging). But this is not an easy thing. These characteristics are now determined per node type, per field. I see two alternatives: 1. Provide blocks for all vocabularies; 2. Provide checkboxes on the settings page to check the vocabularies for which a block will be provided. Both don't scale very well with large numbers of vocabs, but the second option is the least problematic of the two.

rmiddle’s picture

Status: Needs review » Fixed

A big shout out to Sutharsan who basic wrote the D7 port of similar by terms. I will push alpha3 now to get some more testing.

Thanks
Robert

Status: Fixed » Closed (fixed)

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

bc’s picture

Status: Closed (fixed) » Active

I ran into a bug when instantiating more than one similarterms block in a single node page: the usage of drupal_static to define $terms in similarterms_taxonomy_node_get_terms() was the root of the problem. Is there a reason to define $terms as a static variable here?

The module works fine for me when I remove that line.

bc’s picture

better yet:

<?php
$terms = &drupal_static(__FUNCTION__ . '_' . $vid);
?>
Sutharsan’s picture

Status: Active » Closed (fixed)

@bc, Please create a new issue for this. Lets keep issues focused to one subject.

Issue status back to closed.