summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormoshe weitzman2010-03-18 13:11:29 (GMT)
committer moshe weitzman2010-03-18 13:11:29 (GMT)
commitfed8a513581e7984415550e2921555eb2b5085fe (patch)
tree9518720429254731bd6d5643d617ef47afb3c88e
parent8875dcac521e4c15cca0403b1436d1f2b9b09cf1 (diff)
Remove another call to the DONT CALL ME function that is taxonomy_allowed_values()
-rw-r--r--devel_generate/taxonomy.devel_generate.inc21
1 files changed, 13 insertions, 8 deletions
diff --git a/devel_generate/taxonomy.devel_generate.inc b/devel_generate/taxonomy.devel_generate.inc
index eac8be8..8cc68e1 100644
--- a/devel_generate/taxonomy.devel_generate.inc
+++ b/devel_generate/taxonomy.devel_generate.inc
@@ -14,13 +14,18 @@ function _taxonomy_devel_generate($object, $field, $instance, $bundle) {
$object_field = array();
// TODO: For free tagging vocabularies that do not already have terms, this
// will not result in any tags being added.
- $allowed_values = taxonomy_allowed_values($field);
- if (!empty($allowed_values)) {
- // Pick one of the allowed values.
- $object_field['tid'] = array_rand($allowed_values);
- }
- else {
- $object_field['tid'] = 0;
- }
+ // Insert new data:
+ $max = db_query('SELECT MAX(tid) FROM taxonomy_term_data')->fetchField();
+ $candidate = mt_rand(1, $max);
+ $query = db_select('taxonomy_term_data', 't');
+ $query->innerJoin('taxonomy_vocabulary', 'v', 't.vid = v.vid');
+ $tid = $query
+ ->fields('t', array('tid'))
+ ->condition('v.vid', $field['settings']['allowed_values'][0]['vid'], '=')
+ ->condition('t.tid', $candidate, '>=')
+ ->range(0,1)
+ ->execute()
+ ->fetchField();
+ $object_field['tid'] = (int) $tid;
return $object_field;
}