Skip to content

Commit

Permalink
Merge pull request #7701 from open-sausages/pulls/4.0/better-summary-…
Browse files Browse the repository at this point in the history
…merging

 BUG Fix incorrect merge of associative / non-associative summary fields
  • Loading branch information
dhensby committed Dec 14, 2017
2 parents a2fa9f0 + 1c8576c commit 7733e9c
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 112 deletions.
12 changes: 6 additions & 6 deletions src/Core/Injector/Injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,13 @@ public function load($config = array())
// to ensure we get cached
$spec['id'] = $id;

// We've removed this check because new functionality means that the 'class' field doesn't need to refer
// specifically to a class anymore - it could be a compound statement, ala SilverStripe's old Object::create
// functionality
// We've removed this check because new functionality means that the 'class' field doesn't need to refer
// specifically to a class anymore - it could be a compound statement, ala SilverStripe's old Object::create
// functionality
//
// if (!class_exists($class)) {
// throw new Exception("Failed to load '$class' from $file");
// }
// if (!class_exists($class)) {
// throw new Exception("Failed to load '$class' from $file");
// }

// store the specs for now - we lazy load on demand later on.
$this->specs[$id] = $spec;
Expand Down
10 changes: 5 additions & 5 deletions src/Dev/BulkLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ public function __construct($objectClass)
}

/*
* Load the given file via {@link self::processAll()} and {@link self::processRecord()}.
* Optionally truncates (clear) the table before it imports.
*
* @return BulkLoader_Result See {@link self::processAll()}
*/
* Load the given file via {@link self::processAll()} and {@link self::processRecord()}.
* Optionally truncates (clear) the table before it imports.
*
* @return BulkLoader_Result See {@link self::processAll()}
*/
public function load($filepath)
{
Environment::increaseTimeLimitTo(3600);
Expand Down
8 changes: 4 additions & 4 deletions src/Dev/DevelopmentAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public function runRegisteredController(HTTPRequest $request)


/*
* Internal methods
*/
* Internal methods
*/

/**
* @return array of url => description
Expand Down Expand Up @@ -175,8 +175,8 @@ protected function getRegisteredController($baseUrlPart)


/*
* Unregistered (hidden) actions
*/
* Unregistered (hidden) actions
*/

/**
* Build the default data, calling requireDefaultRecords on all
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/FieldList.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public function changeFieldOrder($fieldNames)
$fieldMap[$field->getName()] = $field;
}

// Iterate through the ordered list of names, building a new array to be put into $this->items.
// Iterate through the ordered list of names, building a new array to be put into $this->items.
// While we're doing this, empty out $fieldMap so that we can keep track of leftovers.
// Unrecognised field names are okay; just ignore them
$fields = array();
Expand Down
24 changes: 12 additions & 12 deletions src/ORM/Connect/DBSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -890,13 +890,13 @@ abstract public function enumValuesForField($tableName, $fieldName);


/*
* This is a lookup table for data types.
* For instance, Postgres uses 'INT', while MySQL uses 'UNSIGNED'
* So this is a DB-specific list of equivilents.
*
* @param string $type
* @return string
*/
* This is a lookup table for data types.
* For instance, Postgres uses 'INT', while MySQL uses 'UNSIGNED'
* So this is a DB-specific list of equivilents.
*
* @param string $type
* @return string
*/
abstract public function dbDataType($type);

/**
Expand Down Expand Up @@ -1151,10 +1151,10 @@ abstract public function time($values);
abstract public function varchar($values);

/*
* Returns data type for 'year' column
*
* @param array $values Contains a tokenised list of info about this data type
* @return string
*/
* Returns data type for 'year' column
*
* @param array $values Contains a tokenised list of info about this data type
* @return string
*/
abstract public function year($values);
}
16 changes: 8 additions & 8 deletions src/ORM/Connect/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,14 @@ public function withTransaction(
}

/*
* Determines if the current database connection supports a given list of extensions
*
* @param array $extensions List of extensions to check for support of. The key of this array
* will be an extension name, and the value the configuration for that extension. This
* could be one of partitions, tablespaces, or clustering
* @return boolean Flag indicating support for all of the above
* @todo Write test cases
*/
* Determines if the current database connection supports a given list of extensions
*
* @param array $extensions List of extensions to check for support of. The key of this array
* will be an extension name, and the value the configuration for that extension. This
* could be one of partitions, tablespaces, or clustering
* @return boolean Flag indicating support for all of the above
* @todo Write test cases
*/
public function supportsExtensions($extensions)
{
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/ORM/Connect/MySQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,11 @@ public function varchar($values)
}

/*
* Return the MySQL-proprietary 'Year' datatype
*
* @param array $values Contains a tokenised list of info about this data type
* @return string
*/
* Return the MySQL-proprietary 'Year' datatype
*
* @param array $values Contains a tokenised list of info about this data type
* @return string
*/
public function year($values)
{
return 'year(4)';
Expand Down
17 changes: 10 additions & 7 deletions src/ORM/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3337,12 +3337,15 @@ public function fieldLabel($name)
*/
public function summaryFields()
{
$fields = $this->config()->get('summary_fields');
$rawFields = $this->config()->get('summary_fields');

// if fields were passed in numeric array,
// convert to an associative array
if ($fields && array_key_exists(0, $fields)) {
$fields = array_combine(array_values($fields), array_values($fields));
// Merge associative / numeric keys
$fields = [];
foreach ($rawFields as $key => $value) {
if (is_int($key)) {
$key = $value;
}
$fields[$key] = $value;
}

if (!$fields) {
Expand Down Expand Up @@ -3418,8 +3421,8 @@ public function isInDB()
}

/*
* @ignore
*/
* @ignore
*/
private static $subclass_access = true;

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/behat/src/CmsFormsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ public function iClickOnTheHtmlFieldButton($button)
}

/*
* @example Given the CMS settings has the following data
* | Title | My site title |
* | Theme | My site theme |
* @Given /^the CMS settings have the following data$/
*/
* @example Given the CMS settings has the following data
* | Title | My site title |
* | Theme | My site theme |
* @Given /^the CMS settings have the following data$/
*/
public function theCmsSettingsHasData(TableNode $fieldsTable)
{
$fields = $fieldsTable->getRowsHash();
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Control/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ public function testHasAction()
'Numeric actions do not slip through.'
);
//$this->assertFalse(
// $controller->hasAction('lowercase_permission'),
// 'Lowercase permission does not slip through.'
// $controller->hasAction('lowercase_permission'),
// 'Lowercase permission does not slip through.'
//);
$this->assertFalse(
$controller->hasAction('undefined'),
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Dev/CsvBulkLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function testLoadWithIdentifiers()

// null values are valid imported
// $this->assertEquals($player->Biography, 'He\'s a good guy',
// 'Test retaining of previous information on duplicate when overwriting with blank field');
// 'Test retaining of previous information on duplicate when overwriting with blank field');
}

public function testLoadWithCustomImportMethods()
Expand Down
10 changes: 5 additions & 5 deletions tests/php/Forms/ListboxFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ public function testValidationWithDataList()
* @todo re-enable these tests when field validation is removed from {@link ListboxField::setValue()} and moved
* to the {@link ListboxField::validate()} function
*/
// $field->setValue(4);
// $this->assertFalse(
// $field->validate($validator),
// 'Field does not validate values outside of source map'
// );
// $field->setValue(4);
// $this->assertFalse(
// $field->validate($validator),
// 'Field does not validate values outside of source map'
// );
$field->setValue(
false,
new ArrayData(
Expand Down
Loading

0 comments on commit 7733e9c

Please sign in to comment.