Redirection issue after self enrolment

Redirection issue after self enrolment

by Mathias Chouet -
Number of replies: 6

Hello,

I'm using the self_enrol method to allow students to enrol in a course.

Clicking the enrolment button at the bottom of the enrol/index.php page is supposed to enrol the user, and redirect him/her to course/view.php.

And this is where I'm facing a strange issue : at times, the user is not taken to course/view.php but to the URL of an image, that I uploaded to Moodle and use in an HTML block ! It's a basic illustration with nothing special. The image is shown at the center on the page, no Moodle menus around, it's really the image URL.

I couldn't say exactly when it happens. At first I thought it was linked to the user's (in-)ability to view the sections of the course, which in my case are hidden at the moment. But when performing multiple self enrolments/unenrolments, the issue does not happen everytime. It seems that it happens a few times, then doesn't happen anymore for a given user.

The bug is hard to replay, seems pretty randomish.

I don't use any enrolment key. The course is open and visible, but most of the sections are not. That said, the first section (section0) is open and visible for students.

Where does this "redirection" come from ? Is Moodle trying to redirect the user to an invisible course element, thus leading to an incorrect place ? I tried to look at the execution flow in the code but I just ended up confused.

Any clue would be greatly appreciated.

Thanks a lot,

Mathias

Average of ratings: -
In reply to Mathias Chouet

Re: Redirection issue after self enrolment

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

This normally means that something is corrupt.  Have you cleared caches?  I would start there.

In reply to Emma Richardson

Re: Redirection issue after self enrolment

by Mathias Chouet -

Thanks Emma,

I'm pretty sure I cleared all the caches, but I will double check this. Also, for the first time today, logging in as administrator triggered the same bug : I was taken to an image URL again (not the same image, though).

As it happened as "admin", I now doubt it's linked to any visibility issue.

This Moodle instance has been migrated several times, using the doc's recommandations. Maybe the migrations have an impact ?

Mathias

In reply to Mathias Chouet

Re: Redirection issue after self enrolment

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

With me, it was actually a theme issue.  Then one day it just stopped happening which made me think it was a cache problem.

In reply to Emma Richardson

Re: Redirection issue after self enrolment

by Mathias Chouet -

Hi,

I "cleared all caches", and it seems that the bug doesn't happen anymore at login time. But it still does at enrol time...

Do you think it might be linked to the use of a PHP Opcode cache (I'm using OpCache) ? If I remember correctly, it happened already before I set OpCache up, but I'm not sure.

Might there be any cache that is not cleared bu the "clear all caches" button ?

Anyway thanks a lot,

Greetings,

Mathias

In reply to Mathias Chouet

Re: Redirection issue after self enrolment

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

You can actually go into your moodleDATA (NOT moodle) folder and delete the cache and localcache folders to fully clear it all out.  They will be recreated.  Do you have a custom theme?

In reply to Emma Richardson

Re: Redirection issue after self enrolment

by Mathias Chouet -

Just tried what you suggested and unfortunately it didn't prevent the problem from happening... the cache and localcache folders were recreated as expected but nothing changed.

I'm using a custom theme, more exactly Adaptable that we slightliy customized (mostly CSS).