Makoto Posted March 17, 2019 Posted March 17, 2019 There's an issue with the Db table helper where if your table has filters that can return zero results, it will return an error on ajax requests due to an underflow exception and does not change the table results at all (while the correct behavior is to indicate there are no results). I attached a patch that resolves this issue by running a try/catch statement before iterating over the select results. DbEmptyFilter.patch Let me know if you need me to elaborate on the issue/fix.
bfarber Posted March 18, 2019 Posted March 18, 2019 I don't understand your patch. Calling foreach against an iterator that has no results should never result in an UnderflowException (that occurs when calling ->first() against a select object with no results). I set up this example script to test and did not get any UnderflowException thrown: <?php require 'init.php'; \IPS\Dispatcher\External::i(); $iterator = \IPS\Db::i()->select( '*', 'core_members', array( 'member_id > ?', 999999 ) ); foreach( $iterator as $row ) { var_dump($row); } die( "No exception" ); Is there a way to test the issue you ran into in the core software? I mean, I regularly adjust filters and end up with no results in table helper instances, so I'm not clear on why you'd be seeing anything different.
Makoto Posted March 18, 2019 Author Posted March 18, 2019 My bad, this is why I shouldn't report bugs after 24 hours with no sleep. It was a third-party issue. Wasn't the foreach throwing the exception, was a call to first() in a custom table helper class I was working on that I.. just happened to fix at the same time, so I thought that was the issue. Should have tested further. Sorry for wasting your time >_>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.