I ran into an issue with fixed default date arguments while creating some views that use a path containing node/%/

I believe I have located the bug within the views_handler_argument_date.inc file.

The code in the get_default_argument() method checks if the url path contains node/nid and if it does it attempts to load the node.

If it doesn't manage to load a node, default argument types such as default & php will work normally.

However if it does manage to load a node, the method only handles node_created and node_changed argument types correctly.

I have attached a sample view to reproduce this issue, once imported you need to visit a path such as

node/nid/news - replace nid for a valid node id.

As it stands you will get a page not found, unless you specify the argument explicitly such as - node/nid/news/all

With the attached patch, I add a check to see if it needs to even try to load the node - if not it just passes to the parent handler's method.

Comments

smoothify’s picture

I did search the issue queue, and found a similar issue here, which was closed:

#380478: Default argument for 'Node: Created year' does not work

Also another issue on the Date API queue, which is affected by this too

#459566: date arguments not passed to block view

smoothify’s picture

Title: Correct Default date argument not set when path contains node/% » Default date arguments set incorrectly when path contains node/%

adjust title

merlinofchaos’s picture

Status: Active » Needs review

Setting correct status.

merlinofchaos’s picture

Version: 6.x-2.8 » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Fixed in 6.x -- does not apply to 7.x, needs porting.

dawehner’s picture

Status: Patch (to be ported) » Fixed

and ported.

The problem was that time() was moved to REQUEST_TIME

Status: Fixed » Closed (fixed)

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