#include "__whilerow.h" #include "Exception.h" #include "__mysql.h" #include namespace jet { __whilerow::__whilerow(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) { // A bare (no count= attribute at all - the overwhelming // majority of real usage: modular1_patches.page, account.page, // task.page, project.page, editinvoice.page, musicianhome.page, // invoice.method, modular1_1_preset_admin.page) used to default // count to 0 - keywords["count"] auto-vivifies an empty string for // a missing attribute, and "".asInteger() is 0 - which made the // loop's own (count != 0) condition false on the very first check, // before hasRow() was ever even consulted. Every one of those // pages' row-based content silently rendered nothing, for every // request, this entire session - never caught because nothing // that exercised a bare with real row data also had its // actual rendered output inspected until now. count= is meant as // an OPTIONAL cap ("show at most N rows"); absent, it must mean // unlimited, not zero - -1 as a sentinel keeps working with the // existing (count != 0) loop test forever (decrementing through // negative numbers never hits 0), letting hasRow() alone decide // when the loop ends, exactly as bare usage always intended. int count = keywordDefined("count") ? keywords["count"].asInteger() : -1; __mysql *session = global.getSession(resolveKeyword("sessionid")); while((count != 0) && session->hasRow()) { processContainer(container); container.reset(); session->nextRow(); --count; } } }