Skip to content

Commit

Permalink
Dev Remove obsolete error logging code from EM
Browse files Browse the repository at this point in the history
  • Loading branch information
TMSWhite committed Mar 22, 2012
1 parent af10f1c commit d443210
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 516 deletions.
178 changes: 35 additions & 143 deletions classes/expressions/LimeExpressionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
define('LEM_DEBUG_TIMING',1);
define('LEM_DEBUG_VALIDATION_SUMMARY',2); // also includes SQL error messages
define('LEM_DEBUG_VALIDATION_DETAIL',4);
define('LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB',8);
define('LEM_PRETTY_PRINT_ALL_SYNTAX',32);

define('LEM_DEFAULT_PRECISION',12);
Expand Down Expand Up @@ -58,7 +57,6 @@ class LimeExpressionManager {
private $maxGroupSeq; // the maximum groupSeq reached - this is needed for Index
private $q2subqInfo; // mapping of questions to information about their subquestions.
private $qattr; // array of attributes for each question
private $syntaxErrors=array();
private $subQrelInfo=array(); // list of needed sub-question relevance (e.g. array_filter)
private $gRelInfo=array(); // array of Group-level relevance status

Expand Down Expand Up @@ -2553,20 +2551,6 @@ static function ProcessString($string, $questionNum=NULL, $replacementFields=arr
$qnum = is_null($questionNum) ? 0 : $questionNum;
$result = $LEM->em->sProcessStringContainingExpressions($stringToParse,$qnum, $numRecursionLevels, $whichPrettyPrintIteration, $groupSeq, $questionSeq, $staticReplacement);
$hasErrors = $LEM->em->HasErrors();
if ($hasErrors && (($LEM->debugLevel & LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB) == LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB)) {
$error = array(
'errortime' => date('Y-m-d H:i:s'),
'sid' => $LEM->sid,
'type' => 'Text',
'gid' => $LEM->groupNum,
'gseq' => $groupSeq,
'qid' => $qnum,
'qseq' => $questionSeq,
'eqn' => $stringToParse,
'prettyPrint' => $LEM->em->GetLastPrettyPrintExpression(),
);
$LEM->syntaxErrors[] = $error;
}

if ($timeit) {
$LEM->runtimeTimings[] = array(__METHOD__,(microtime(true) - $now));
Expand Down Expand Up @@ -2633,23 +2617,6 @@ private function _ProcessRelevance($eqn,$questionNum=NULL,$gseq=NULL,$jsResultVa
$result = $this->em->ProcessBooleanExpression($stringToParse,$groupSeq, $questionSeq);
$hasErrors = $this->em->HasErrors();

if ($hasErrors && (($this->debugLevel & LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB) == LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB)) {
$prettyPrint = $this->em->GetPrettyPrintString();
$error = array(
'errortime' => date('Y-m-d H:i:s'),
'sid' => $this->sid,
'type' => 'Relevance',
'gid' => $groupNum,
'gseq' => $groupSeq,
'qid' => $questionNum,
'qseq' => $questionSeq,
'eqn' => $stringToParse,
'prettyPrint' => $prettyPrint,
'hasErrors' => $hasErrors,
);
$this->syntaxErrors[] = $error;
}

if (!is_null($questionNum) && !is_null($jsResultVar)) { // so if missing either, don't generate JavaScript for this - means off-page relevance.
$jsVars = $this->em->GetJSVarsUsed();
$relevanceVars = implode('|',$this->em->GetJSVarsUsed());
Expand Down Expand Up @@ -2701,41 +2668,27 @@ private function _ProcessSubQRelevance($eqn,$questionNum=NULL,$rowdivid=NULL, $t
$prettyPrint= $this->em->GetPrettyPrintString();
}

if ($hasErrors && (($this->debugLevel & LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB) == LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB)) {
$error = array(
'errortime' => date('Y-m-d H:i:s'),
'sid' => $this->sid,
'type' => $type,
'gid' => $this->groupNum,
'gseq' => $groupSeq,
'qid' => $questionNum,
'qseq' => $questionSeq,
'eqn' => $stringToParse,
'prettyPrint' => $prettyPrint,
);
$this->syntaxErrors[] = $error;
}
else if (!is_null($questionNum)) {
$jsVars = $this->em->GetJSVarsUsed();
$relevanceVars = implode('|',$this->em->GetJSVarsUsed());
$relevanceJS = $this->em->GetJavaScriptEquivalentOfExpression();
if (!is_null($questionNum)) {
$jsVars = $this->em->GetJSVarsUsed();
$relevanceVars = implode('|',$this->em->GetJSVarsUsed());
$relevanceJS = $this->em->GetJavaScriptEquivalentOfExpression();

if (!isset($this->subQrelInfo[$questionNum])) {
$this->subQrelInfo[$questionNum] = array();
}
$this->subQrelInfo[$questionNum][$rowdivid] = array(
'qid' => $questionNum,
'eqn' => $eqn,
'prettyPrintEqn' => $prettyPrint,
'result' => $result,
'numJsVars' => count($jsVars),
'relevancejs' => $relevanceJS,
'relevanceVars' => $relevanceVars,
'rowdivid' => $rowdivid,
'type'=>$type,
'qtype'=>$qtype,
'sgqa'=>$sgqa,
'hasErrors'=>$hasErrors,
if (!isset($this->subQrelInfo[$questionNum])) {
$this->subQrelInfo[$questionNum] = array();
}
$this->subQrelInfo[$questionNum][$rowdivid] = array(
'qid' => $questionNum,
'eqn' => $eqn,
'prettyPrintEqn' => $prettyPrint,
'result' => $result,
'numJsVars' => count($jsVars),
'relevancejs' => $relevanceJS,
'relevanceVars' => $relevanceVars,
'rowdivid' => $rowdivid,
'type'=>$type,
'qtype'=>$qtype,
'sgqa'=>$sgqa,
'hasErrors'=>$hasErrors,
);
}
return $result;
Expand Down Expand Up @@ -2766,39 +2719,22 @@ private function _ProcessGroupRelevance($groupSeq)
$result = $this->em->ProcessBooleanExpression($stringToParse,$groupSeq);
$hasErrors = $this->em->HasErrors();

if ($hasErrors && (($this->debugLevel & LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB) == LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB)) {
$prettyPrint = $this->em->GetPrettyPrintString();
$error = array(
'errortime' => date('Y-m-d H:i:s'),
'sid' => $this->sid,
'type' => '',
'gid' => $this->groupNum,
'gseq' => $groupSeq,
'qid' => -1,
'qseq' => -1,
'eqn' => $stringToParse,
'prettyPrint' => $prettyPrint,
);
$this->syntaxErrors[] = $error;
}
else {
$jsVars = $this->em->GetJSVarsUsed();
$relevanceVars = implode('|',$this->em->GetJSVarsUsed());
$relevanceJS = $this->em->GetJavaScriptEquivalentOfExpression();
$prettyPrint = $this->em->GetPrettyPrintString();
$jsVars = $this->em->GetJSVarsUsed();
$relevanceVars = implode('|',$this->em->GetJSVarsUsed());
$relevanceJS = $this->em->GetJavaScriptEquivalentOfExpression();
$prettyPrint = $this->em->GetPrettyPrintString();

$this->gRelInfo[$groupSeq] = array(
'gseq' => $groupSeq,
'eqn' => $stringToParse,
'result' => $result,
'numJsVars' => count($jsVars),
'relevancejs' => $relevanceJS,
'relevanceVars' => $relevanceVars,
'prettyPrint'=> $prettyPrint,
'hasErrors' => $hasErrors,
);
$_SESSION['relevanceStatus']['G' . $groupSeq] = $result;
}
$this->gRelInfo[$groupSeq] = array(
'gseq' => $groupSeq,
'eqn' => $stringToParse,
'result' => $result,
'numJsVars' => count($jsVars),
'relevancejs' => $relevanceJS,
'relevanceVars' => $relevanceVars,
'prettyPrint'=> $prettyPrint,
'hasErrors' => $hasErrors,
);
$_SESSION['relevanceStatus']['G' . $groupSeq] = $result;
}

/**
Expand Down Expand Up @@ -4806,28 +4742,6 @@ static function FinishProcessingPage()

$LEM->runtimeTimings = array(); // reset them

if (count($LEM->syntaxErrors) > 0 && (($LEM->debugLevel & LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB) == LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB))
{
global $connect;
foreach ($LEM->syntaxErrors as $err)
{
$query = "INSERT INTO ".db_table_name('expression_errors')." (errortime,sid,gid,qid,gseq,qseq,type,eqn,prettyprint) VALUES("
.db_quoteall($err['errortime'])
.",".$err['sid']
.",".$err['gid']
.",".$err['qid']
.",".$err['gseq']
.",".$err['qseq']
.",".db_quoteall($err['type'])
.",".db_quoteall($err['eqn'])
.",".db_quoteall($err['prettyPrint'])
.")";
if (!$connect->Execute($query))
{
print $connect->ErrorMsg();
}
}
}
$LEM->initialized=false; // so detect calls after done
$LEM->ParseResultCache=array(); // don't need to persist it in session
$_SESSION['LEMsingleton']=serialize($LEM);
Expand Down Expand Up @@ -5448,27 +5362,6 @@ static function GetRelevanceAndTailoringJavaScript()
return implode('',$jsParts);
}

/**
* Return array of most recent syntax errors for whatever scope was most recently processed
* @return <type>
*/
static function GetSyntaxErrors()
{
$query = "SELECT * FROM ".db_table_name('expression_errors');
$data = db_execute_assoc($query);
return $data->GetRows();
}

/**
* Truncate the expression_errors table to clear the history of syntax errors.
*/
static function ResetSyntaxErrorLog()
{
// truncate the table
$query = "TRUNCATE TABLE ".db_table_name('expression_errors');
db_execute_assoc($query);
}

static function setTempVars($vars)
{
$LEM =& LimeExpressionManager::singleton();
Expand Down Expand Up @@ -5591,7 +5484,6 @@ static function UnitTestProcessStringContainingExpressions()
}
print '</table>';
LimeExpressionManager::FinishProcessingGroup();
$LEM->syntaxErrors=array(); // so doesn't try to write test errors to database
LimeExpressionManager::FinishProcessingPage();
}

Expand Down
16 changes: 0 additions & 16 deletions classes/expressions/test/data.php

This file was deleted.

2 comments on commit d443210

@TMSWhite
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be ported to Yii

@TMSWhite
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Please sign in to comment.