Hi

I have installed the latest dev version of commerce kickstart but whenever i want to edit an order i got this message:

Fatal error: Class name must be a valid object or a string in E:\xampp\htdocs\dhl\includes\common.inc on line 7894

I tried the same operation on another site using commerce kickstart dev version but there is no problem in it

I have this module installed in my site: cck phone,commerce stock,field validation,fivestar,userpoints,votingapi

So what could be the reason for this error? and how fix it?

Comments

bojanz’s picture

Status:Active» Fixed

The error is too generic for me to be able to debug it.
I was unable to reproduce it on multiple installs.

If you find a solution, let us know.

web.dev1337’s picture

Hello, I too have the same problem when trying to edit an order. - but I'm not using commerce kickstart but just drupal commerce.

I get:
Fatal error: Class name must be a valid object or a string in /var/www/vhosts/****/****/****/includes/common.inc on line 7749.

please check my pm for my site details.

web.dev1337’s picture

Fixed - there is a bug somewhere, installed the "commerce coupon" module

mbasfour’s picture

I discovered the reason behind this error message it seems that i have to enable the commerce discount module for the order editing page to work because the site using a controller class from this module despite that this module is enabled or not i think this problem is caused by one of the commerce kickstart custom modules

mbasfour’s picture

Category:support» bug
Status:Fixed» Active

I think it's better to reopen this issue as a bug report so it could be fixed in the next dev version of commerce kickstart

polmaresma’s picture

#4 works for me. Reenabling DISCOUNTS make this work again.

jsacksick’s picture

Project:Commerce Kickstart» Commerce Coupon
Version:7.x-2.x-dev» 7.x-1.x-dev

This issue is coming from the commerce_coupon module, this module adds a commerce_coupon_order_reference_field on the order that is deleted on hook_uninstall()..
This means that if you use drush to disable commerce_coupon using the drush dis command, the hook_uninstall won't be fired, the field will remain, but the entity commerce_coupon is no longer declared.
This could be fixed by implementing a hook_disable() instead.

mbasfour’s picture

i didn't install the commerce coupon module on my site so it's impossible that this problem could be from this module

pcambra’s picture

I think we're sharing the pain in commerce coupon and commerce discount
http://drupalcode.org/project/commerce_discount.git/blob/refs/heads/7.x-...

pcambra’s picture

I've opened this issue in Entity Reference to improve the check on disabled entities.

#1940540: Don't load the widget form if the entity type referenced doesn't exist

corbin’s picture

#4 and #10 do not work for me

Trying to get property of non-object in commerce_coupon_commerce_cart_order_refresh() (line 1077 in /.../www/sites/all/modules/commerce_coupon/commerce_coupon.module).
EntityMetadataWrapperException : Unable to get the data property commerce_unit_price as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 442 in /.../www/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.wrapper.inc).

Moreover, trying to desactivate commerce coupon (and UI and ... the other one : i had also commerce_coupon_pct-7.x-1.0-beta7), when editing a command, i got:

Fatal error: Class name must be a valid object or a string in /.../www/includes/common.inc on line 7749

i had to uninstall them

pcambra’s picture

corbin, your error is completely unrelated as it's referring to commerce_unit_price and we're dealing with entity reference in this issue.

corbin’s picture

!?!?

Error message when trying to edit an order

Fatal error: Class name must be a valid object or a string in....

didn't i read this at the beginning of the post ?

and also

This issue is coming from the commerce_coupon module

??

pcambra’s picture

!?!?

Don't speak Qbert, sorry ;)

The output error might be the same, but your error is coming from a very different place and may or may not be related to commerce coupon.

You're getting

EntityMetadataWrapperException : Unable to get the data property commerce_unit_price

That's something related with your line item structure.

corbin’s picture

uninstalling coupon chance makes things well : no more problem now

dianikol’s picture

I'm using the latest version. For me the error comes from commerce discount. I had to enable it in order to add or edit an order.

x1d’s picture

Same error. Enabling commerce discount fix it.

corbin’s picture

commerce discount was activated and it was not fixed

varuntaliyan’s picture

I was getting the same issue and Enabling "Commerce Discount" fixed it for me.

zpolgar’s picture

I was the same probleme, ens commerce discont really fixed.
My problem that I use Commerce sale price, because i have different discount / product, but sale price and commerce discount usage one time give me a database error.

Maybe there is a relationship between order and discount.

pcambra’s picture

Status:Active» Postponed (maintainer needs more info)

The solution for the entity reference fields is in #10 already, not much that we can do.

