Comments (7)
Just chiming in to mention that I believe this issue was actually a result of me having set Moodle's message debugging level to DEVELOPER
. Turning that off, I no longer had the errors, and sign in functionality worked as intended, leading me to believe that the "errors" I had were mere warnings.
from moodle-local_cohortauto.
Thanks @lukecarr - I've got a site using oauth that is about to use this plugin pretty soon - feel free to submit a PR otherwise I'm likely to need to look at this at some point soon.
from moodle-local_cohortauto.
@danmarsden I'm not too well versed in Moodle plugin development, so I wouldn't know where to start!
Do you think you'd be able to have a fix ready by October 9th? I've got a Moodle site currently succumbing to this error that I'd like to push to production on that date.
from moodle-local_cohortauto.
Looking at this now. It appears that the issue might be to do with format_string()
requiring a context that it is not able to pick up automatically when an event is triggered during OAuth2 negotiation.
Unfortunately I'm not able to replicate this error on the 3.9 site I have available to me (Version 3.9.2+ (Build: 20200929) (2020061502.03))
I think we could maybe fix this by explicitly passing the system context through to the format_string()
calls that are initiated by the event observer. E.g. in the user_profile_hook()
function, changing the line:
$cohortslist[$cohort->id] = format_string($cohort->name);;
to:
$cohortslist[$cohort->id] = format_string($cohort->name, true, array('context' => $context));
This should pick up the $context = context_system::instance();
earlier in the function.
@lukecarr, are you in a position to make this change locally, and see if it helps on your site?
from moodle-local_cohortauto.
Thanks for the reply @DrCuriosity. Unfortunately, after implementing your proposed fix locally, the issue still persists. The error message hasn't changed at all. I can still click 'Continue' to log in successfully, the same as before.
from moodle-local_cohortauto.
Curses. Same stack trace and everything?
Unfortunately I still haven't been able to replicate the issue locally. I'll see if I can find another approach to try on (UTC+13) Monday.
from moodle-local_cohortauto.
No luck, I'm afraid. Even testing the event trigger via a CLI script, it seems to work fine here.
The only thing I can think of is that somewhere along the line, the format_string()
function is trying to do something else that relies on an implicit context being set outside of the explicit system context we're giving it, when the event is triggered via OAuth2. If this is the case, it might be best to try the "dumb" context-free fallback option of using strip_tags()
, as per this snippet from weblib.php
:
if (!$options['context']) {
// We did not find any context? weird.
return $string = strip_tags($string);
}
i.e.:
$cohortslist[$cohort->id] = strip_tags($cohort->name);
It's not an elegant fix but it might be worth trying out, if only to see if the problem goes away or not.
from moodle-local_cohortauto.
Related Issues (20)
- Looking for a way to create cohort based on user creation time HOT 6
- Force cohorts to update without logging in users HOT 2
- Can't delete generated cohorts HOT 1
- Support for 3.11? HOT 1
- Deprecated: Required parameter $result follows optional parameter $prefix in HOT 1
- allow match on cohortid HOT 1
- Compatible moodle 4.X ? HOT 1
- UI checks making unit tests failure HOT 1
- sync_users.php not working in moodle 4 HOT 3
- Massive Server Load HOT 7
- NULL value for column idnumber is not allowed on Moodle 4.1+ anymore HOT 1
- Problems when using the Plugin HOT 1
- Moodle 4.0 or 4.1 HOT 1
- Prevent warnings on empty emails HOT 2
- warning for $PAGE->context not set when logging in user HOT 2
- settings.php: curious why this plugin is not listed in the local plugin settings HOT 1
- 50 unicode symbols is too short HOT 2
- support for split+replace and fields on inner arrays on split commands. HOT 3
- Moodle 3.9 issues HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moodle-local_cohortauto.