function filedepottest_selectRandomFolder in filedepot 6
1 call to filedepottest_selectRandomFolder()
File
- ./
lib-test.php, line 100 - lib-test.php Test code that will only be used to create test folders and files for load testing
Code
function filedepottest_selectRandomFolder($tries = 0) {
global $parent_folders, $_foldersCreated, $_maxrecordsperfolder;
if ($tries > 100) {
return 0;
}
// only try 100 times and then abort
$cid = db_result(db_query_range("SELECT cid from {filedepot_categories} WHERE pid in ({$parent_folders}) ORDER BY RAND()", array(), 0, 1));
if ($cid > 0 and $_foldersCreated[$cid] >= $_maxrecordsperfolder) {
watchdog('filedepot', "Max records @maxrecords for folder: @cid", array(
'@maxrecords' => $_maxrecordsperfolder,
'@cid' => $cid,
));
$tries++;
$cid = filedepottest_selectRandomFolder($tries);
if ($cid == 0) {
drupal_set_message('error', 'create_testrecords: abort. Max attempts to find a folder with less then @maxrecordsperfolder exceeded.', array(
'@maxrecordsperfolder' => $_maxrecordsperfolder,
));
die;
}
}
return $cid;
}