← Back to team overview

anewt-developers team mailing list archive

[Branch ~uws/anewt/anewt.uws] Rev 1787: [autorecord] Correctly handle empty lists in db_find_*_by_id

 

------------------------------------------------------------
revno: 1787
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt
timestamp: Sat 2010-10-02 15:02:32 +0200
message:
  [autorecord] Correctly handle empty lists in db_find_*_by_id
  
  ...instead of crashing for no good reason. Just return an
  empty list in case no values were supplied.
modified:
  autorecord/autorecord.lib.php


--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws

Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription
=== modified file 'autorecord/autorecord.lib.php'
--- autorecord/autorecord.lib.php	2010-02-15 23:50:48 +0000
+++ autorecord/autorecord.lib.php	2010-10-02 13:02:32 +0000
@@ -150,7 +150,7 @@
 		$methods['db_find_all_by_id'] =
 			'final public static function db_find_all_by_id($values=array())
 			{
-				assert(\'is_numeric_array($values) && $values\');
+				assert(\'is_numeric_array($values)\');
 				return AnewtAutoRecord::_db_find_by_id(\'@@CLASS@@\', false, $values, @@CLASS@@::db_connection());
 			}';
 
@@ -755,7 +755,10 @@
 	 */
 	final protected static function _db_find_by_id($class, $just_one_result, $values, $connection)
 	{
-		assert('is_numeric_array($values) && $values;');
+		assert('is_numeric_array($values);');
+
+		if (!$values)
+			return array();
 
 		$columns = call_user_func(array($class, 'db_columns'));
 		$primary_key_column = call_user_func(array($class, 'db_primary_key_column'));