BUG Error setting options

When setting options that have a NULL value by default (such as imageFieldName) the setConfig function would incorrectly assume the option was not available and would silently ignore.

This fix implements a correct option validation mechanism, and throws an error if an incorrect option assignment is attempted.
This commit is contained in:
Damian Mooyman 2012-11-23 15:09:11 +13:00
parent 834d7466e7
commit 447ab87601

View File

@ -53,8 +53,10 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
*/
function setConfig ( $reference, $value )
{
if ( isset( $this->config[$reference] ) )
{
if (!key_exists($reference, $this->config) ) {
user_error("Unknown option reference: $reference", E_USER_ERROR);
}
if ( ($reference == 'fieldsClassBlacklist' || $reference == 'fieldsClassBlacklist' || $reference == 'editableFields') && !is_array($value) )
{
$value = array($value);
@ -68,7 +70,6 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
$this->config[$reference] = $value;
}
}
/**
* Returns one $config parameter of the full $config