I've just upgraded to 4.7.6 and Views 4.7.x-1.5, and a View that was previously sorting randomly no longer does.

I have two similar views, one of which is still sorting randomly, and the other of which has stopped. The working view is a page teaser view which displays all the nodes in a certain category ("Artists"). The failing one is also a page teaser view, but this one takes an argument ("artists/$arg"), and displays only the nodes in that subcategory.

The second view still works, but it just doesn't randomly sort anymore.

I've attached an export of the non-working view. You can see it at encompassarts.com/artists/soprano

Thanks in advance for your assistance. I thought I had it right, but maybe not.

CommentFileSizeAuthor
#1 views_random.0.patch598 bytesdfletcher
artist_category_view.txt1.27 KBmmahoney

Comments

dfletcher’s picture

StatusFileSize
new598 bytes

This issue is caused by the AS alias in the query. Views happily keeps the parenthesis around when building the "AS" part of the query during add_orderby. "SELECT RAND() AS _RAND()" is not valid SQL to mysql, so it chokes on the query.

This simple patch squeezes "(" and ")" out of the $as string before it is appended to the query.

dfletcher’s picture

I appear to have an older version of views installed. This appears to be fixed in the latest CVS through improved handling of the alias argument. My bad.

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

I don't see why this view might be giving you problems. I imported it and after I stripped out the book filter I got it to work okay for me. It's possible it's the book filter.

Also, your url should be just 'artists' not 'artists/$arg' -- $arg should only be used if it's in the middle of the URL, i.e, node/$arg/edit

mmahoney’s picture

It wasn't the view, it turns out. I got it working after I realized I had a conflicting taxonomy view. Sorry for the fire drill.

merlinofchaos’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)