mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge branch '4.1' into 4.2
This commit is contained in:
commit
94bbbc0954
@ -23,8 +23,9 @@ before_script:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit --coverage-clover coverage.clover userforms/tests
|
- vendor/bin/phpunit --coverage-clover coverage.clover userforms/tests
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- mv coverage.clover ~/build/$TRAVIS_REPO_SLUG/
|
||||||
|
- cd ~/build/$TRAVIS_REPO_SLUG
|
||||||
- wget https://scrutinizer-ci.com/ocular.phar
|
- wget https://scrutinizer-ci.com/ocular.phar
|
||||||
- cd ./userforms
|
|
||||||
- git remote rm origin
|
|
||||||
- git remote add origin git@github.com:silverstripe/silverstripe-userforms.git
|
|
||||||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
||||||
|
@ -142,18 +142,32 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
*/
|
*/
|
||||||
public function onAfterPublish($original)
|
public function onAfterPublish($original)
|
||||||
{
|
{
|
||||||
// Remove fields on the live table which could have been orphaned.
|
// store IDs of fields we've published
|
||||||
$live = Versioned::get_by_stage("EditableFormField", "Live")
|
$seenIDs = array();
|
||||||
->filter('ParentID', $original->ID);
|
|
||||||
|
|
||||||
if ($live) {
|
|
||||||
foreach ($live as $field) {
|
|
||||||
$field->doDeleteFromStage('Live');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->owner->Fields() as $field) {
|
foreach ($this->owner->Fields() as $field) {
|
||||||
|
// store any IDs of fields we publish so we don't unpublish them
|
||||||
|
$seenIDs[] = $field->ID;
|
||||||
$field->doPublish('Stage', 'Live');
|
$field->doPublish('Stage', 'Live');
|
||||||
|
$field->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetch any orphaned live records
|
||||||
|
$live = Versioned::get_by_stage("EditableFormField", "Live")
|
||||||
|
->filter(array(
|
||||||
|
'ParentID' => $original->ID,
|
||||||
|
));
|
||||||
|
|
||||||
|
if (!empty($seenIDs)) {
|
||||||
|
$live = $live->exclude(array(
|
||||||
|
'ID' => $seenIDs,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete orphaned records
|
||||||
|
foreach ($live as $field) {
|
||||||
|
$field->doDeleteFromStage('Live');
|
||||||
|
$field->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,14 +83,14 @@ class EditableFormField extends DataObject
|
|||||||
"CustomSettings" => "Text", // @deprecated from 2.0
|
"CustomSettings" => "Text", // @deprecated from 2.0
|
||||||
"Migrated" => "Boolean", // set to true when migrated
|
"Migrated" => "Boolean", // set to true when migrated
|
||||||
|
|
||||||
"ExtraClass" => "Text", // from CustomSettings
|
"ExtraClass" => "Text", // from CustomSettings
|
||||||
"RightTitle" => "Varchar(255)", // from CustomSettings
|
"RightTitle" => "Varchar(255)", // from CustomSettings
|
||||||
"ShowOnLoad" => "Boolean(1)", // from CustomSettings
|
"ShowOnLoad" => "Boolean(1)", // from CustomSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $defaults = array(
|
private static $defaults = array(
|
||||||
'ShowOnLoad' => true,
|
'ShowOnLoad' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -487,11 +487,27 @@ class EditableFormField extends DataObject
|
|||||||
{
|
{
|
||||||
$this->publish($fromStage, $toStage, $createNewVersion);
|
$this->publish($fromStage, $toStage, $createNewVersion);
|
||||||
|
|
||||||
// Don't forget to publish the related custom rules...
|
$seenIDs = array();
|
||||||
foreach ($this->DisplayRules() as $rule) {
|
|
||||||
$rule->doPublish($fromStage, $toStage, $createNewVersion);
|
// Don't forget to publish the related custom rules...
|
||||||
|
foreach ($this->DisplayRules() as $rule) {
|
||||||
|
$seenIDs[] = $rule->ID;
|
||||||
|
$rule->doPublish($fromStage, $toStage, $createNewVersion);
|
||||||
|
$rule->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove any orphans from the "fromStage"
|
||||||
|
$rules = Versioned::get_by_stage('EditableCustomRule', $toStage)
|
||||||
|
->filter('ParentID', $this->ID);
|
||||||
|
|
||||||
|
if (!empty($seenIDs)) {
|
||||||
|
$rules = $rules->exclude('ID', $seenIDs);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
foreach ($rules as $rule) {
|
||||||
|
$rule->deleteFromStage($toStage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete this field from a given stage
|
* Delete this field from a given stage
|
||||||
|
Loading…
Reference in New Issue
Block a user