Skip to content

Commit

Permalink
Hotfix - Importación - Evitar errores innecesarios en el log (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
enricsinergia authored Dec 19, 2024
1 parent 9e2787a commit b0af986
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
25 changes: 24 additions & 1 deletion modules/Import/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,10 @@ public static function getImportableModules()
*/
public static function handleImportErrors($errno, $errstr, $errfile, $errline)
{
$GLOBALS['log']->fatal("Caught error: $errstr");
// STIC-Custom EPS 20241217 Instead of writing always fatal errors, we use the corresponding log
// https://github.com/SinergiaTIC/SinergiaCRM/pull/518
// $GLOBALS['log']->fatal("Caught error: $errstr");
// END STIC-Custom

if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', '8192');
Expand All @@ -839,25 +842,45 @@ public static function handleImportErrors($errno, $errstr, $errfile, $errline)
switch ($errno) {
case E_USER_ERROR:
$message = "ERROR: [$errno] $errstr on line $errline in file $errfile<br />\n";
// STIC-Custom EPS 20241217 Instead of writing always fatal errors, we use the corresponding log
// https://github.com/SinergiaTIC/SinergiaCRM/pull/518
$GLOBALS['log']->fatal("Caught error: $errstr $errfile $errline");
// END STIC-Custom
$isFatal = true;
break;
case E_USER_WARNING:
case E_WARNING:
$message = "WARNING: [$errno] $errstr on line $errline in file $errfile<br />\n";
// STIC-Custom EPS 20241217 Instead of writing always fatal errors, we use the corresponding log
// https://github.com/SinergiaTIC/SinergiaCRM/pull/518
$GLOBALS['log']->warn("Caught error: $errstr $errfile $errline");
// END STIC-Custom
break;
case E_USER_NOTICE:
case E_NOTICE:
$message = "NOTICE: [$errno] $errstr on line $errline in file $errfile<br />\n";
// STIC-Custom EPS 20241217 Instead of writing always fatal errors, we use the corresponding log
// https://github.com/SinergiaTIC/SinergiaCRM/pull/518
$GLOBALS['log']->error("Caught error: $errstr $errfile $errline");
// END STIC-Custom
break;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
// don't worry about these
// $message = "STRICT ERROR: [$errno] $errstr on line $errline in file $errfile<br />\n";
// STIC-Custom EPS 20241217 Instead of writing always fatal errors, we use the corresponding log
// https://github.com/SinergiaTIC/SinergiaCRM/pull/518
$GLOBALS['log']->warn("Caught error: $errstr $errfile $errline");
// END STIC-Custom
$message = "";
break;
default:
$message = "Unknown error type: [$errno] $errstr on line $errline in file $errfile<br />\n";
// STIC-Custom EPS 20241217 Instead of writing always fatal errors, we use the corresponding log
// https://github.com/SinergiaTIC/SinergiaCRM/pull/518
$GLOBALS['log']->fatal("Caught error: $errstr $errfile $errline");
// END STIC-Custom
break;
}

Expand Down
1 change: 1 addition & 0 deletions modules/stic_Attendances/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static function createAttendances($date = null, $registrationId = null, $
}

// Add session filter if needed
$sessionIdWhere = '';
if (!empty($sessionId)) {
$sessionIdWhere = " AND s.id='$sessionId' ";
}
Expand Down
7 changes: 5 additions & 2 deletions modules/stic_Import_Validation/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,6 @@ public static function getImportableModules()
*/
public static function handleImportErrors($errno, $errstr, $errfile, $errline)
{
$GLOBALS['log']->fatal("Caught error: $errstr");

if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', '8192');
}
Expand All @@ -991,25 +989,30 @@ public static function handleImportErrors($errno, $errstr, $errfile, $errline)
switch ($errno) {
case E_USER_ERROR:
$message = "ERROR: [$errno] $errstr on line $errline in file $errfile<br />\n";
$GLOBALS['log']->fatal("Caught error: $errstr $errfile $errline");
$isFatal = true;
break;
case E_USER_WARNING:
case E_WARNING:
$message = "WARNING: [$errno] $errstr on line $errline in file $errfile<br />\n";
$GLOBALS['log']->warn("Caught error: $errstr $errfile $errline");
break;
case E_USER_NOTICE:
case E_NOTICE:
$message = "NOTICE: [$errno] $errstr on line $errline in file $errfile<br />\n";
$GLOBALS['log']->error("Caught error: $errstr $errfile $errline");
break;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
// don't worry about these
// $message = "STRICT ERROR: [$errno] $errstr on line $errline in file $errfile<br />\n";
$GLOBALS['log']->warn("Caught error: $errstr $errfile $errline");
$message = "";
break;
default:
$message = "Unknown error type: [$errno] $errstr on line $errline in file $errfile<br />\n";
$GLOBALS['log']->fatal("Caught error: $errstr $errfile $errline");
break;
}

Expand Down
3 changes: 2 additions & 1 deletion modules/stic_Registrations/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,13 @@ public static function createAttendancesForNewRegistration($registrationBean) {
}
$endDay = date('Y-m-d');

$GLOBALS['log']->debug('Line ' . __LINE__ . ': ' . __METHOD__ . ': ' . $startDay . '|' . $today);
$GLOBALS['log']->debug('Line ' . __LINE__ . ': ' . __METHOD__ . ': ' . $startDay . '|' . $endDay);
$start = new DateTime($startDay);
$end = new DateTime($endDay);

$numDays = $start->diff($end)->days;
$dayToCreate = $start->format('Y-m-d');
$a = 0;
while ($a <= $numDays) {
stic_AttendancesUtils::createAttendances($dayToCreate, $registrationBean->id, null);
$dayToCreate = $start->add(new DateInterval('P1D'))->format('Y-m-d');
Expand Down

0 comments on commit b0af986

Please sign in to comment.