Project

General

Profile

Bug #6183

Course redirection bug

Added by Yannick Warnier about 8 years ago. Updated about 7 years ago.

Status:
Needs testing
Priority:
Urgent
Assignee:
-
Category:
Global / Others / Misc
Target version:
Start date:
31/05/2013
Due date:
% Done:

50%

Estimated time:
Spent time:
Complexity:
Challenging
SCRUM pts - complexity:
?

Description

  • Create a course called "English".
  • Delete it.
  • Create another course called "English" (its directory will change because the previous directory is not deleted by default when the course is deleted)
  • Click on the course's name in the courses list
  • You get a 404 page

I'm not yet skilled enough in Silex to understand where it goes but I definitely understand that it's somehow not going to the right place (I placed an error_log in CourseHomeController::indexAction() and it's never found.

Associated revisions

Revision 1644a208 (diff)
Added by Julio Montoya about 8 years ago

Fixing delete course see #6183

Revision d69f4ffe (diff)
Added by Julio Montoya about 8 years ago

Fixing delete course see #6183

Revision ff01d5d3 (diff)
Added by Julio Montoya about 7 years ago

Fixing delete course course_rel_class is no longer use see #6183

History

#1

Updated by Julio Montoya about 8 years ago

The problem was in the delete course function this should be fixed here: (The course was not completely deleted)

https://github.com/chamilo/chamilo-lms/commit/d69f4ffe8320e583669f0a111d320c9c374b8354

The 404 error is "correct" because that course code does not exists.

Before the "CourseHomeController::indexAction" function is executed, there are some middlewares see (http://silex.sensiolabs.org/doc/middlewares.html) located in the "routes.php" file.

For that action in particular we have this:

/** Course home instead of courses/MATHS the new URL is web/courses/MATHS  */
$app->match('/courses/{cidReq}/{id_session}/', 'course_home.controller:indexAction', 'GET|POST')
    ->assert('id_session', '\d+')
    ->assert('type', '.+')
    ->before($settingCourseConditions)
    ->before($userPermissionsInsideACourse)
    ->bind('course');

As you can see there are 2 "before" middlewares "$settingCourseConditions" and "$userPermissionsInsideACourse" those are are anonymous functions that validate the existence of the course and other things. One of them throws a 404 thanks to the "abort()" function. Like this: (sample function)

$settingCourseConditions = function (Request $request) use ($cidReset, $app) {

$courseInfo = api_get_course_info($cidReq);

if (!empty($courseInfo)) {
    $courseCode = $courseInfo['code'];
    $courseId   = $courseInfo['real_id'];

    Session::write('_real_cid', $courseId);
    Session::write('_cid', $courseCode);
    Session::write('_course', $courseInfo);

} else {
    $app->abort(404, 'Course not available');
}    


#2

Updated by Julio Montoya about 8 years ago

  • Status changed from Assigned to Needs testing
  • Assignee deleted (Julio Montoya)
  • % Done changed from 0 to 50
#3

Updated by Laura Guirao about 7 years ago

I have tested it in stable.chamilo.org:

I have created a course called "paraborrar"
I have deleted this course, the course is deleted, but the screen shows an error:

DATABASE ERROR #1146:
 Table 'stablechamilo.course_rel_class' doesn't exist
QUERY       :
 DELETE FROM `stablechamilo`.`course_rel_class` WHERE course_code='PARABORRAR'
FILE        :
 /var/www/stable.chamilo.org/www/main/inc/lib/course.lib.php
LINE        :
 2088
CLASS       :
 CourseManager
METHOD      :
 delete_course

I have created a new course called "paraborrar"
I go to the course main page, there is no error. The course page is normal.

#4

Updated by Julio Montoya about 7 years ago

Laura Guirao wrote:

I have tested it in stable.chamilo.org:

I have created a course called "paraborrar"
I have deleted this course, the course is deleted, but the screen shows an error:
[...]

I have created a new course called "paraborrar"
I go to the course main page, there is no error. The course page is normal.

I just sent a fix for this.

Also available in: Atom PDF