diff --git a/docs/en/04_Changelogs/3.5.7.md b/docs/en/04_Changelogs/3.5.7.md new file mode 100644 index 000000000..0056bdb71 --- /dev/null +++ b/docs/en/04_Changelogs/3.5.7.md @@ -0,0 +1,18 @@ +# 3.5.7 + + + +## Change Log + +### Bugfixes + + * 2018-01-26 [416915b08](https://github.com/silverstripe/silverstripe-framework/commit/416915b08248285083518850ad8d015ca8ed25c2) tableName is blank in CompositeDBField->addToQuery (Dominik Beerbohm) + * 2018-01-25 [cf69d0486](https://github.com/silverstripe/silverstripe-framework/commit/cf69d048665befa90eb43146f86cde984b876b3a) Fix ping including requirements (Damian Mooyman) + * 2018-01-24 [c2cd6b383](https://github.com/silverstripe/silverstripe-framework/commit/c2cd6b3832c6bc4775b2742df593b445c2aca391) Fix Member_GroupSet::removeAll() (fixes #3948) (Loz Calver) + * 2018-01-24 [f2b4c192e](https://github.com/silverstripe/silverstripe-framework/commit/f2b4c192ec4d70779f7c667a976e741a7f3a26c5) Fix UploadField cuts off “Save” button (closes #2862) (Loz Calver) + * 2018-01-23 [7384e3fc2](https://github.com/silverstripe/silverstripe-framework/commit/7384e3fc25987742ea08af74b704857a936e8ec0) Gridfields with dropdowns having lots of overflow (Scott Hutchinson) + * 2017-12-21 [44930f211](https://github.com/silverstripe/silverstripe-framework/commit/44930f211be3f658fc92f2d5318255de03078701) Allow HTML 5 input tags in FunctionalTest form submissions (Daniel Hensby) + * 2017-12-14 [81150c592](https://github.com/silverstripe/silverstripe-framework/commit/81150c59225dbf1e95bb0b4dbcfbe18346f2bdff) Use PHP 5.3 array syntax (Daniel Hensby) + * 2016-10-21 [8e5bb6fbd](https://github.com/silverstripe/silverstripe-framework/commit/8e5bb6fbdce0b2ca2d08a45534df2264db5e6b12) Fix : relObject() should return null if one of the node is null (Jason) + * 2016-03-15 [22b3a71ec](https://github.com/silverstripe/silverstripe-framework/commit/22b3a71ec0c8cd8c38030fa0bf5449abefafe8a3) ing val reference to url in https hotlink (Denise Rivera) + * 2015-04-22 [1f63637b9](https://github.com/silverstripe/silverstripe-framework/commit/1f63637b9369d4644a92523ada5d1a5dc0576c12) for #4095, TinyMCE not able to modify props of embed media (bug 1) and invalid HTML inserted (bug 2) (Patrick Nelson) diff --git a/docs/en/04_Changelogs/3.6.4.md b/docs/en/04_Changelogs/3.6.4.md new file mode 100644 index 000000000..02de9d367 --- /dev/null +++ b/docs/en/04_Changelogs/3.6.4.md @@ -0,0 +1,11 @@ +# 3.6.4 + + + +## Change Log + +### Bugfixes + + * 2018-01-09 [2ef4a2d4e](https://github.com/silverstripe/silverstripe-framework/commit/2ef4a2d4ee86577b00311e65bbeb0439f7aaa1fc) , adding a missing return statement. (Nathan) + * 2017-12-21 [44930f211](https://github.com/silverstripe/silverstripe-framework/commit/44930f211be3f658fc92f2d5318255de03078701) Allow HTML 5 input tags in FunctionalTest form submissions (Daniel Hensby) + * 2017-12-14 [81150c592](https://github.com/silverstripe/silverstripe-framework/commit/81150c59225dbf1e95bb0b4dbcfbe18346f2bdff) Use PHP 5.3 array syntax (Daniel Hensby) diff --git a/docs/en/04_Changelogs/3.6.5.md b/docs/en/04_Changelogs/3.6.5.md new file mode 100644 index 000000000..2683d9e1f --- /dev/null +++ b/docs/en/04_Changelogs/3.6.5.md @@ -0,0 +1,16 @@ +# 3.6.5 + + + +## Change Log + +### Bugfixes + + * 2018-01-26 [416915b08](https://github.com/silverstripe/silverstripe-framework/commit/416915b08248285083518850ad8d015ca8ed25c2) tableName is blank in CompositeDBField->addToQuery (Dominik Beerbohm) + * 2018-01-25 [cf69d0486](https://github.com/silverstripe/silverstripe-framework/commit/cf69d048665befa90eb43146f86cde984b876b3a) Fix ping including requirements (Damian Mooyman) + * 2018-01-24 [c2cd6b383](https://github.com/silverstripe/silverstripe-framework/commit/c2cd6b3832c6bc4775b2742df593b445c2aca391) Fix Member_GroupSet::removeAll() (fixes #3948) (Loz Calver) + * 2018-01-24 [f2b4c192e](https://github.com/silverstripe/silverstripe-framework/commit/f2b4c192ec4d70779f7c667a976e741a7f3a26c5) Fix UploadField cuts off “Save” button (closes #2862) (Loz Calver) + * 2018-01-23 [7384e3fc2](https://github.com/silverstripe/silverstripe-framework/commit/7384e3fc25987742ea08af74b704857a936e8ec0) Gridfields with dropdowns having lots of overflow (Scott Hutchinson) + * 2016-10-21 [8e5bb6fbd](https://github.com/silverstripe/silverstripe-framework/commit/8e5bb6fbdce0b2ca2d08a45534df2264db5e6b12) Fix : relObject() should return null if one of the node is null (Jason) + * 2016-03-15 [22b3a71ec](https://github.com/silverstripe/silverstripe-framework/commit/22b3a71ec0c8cd8c38030fa0bf5449abefafe8a3) ing val reference to url in https hotlink (Denise Rivera) + * 2015-04-22 [1f63637b9](https://github.com/silverstripe/silverstripe-framework/commit/1f63637b9369d4644a92523ada5d1a5dc0576c12) for #4095, TinyMCE not able to modify props of embed media (bug 1) and invalid HTML inserted (bug 2) (Patrick Nelson) diff --git a/src/Forms/GridField/GridFieldExportButton.php b/src/Forms/GridField/GridFieldExportButton.php index c9d65e036..e676cc020 100644 --- a/src/Forms/GridField/GridFieldExportButton.php +++ b/src/Forms/GridField/GridFieldExportButton.php @@ -155,7 +155,7 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP * Generate export fields for CSV. * * @param GridField $gridField - * @return array + * @return string */ public function generateExportFileData($gridField) { @@ -232,7 +232,7 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP // Convert the $fileData array into csv by capturing fputcsv's output $csv = fopen('php://temp', 'r+'); foreach ($fileData as $line) { - fputcsv($csv, $line, $this->csvSeparator, $this->csvEnclosure); + fputcsv($csv, $line, $this->getCsvSeparator(), $this->getCsvEnclosure()); } rewind($csv); return stream_get_contents($csv); diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 712156a18..f8ad2560c 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -2737,8 +2737,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $relations = explode('.', $fieldName); $fieldName = array_pop($relations); foreach ($relations as $relation) { + if (!$component) { + return null; // Inspect $component for element $relation - if ($component->hasMethod($relation)) { + } elseif ($component->hasMethod($relation)) { // Check nested method $component = $component->$relation(); } elseif ($component instanceof SS_List) { diff --git a/src/Security/Member_GroupSet.php b/src/Security/Member_GroupSet.php index 582cd2816..ed5abef80 100644 --- a/src/Security/Member_GroupSet.php +++ b/src/Security/Member_GroupSet.php @@ -5,6 +5,7 @@ namespace SilverStripe\Security; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; use SilverStripe\ORM\ManyManyList; +use SilverStripe\ORM\Queries\SQLDelete; use SilverStripe\ORM\Queries\SQLSelect; /** @@ -85,6 +86,36 @@ class Member_GroupSet extends ManyManyList } } + public function removeAll() + { + // Remove the join to the join table to avoid MySQL row locking issues. + $query = $this->dataQuery(); + $foreignFilter = $query->getQueryParam('Foreign.Filter'); + $query->removeFilterOn($foreignFilter); + + // Select ID column + $selectQuery = $query->query(); + $dataClassIDColumn = DataObject::getSchema()->sqlColumnForField($this->dataClass(), 'ID'); + $selectQuery->setSelect($dataClassIDColumn); + + $from = $selectQuery->getFrom(); + unset($from[$this->joinTable]); + $selectQuery->setFrom($from); + $selectQuery->setOrderBy(); // ORDER BY in subselects breaks MS SQL Server and is not necessary here + $selectQuery->setDistinct(false); + + // Use a sub-query as SQLite does not support setting delete targets in + // joined queries. + $delete = new SQLDelete(); + $delete->setFrom("\"{$this->joinTable}\""); + $delete->addWhere(parent::foreignIDFilter()); + $subSelect = $selectQuery->sql($parameters); + $delete->addWhere(array( + "\"{$this->joinTable}\".\"{$this->localKey}\" IN ($subSelect)" => $parameters + )); + $delete->execute(); + } + /** * Determine if the following groups IDs can be added * diff --git a/src/Security/Security.php b/src/Security/Security.php index f40a5a4c5..78ccfa8f3 100644 --- a/src/Security/Security.php +++ b/src/Security/Security.php @@ -25,6 +25,7 @@ use SilverStripe\ORM\FieldType\DBField; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\ORM\ValidationResult; use SilverStripe\View\ArrayData; +use SilverStripe\View\Requirements; use SilverStripe\View\SSViewer; use SilverStripe\View\TemplateGlobalProvider; @@ -471,6 +472,7 @@ class Security extends Controller implements TemplateGlobalProvider */ public function ping() { + Requirements::clear(); return 1; } diff --git a/tests/php/Security/MemberTest.php b/tests/php/Security/MemberTest.php index e9b649ac9..6d8c5694d 100644 --- a/tests/php/Security/MemberTest.php +++ b/tests/php/Security/MemberTest.php @@ -411,6 +411,35 @@ class MemberTest extends FunctionalTest ); } + /** + * Assertions to check that Member_GroupSet is functionally equivalent to ManyManyList + */ + public function testRemoveGroups() + { + $staffmember = $this->objFromFixture(Member::class, 'staffmember'); + + $staffgroup = $this->objFromFixture(Group::class, 'staffgroup'); + $managementgroup = $this->objFromFixture(Group::class, 'managementgroup'); + + $this->assertTrue( + $staffmember->inGroups(array($staffgroup, $managementgroup)), + 'inGroups() succeeds if a membership is detected on one of many passed groups' + ); + + $staffmember->Groups()->remove($managementgroup); + $this->assertFalse( + $staffmember->inGroup($managementgroup), + 'member was not removed from group using ->Groups()->remove()' + ); + + $staffmember->Groups()->removeAll(); + $this->assertCount( + 0, + $staffmember->Groups(), + 'member was not removed from all groups using ->Groups()->removeAll()' + ); + } + public function testAddToGroupByCode() { /** @var Member $grouplessMember */