Adding a random sort to a view causes a "Missing Join: rand node" debug message be logged. This occurs on a minimal Drupal install and in both Views 3.1 and 3.x-7.x.

To replicate on a minimal Drupal Install

  • Create a generic content type (e.g. "Page")
  • Add New View (Content - "Page")
    • View Name: Test Rand View
    • Show: "Content" of type "All" sorted by "Newest First"
    • Uncheck "Create a page"
    • Check "Create a block"
    • Set "Items per page" to 3
  • Continue & edit
  • Add Sort Filter "Global: Random (asc)"

The message is logged and when viewing the block on another or when clicking "Update preview" on the view edit screen. I have tried both with only displaying 3 items and with displaying all items and the debug message is still generated.

Debug Message

Details
Type	views_logging
Date	Saturday, February 11, 2012 - 15:18
User	admin
Location .../admin/structure/views/view/test_rand_view/preview/block/ajax
Referrer .../admin/structure/views/view/test_rand_view/edit
Message	Missing join: rand node
Severity	notice
Hostname	xx.xxx.xxx.xxx
Operations	

If I disable Devel the debug message is not logged as expected.

Impact

This does not appear to be impacting any functionality and I am suspecting that maybe this debug message is being triggered by mistake. However, I want to be sure that there is not a deeper error that could break functionality in the future.

View

Attached Files:

  • Test Random View Export - View Export
  • Test Random View Config - Screen Shot of View Config

Views Query

SELECT node.title AS node_title, node.nid AS nid, 'test_rand_view:block' AS view_name, RAND() AS random_field
FROM 
{node} node
WHERE (( (node.status = '1') ))
ORDER BY random_field ASC
LIMIT 3 OFFSET 0

Installation Details

Package           Name                                   Type    Version     
 Chaos tool suite  Chaos tools (ctools)                   Module  7.x-1.0-rc1 
 Core              Block (block)                          Module  7.12        
 Core              Database logging (dblog)               Module  7.12        
 Core              Field (field)                          Module  7.12        
 Core              Field SQL storage (field_sql_storage)  Module  7.12        
 Core              Filter (filter)                        Module  7.12        
 Core              Node (node)                            Module  7.12        
 Core              System (system)                        Module  7.12        
 Core              Text (text)                            Module  7.12        
 Core              Update manager (update)                Module  7.12        
 Core              User (user)                            Module  7.12        
 Development       Devel (devel)                          Module  7.x-1.2     
 Views             Views (views)                          Module  7.x-3.1     
 Views             Views UI (views_ui)                    Module  7.x-3.1     
 Core              Bartik (bartik)                        Theme   7.12    
 Core              Garland (garland)                      Theme   7.12  
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
1.14 KB

Wow thanks for the perfect report. Even the export would have helped, but this detailed description is simply awesome.

In previous version of views, this error wasn't shown, because the debug modes were kind of unusable and based on this maybe some bugs were overseen, for example this small one.

Here is a small fix for this, maybe there are more elegant ways to do it.

dawehner’s picture

Status: Needs review » Fixed

Thanks for the really detailed report again, really appreciate it.

Committed that patch to 7.x-3.x

Status: Fixed » Closed (fixed)

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

alphageekboy’s picture

This worked perfectly. Thanks again.