When I create a view with union, after saving it all works well and all fields requested are shown. After reloading page, I obtain the page but with no fields shown (only title).
Before submitting patch in http://drupal.org/node/182968, seem that the cause was that union's parameters was lost (in the edit page, no views were selected in union's field).
After that patch, in union's field there are the views selected, but no data is shown.

Drupal 5.2, last views version

CommentFileSizeAuthor
#21 object_serial.patch828 bytesowen barton

Comments

aries’s picture

+1

liquidcms’s picture

Priority: Normal » Critical

have been battling this same issue but was working for me on my Windows devel box but same result you show once moving to server..

then i realized what difference there was between devel (Windows) and server (Debian)

i have this code in a module i use for test:

  $_isWindows = (strToLower(substr(PHP_OS, 0, 3)) === 'win');
  if ($_isWindows) {
      db_query("DELETE FROM {cache}");
      db_query("DELETE FROM {cache_filter}");  
      db_query("DELETE FROM {cache_menu}"); 
      db_query("DELETE FROM {cache_page}");
  } 

which i copied over from 4.7 days because when doing devel i hate having things hanging around in cache and confusing my debug.

sure enough, when i comment out this code - and basically make Windows box same as linux - viwes union is now busted on Windows box as well.. so, it would seem that this issue has something to do with caching..???

continuing to llok

liquidcms’s picture

ok this is definitely cache related but i dont think union related. I have similar issues with fused views. What version of views module do you use. I think this issue started when i upgraded from 1.5 to 1.6.. trying to back rev now and test.

liquidcms’s picture

just gets more and more odd...

this is the only cache dump line i need to fix this

db_query("DELETE FROM {cache} WHERE cid = 'imagecache:presets'"); 

and i have it running in a menu hook (i.e. runs on every page)

so looks like a bug in imagecache.. go figure...

enxox’s picture

I'm using the last version of views, don't know about previous release...

dellis’s picture

I'm noticing this as well. The union-view displays all of the data the first time, but on page refresh it goes blank.

dellis’s picture

Also, if I edit the view and then save it again, it shows up again.

dellis’s picture

Sorry--one more thing, this may be a separate issue, but it may be related to the cache/settings... when I try and create a new (non-Unioned) view, the UNION settings from the Union view that I created last are still set as defaults for this view...

liquidcms’s picture

working through this and a few things... the query in the cache_views table is wrong - i suspect perhaps the the query without doing the merge??? but never gets to do the merge since it sees a value in the table so it never runs any of the views_union query alter code.

I guess this would point to something doing the right query to start with but then stores wrong value in cache.. which is why it works first time but not after wards.

i just need to find code where the cache query is getting filled... getting close

liquidcms’s picture

well getting pretty late here but this is where i have got to:

- i think that the main view gets stored in cache table and since it is there it pulls it and never runs views_union_views_query_alter
- and that view on its own has no results without the 2 views that it is joining

so heres a question on usability of this module??? if i have view A and view B to get a union do i create C as union of A and B

OR

do i simply create A and set it to be union'ed with B??? originally i could have swore i had this working with 2nd method; but afterwards only got it working with 1st method.. but perhaps if 2nd is correct this would fix this issue???

anyway.. since i have A, B, and C.. and C returns nothing on its own and this is what gets stored in cache.. i get no results

i can also see that A and B are marked in views table as not being cacheable.. but C is cacheable... so, of course, when i set the C view to not be cacheable either.. my view works correctly and all is well

but this isnt likely the answer here??

enxox’s picture

I think that about usability question there isn't a right and wrong answer. I was made an A, B and C =A+B views because I want to create a resultant view with some fields invisible for not autenticated user.

So you think that the problem is in database views table? I think that have sense that a view isn't cacheable...

liquidcms’s picture

yes, if i set C to not be cacheable (directly edit the view_view table) then my issues go away - however anytime i edit or just resubmit the view the tbale gets set back to allow it to cache. Would need to find out where in the code this is being set??

enxox’s picture

Set is_cacheable to 0 solve issues for me too.
Editing view.module, i've found that _views_is_cacheable function
* Determine whether or not a view is cacheable. A view is not cacheable if
* there is some kind of user input or data required. For example, views
* that need to restrict to the 'current' user, or any views that require
* arguments or allow click-sorting are not cacheable.

I don't know how to add a condition that include also a view with view_union field active. I'm not a coder.

But searching around, I've found in http://drupal.org/node/70145 that writing in arguments

$view->is_cacheable = 0;

force the caching to off and solve the issue.

How to automatize it?

enxox’s picture

I don't understand...now I added an argument in mi view, right? so, if the views function says that a view isn't cacheable when there is some arguments, my C view must result not cacheable. But in database is_cacheable is again set to 1...

liquidcms’s picture

hmmm.. interesting.. i think the key here is to find in the union code where it sets whatever it sets to make view cacheable.. or more likely i would guess this inst touched (and i dont think it is since i went looking for it) in the union module.. just views module setting by default.. but likely in the pre_view (i think that was there) hook in the union module it needs to explicitly set that it cant be cacheable???

enxox’s picture

probably is set by default... I cant' find a reference in union's code...

Anonymous’s picture

Status: Active » Fixed

Hi. Sorry, I haven't had much time to work on this module, but I finally looked at it and I think that the fix for this problem is now in the latest cvs. I had been relying on the _view_query_alter hook to look up the views_union information in the database. But hook_view_query_alter doesn't get called if the view was cached. The problem was that I was also not caching the union info.

Now I cache the union info and I get it back out, too.

liquidcms’s picture

very cool.. thanks for adding this..

Anonymous’s picture

Version: 5.x-1.x-dev » 5.x-1.1
Status: Fixed » Closed (fixed)
elgreg’s picture

Status: Closed (fixed) » Active

This is still occurring - see thread here: http://drupal.org/node/234081

owen barton’s picture

Status: Active » Needs review
StatusFileSize
new828 bytes

The new problem is caused by php not correctly serializing and unserializing the query object in some cases (it happened with pager queries for me, but not regular ones) causing a php 'invalid class/object', You can see this by doing a print_r on the 'master_queryobj' once it has been retrieved from the cache.

Apparently this can occur is the class definition is no longer available (perhaps we need to include a views .inc file that isn't included when the view is cached). The simplest way around it, however is simply to cast the views object to an array, and then back to a generic stdclass object. This worked for me at least!

owen barton’s picture

Actually, I can reproduce this on PHP 5.2.3 (Ubuntu Gutsy), but not on 5.2.4 (Ubuntu Hardy). With 5.2.4 the unserialized view is already a stdclass object (and so is accessible by the code). Can anyone else reproduce the serialization issue above?

marantz’s picture

I was able to reproduce the serialization issue with PHP 5.2.5 under MAMP, but your patch seems to have solved things, Grugnog2.