• (cs)

    "Paging algorithm" didn't mean what you think it does, back in the days of the dinosaur. It meant ways to decide which page goes in the pagefile. In fact, this concept is probably almost old enough to qualify for having been designed by trilobites.

  • Mike (unregistered)

    Back in those days "next page" and "previous page" were always implemented by turning over a piece of paper. This wtf isn't as prehistoric as advertised; these dinosaurs are too modern.

  • (cs)

    That's not a 'curious perversion', that's just plain wrong.

  • (cs)

    Still makes you wonder why the user got 75 records when from the look of it this code should only give the first 30.

  • Kuli (unregistered)

    I like that the offset variable is called "limit".

  • Nick (unregistered)

    What.

  • Catprog (unregistered) in reply to NMe
    NMe:
    Still makes you wonder why the user got 75 records when from the look of it this code should only give the first 30.

    50+25 = 75

  • (cs)

    This was a lovely story about dinosaurs... why'd you have to ruin it with algorithms, eh?

  • MrPotes (unregistered)

    Arrgh. Unicorns! (haven't seen them for a while)

  • (cs)

    75 records should be more than enough for anyone!

  • RFoxMich (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    "Paging algorithm" didn't mean what you think it does, back in the days of the dinosaur. It meant ways to decide which page goes in the pagefile. In fact, this concept is probably almost old enough to qualify for having been designed by trilobites.

    Yeh... I read this and expected to see something about demand paging in virtual memory systems and was looking forward to seeing some subtle race condition or low bandwidth covert channel attack sigh

    Should have known better... just one of those frist page second pages thrid page things.

  • Anonymous Paranoiac (a.k.a. "The Lowlander") (unregistered)

    There can ONLY be THREE!

  • doohrooz (unregistered)

    Who's going to need more than three pages of data, anyway?

  • anonymous (unregistered) in reply to snoofle
    snoofle:
    75 records should be more than enough for anyone!
    Two epic clairvoyance fails on Bill Gates? Impossible!
  • Pedantic Schmuck (unregistered)
    $page = (int)$_GET['page'];
    Someone needs to brush up on their article previewing skills.
  • Chronomium (unregistered)

    Clearly some hotshot developer figured he could get a buck or two adding a few pages to the system every now and then, not expecting someone to come along and need a ton at once.

  • Smug Unix User (unregistered)

    The code is a bit shortsighted, but in all fairness if the users are paging through more than three pages records they should probably refine their search terms.

  • Dilbertino (unregistered)

    s/paging/pagination/g;

  • QJo (unregistered)

    Rats. And I thought my frist comment saying just "fr" was quite relevant and witty. Shame all frist comments are now automatically purged.

    Never mind, back to reading the remaining boring humourless diatribes.

  • Ad reader (unregistered) in reply to Pedantic Schmuck
    Pedantic Schmuck:
    $page = (int)$_GET['page'];
    Someone needs to brush up on their article previewing skills.

    Turn on javascript you freeloading schmuck

  • anonymous (unregistered)
    <!-- Important dinosaur facts: T-Rex typed with both claws on a one-handed Dvorak layout. All stegosauruses were hunt-and-peck typists. The Archaeopteryx is actually quite an accomplished typist, and was the first species to break the 75wpm barrier. -->
    Made-up dinosaur facts are not really the sort of comment that I enjoy reading on TDWTF.
  • nitePhyyre (unregistered) in reply to anonymous

    Then there is something very wrong with you.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered)

    TRWTF is that they didn't use a switch statement, amirite?

    $page = (int)$_GET['page']; switch($page){   case 1:{$limit = 0;$this_page = 1;$prev = 1;$next = 2;}break;   case 2:{$limit = 25;$this_page = 2;$prev = 1;$next = 3;}break;   case 3:{$limit = 50;$this_page = 3;$prev = 2;$next = 3;}break;   default:{$limit = 0;$this_page = 1;$prev = 1;$next = 2;}break; }

    There you go, much better!

  • doramjan (unregistered)

    THERE ARE FOUR PAGES!

  • YellowOnline (unregistered) in reply to anonymous
    anonymous:
    snoofle:
    75 records should be more than enough for anyone!
    Two epic clairvoyance fails on Bill Gates? Impossible!

    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    Bill Gates:
    I've said some stupid things and some wrong things, but not that. No one involved in computers would ever say that a certain amount of memory is enough for all time.

    [...]

    Meanwhile, I keep bumping into that silly quotation attributed to me that says 640K of memory is enough. There's never a citation; the quotation just floats like a rumor, repeated again and again.

  • F (unregistered) in reply to YellowOnline
    YellowOnline:
    anonymous:
    snoofle:
    75 records should be more than enough for anyone!
    Two epic clairvoyance fails on Bill Gates? Impossible!

    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    Bill Gates:
    I've said some stupid things and some wrong things, but not that. No one involved in computers would ever say that a certain amount of memory is enough for all time.

    [...]

    Meanwhile, I keep bumping into that silly quotation attributed to me that says 640K of memory is enough. There's never a citation; the quotation just floats like a rumor, repeated again and again.

    Of course, we only have your word for it that he ever said that.

  • Pete (unregistered)

    In times of PRISM and TEMPORA, it is very wise to limit the amount of accessible data. So the developer just added his variant of a data protection layer. Why can't you see that???? This was written by a true hero, fighting for your freedom!!!

  • QJo (unregistered) in reply to F
    F:
    YellowOnline:
    anonymous:
    snoofle:
    75 records should be more than enough for anyone!
    Two epic clairvoyance fails on Bill Gates? Impossible!

    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    Bill Gates:
    I've said some stupid things and some wrong things, but not that. No one involved in computers would ever say that a certain amount of memory is enough for all time.

    [...]

    Meanwhile, I keep bumping into that silly quotation attributed to me that says 640K of memory is enough. There's never a citation; the quotation just floats like a rumor, repeated again and again.

    Of course, we only have your word for it that he ever said that.

    More to the point, even if we were to take your word for it that he ever said that, we then have to take his word for it that he never said that.

  • Been There Done That (unregistered) in reply to F
    F:
    YellowOnline:
    anonymous:
    snoofle:
    75 records should be more than enough for anyone!
    Two epic clairvoyance fails on Bill Gates? Impossible!

    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    Bill Gates:
    I've said some stupid things and some wrong things, but not that. No one involved in computers would ever say that a certain amount of memory is enough for all time.

    [...]

    Meanwhile, I keep bumping into that silly quotation attributed to me that says 640K of memory is enough. There's never a citation; the quotation just floats like a rumor, repeated again and again.

    Of course, we only have your word for it that he ever said that.

    He purged the interwebs before he left Microsoft. That NSA stuff that we're hearing about now? His top engineers wrote that initially as a universal search and replace, and tested it by replacing that quote with Ballmer's "developers" rant. Bill had a bit too much Aqua vitae and was feeling frisky when he first turned it on.

  • (cs)

    This is no bug: The users just need to shell out for the Enterprise Edition.

  • (cs) in reply to YellowOnline
    YellowOnline:
    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    More like: 640K is as much as anyone can afford right now.

    You paid $100-$200 for each row of DRAM you installed. I read the computer lab copy of "Creative Computing" every month. The system prices, at a grand or so -- even for the homebrew/hobbyist systems, were a world away for someone who didn't even get an allowance. The business systems, with a VDT and a hard drive or two, were in the next galaxy at 10+ grand.

  • stew (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL

    TRWTF is DRY.

    ¯\(°_o)/¯ I DUNNO LOL:
    switch((int)$_GET['page']){
      case 2: $limit = 25;$this_page = 2;$prev = 1;$next = 3;break;
      case 3: $limit = 50;$this_page = 3;$prev = 2;$next = 3;break;
      default:$limit = 0;$this_page = 1;$prev = 1;$next = 2;break;
    }
    There, FTFY.
  • giesen (unregistered) in reply to doramjan

    Love the TNG "Chain of Command" reference. Picard FTW!

  • (cs) in reply to snoofle
    snoofle:
    75 records should be more than enough for anyone!
    25 records should be more than enough for anyone! The original designers tripled number of records available. Brillant!
  • Chelloveck (unregistered)

    Where's the WTF?

    Bug closed. WORKS PER DESIGN

  • Hannes (unregistered) in reply to YellowOnline
    YellowOnline:
    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    Right or wrong, this is what he always said back in the days!

  • Hexadecima (unregistered) in reply to Kuli

    That's a MySQLism. Selection with a "LIMIT x, y" clause has "x" being the offset and "y" being the number of records to return.

    http://php.about.com/od/mysqlcommands/g/Limit_sql.htm http://dev.mysql.com/doc/refman/5.0/en/select.html

    ...it's perhaps the least illogical thing about this code, despite its general obtuseness.

  • (cs) in reply to Hannes
    Hannes:
    YellowOnline:
    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    Right or wrong, this is what he always said back in the days!

    No. It should be, "Right or wrong, this is what they always quoted him saying, back in the day!"

    Right or wrong precedes something that actually was done. Not something provably never done. Specifically something that has been debated before.

    Right or wrong, people believe in God. Whether she is right or wrong, this is my country.

    Not

    Right or wrong, God exists. Right or wrong, my country invaded mars.

  • (cs) in reply to xaade
    xaade:
    Hannes:
    YellowOnline:
    That he ever said "640K is Enough For Anyone" was debunked so many times already...

    Right or wrong, this is what he always said back in the days!

    No. It should be, "Right or wrong, this is what they always quoted him saying, back in the day!"

    Right or wrong precedes something that actually was done. Not something provably never done. Specifically something that has been debated before.

    Right or wrong, people believe in God. Whether she is right or wrong, this is my country.

    Not

    Right or wrong, God exists. Right or wrong, my country invaded mars.

    Right or wrong, that is what Hannes posted back a few hours ago.

  • Bananas (unregistered)

    The best algorithm is a hard-coded algorithm. No need to worry about what happens when the inputs get too large. Nope, this algorithm is guaranteed to never ever cause the application to crash and burn. Kudos to the developer who wrought this work of art!

  • drummerp (unregistered) in reply to xaade

    Actually, that last one does work -- you just have to interpret "right or wrong" as being a statement of moral ambiguity, not factual accuracy.

  • (cs)

    If you think about how short T-rex arms are, and then look at the keypad on the right side of the keyboard, it's obvious that they couldn't reach the third row. Easy to explain.

  • ratis (unregistered)

    Right or wrong, this is simply how paging was handled back in those days.

    Captcha 'ratis' - I don't give a ratis ass how many records you have, I'm only giving you three pages of data.

  • (cs) in reply to Bananas
    Bananas:
    The best algorithm is a hard-coded algorithm. No need to worry about what happens when the inputs get too large. Nope, this algorithm is guaranteed to never ever cause the application to crash and burn. Kudos to the developer who wrought this work of art!
    So not only is it obtuse, it's also robust.

    It's robustuse!

  • Anomaly (unregistered)

    Please be considerate I had a brother that was largely unscathed in a dramatic paging accident.

    The paper cut took hours to heal! HOURS!

  • (cs) in reply to Steve The Cynic

    And I'm guessing the QA person (there was a QA person, right???) looked at page 1 -- OK; page 2 -- OK; page 3 --OK; Probably works for all pages. Signoff, go on to next task.

    Unfortunately, QA often has limited time, and can't test EVERY page. So this code passes; and no one knows until a customer tries page 4.

  • floating ground (unregistered)

    Maybe limit=0 is supposted to mean unlimited.

  • (cs) in reply to eViLegion
    eViLegion:

    Right or wrong, that is what Hannes posted back a few hours ago.

    And that is the correct way to use it.

  • (cs) in reply to Anomaly
    Anomaly:
    Please be considerate I had a brother that was largely unscathed in a dramatic paging accident.
    ... and it was me!
  • (cs) in reply to DrPepper
    DrPepper:
    And I'm guessing the QA person (there was a QA person, right???) looked at page 1 -- OK; page 2 -- OK; page 3 --OK; Probably works for all pages. Signoff, go on to next task.

    Unfortunately, QA often has limited time, and can't test EVERY page. So this code passes; and no one knows until a customer tries page 4.

    And how would you know it couldn't be more than 4 if your testing environment didn't have more than 75 records.

    And how would QA know on a testing environment with more than 75 records, if QA didn't anticipate stupid and always put some amount of search criteria.

    And how would QA know if they left off search criteria and the result reported no more than 75 entries, if QA wasn't tracking how many entries existed.

    And how would QA know if there wasn't more than 65535 pages?

    Me thinks it's time to add a go to last page feature.

Leave a comment on “The Page at Fault”

Log In or post as a guest

Replying to comment #:

« Return to Article