I'm getting a PHP fatal error whenever I try to use taxonomy_term_save(). I am using it in an install script which may be pertinent information.
PHP Fatal error: Class name must be a valid object or a string in /var/www/proface.com/includes/common.inc on line 7779, referer: http://domain/install.php?profile=company_install_profile&locale=en&op=start&id=1
Why would this happen? The terms look correct to me:
$terms = array();
drupal_load('module', 'taxonomy');
$vocabulary = taxonomy_vocabulary_machine_name_load('distributor_types');
$term = new stdClass();
$term->name = "Platinum Distributors";
$term->description = '';
$term->vid = $vocabulary->vid;
$term->weight = 0;
$term->vocabulary_machine_name = 'distributor_types';
$term->format = 'plain_text';
$term->uuid = 'ee4e4f18-ad5e-46df-a2e7-145876efd907';
$terms[] = $term;
Pulled out each of the terms from a foreach loop and...
taxonomy_term_save($term);
And when I print out the entity name that is causing problems, it spits out, "taxonomy_vocabulary".
This is the function throwing the error, the line with "new $class($entity_type)" is line 7779.
function entity_get_controller($entity_type) {
$controllers = &drupal_static(__FUNCTION__, array());
if (!isset($controllers[$entity_type])) {
$type_info = entity_get_info($entity_type);
$class = $type_info['controller class'];
$controllers[$entity_type] = new $class($entity_type);
}
return $controllers[$entity_type];
}
I believe the version for this is 7.22.