Fix safeMode triggering unnecessarily
Fixes a long standing issue where when safe mode is enabled and the line endings present in the templates differed from the line endings used by the user's browser it would cause safe mode to prevent saving any changes (even when those changes did not include real changes to the code property) because the user's browser would "helpfully" change the original line endings to the line endings of the browser before sending it back to the server.
This commit is contained in:
parent
505b1ce0db
commit
47b2aa0f15
|
|
@ -98,6 +98,16 @@ class CmsCompoundObject extends CmsObject
|
|||
*/
|
||||
public function beforeSave()
|
||||
{
|
||||
// Ignore line-ending only changes to the code property to avoid triggering safe mode
|
||||
// when no changes actually occurred, it was just the browser reformatting line endings
|
||||
if ($this->isDirty('code')) {
|
||||
$oldCode = str_replace("\n", "\r\n", str_replace("\r", '', $this->getOriginal('code')));
|
||||
$newCode = str_replace("\n", "\r\n", str_replace("\r", '', $this->code));
|
||||
if ($oldCode === $newCode) {
|
||||
$this->code = $this->getOriginal('code');
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkSafeMode();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue