There seems to be an issue in the argument handling code that leaves a '\r' at the end of the first argument. This leads to a view that returns no values.

For example, I have a view that takes two arguments: og_name and node type. The view works as you'd expect when invoked via a URL, returning only nodes from the named group of the node type. Also, if I invoke the view from Custom Pagers without arguments, everything works as expected. However, things break when I add the following to the "View arguments" section of my custom pager:

[ogname]
[type]

If you follow it all the way through with a debugger, you discover that the query is being built with the group name with an appended '\r', resulting in no matching nodes. I believe you need to trim the arguments after resolving the tokens.

It seems that adding the following around line 450 of custom_pagers.module, just after the lines

  // Use a view to generate the list.
  $args = explode("\n", $pager->args);

resolves the problem:

      for ($curIndex = 0; $curIndex < sizeof($args); $curIndex++) {
        $args[$curIndex] = trim($args[$curIndex]);
      }

(I'm new to PHP (though very experienced at C, C++, and Java), so there might be a better way to do this.) Sorry, I've never created a patch for a Drupal module so I don't know how to patchify this. If I have some free time later I'll figure it out and post a patch, but if someone can whip this up in a flash it might be faster.

CommentFileSizeAuthor
#1 fix_args.patch596 bytesmrothroc

Comments

mrothroc’s picture

Status: Active » Needs review
StatusFileSize
new596 bytes

I took a minute and figured out how to create a patch. If it isn't right, somebody let me know.

eaton’s picture

Committed a slightly modified version of the patch to the Drupal 6 branch. Will backport if I have a chance, thanks!

eaton’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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