Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-73564

PHP Fatal error: Cannot declare class webservice, because the name is already in use

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 3.11.5
    • 3.10.8, 3.11.4, 4.0
    • Web Services
    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE
    • MDL-73564-master
    • Hide
      1. Enable web services and web services documentation (enablewebservices and enablewsdocumentation)
      2. As admin go to Server>Web services>Documentation and make sure the page works
      3. Create a user and give them a capability 'moodle/webservice:createtoken' in the system context (either by creating and assigning a new role or adding this capability to an existing role of this user)
      4. Create a token for this user on Site administration>Server>Web services>Manage tokens
      5. Login as this user and navigate to your preferences and then click "Security keys"
      6. Make sure you can manage your security keys, click on "Documentation" link next to security key and make sure it works
      7. Modify the file admin/tool/policy/lib.php and add a function:

        function tool_policy_after_config() {
            global $CFG;
            require_once($CFG->dirroot.'/webservice/lib.php');
        }
        

      8. Purge caches
      9. Open the "Security keys" page as a user, there should be no exceptions
      10. Click on Documentation link next to the key and make sure there are on exceptions there either
      11. As admin go to Server>Web services>Documentation and make sure the page works
      Show
      Enable web services and web services documentation (enablewebservices and enablewsdocumentation) As admin go to Server>Web services>Documentation and make sure the page works Create a user and give them a capability 'moodle/webservice:createtoken' in the system context (either by creating and assigning a new role or adding this capability to an existing role of this user) Create a token for this user on Site administration>Server>Web services>Manage tokens Login as this user and navigate to your preferences and then click "Security keys" Make sure you can manage your security keys, click on "Documentation" link next to security key and make sure it works Modify the file admin/tool/policy/lib.php and add a function: function tool_policy_after_config() { global $CFG; require_once($CFG->dirroot.'/webservice/lib.php'); } Purge caches Open the "Security keys" page as a user, there should be no exceptions Click on Documentation link next to the key and make sure there are on exceptions there either As admin go to Server>Web services>Documentation and make sure the page works

    Description

      When 3rd party plugins are installed they may include the file webservice/lib.php during the page setup (in admin settings, page headers, not exactly sure where).

      In this case the following exception is thrown when a user tries to access "Security keys" in their profile:

      PHP Fatal error:  Cannot declare class webservice, because the name is already in use in /var/www/webservice/lib.php on line 50, referer https://XYZ/user/preferences.php
      

      This happens because the file user/managetoken.php calls require() instead of require_once().

      Attachments

        1. MDL-73564_master_Step 10.webm
          415 kB
        2. MDL-73564_master_Step 11.png
          MDL-73564_master_Step 11.png
          137 kB
        3. MDL-73564_master_Step 2.png
          MDL-73564_master_Step 2.png
          137 kB
        4. MDL-73564_master_Step 6.webm
          413 kB
        5. MDL-73564_v311_Step 10.webm
          437 kB
        6. MDL-73564_v311_Step 11.png
          MDL-73564_v311_Step 11.png
          154 kB
        7. MDL-73564_v311_Step 2.png
          MDL-73564_v311_Step 2.png
          154 kB
        8. MDL-73564_v311_Step 6.webm
          549 kB

        Issue Links

          Activity

            People

              marina Marina Glancy
              marina Marina Glancy
              Paul Holden Paul Holden
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Angelia Dela Cruz Angelia Dela Cruz
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 20 minutes
                  1h 20m

                  Clockify

                    Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.