Ordering in printer listing broken #4170

Closed
michaelrsweet opened this Issue Aug 23, 2012 · 5 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Aug 23, 2012

Version: 1.5.3
CUPS.org User: coffeelover

Steps to reproduce:

  1. Create min. 150 printers:

    for i in $(seq 1 1 150); do lpadmin -p printer$i -E ; done

  2. Open the printer listing (http://localhost:631/printers), the first 100 printers are shown and ordered ascending.
  3. Click on "Show next"
  4. The last 50 printers are show and ordered descending (aka "the first 50 printers")

The form values are now initialized, the pagination is working from now on.

To fix the broken initial behavior, a default value of ORDER="asc" should be set for the "Show next" and "Show previous" buttons.

Collaborator

michaelrsweet commented Aug 28, 2012

CUPS.org User: mike

Have you tried this with the current stable release of CUPS (1.6.1)? There have been a LOT of bug fixes since 1.5.3 came out...

Collaborator

michaelrsweet commented Aug 29, 2012

CUPS.org User: coffeelover

I've tried it with 1.6svn (don't know the exact version) on MacOSX Mountain Lion and can reproduce this error. So it's still an issue for 1.6 I guess.

Collaborator

michaelrsweet commented Sep 15, 2012

CUPS.org User: mike

Fixed in Subversion repository.

Collaborator

michaelrsweet commented Sep 15, 2012

"pager.patch":

--- pager.tmpl.orig 2012-08-23 17:16:14.815881340 +0200
+++ pager.tmpl 2012-08-23 17:17:11.467880800 +0200
@@ -1,6 +1,6 @@

- - - -
{PREV?: }{NEXT?: }{PREV?: }{NEXT?: }
Collaborator

michaelrsweet commented Sep 15, 2012

"str4170.patch":

Index: cgi-bin/printers.c

--- cgi-bin/printers.c (revision 10596)
+++ cgi-bin/printers.c (working copy)
@@ -397,7 +397,7 @@
sprintf(val, "%d", count);
cgiSetVariable("TOTAL", val);

  • if ((var = cgiGetVariable("ORDER")) != NULL)
  • if ((var = cgiGetVariable("ORDER")) != NULL && *var)
    ascending = !_cups_strcasecmp(var, "asc");
    else
    ascending = 1;

Index: cgi-bin/ipp-var.c

--- cgi-bin/ipp-var.c (revision 10596)
+++ cgi-bin/ipp-var.c (working copy)
@@ -1432,7 +1432,7 @@
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
"ipp://localhost/");

  • if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
  • if ((which_jobs = cgiGetVariable("which_jobs")) != NULL && *which_jobs)
    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
    NULL, which_jobs);

@@ -1480,10 +1480,11 @@
if (first < 0)
first = 0;

  • if ((var = cgiGetVariable("ORDER")) != NULL)

  • if ((var = cgiGetVariable("ORDER")) != NULL && *var)
    ascending = !_cups_strcasecmp(var, "asc");
    else

  •  ascending = !which_jobs || !_cups_strcasecmp(which_jobs, "not-completed");
    
  •  ascending = !which_jobs || !*which_jobs ||
    
  •              !_cups_strcasecmp(which_jobs, "not-completed");
    

    section = cgiGetVariable("SECTION");

Index: cgi-bin/classes.c

--- cgi-bin/classes.c (revision 10596)
+++ cgi-bin/classes.c (working copy)
@@ -380,7 +380,7 @@
sprintf(val, "%d", count);
cgiSetVariable("TOTAL", val);

  • if ((var = cgiGetVariable("ORDER")) != NULL)
  • if ((var = cgiGetVariable("ORDER")) != NULL && *var)
    ascending = !_cups_strcasecmp(var, "asc");
    else
    ascending = 1;

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment