If the default display does not have an offset, while another display overrides the default with an offset, the default offset will be set to the overridden value after the view has been exported to code.
Steps to reproduce:
* Ensure that the default value of offset is 0 in "items to display"
* Create a new display, override "items to display" and set the offset to 3
* Verify that the default value of offset is still 0
* Export the view to code
* Revert the view
Result: the default value for offset is now 3
Expected: the default value for offset should be 0
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 660606_views_offset_not_exported_correctly_0.patch | 3.71 KB | au_dave |
| #13 | 660606_views_offset_not_exported_correctly.patch | 3.69 KB | voxpelli |
| #12 | 660606_views_offset_not_exported_correctly.patch | 3.38 KB | voxpelli |
| #11 | view.myview.txt | 2.76 KB | manuel garcia |
| #11 | view.myview(bugged).txt | 1.92 KB | manuel garcia |
Comments
Comment #1
jhedstromsubscribing
Comment #2
dawehnerIt would be cool, if someone could export this kind of view, so its possible to see, whether the import or the export goes wrong.
Comment #3
manuel garcia commentedOK, I've encountered the same problem, and I think I've found what is causing this.
If you have a view, where you have displays overriding the 'offset' value, these will not get picked up from the exported code, and this is because (as merlin suggested) 'offset' and 'items_per_page' share the same override flag.
So, what I did was added the line
$handler->override_option('items_per_page', 10);just above the line$handler->override_option('offset', 0);, for each display which was overriding the offset value. Cleared the cache, and voila, correct values for all get pickedup. You HAVE to do this for every display that overrides the offset, otherwise none get picked up.So what I suggest we do here, is well, include the line for 'items_per_page' AND the one for 'offset', if either are overriden, because they share the same override flag, and otherwise it looks like views doesn't pick the line up, even if it's for the default display.
I attach both the original export, and the fixed export that works, so u can use diff on it, but it will get you this:
Comment #4
manuel garcia commentedComment #5
brynbellomy commentedsubscribe
Comment #6
thebuckst0p commentedSubscribe, seeing the same issue with exporting Views in Features.
Comment #7
brynbellomy commentedHere's a patch. Can someone review this?
Comment #8
brynbellomy commentedHere's a better patch that saves things like 'path' correctly.
Comment #9
brynbellomy commentedbump and version bump
Comment #10
gnat commentedI can confirm that the workaround in #3 is functional.
Comment #11
manuel garcia commentedOK, finaly found some quite time to test out the patch brynbellomy =)
I've tested it on a fresh install of d6, 6.x-2.11 version of views, with generated content from devel, and the attached view, which is simple enough. Good for testing it if anyone wants to help out. I assume before this gets committed this would have to get rolled out for the latest 6.x dev version of views, and tested there.
The patch #8 does solve the problem, the exported attached view is the result of the export being done with the patch.
I also attach the exported view prior to applying the patch, in which the default offset got the value from the overriden display, in case this helps the reviewing process.
I would set it as RTBC but I think a code review would be nice. I've gone over the patch and it looks good, but I'm not that knowledagble in views ways to stand by it, so I hope someone from the core views dev team would take a peak.
Comment #12
voxpelli commentedRefactored the above patch into something that more closely reassembles what Views does today.
UPDATE: Ignore this patch - hadn't tested it enough.
Comment #13
voxpelli commentedCorrected version of above refactoring of the original patch.
Comment #14
merlinofchaos commentedCan I get some further testing of this patch? It's a little too much for me to just eyeball and feel comfortable with just now. Some solid use testing would make me feel better about it.
Comment #15
merlinofchaos commentedAssigning to bojanz for testing.
Comment #16
brunodboPatch in #13 fails for me with the following error (with patch file in Views' directory):
Comment #17
dawehnerYou should probably use patch -p0 to apply this patch.
Comment #18
madmanmax commentedThe problem still happens in the latest stable version (6.x-2.14) with a fresh install of Drupal 6.22
Unfortunately the patch #660606-13: Offset is not exported to code correctly, overrides default value doesn't seem to fix the issue. To apply the patch this worked for me:
sites/all/modules/views)patch -p0 < /path/to/patch/name_of.patchSteps to reproduce the problem:
So what we had initially before the export:
After the export and import, the settings look like this:
Looks like after the import the default settings now inherited the offset and Block 2 also inherited the offset although it was overriding the default settings.
Comment #19
daggerhart commentedFound a quick work around.
In your exported code, you need to manually override the items_per_page also, and it will work.
So find your override for the offset, and add this above it. Even if the items_per_page is the same for each display.
Clearly these two are linked in some way.
Comment #20
manuel garcia commented@daggerhart if you have the way to reproduce this handy, would you mind testing the patch on #13 please?
Comment #21
daggerhart commented@Manuel Garcia
The patch did not work for me. My testing environment has 2.16, so I applied the patch manually.
Create a new view w/ 2 block displays: first block shows 2 items no offset, second block shows 2 items with offset of 2.
Exported to code:
There is no items_per_page or offset for block_1. Import used block_2's settings as the default.
If I manually add the items_per_page and offset to block 1, it imports correctly.
Comment #22
manuel garcia commentedThanks for the review daggerhart !
Comment #23
au_dave commentedHi guys
I have applied the patch in #13 and it doesn't quite work.
I think it is setting the override options correctly in the overridden display, but not setting the offset of 0 (or whatever) in the default display.
The work around of adding
$handler->override_option('offset', 0);
$handler->override_option('items_per_page', 10);
to the default display works here too.
I will try and look at this and update the patch when I have time.
Comment #24
au_dave commentedHere is an updated patch.
Comment #25
manuel garcia commentedComment #27
senpai commentedFYI, final QA testing for the drupal.org D7 upgrade begins next week, and we're going to need this fix as part of the Git Team's requirements.
Comment #28
senpai commentedAny movement on this one?
Comment #29
chris matthews commentedThe Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue