Permalink
Browse files

Unset non-existing fields when restoring versions (see #5219)

  • Loading branch information...
1 parent 1697a95 commit 0bf3365e56783bced0d88cfb5a004f4b0622a052 @leofeyer leofeyer committed Jan 14, 2013
Showing with 15 additions and 0 deletions.
  1. +3 −0 CHANGELOG.md
  2. +12 −0 system/drivers/DC_Table.php
View
@@ -4,6 +4,9 @@ Contao Open Source CMS Changelog
Version 2.11.9 (2013-XX-XX)
---------------------------
+### Fixed
+Unset non-existing fields when restoring versions (see #5219).
+
Version 2.11.8 (2013-01-07)
---------------------------
@@ -1575,6 +1575,18 @@ public function edit($intID=null, $ajaxId=null)
if (is_array($data))
{
+ // Get the currently available fields
+ $arrFields = array_flip($this->Database->getFieldnames($this->strTable));
+
+ // Unset fields that do not exist (see #5219)
+ foreach (array_keys($data) as $k)
+ {
+ if (!isset($arrFields[$k]))
+ {
+ unset($data[$k]);
+ }
+ }
+
$this->Database->prepare("UPDATE " . $objData->fromTable . " %s WHERE id=?")
->set($data)
->execute($this->intId);

0 comments on commit 0bf3365

Please sign in to comment.