Moodle
  1. Moodle
  2. MDL-27563

Error on Shibboleth login when using user profile menu field

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide

      1. Turn on Shibboleth authentication.
      2. Turn on Developer-level debugging.
      3. Hit the Shibboleth login page.

      You shouldn't get any notices.

      Show
      1. Turn on Shibboleth authentication. 2. Turn on Developer-level debugging. 3. Hit the Shibboleth login page. You shouldn't get any notices.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-27563-master
    • Rank:
      17229

      Description

      After creating a user profile menu field, started to get the following error when on Shibboleth login:
      Coding problem: this page does not set $PAGE->context properly.
      line 341 of /lib/pagelib.php: call to debugging()
      line 599 of /lib/pagelib.php: call to moodle_page->magic_get_context()
      line 1236 of /lib/weblib.php: call to moodle_page->__get()
      line 23 of /user/profile/field/menu/field.class.php: call to format_string()
      line 496 of /user/profile/lib.php: call to profile_field_menu->profile_field_menu()
      line 517 of /user/profile/lib.php: call to profile_user_record()
      line 3820 of /lib/moodlelib.php: call to profile_load_custom_fields()
      line 3504 of /lib/moodlelib.php: call to get_complete_user_data()
      line 42 of /auth/shibboleth/index.php: call to authenticate_user_login()

      Adding $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); to the top of auth/shibboleth/index.php appears to fix the problem.

      This is similar to MDL-27192, but in a different area. The same problem likely appears in other areas as well.

      A comment on the line in format_string predicts problems, so, ideally, we could have a more general solution...

      1234 if (empty($options['context'])) {
      1235 // fallback to $PAGE->context this may be problematic in CLI and other non-standard pages
      1236 $options['context'] = $PAGE->context;

        Issue Links

          Activity

          Hide
          Charles Fulton added a comment -

          This error is more general than reported; it'll occur in any Shibboleth environment because the login page doesn't set context. Colin's fix works but I think it's better to match login/index.php and set $context separately. Should be clean to cherry-pick to stable branches.

          Show
          Charles Fulton added a comment - This error is more general than reported; it'll occur in any Shibboleth environment because the login page doesn't set context. Colin's fix works but I think it's better to match login/index.php and set $context separately. Should be clean to cherry-pick to stable branches.
          Hide
          Dan Poltawski added a comment -

          Hi Charles,

          Looks good, but since 2.2 we have introduced an object-based API for getting to contexts, so should be:

          context_system::instance() to get system context.

          Show
          Dan Poltawski added a comment - Hi Charles, Looks good, but since 2.2 we have introduced an object-based API for getting to contexts, so should be: context_system::instance() to get system context.
          Hide
          Charles Fulton added a comment -

          Thanks--rebased and updated.

          Show
          Charles Fulton added a comment - Thanks--rebased and updated.
          Hide
          Dan Poltawski added a comment -

          Thanks, submitting for integration.

          Show
          Dan Poltawski added a comment - Thanks, submitting for integration.
          Hide
          Dan Poltawski added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Sam Hemelryk added a comment -

          Thanks Charles, this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks Charles, this has been integrated now
          Hide
          Dan Poltawski added a comment -

          As we don't currently have a shibboleth install setup here for testing (and its quite complex to do so) i'm going to propose we test this via code review only.

          Show
          Dan Poltawski added a comment - As we don't currently have a shibboleth install setup here for testing (and its quite complex to do so) i'm going to propose we test this via code review only.
          Hide
          Rossiani Wijaya added a comment -

          +1 for Dan's suggestion.

          Show
          Rossiani Wijaya added a comment - +1 for Dan's suggestion.
          Hide
          Rossiani Wijaya added a comment -

          Patch looks good.

          Test passed.

          Show
          Rossiani Wijaya added a comment - Patch looks good. Test passed.
          Hide
          Dan Poltawski added a comment -

          *Notice*: Undefined variable: friendlyintegrator in /Users/danp/git/tokenintegrationthanks.php on line 26

          Congratulations

          {tracker.user.name}

          !

          You've made into Moodle

          {tracker.fixversion-1}

          +

          I would like to personally thank you for this contribution on behalf of all Moodle users throughout the world.

          cheers!

          {tracker.friendlyintegrator}
          Show
          Dan Poltawski added a comment - * Notice *: Undefined variable: friendlyintegrator in /Users/danp/git/tokenintegrationthanks.php on line 26 Congratulations {tracker.user.name} ! You've made into Moodle {tracker.fixversion-1} + I would like to personally thank you for this contribution on behalf of all Moodle users throughout the world. cheers! {tracker.friendlyintegrator}
          Hide
          Colin Campbell added a comment -

          This defect has never been fixed. I just tried the latest 2.6 code to confirm there before applying my own local fix to 2.6. When I log in, I get the following error on auth/shibboleth/index.php.

          Coding problem: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result
          line 451 of /lib/pagelib.php: call to debugging()
          line 734 of /lib/pagelib.php: call to moodle_page->magic_get_context()
          line 1342 of /lib/weblib.php: call to moodle_page->__get()
          line 23 of /user/profile/field/menu/field.class.php: call to format_string()
          line 509 of /user/profile/lib.php: call to profile_field_menu->profile_field_menu()
          line 530 of /user/profile/lib.php: call to profile_user_record()
          line 4691 of /lib/moodlelib.php: call to profile_load_custom_fields()
          line 4248 of /lib/moodlelib.php: call to get_complete_user_data()
          line 48 of /auth/shibboleth/index.php: call to authenticate_user_login()

          As I stated in the original description of the problem, setting the context at the top of auth/shibboleth/index.php fixes the problem. It might not be the best solution for whatever reason, but it does work.

          Show
          Colin Campbell added a comment - This defect has never been fixed. I just tried the latest 2.6 code to confirm there before applying my own local fix to 2.6. When I log in, I get the following error on auth/shibboleth/index.php. Coding problem: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result line 451 of /lib/pagelib.php: call to debugging() line 734 of /lib/pagelib.php: call to moodle_page->magic_get_context() line 1342 of /lib/weblib.php: call to moodle_page->__get() line 23 of /user/profile/field/menu/field.class.php: call to format_string() line 509 of /user/profile/lib.php: call to profile_field_menu->profile_field_menu() line 530 of /user/profile/lib.php: call to profile_user_record() line 4691 of /lib/moodlelib.php: call to profile_load_custom_fields() line 4248 of /lib/moodlelib.php: call to get_complete_user_data() line 48 of /auth/shibboleth/index.php: call to authenticate_user_login() As I stated in the original description of the problem, setting the context at the top of auth/shibboleth/index.php fixes the problem. It might not be the best solution for whatever reason, but it does work.
          Hide
          Dan Poltawski added a comment -

          Hi Colin,

          Please can you report that as a new issue? As this issue has now been clsoed we can't deal with it here.

          Show
          Dan Poltawski added a comment - Hi Colin, Please can you report that as a new issue? As this issue has now been clsoed we can't deal with it here.
          Hide
          Matt Petro added a comment -

          New issue is here: MDL-45118

          Show
          Matt Petro added a comment - New issue is here: MDL-45118

            People

            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: