Adding error_log

1.10.x
Julio 9 years ago
parent abada84cc0
commit 50c4d7021a
  1. 46
      main/install/install.lib.php

@ -2218,7 +2218,10 @@ function fixIds(EntityManager $em)
error_log('Getting course list'); error_log('Getting course list');
} }
foreach ($courseList as $courseData) { $totalCourse = count($courseList);
$counter = 0;
foreach ($courseList as $courseData) {
$courseId = $courseData['id']; $courseId = $courseData['id'];
if ($debug) { if ($debug) {
error_log('Updating course: '.$courseData['code']); error_log('Updating course: '.$courseData['code']);
@ -2226,8 +2229,6 @@ function fixIds(EntityManager $em)
$sql = "SELECT * FROM c_item_property WHERE c_id = $courseId"; $sql = "SELECT * FROM c_item_property WHERE c_id = $courseId";
$result = $connection->fetchAll($sql); $result = $connection->fetchAll($sql);
$counter = 0;
error_log("Items to process: ".count($result));
foreach ($result as $item) { foreach ($result as $item) {
//$courseId = $item['c_id']; //$courseId = $item['c_id'];
@ -2285,9 +2286,10 @@ function fixIds(EntityManager $em)
error_log($sql); error_log($sql);
$connection->executeQuery($sql); $connection->executeQuery($sql);
} }
if ($counter % 100 == 0) {
if ($debug) {
// Print a status in the log once in a while // Print a status in the log once in a while
error_log("Process item #$counter"); error_log("Process item #$counter/$totalCourse");
} }
$counter++; $counter++;
} }
@ -2385,8 +2387,8 @@ function fixIds(EntityManager $em)
$oldId, $oldId,
'system' 'system'
); );
if (!empty($path)) {
if (!empty($path)) {
$newPath = str_replace( $newPath = str_replace(
"groups/$oldId/", "groups/$oldId/",
"groups/$newId/", "groups/$newId/",
@ -2481,10 +2483,16 @@ function fixIds(EntityManager $em)
foreach ($extraFieldTables as $type => $table) { foreach ($extraFieldTables as $type => $table) {
//continue; //continue;
$sql = "SELECT * FROM $table "; $sql = "SELECT * FROM $table ";
if ($debug) {
error_log($sql);
}
$result = $connection->query($sql); $result = $connection->query($sql);
$fields = $result->fetchAll(); $fields = $result->fetchAll();
foreach ($fields as $field) { foreach ($fields as $field) {
if ($debug) {
error_log("Loading field $field");
}
$originalId = $field['id']; $originalId = $field['id'];
$extraField = new ExtraField(); $extraField = new ExtraField();
$extraField $extraField
@ -2502,6 +2510,7 @@ function fixIds(EntityManager $em)
$em->flush(); $em->flush();
$values = array(); $values = array();
$handlerId = null;
switch ($type) { switch ($type) {
case ExtraField::USER_FIELD_TYPE: case ExtraField::USER_FIELD_TYPE:
$optionTable = Database::get_main_table( $optionTable = Database::get_main_table(
@ -2556,17 +2565,24 @@ function fixIds(EntityManager $em)
if (!empty($values)) { if (!empty($values)) {
foreach ($values as $value) { foreach ($values as $value) {
$extraFieldValue = new ExtraFieldValues(); if (isset($value[$handlerId])) {
$extraFieldValue $extraFieldValue = new ExtraFieldValues();
->setValue($value['field_value']) $extraFieldValue
->setField($extraField) ->setValue($value['field_value'])
->setItemId($value[$handlerId]); ->setField($extraField)
$em->persist($extraFieldValue); ->setItemId($value[$handlerId]);
$em->flush(); $em->persist($extraFieldValue);
$em->flush();
}
} }
} }
} }
} }
if ($debug) {
error_log('Remove index');
}
// Drop temporary indexes added to increase speed of this function's queries // Drop temporary indexes added to increase speed of this function's queries
$sql = "ALTER TABLE c_document DROP INDEX tmpidx_doc"; $sql = "ALTER TABLE c_document DROP INDEX tmpidx_doc";
$connection->executeQuery($sql); $connection->executeQuery($sql);
@ -2576,6 +2592,10 @@ function fixIds(EntityManager $em)
$connection->executeQuery($sql); $connection->executeQuery($sql);
$sql = "ALTER TABLE c_item_property DROP INDEX tmpidx_ip"; $sql = "ALTER TABLE c_item_property DROP INDEX tmpidx_ip";
$connection->executeQuery($sql); $connection->executeQuery($sql);
if ($debug) {
error_log('Finish fixId function');
}
} }
/** /**

Loading…
Cancel
Save