default userpic

Bug in php/lib/mtdb_base.php line 229 - list() causes only first result in a array to be returned

Vote 0 Votes

227 function fetch_config() {
228 $sql = "select * from mt_config";
229 list($row) = $this->get_results($sql, ARRAY_A);
230 if (!$row) return null;
231 return $row;
232 }

the use of list here is problematic if the desire is to return multiple rows of config values from the mt_config table. In a multirow result list() will only grab the results in the first array it encounters.

its not clear to me the design of mt_config because MT is stuffing all config values into one row (seems to defeat the point of using a table). since its a table I would assume mutliple rows is the intent (no matter what the MT kernel is doing with the base config values), and thus this function seems broken.

the fix is obvious, iterate over the returned hash and merge the results (pretty nasty results, but its what the caller would expect at least).

Though I have not installed any of the 5beta branches it seems like those will have a similar problem as the code still doesnt look for multiple rows returned - tho that code doesnt seem to make sense to me at all since I dont see where Load learns to select from mt_config, the table is not passed in a class.mt_config.php Load function, which is what I would have expected looking at that code.

Reported on Movable Type 4.25

1 Reply

| Add a Reply

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1264 4146

Last Topic: HTML Table query by Parag on Mar 18, 2010

64 196

Last Topic: movable type 5 custom fields by kljx on Mar 17, 2010

1006 3224

Last Topic: When will MT v5.02 be Released? by Jim S. on Mar 18, 2010

483 1984

Last Topic: I have upgraded and I cant login! by Aleksandar on Mar 18, 2010

19 69

Last Topic: Custom main index page by Richard on Feb 7, 2010

11 22

Last Topic: Monthly Calendars Help Needed by joe leblanc on Jan 19, 2010

91 326

Last Topic: SpamLookup Keyword Filter 2.1 not work by b.n09 on Nov 17, 2009

55 206

Last Topic: URL Problems by NoSnaiL on Mar 17, 2010

code.sixapart.com

129 449

Last Topic: Action Stream for Google Buzz by jack lail on Feb 16, 2010