From 88c5ef484f8a3240ac0d0e3d0a4817ae7f1086ba Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 6 Sep 2012 10:38:14 -0400 Subject: [PATCH 01/11] Formatting --- airtime_mvc/application/common/Database.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/common/Database.php b/airtime_mvc/application/common/Database.php index 3dd937a70..91da38678 100644 --- a/airtime_mvc/application/common/Database.php +++ b/airtime_mvc/application/common/Database.php @@ -1,7 +1,8 @@ prepare($sql); From f3ff9cc461757e6085bccee5a59defa220213025 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 6 Sep 2012 11:03:24 -0400 Subject: [PATCH 02/11] cc-4360: Fix for this bug. Table name was being quoted needlessly. --- airtime_mvc/application/models/Schedule.php | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 74a45da2d..4c3706f5b 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1063,23 +1063,25 @@ SQL; * In both cases (new and edit) we only grab shows that * are scheduled 2 days prior */ - $se = $show_end->format('Y-m-d H:i:s'); + //$se = $show_end->format('Y-m-d H:i:s'); if ($update) { $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." where (ends <= '{$show_end->format('Y-m-d H:i:s')}' or starts <= '{$show_end->format('Y-m-d H:i:s')}') and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') and modified_instance = false and id != ".$instanceId. " order by ends"; - $stmt = $con->prepare("SELECT id, starts, ends FROM :showInstances + + $stmt = $con->prepare("SELECT id, starts, ends FROM {$CC_CONFIG['showInstances']} where (ends <= :show_end1 or starts <= :show_end2) and date(starts) >= (date(:show_end3) - INTERVAL '2 days') and modified_instance = false and id != :instanceId order by ends"); + $stmt->execute(array( ':showInstances' => $CC_CONFIG['showInstances'], - ':show_end1' => $se, - ':show_end2' => $se, - ':show_end3' => $se, + ':show_end1' => $show_end->format('Y-m-d H:i:s'), + ':show_end2' => $show_end->format('Y-m-d H:i:s'), + ':show_end3' => $show_end->format('Y-m-d H:i:s'), ':instanceId' => $instanceId )); } else { @@ -1089,16 +1091,17 @@ SQL; or starts <= '{$show_end->format('Y-m-d H:i:s')}') and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') and modified_instance = false order by ends"; - $stmt = $con->prepare("SELECT id, starts, ends FROM :showInstances - where (ends <= :show_end1 - or starts <= :show_end2) + + $stmt = $con->prepare("SELECT id, starts, ends FROM + {$CC_CONFIG['showInstances']} + where (ends <= :show_end1 or starts <= :show_end2) and date(starts) >= (date(:show_end3) - INTERVAL '2 days') and modified_instance = false order by ends"); + $stmt->execute(array( - ':showInstances' => $CC_CONFIG['showInstances'], - ':show_end1' => $se, - ':show_end2' => $se, - ':show_end3' => $se, + ':show_end1' => $show_end->format('Y-m-d H:i:s'), + ':show_end2' => $show_end->format('Y-m-d H:i:s'), + ':show_end3' => $show_end->format('Y-m-d H:i:s') )); } //$rows = $con->query($sql); @@ -1106,7 +1109,7 @@ SQL; foreach ($rows as $row) { $start = new DateTime($row["starts"], new DateTimeZone('UTC')); - $end = new DateTime($row["ends"], new DateTimeZone('UTC')); + $end = new DateTime($row["ends"], new DateTimeZone('UTC')); if ($show_start->getTimestamp() < $end->getTimestamp() && $show_end->getTimestamp() > $start->getTimestamp()) { From f06b3e2c360f27d3b325617ce32affdc3090aecb Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 6 Sep 2012 11:11:09 -0400 Subject: [PATCH 03/11] CC-4345: Prepared statements - part 1 -modified Block.php to use Application_Common_Database::prepareAndExecute() --- airtime_mvc/application/models/Block.php | 265 ++++++++--------------- 1 file changed, 88 insertions(+), 177 deletions(-) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index bfb6e499c..dc05ab5a0 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -199,16 +199,8 @@ class Application_Model_Block implements Application_Model_LibraryEditable WHERE pc.block_id = :block_id ORDER BY pc.position; EOT; - $con = Propel::getConnection(); - $stmt = $con->prepare($sql); - $stmt->bindParam(':block_id', $this->id); - - if ($stmt->execute()) { - $rows = $stmt->fetchAll(); - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); - } + + $rows = Application_Common_Database::prepareAndExecute($sql, array(':block_id'=>$this->id)); $offset = 0; foreach ($rows as &$row) { @@ -332,15 +324,8 @@ EOT; public function getStaticLength() { $sql = "SELECT SUM(cliplength) as length FROM cc_blockcontents WHERE block_id = :block_id"; - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':block_id', $this->id); - - if ($stmt->execute()) { - $result = $stmt->fetchAll(PDO::FETCH_NUM); - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("error: $msg"); - } + $result = Application_Common_Database::prepareAndExecute($sql, array(':block_id'=>$this->id), 'all', PDO::FETCH_NUM); + Logging::info($result); return $result[0][0]; } @@ -653,39 +638,31 @@ EOT; if (!is_null($fadeIn)) { $sql = "SELECT :fade_in::INTERVAL > :clip_length::INTERVAL"; + $params = array( + ':fade_in' => $fadeIn, + ':clip_length' => $clipLength + ); - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':fade_in', $fadeIn); - $stmt->bindParam(':clip_length', $clipLength); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - //"Fade In can't be larger than overall playlength."; - $fadeIn = $clipLength; - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + //"Fade In can't be larger than overall playlength."; + $fadeIn = $clipLength; } - $row->setDbFadein($fadeIn); + } if (!is_null($fadeOut)) { $sql = "SELECT :fade_out::INTERVAL > :clip_length::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':fade_out', $fadeOut); - $stmt->bindParam(':clip_length', $clipLength); + $params = array( + ':fade_out' => $fadeOut, + ':clip_length' => $clipLength + ); - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - //Fade Out can't be larger than overall playlength."; - $fadeOut = $clipLength; - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + //"Fade Out can't be larger than overall playlength."; + $fadeOut = $clipLength; } $row->setDbFadeout($fadeOut); } @@ -773,52 +750,31 @@ EOT; $cueOut = $origLength; } - $sql = "SELECT :cue_in::INTERVAL > :cue_out::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':cue_in', $cueIn); - $stmt->bindParam(':cue_out', $cueOut); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - $errArray["error"] = "Can't set cue in to be larger than cue out."; - - return $errArray; - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $sql = "SELECT :cue_out::INTERVAL > :orig_length::INTERVAL"; + $params = array( + ':cue_out' => $cueOut, + ':orig_length' => $origLength + ); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + $errArray["error"] = "Can't set cue out to be greater than file length."; + return $errArray; } - $sql = "SELECT :cue_out::INTERVAL > INTERVAL :orig_length::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':cue_out', $cueOut); - $stmt->bindParam(':orig_length', $origLength); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - $errArray["error"] = "Can't set cue out to be greater than file length."; - - return $errArray; - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $sql = "SELECT :cue_in::INTERVAL > :cue_out::INTERVAL"; + $params = array( + ':cue_in' => $cueIn, + ':cue_out' => $cueOut + ); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + $errArray["error"] = "Can't set cue in to be larger than cue out."; + return $errArray; } $sql = "SELECT :cue_out::INTERVAL - :cue_in::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':cue_out', $cueOut); - $stmt->bindParam(':cue_in', $cueIn); - - if ($stmt->execute()) { - $cliplength = $stmt->fetchColumn(0); - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); - } + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + $cliplength = $result; $row->setDbCuein($cueIn); $row->setDbCueout($cueOut); @@ -827,89 +783,54 @@ EOT; } elseif (!is_null($cueIn)) { $sql = "SELECT :cue_in::INTERVAL > :old_cue_out::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':cue_in', $cueIn); - $stmt->bindParam(':old_cue_out', $oldCueOut); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - $errArray["error"] = "Can't set cue in to be larger than cue out."; - - return $errArray; - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $params = array( + ':cue_in' => $cueIn, + ':old_cue_out' => $oldCueOut + ); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + $errArray["error"] = "Can't set cue in to be larger than cue out."; + return $errArray; } $sql = "SELECT :old_cue_out::INTERVAL - :cue_in::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':old_cue_out', $oldCueOut); - $stmt->bindParam(':cue_in', $cueIn); - - if ($stmt->execute()) { - $cliplength = $stmt->fetchColumn(0); - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); - } + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + $cliplength = $result; $row->setDbCuein($cueIn); $row->setDBCliplength($cliplength); + } elseif (!is_null($cueOut)) { if ($cueOut === "") { $cueOut = $origLength; } - $sql = "SELECT :cue_out::INTERVAL < :old_cue_in::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':cue_out', $cueOut); - $stmt->bindParam(':old_cue_in', $oldCueIn); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - $errArray["error"] = "Can't set cue out to be smaller than cue in."; - - return $errArray; - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $sql = "SELECT :cue_out::INTERVAL > :orig_length::INTERVAL"; + $params = array( + ':cue_out' => $cueOut, + ':orig_length' => $origLength + ); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + $errArray["error"] = "Can't set cue out to be greater than file length."; + return $errArray; } - $sql = "SELECT :cue_out::INTERVAL > :orig_length::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':cue_out', $cueOut); - $stmt->bindParam(':orig_length', $origLength); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - $errArray["error"] = "Can't set cue out to be greater than file length."; - - return $errArray; - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $sql = "SELECT :cue_out::INTERVAL < :old_cue_in::INTERVAL"; + $params = array( + ':cue_out' => $cueOut, + ':old_cue_in' => $oldCueIn + ); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + $errArray["error"] = "Can't set cue out to be smaller than cue in."; + return $errArray; } $sql = "SELECT :cue_out::INTERVAL - :old_cue_in::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':cue_out', $cueOut); - $stmt->bindParam(':old_cue_in', $oldCueIn); - - if ($stmt->execute()) { - $cliplength = $stmt->fetchColumn(0); - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); - } + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + $cliplength = $result; $row->setDbCueout($cueOut); $row->setDBCliplength($cliplength); @@ -918,35 +839,25 @@ EOT; $cliplength = $row->getDbCliplength(); $sql = "SELECT :fade_in::INTERVAL > :clip_length::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':fade_in', $fadeIn); - $stmt->bindParam(':clip_length', $cliplength); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - $fadeIn = $cliplength; - $row->setDbFadein($fadeIn); - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $params = array( + ':fade_in' => $fadeIn, + ':clip_length' => $cliplength + ); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + $fadeIn = $cliplength; + $row->setDbFadein($fadeIn); } $sql = "SELECT :fade_out::INTERVAL > :clip_length::INTERVAL"; - - $stmt = $this->con->prepare($sql); - $stmt->bindParam(':fade_out', $fadeOut); - $stmt->bindParam(':clip_length', $cliplength); - - if ($stmt->execute()) { - if ($stmt->fetchColumn(0)) { - $fadeOut = $cliplength; - $row->setDbFadein($fadeOut); - } - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); + $params = array( + ':fade_out' => $fadeOut, + ':clip_length' => $cliplength + ); + $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); + if ($result) { + $fadeOut = $cliplength; + $row->setDbFadein($fadeOut); } $row->save($this->con); From bed360cd3ebe22cd8f39ced654e7a2070d25fc1a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 6 Sep 2012 11:15:01 -0400 Subject: [PATCH 04/11] Formatting --- .../application/controllers/ScheduleController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 58c2db1de..27239bee4 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -781,7 +781,10 @@ class ScheduleController extends Zend_Controller_Action $data['add_show_record'] = $show->isRecorded(); $origianlShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime()); - $success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate, $origianlShowStartDateTime, true, $data['add_show_instance_id']); + + $success = Application_Model_Schedule::addUpdateShow($data, $this, + $validateStartDate, $origianlShowStartDateTime, true, + $data['add_show_instance_id']); if ($success) { $this->view->addNewShow = true; @@ -818,14 +821,17 @@ class ScheduleController extends Zend_Controller_Action } $validateStartDate = true; - $success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate); + $success = Application_Model_Schedule::addUpdateShow($data, $this, + $validateStartDate); if ($success) { $this->view->addNewShow = true; - $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); + $this->view->newForm = $this->view->render( + 'schedule/add-show-form.phtml'); } else { $this->view->addNewShow = true; - $this->view->form = $this->view->render('schedule/add-show-form.phtml'); + $this->view->form = $this->view->render(' + schedule/add-show-form.phtml'); } } From 9b29f5e701a8b48702efdb6d5def14a53622841c Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 6 Sep 2012 11:21:36 -0400 Subject: [PATCH 05/11] CC-4345: Prepared statements - part 1 -modified Datatables.php to use Application_Common_Database::prepareAndExecute() --- airtime_mvc/application/models/Datatables.php | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php index 041530407..4a455fedd 100644 --- a/airtime_mvc/application/models/Datatables.php +++ b/airtime_mvc/application/models/Datatables.php @@ -164,35 +164,14 @@ class Application_Model_Datatables $totalRows = $r->fetchColumn(0); if (isset($sqlTotalDisplayRows)) { - $stmt = $con->prepare($sqlTotalDisplayRows); - foreach($params as $param=>&$value) { - $stmt->bindParam(":$param", $value); - } - if ($stmt->execute()) { - $totalDisplayRows = $stmt->fetchColumn(0); - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); - } + $totalDisplayRows = Application_Common_Database::prepareAndExecute($sqlTotalDisplayRows, $params, 'column'); } else { $totalDisplayRows = $totalRows; } //TODO if ($needToBind) { - $stmt = $con->prepare($sql); - - foreach($params as $param=>&$value) { - $stmt->bindParam(":$param", $value); - } - - if ($stmt->execute()) { - $stmt->setFetchMode(PDO::FETCH_ASSOC); - $results = $stmt->fetchAll(); - } else { - $msg = implode(',', $stmt->errorInfo()); - throw new Exception("Error: $msg"); - } + $results = Application_Common_Database::prepareAndExecute($sql, $params); } else { $stmt = $con->query($sql); $stmt->setFetchMode(PDO::FETCH_ASSOC); From 8d1003bbbec08d4ce9a43a43e1e17bddb74145db Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 6 Sep 2012 11:48:00 -0400 Subject: [PATCH 06/11] CC-4303: Library Tab grays out after certain scenario with normal playlist -fixed --- airtime_mvc/application/controllers/PlaylistController.php | 2 +- airtime_mvc/public/js/airtime/library/spl.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index d352344ff..6d9a9d8c3 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -447,7 +447,7 @@ class PlaylistController extends Zend_Controller_Action } catch (PlaylistOutDatedException $e) { $this->playlistOutdated($e); } catch (PlaylistNotFoundException $e) { - $this->playlistNotFound($type); + $this->playlistNotFound($type, true); } catch (Exception $e) { $this->playlistUnknownError($e); } diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 46a0945b7..907078e18 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -632,6 +632,10 @@ var AIRTIME = (function(AIRTIME){ {format: "json", data: criteria, name: block_name, description: block_desc, obj_id: obj_id, type: obj_type, modified: lastMod}, function(data){ var json = $.parseJSON(data); + if (json.error !== undefined) { + alert(json.error); + } + AIRTIME.playlist.fnOpenPlaylist(json); setModified(json.modified); if (obj_type == "block") { callback(data, "save"); From 56527e727c383ffa591465b1fd2bd465de6795cc Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 6 Sep 2012 12:17:18 -0400 Subject: [PATCH 07/11] extra debuggin --- .../controllers/ScheduleController.php | 8 ++++++-- airtime_mvc/application/logging/Logging.php | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 27239bee4..361798679 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -813,8 +813,8 @@ class ScheduleController extends Zend_Controller_Action $data[$j["name"]] = $j["value"]; } - $data['add_show_hosts'] = $this->_getParam('hosts'); - $data['add_show_day_check'] = $this->_getParam('days'); + $data['add_show_hosts'] = $this->_getParam('hosts'); + $data['add_show_day_check'] = $this->_getParam('days'); if ($data['add_show_day_check'] == "") { $data['add_show_day_check'] = null; @@ -828,10 +828,14 @@ class ScheduleController extends Zend_Controller_Action $this->view->addNewShow = true; $this->view->newForm = $this->view->render( 'schedule/add-show-form.phtml'); + Logging::debug("Show creation succeeded"); + Logging::sparse_debug( $data ); } else { $this->view->addNewShow = true; $this->view->form = $this->view->render(' schedule/add-show-form.phtml'); + Logging::debug("Show creation failed"); + Logging::sparse_debug( $data ); } } diff --git a/airtime_mvc/application/logging/Logging.php b/airtime_mvc/application/logging/Logging.php index e89f23763..0e2492f53 100644 --- a/airtime_mvc/application/logging/Logging.php +++ b/airtime_mvc/application/logging/Logging.php @@ -69,6 +69,10 @@ class Logging { public static function debug($p_msg) { + if (!(defined('APPLICATION_ENV') && APPLICATION_ENV == "development")) { + return; + } + $bt = debug_backtrace(); $caller = array_shift($bt); @@ -78,11 +82,16 @@ class Logging { $caller = array_shift($bt); $function = $caller['function']; - - if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development") { - $logger = self::getLogger(); - $logger->debug("[$file : $function() : line $line] - ".self::toString($p_msg)); - } + $logger = self::getLogger(); + $logger->debug("[$file : $function() : line $line] - ".self::toString($p_msg)); + } + // kind of like debug but for printing arrays more compactly (skipping + // empty elements + + public static function debug_sparse(array $p_msg) + { + Logging::debug("Sparse output:"); + Logging::debug( array_filter($p_msg) ); } public static function enablePropelLogging() From 6cb8dd35e2937e905cab38cae90af05d8d930be6 Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 6 Sep 2012 12:23:53 -0400 Subject: [PATCH 08/11] - fixed sql error --- airtime_mvc/application/models/User.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index fbfb84794..88e8a42c9 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -311,13 +311,12 @@ class Application_Model_User return Application_Common_Database::prepareAndExecute($sql, $params, "all"); } - public static function getUserCount($type=null) + public static function getUserCount() { $con = Propel::getConnection(); - $sql = ''; $sql_gen = "SELECT count(*) AS cnt FROM cc_subjs"; - $query = $con->query($sql)->fetchColumn(0); + $query = $con->query($sql_gen)->fetchColumn(0); return ($query !== false) ? $query : null; } From 3f898bfc3a67ab0c447d8679c953dbb61c52fe9a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 6 Sep 2012 12:33:04 -0400 Subject: [PATCH 09/11] Fixed wrong function name --- airtime_mvc/application/controllers/ScheduleController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 361798679..eba69211f 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -829,13 +829,13 @@ class ScheduleController extends Zend_Controller_Action $this->view->newForm = $this->view->render( 'schedule/add-show-form.phtml'); Logging::debug("Show creation succeeded"); - Logging::sparse_debug( $data ); + Logging::debug_sparse( $data ); } else { $this->view->addNewShow = true; $this->view->form = $this->view->render(' schedule/add-show-form.phtml'); Logging::debug("Show creation failed"); - Logging::sparse_debug( $data ); + Logging::debug_sparse( $data ); } } From 744577a8b583f8cca5085874975c901a66dda49b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 6 Sep 2012 12:38:55 -0400 Subject: [PATCH 10/11] Removed bad line break --- airtime_mvc/application/controllers/ScheduleController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index eba69211f..f96d8ffb2 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -832,8 +832,8 @@ class ScheduleController extends Zend_Controller_Action Logging::debug_sparse( $data ); } else { $this->view->addNewShow = true; - $this->view->form = $this->view->render(' - schedule/add-show-form.phtml'); + $this->view->form = $this->view->render( + 'schedule/add-show-form.phtml'); Logging::debug("Show creation failed"); Logging::debug_sparse( $data ); } From d196666c31125cb7edaaeaa1d8f74b543d0aa7d6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 6 Sep 2012 12:52:11 -0400 Subject: [PATCH 11/11] got rid of print statements possible interfering with view --- airtime_mvc/application/models/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 88e8a42c9..6753f34f0 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -304,8 +304,8 @@ class Application_Model_User $sql = $sql . " AND ".$like; } - echo $sql.PHP_EOL; - print_r($params); + //echo $sql.PHP_EOL; + //print_r($params); $sql = $sql ." ORDER BY login"; return Application_Common_Database::prepareAndExecute($sql, $params, "all");