used to work, doesn't anymore with latest checkins...no errors in log only an empty list

query build is

SELECT node.sticky AS node_sticky, node.created AS node_created FROM node node  WHERE (node.promote <> 0) AND (node.status <> 0) ORDER BY node_sticky DESC, node_created DESC

Comments

merlinofchaos’s picture

Title: Frontpage override results in empty list » Node row style needs to be sure nid is in query before trying to use it

ahh the group by stuff required we remove the automatic base field adding. It appears that the node row style is relying on this field being added automatically.

dagmar’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB

Here is a patch.

bwynants’s picture

Status: Needs review » Needs work

this does not work, the line just above the patch

    $fields_array = $this->fields;

puts

 (
     [node_sticky] => Array
         (
             [field] => sticky
             [table] => node
             [alias] => node_sticky
         )
  
     [node_created] => Array
         (
             [field] => created
             [table] => node
             [alias] => node_created
         )
  
 )

in $fields_array (for frontpage) and therefor the check if (!is_array($fields_array)) is false and nid is still not added

could it be you meant

    $fields_array = $this->fields;
    
    if (!is_array($fields_array)) {
      $fields_array = array();
    }
    $fields_array[$this->base_field] = array(
          'table' => $this->base_table,
          'field' => $this->base_field,
          'alias' => $this->base_field,
        );

because that seems to work....

dagmar’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

Yes, you are right. I test it without filters and sorts, and for this reason my previous patch worked fine.

New patch.

bwynants’s picture

Status: Needs review » Reviewed & tested by the community

Works OK

merlinofchaos’s picture

Status: Reviewed & tested by the community » Needs review

Wait, no, we no longer want the base field to be added automatically. Instead, I think the row style(s) should be fixed to ensure the fields they need are added.

dagmar’s picture

StatusFileSize
new3.71 KB

It is true. I have created a new patch that modified node row (view / rss) and comment (view / rss).

There is another plugin to modify?

merlinofchaos’s picture

Status: Needs review » Needs work

Hm. I think things external to the query object should not directly modify that tables. It should use add_field like normal things (and also, styles can have relationships so that can be used to ensure relationship safety as well).

dagmar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.95 KB

Here is the patch using add_field()

and also, styles can have relationships so that can be used to ensure relationship safety as well

Sorry merlinofchaos, I didn't understand this. Can you explain a bit more your idea? Or this is already done by using add_field?

merlinofchaos’s picture

What I mean is that like fields, styles can have the relationship setting. (yched patched this in so I don't remember precisely how it works).

The example is this: Let's say I want to use the node row style on a nodereferenced node. My argument is for the 'base' node, I add a node reference relationship, and then the style uses that relationship. This turned out to be necessary because sometimes it's hard to get the relationships to work in reverse, properly, so always having the actual node displayed be the base node was a difficult problem.

dagmar’s picture

Issue tags: +alpha-2 blocker

tagging

dagmar’s picture

Title: Node row style needs to be sure nid is in query before trying to use it » Node and Comment row styles needs to be sure nid/cid is in query before trying to use it
StatusFileSize
new3.57 KB

Ok, finally I found the mentioned issue #327366: Let row plugins follow relationship and here is a new patch that check if relationship es defined.

With patch #9 and using relathionships I get this query

SELECT node_node_data_field_related.nid AS node_node_data_field_related_nid,
node.nid AS nid
FROM node node 
LEFT JOIN content_type_page node_data_field_related ON node.vid = node_data_field_related.vid
INNER JOIN node node_node_data_field_related ON node_data_field_related.field_related_nid = node_node_data_field_related.nid

With this patch and using relationships

SELECT node_node_data_field_related.nid AS node_node_data_field_related_nid
FROM node node 
LEFT JOIN content_type_page node_data_field_related ON node.vid = node_data_field_related.vid
INNER JOIN node node_node_data_field_related ON node_data_field_related.field_related_nid = node_node_data_field_related.nid

So, it seems to be working fine.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I tested every of this 4 szenarious. Before it didn't worked. Now with the patch it worked fine.

mxmilkiib’s picture

subscribe

bwynants’s picture

I applied #12 and it seems to work just fine. Thanks @dagmar

merlinofchaos’s picture

Status: Reviewed & tested by the community » Needs work

I think the only change that needs to be made here is to views_plugin_row::query() which is already doing an add_field() -- I do not believe we need to do this more.

It does seem that a couple of rows (comment and comment_rss) are not relationship safe. That should probably also be fixed.

dagmar’s picture

Status: Needs work » Needs review
StatusFileSize
new970 bytes

Here is the patch

merlinofchaos’s picture

StatusFileSize
new8.4 KB

Let's test out this patch.

This fixes several row styles to be relationship safe, which is important. Those fixes actually should be backported to Views 2.x as those are serious, though very rarely seen bugs.

dagmar’s picture

Status: Needs review » Reviewed & tested by the community

Yes, works fine. Even this respect the ability of define relationships in rows plugins.

bwynants’s picture

reverted #12 and applied #18 and things still work. Also some custom views I made.

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Needs porting to 7.x -- relies on GROUP BY so needs to wait for that.

dawehner’s picture

Issue tags: -alpha-2 blocker

remove tag.

dawehner’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new5.63 KB

Here a patch comes.

For comments and node it worked.

dawehner’s picture

Status: Needs review » Fixed

commited

Status: Fixed » Closed (fixed)

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