Skip to content

Commit

Permalink
Fix DB errors in mysql >= 5.7.10
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Jan 13, 2016
1 parent 1c3b188 commit f9281cc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions main/exercice/exercise.class.php
Expand Up @@ -790,13 +790,13 @@ public function save($type_e = '')
if ($id) {
// we prepare date in the database using the api_get_utc_datetime() function
if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
$start_time = Database::escape_string($this->start_time);
$start_time = $this->start_time;
} else {
$start_time = '0000-00-00 00:00:00';
}

if (!empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00') {
$end_time = Database::escape_string($this->end_time);
$end_time = $this->end_time;
} else {
$end_time = '0000-00-00 00:00:00';
}
Expand Down
2 changes: 2 additions & 0 deletions main/inc/lib/course.lib.php
Expand Up @@ -4368,6 +4368,8 @@ public static function update_course_ranking(
'session_id' => $session_id,
'url_id' => $url_id,
'creation_date' => $now,
'total_score' => 0,
'users' => 0
);

$result = Database::select(
Expand Down
2 changes: 1 addition & 1 deletion main/inc/lib/document.lib.php
Expand Up @@ -4666,7 +4666,7 @@ public static function generateDefaultCertificate($courseData, $fromBaseCourse =
$fileFullPath = "{$filePath}/{$fileName}.html";
$fileSize = 0;
$fileType = 'file';
$templateContent = file_get_contents(api_get_path(SYS_CODE_PATH) . 'gradebook/certificate_template/template.html');
$templateContent = file_get_contents(api_get_path(SYS_CODE_PATH).'gradebook/certificate_template/template.html');

$search = array('{CSS}', '{IMG_DIR}', '{REL_CODE_PATH}', '{COURSE_DIR}');
$replace = array($css.$js, $img_dir, $codePath, $default_course_dir);
Expand Down
24 changes: 10 additions & 14 deletions main/inc/lib/events.lib.php
Expand Up @@ -174,21 +174,17 @@ public static function event_access_tool($tool, $id_session = 0)
$pos2 = isset($_SERVER['HTTP_REFERER']) ? strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower(api_get_path(WEB_PATH)."index")) : false;
// end "what's new" notification
if ($pos !== false || $pos2 !== false) {
$sql = "INSERT INTO ".$TABLETRACK_ACCESS."
(access_user_id,
c_id,
access_tool,
access_date,
access_session_id
)
VALUES
(".$user_id.",".// Don't add ' ' around value, it's already done.
"'".$courseId."' ,
'".$tool."',
'".$reallyNow."',
'".$id_session."')";
Database::query($sql);
$params = [
'access_user_id' => $user_id,
'c_id' => $courseId,
'access_tool' => $tool,
'access_date' => $reallyNow,
'access_session_id' => $id_session,
'user_ip' => api_get_real_ip()
];
Database::insert($TABLETRACK_ACCESS, $params);
}

// "what's new" notification
$sql = "UPDATE $TABLETRACK_LASTACCESS
SET access_date = '$reallyNow'
Expand Down
1 change: 0 additions & 1 deletion main/inc/lib/fileUpload.lib.php
Expand Up @@ -1226,7 +1226,6 @@ function add_document(
$table_document = Database::get_course_table(TABLE_DOCUMENT);

$params = [
'id' => '',
'c_id' => $c_id,
'path' => $path,
'filetype' => $filetype,
Expand Down

0 comments on commit f9281cc

Please sign in to comment.