tasfe / silverstripe-ecommerce

Automatically exported from code.google.com/p/silverstripe-ecommerce
0 stars 0 forks source link

Many config functions cause "must be an instance of..." errors #198

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Quite a number of configuration functions (e.g., 
EcommerceCountry::set_auto_add_countries()) result in "must be an instance 
of..." errors. For example, EcommerceCountry::set_auto_add_countries(true); 
results in the following error:
Catchable fatal error: Argument 1 passed to 
EcommerceCountry::set_auto_add_countries() must be an instance of boolean, 
boolean given, called in C:\wamp\www\mysite\_config.php on line 86 and defined 
in C:\wamp\www\ecommerce\code\model\address\EcommerceCountry.php on line 25

The reason for this is that an attempt has been made to specify the type, but 
this is only possible for objects, not for elementary data types such as 
booleans, integers, floats, or strings. So, these type specifications need to 
be removed.

NOTES:
- This was tested with PHP 5.3.8. 
- This was with the latest SVN code

Original issue reported on code.google.com by hjr29s...@gmail.com on 19 Jan 2012 at 3:17

GoogleCodeExporter commented 9 years ago
this was my fault (nicolaas).  I have fixed this in the SSU branch.  It seems a 
bit strange in PHP that it does not work... 

Original comment by nfranc...@gmail.com on 19 Jan 2012 at 11:14

GoogleCodeExporter commented 9 years ago
to preview the SSU Branch, go to: www.silverstripe-ecommerce.com

Original comment by nfranc...@gmail.com on 19 Jan 2012 at 11:21

GoogleCodeExporter commented 9 years ago
Coming from a C/C++ background, I also find it strange that it works for 
classes but not fundamental datatypes. It lacks consistency, not to mention 
that it would be useful to specify the required parameter types in all cases. 

Anyway, I just switched to the SSU branch, and you missed a few of them:

Catchable fatal error: Argument 1 passed to 
Order::set_maximum_ignorable_sales_payments_difference() must be an instance of 
float, double given, called in C:\wamp\www\mysite\_config.php on line 84 and 
defined in C:\wamp\www\ecommerce\code\model\Order.php on line 204

Catchable fatal error: Argument 1 passed to ExpiryDateField::set_short_months() 
must be an instance of boolean, boolean given, called in 
C:\wamp\www\mysite\_config.php on line 88 and defined in 
C:\wamp\www\ecommerce\code\forms\fields\ExpiryDateField.php on line 18

Catchable fatal error: Argument 1 passed to 
EcommerceRole::set_customer_group_name() must be an instance of string, string 
given, called in C:\wamp\www\mysite\_config.php on line 97 and defined in 
C:\wamp\www\ecommerce\code\dod\EcommerceRole.php on line 52

Catchable fatal error: Argument 1 passed to 
EcommerceRole::set_admin_group_name() must be an instance of string, string 
given, called in C:\wamp\www\mysite\_config.php on line 98 and defined in 
C:\wamp\www\ecommerce\code\dod\EcommerceRole.php on line 87

These were found by using the commented out code in ecommerce/_config.php which 
the documentation says should be copied to mysite/_config.php. This example 
configuration is clearly out-of-date (including some methods which don't even 
exist any more).

Original comment by hjr29s...@gmail.com on 19 Jan 2012 at 10:54

GoogleCodeExporter commented 9 years ago
I have just committed a fix for both issues (r 2018).  THANK YOU SO MUCH for 
reporting this.  Over the next month or so I will further clean up the _config 
options, perhaps moving a few more to the siteconfig so that they can be set 
within the CMS.

Original comment by nfranc...@gmail.com on 19 Jan 2012 at 11:37

GoogleCodeExporter commented 9 years ago

Original comment by nfranc...@gmail.com on 6 Apr 2012 at 12:19