Hi there,

What is your idea for related content with Domain module in 6th Drupal?

Relevant Content and Similar By Terms modules don't respect domain
restrictions, displaying all domains' nodes, what is a bit confusing for me.

I can make a view with Views and Domain Views, but I can't sort it
by related tags' number, like RC and SBT do...

Any your experience with that? Hints?

Szy.

Comments

agentrickard’s picture

If those other two modules do not respect the domain, that is likely a bug in their (mis)use of db_rewrite_sql().

All node listing queries are supposed to be wrapped in db_rewrite_sql() in order to enforce node access rules.

szy’s picture

Thanks, I've submitted issues for those modules.

But the question remains open: how people get related/relevant/similar content
with Domain Access in 6th Drupal?

Szy.

szy’s picture

Similar by Terms' author says his module works fine. You said that
your Domain module works fine too...

But somewhere there must be something wrong, what makes
Similar by Terms block to display nodes from all system domains,
instead of the active one.

Could you please look into it, Agent? :]

Tia,
Szy.

My DA Settings:

New content settings: *
( ) Show on all affiliate sites
(o) Only show on selected sites

Content editing forms: *
(o) Pass the default form values as hidden fields
( ) Take user to the default domain
...

Debugging status: *
(o) Do not show debugging output
( ) Show debugging output on node view

Sort domain lists: *
(o) Creation order, oldest > newest
( ) Creation order, newest > oldest
...

Search settings:
(o) Search content for the current domain only
( ) Search all domains from any URL

Search engine optimization:
( ) Do not rewrite URLs
(o) Rewrite all URLs to point to a single source

WWW prefix handling:
(o) Process all host requests normally
( ) Treat www.*.example.com as an alias of *.example.com

I don't use Domain Source.

agentrickard’s picture

Node access rules do not apply to user 1 or users who can 'administer nodes.' Be sure to test as another user.

agentrickard’s picture

Also check the advanced node type settings to be sure that you have disabled the 'send to all affiliates' for all content types.

szy’s picture

Both user 1 and anonymous can see content from all domains. 'Send to all...'
is disabled..., all node types are disabled at Node settings / Domain node types.

... still Relevant Content and Similar by Terms show not correct nodes :/

There is the first row in node_access table:

nid | gid |   realm    | grant_view | grant_update | grant_delete 
----------------------------------------------------------------
 0   |  0  | domain_all |     1      |      0       |      0   

... are these values correct?

Am I the only user displaying related content in Domain Access? :/

Szy.

agentrickard’s picture

Those values are correct. See section 4.4 of README.txt.

What other values are in the {node_access} table?

szy’s picture

      82518 11 domain_id 1 1 1 
      82519 11 domain_id 1 1 1 
      82520 4 domain_id 1 1 1 
      82521 5 domain_id 1 1 1 
      82522 6 domain_id 1 1 1 
      82523 7 domain_id 1 1 1 
      82524 8 domain_id 1 1 1 
      82525 10 domain_id 1 1 1 
      82526 1 domain_id 1 1 1 
      82527 8 domain_id 1 1 1

... etc, over 25,000 records, one per every node I have. There were records
'domain_source' too, but they disappear after uinstallation of Domain Source.

I've found Similar Entries and barely working Related Links modules - they display
content from all domains too... :/ And there is no more way to display related
content in D6.

I even have wrapped SELECT queries with db_rewrite_sql where needed, but
nothing has changed (there is db_rewrite_sql in Similar by Terms, afair).

Szy.

nonsie’s picture

Why not attempt to achieve this with Views?

szy’s picture

@nonsie - with pleasure - how? :]

This is the most wanted thing for me now: having a views code (not block)
working as these 'related' modules do. Then I could filter them with Domain
Views.

Related modules work this way: looking for nodes with specified terms, then
sorting them by terms number, then by posting date.

This code would be all related modules killer... ;)

Szy.

szy’s picture

@agent - could it have anything in common with my issue?

-> http://drupal.org/node/216148 ...?

Szy.

agentrickard’s picture

Component: Miscellaneous » Code
Category: support » bug

Similar Entries module does not appear to use db_rewrite_sql() at all.

Ref: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/similar/sim...

The following queries ignore node access (line 400 and 403):

    $result = db_query_range("SELECT r.nid, MATCH(r.body, r.title) AGAINST ('%s') AS score FROM {node_revisions} r INNER JOIN {node} n ON r.nid = n.nid AND r.vid = n.vid INNER JOIN {term_node} t ON n.nid = t.nid AND t.tid IN (%s) WHERE MATCH(r.body, r.title) AGAINST ('%s') AND n.status <> 0 AND r.nid <> %d AND n.type IN ($types) GROUP BY n.nid ORDER BY score DESC, r.vid DESC", $text, $taxonomy_tids, $text, $node->nid, 0, variable_get('similar_num_display', 5));

    $result = db_query_range("SELECT r.nid, MATCH(r.body, r.title) AGAINST ('%s') AS score FROM {node_revisions} r INNER JOIN {node} n ON r.nid = n.nid AND r.vid = n.vid WHERE MATCH(r.body, r.title) AGAINST ('%s') AND n.status <> 0 AND r.nid <> %d AND n.type IN ($types) GROUP BY n.nid ORDER BY score DESC, r.vid DESC", $text, $text, $node->nid, 0, variable_get('similar_num_display', 5));
  

Even if wrapped in db_rewrite_sql(), these queries will not work, since the default primary key is 'nid' on table 'n' not table 'r'.

These queries are bugs in Similar Module.

Ref: http://api.drupal.org/api/function/db_rewrite_sql

See http://api.drupal.org/api/function/node_db_rewrite_sql, which is where node access rules are enforced.

Similar Terms (if available for D6) should work correctly. Your DA tables are normal.

agentrickard’s picture

Status: Active » Closed (fixed)