Login!
Lost password?
 

MODx Bug/Feature Tracker and Feature Requests

Welcome to the MODx CMS Tracker. Please choose the appropriate project from the drop down menu and provide as much information as possible regarding your server environment and browser. Thanks!

FS#1032 — Incorrect save of TVs in save_content.processor.php

Attached to Project — MODx
Opened by Natalino Busa (natalino) - Monday, 17 March 2008, 04:10PM
Last edited by Ryan Thrash (rthrash) - Saturday, 27 September 2008, 07:47AM
Task Type Bug Report
Category Core Distribution
Status Closed
Assigned To Garry Nutting (garryn)
Operating System All
Severity High
Priority Normal
Reported Version 0.9.6
Due in Version Undecided
Due Date Undecided
Percent Complete 100%

Details

When a TV is made AFTER that a page has been create, saving in "edit" mode will not save the newly added TV.

This has to do with "sirluncelot" which has reduced the sql calls to only "delete" or "update" but no "insert" is there any more, preventing the insetion of new TV content in existing page. Try this code instead (replace code snippet around line 445 in save_content.processor.php)

// Modified by Raymond for TV - OrigAdded by Apodigm - DocVars
$sql = 'SELECT id, tmplvarid FROM '.$tbltvc.' WHERE contentid='.$id;
$rs = mysql_query($sql);
$tvIds = array ();
while ($row = mysql_fetch_assoc($rs)) {
$tvIds[$row['tmplvarid']] = $row['id'];
}
$deletions = array();
$tvChanges = array();
$tvAdded = array();
foreach ($tmplvars as $field => $value) {
if (!is_array($value)) {
if (isset($tvIds[$value])) $deletions[] = $tvIds[$value];
} else {
$tvId = $value[0];
$tvVal = $value[1];

if (isset($tvIds[$tvId])) {
$tvChanges[] = '(\''.$tvIds[$tvId].'\', '.$tvId.', '.$id.', \''.mysql_escape_string($tvVal).'\')';
} else {
$tvAdded[] = "('$tvId','$id', '" . mysql_escape_string($tvVal) . "')";
}
}
}
// Only two queries to the db are made now - sirlancelot
if (!empty($deletions)) {
$sql = 'DELETE FROM '.$tbltvc.' WHERE id IN ('.implode(',', $deletions).')';
$rs = mysql_query($sql);
echo "del:".($rs?"(success)":"(failed)")." $sql"."<br>\n";
}

if (!empty($tvAdded)) {
$sql = 'INSERT INTO '.$tbltvc.' (tmplvarid, contentid, value) VALUES '.implode(',', $tvAdded);
$rs = mysql_query($sql);
echo "add:".($rs?"(success)":"(failed)")." $sql"."<br>\n";
}

if (!empty($tvChanges)) {
$sql = 'REPLACE INTO '.$tbltvc.' (id, tmplvarid, contentid, value) VALUES '.implode(',', $tvChanges);
$rs = mysql_query($sql);
echo "edit:".($rs?"(success)":"(failed)")." $sql"."<br>\n";
}
//End Modification

regards,
Natalino
This task depends upon

This task blocks these from closing
Closed by  Garry Nutting (garryn)
Saturday, 27 September 2008, 12:16PM
Reason for closing:  Fixed
Additional comments about closing:  Fixed in SVN rev #4173
Comment by Natalino Busa (natalino) - Monday, 17 March 2008, 04:13PM
I have attached herewith the complete modified save_content.processor.php
  save_content.processor.php
Comment by Ryan Thrash (rthrash) - Monday, 17 March 2008, 04:38PM
Thank you natalino!