Code Monkey home page Code Monkey logo

Comments (7)

lukecarr avatar lukecarr commented on August 14, 2024 1

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.

danmarsden avatar danmarsden commented on August 14, 2024

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.

lukecarr avatar lukecarr commented on August 14, 2024

@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.

DrCuriosity avatar DrCuriosity commented on August 14, 2024

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.

lukecarr avatar lukecarr commented on August 14, 2024

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.

DrCuriosity avatar DrCuriosity commented on August 14, 2024

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.

DrCuriosity avatar DrCuriosity commented on August 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.