mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8150 from open-sausages/pulls/4.0/fix-postgres-duplication-issue
BUG Fix test that relies on implicit ID order breaking postgres
This commit is contained in:
commit
510b0f7759
@ -4,7 +4,6 @@ namespace SilverStripe\Forms\HTMLEditor;
|
||||
|
||||
use DOMAttr;
|
||||
use DOMElement;
|
||||
use DOMNode;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\View\Parsers\HTMLValue;
|
||||
use stdClass;
|
||||
@ -114,24 +113,20 @@ class HTMLEditorSanitiser
|
||||
if ($attrType === '!') {
|
||||
$element->attributesRequired[] = $attrName;
|
||||
$attr->required = true;
|
||||
} // Denied from global
|
||||
elseif ($attrType === '-') {
|
||||
} elseif ($attrType === '-') { // Denied from global
|
||||
unset($element->attributes[$attrName]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Default value
|
||||
if ($prefix) {
|
||||
// Default value
|
||||
if ($prefix === '=') {
|
||||
if ($prefix === '=') { // Default value
|
||||
$element->attributesDefault[$attrName] = $value;
|
||||
$attr->defaultValue = $value;
|
||||
} // Forced value
|
||||
elseif ($prefix === ':') {
|
||||
} elseif ($prefix === ':') { // Forced value
|
||||
$element->attributesForced[$attrName] = $value;
|
||||
$attr->forcedValue = $value;
|
||||
} // Required values
|
||||
elseif ($prefix === '<') {
|
||||
} elseif ($prefix === '<') { // Required values
|
||||
$attr->validValues = explode('?', $value);
|
||||
}
|
||||
}
|
||||
@ -290,8 +285,7 @@ class HTMLEditorSanitiser
|
||||
// If it's a script or style, we don't keep contents
|
||||
if ($el->tagName === 'script' || $el->tagName === 'style') {
|
||||
$el->parentNode->removeChild($el);
|
||||
} // Otherwise we replace this node with all it's children
|
||||
else {
|
||||
} else { // Otherwise we replace this node with all it's children
|
||||
// First, create a new fragment with all of $el's children moved into it
|
||||
$frag = $doc->createDocumentFragment();
|
||||
while ($el->firstChild) {
|
||||
@ -301,8 +295,7 @@ class HTMLEditorSanitiser
|
||||
// Then replace $el with the frags contents (which used to be it's children)
|
||||
$el->parentNode->replaceChild($frag, $el);
|
||||
}
|
||||
} // Otherwise tidy the element
|
||||
else {
|
||||
} else { // Otherwise tidy the element
|
||||
// First, if we're supposed to pad & this element is empty, fix that
|
||||
if ($elementRule->paddEmpty && !$el->firstChild) {
|
||||
$el->nodeValue = ' ';
|
||||
|
@ -622,8 +622,7 @@ class SQLSelect extends SQLConditionalExpression
|
||||
if (!empty($this->having)) {
|
||||
$records = $this->execute();
|
||||
return $records->numRecords();
|
||||
} // Choose a default column
|
||||
elseif ($column == null) {
|
||||
} elseif ($column == null) { // Choose a default column
|
||||
if ($this->groupby) {
|
||||
$column = 'DISTINCT ' . implode(", ", $this->groupby);
|
||||
} else {
|
||||
|
@ -573,8 +573,7 @@ class ShortcodeParser
|
||||
} elseif ($location == self::AFTER) {
|
||||
// Move after block parent
|
||||
$this->insertAfter($node, $parent);
|
||||
} // Split parent at node
|
||||
elseif ($location == self::SPLIT) {
|
||||
} elseif ($location == self::SPLIT) { // Split parent at node
|
||||
$at = $node;
|
||||
$splitee = $node->parentNode;
|
||||
|
||||
@ -593,8 +592,7 @@ class ShortcodeParser
|
||||
}
|
||||
|
||||
$this->insertAfter($node, $parent);
|
||||
} // Do nothing
|
||||
elseif ($location == self::INLINE) {
|
||||
} elseif ($location == self::INLINE) { // Do nothing
|
||||
if (in_array(strtolower($node->tagName), self::$block_level_elements)) {
|
||||
user_error(
|
||||
'Requested to insert block tag ' . $node->tagName . ' inline - probably this will break HTML compliance',
|
||||
@ -638,7 +636,6 @@ class ShortcodeParser
|
||||
*/
|
||||
public function parse($content)
|
||||
{
|
||||
|
||||
$this->extend('onBeforeParse', $content);
|
||||
|
||||
$continue = true;
|
||||
@ -646,11 +643,9 @@ class ShortcodeParser
|
||||
// If no shortcodes defined, don't try and parse any
|
||||
if (!$this->shortcodes) {
|
||||
$continue = false;
|
||||
} // If no content, don't try and parse it
|
||||
elseif (!trim($content)) {
|
||||
} elseif (!trim($content)) { // If no content, don't try and parse it
|
||||
$continue = false;
|
||||
} // If no shortcode tag, don't try and parse it
|
||||
elseif (strpos($content, '[') === false) {
|
||||
} elseif (strpos($content, '[') === false) { // If no shortcode tag, don't try and parse it
|
||||
$continue = false;
|
||||
}
|
||||
|
||||
@ -659,7 +654,7 @@ class ShortcodeParser
|
||||
// use a proper DOM
|
||||
list($content, $tags) = $this->replaceElementTagsWithMarkers($content);
|
||||
|
||||
/** @var HTMLValue $htmlvalue */
|
||||
/** @var HTMLValue $htmlvalue */
|
||||
$htmlvalue = Injector::inst()->create('HTMLValue', $content);
|
||||
|
||||
// Now parse the result into a DOM
|
||||
|
@ -151,14 +151,14 @@ class DataObjectDuplicationTest extends SapphireTest
|
||||
$oneCopy->twos()->Count(),
|
||||
"Many-to-one relation not copied (has_many)"
|
||||
);
|
||||
$this->assertEquals(
|
||||
$this->assertContains(
|
||||
$three->ID,
|
||||
$oneCopy->threes()->First()->ID,
|
||||
$oneCopy->threes()->column('ID'),
|
||||
"Match between relation of copy and the original"
|
||||
);
|
||||
$this->assertEquals(
|
||||
$this->assertContains(
|
||||
$one->ID,
|
||||
$threeCopy->ones()->First()->ID,
|
||||
$threeCopy->ones()->column('ID'),
|
||||
"Match between relation of copy and the original"
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user