My suggestion if the error it's NOT related to entity reference field is to install commerce coupon using simplytest me or a default install in a dev box and compare what fields are missing for you, I can't reproduce this problem outside entity reference context (that's what the fix in #10 is for) in a consistent way, so I'm marking this as need more info until someone can provide it.

pcambra’s picture

Status:Postponed (maintainer needs more info)» Fixed

Just got the patch in #10 committed into Entity Reference
http://drupalcode.org/project/entityreference.git/commit/1c176da

Please update to the latest ER development version and try again, if you still get the error, open a new issue with details to reproduce the problem.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rphillipsfeynman’s picture

Priority:Normal» Critical
Status:Closed (fixed)» Active

I still have this problem. I have Commerce Discount enabled and installed the last version with the patch in #10 applied. Nothing changed.

pcambra’s picture

Status:Active» Closed (fixed)

Please post a new issue with more details about your error on it.

rphillipsfeynman’s picture

pcambra’s picture

I need the error you're getting, but please, in another issue, let's keep this one alone.

rphillipsfeynman’s picture

Done.

fordp86’s picture

I seem to have a resolution. It works for me at least. Instead of disabling discount just disable the other discount modules discount ui and discount date if you don't want to use discounts and it should work. I was getting an error when adding to cart so I disabled discount and then I got an error editing orders which is fixed when enabling discounts. So I went half way and it seems to work.

freefuelforever’s picture

Anything that interacts with the order data seems to be clashing and causing the error. Both discount and coupon modules being enabled and disabled, probably without running the update script, seem to be related to the error.

Commerce discount gives errors when enabling and disabling, says

FieldException: Attempt to create an instance of field commerce_discount_offer on bundle order_discount that already has an instance of that field. in field_create_instance()

Coupon and discount modules are both causing this.

freefuelforever’s picture

Issue summary:View changes

Remove the blockquote

Peter van den Heuvel’s picture

I got the same error.

For me the solutions was installing Drupal Commerce Coupon, and enable it. Although I don't even use it on the site. Weird, weird.

Max_Headroom’s picture

This worked for me:
Do not just disable Commerce Coupon. Uninstall it as well at /admin/modules/uninstall

drifter’s picture

Yes, same thing with Commerce Discount: needed to uninstall it after disabling it.

dvandusen’s picture

While this issue has been closed, it may have been closed only because the bug could not be tracked down. It needs review, as no fix was actually seen in the thread, and the issue still is apparent.

This issue has been raised and closed (without repair) a huge number of times (more than 50 that I can see). It is, admittedly, a tough one to find. Please fix the issue. I have tracked down the actual cause, but the intricacies of the cache are a bit beyond me.

Clearing the cache could help here. Sadly, you can't always get there, largely because drush cc will also blow up when this error is occurring. So will anything having to do with accessing a user (in my case). . Requiring a user to clear the cache every time this occurs is improper by its nature - you can't have a user do a workaround as a normal course of business.

This is the tip of the iceberg on this problem. (the PHP Fatal error: Class name must be a valid object or a string in /includes/common.inc on line 7522).

[[[[in 7.28, at line 7855, 6 = ]]]]
$class = $type_info['controller class'];
$controllers[$entity_type] = new $class($entity_type);

The symptom appears because the search for the element ['controller class'] is presumed to be successful. It is not, and no secondary message (such as in a try / catch or an actual test here) is generated.

The issue stems from, for whatever reason, not being able to obtain a $class value from the $type_info array by executing module_invoke_all('entity_info'). Certainly a call time pass by reference could do it, but that would normally be caught. The actual problem is in /includes/common.inc at 7644.

if (empty($entity_info)) {
if ($cache = cache_get("entity_info:$langcode")) {
$entity_info = $cache->data;
}
else {
$entity_info = module_invoke_all('entity_info');
// Merge in default values.
foreach ($entity_info as $name => $data) {
$entity_info[$name] += array(
'fieldable' => FALSE,
'controller class' => 'DrupalDefaultEntityController',
'static cache' => TRUE,
'field cache' => TRUE,
'load hook' => $name . '_load',
'bundles' => array(),
'view modes' => array(),
'entity keys' => array(),
'translation' => array(),
);
$entity_info[$name]['entity keys'] += array(
'revision' => '',
'bundle' => '',
);
foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) {
$entity_info[$name]['view modes'][$view_mode] += array(
'custom settings' => FALSE,
);
}
// If no bundle key is provided, assume a single bundle, named after
// the entity type.
if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
$entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label']));
}
// Prepare entity schema fields SQL info for
// DrupalEntityControllerInterface::buildQuery().
if (isset($entity_info[$name]['base table'])) {
$entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']);
if (isset($entity_info[$name]['revision table'])) {
$entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']);
}
}
}
// Let other modules alter the entity info.
drupal_alter('entity_info', $entity_info);
cache_set("entity_info:$langcode", $entity_info);
}
}

Notice that if the condition is true in the if at

if ($cache = cache_get("entity_info:$langcode")) {
$entity_info = $cache->data;
}

then the module_invoke_all('entity_info') is never executed.
It just happens that the condition is always met after some other processing is done to create the cache. That means that there is no way to get the entity_info set up --- in my case there was no way to obtain the 'user' entity info, causing the original error above. I made the 'else' one level higher (took out the 'else {}') for testing, and everything worked as it should to clear the error.

I believe that the real bug is that the checking of cache is less than adequate, and that a check on the existence of the entity_info about the specific entity being searched for is needed. In fact, it may be justifiable to also search for the element ['controller class'] for that entity in the entity_info stored in cache.
D