Moodle
  1. Moodle
  2. MDL-34175

incorrect JS include and other problems when /admin/ folder renamed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Roles / Access
    • Labels:
      None
    • Rank:
      42512

      Description

      In Site Administration/Users/Permissions/Define Roles/.

      When you click on a Role, you will see the error message "Coding error detected, it must be fixed by a programmer: Attempt to require a JavaScript file that does not exist."

      I also get this error message in "Check System Permissions" and "Assign System Roles".

      I am using Moodle 2.3+ (Build: 20120701)

      1. define_roles.jpg
        63 kB
      2. edit_roles.jpg
        115 kB
      3. edit_student_role.jpg
        94 kB
      4. Profile-send_message.jpg
        69 kB
      5. send_message.jpg
        38 kB

        Activity

        Hide
        Petr Škoda added a comment -

        Hello,

        I have tried it and it works fine for me, I also verified the code and I can not see any broken JS includes theres.

        It looks like you are missing some of the JS files in your install, or there is a problem with some contrib plugin or a theme.

        Sorry, can not reproduce. Please try it again in a new git branch from latest MOODLE_23_STABLE.

        Petr

        Show
        Petr Škoda added a comment - Hello, I have tried it and it works fine for me, I also verified the code and I can not see any broken JS includes theres. It looks like you are missing some of the JS files in your install, or there is a problem with some contrib plugin or a theme. Sorry, can not reproduce. Please try it again in a new git branch from latest MOODLE_23_STABLE. Petr
        Hide
        Clarence Prudhoe added a comment -

        Hello Petr,

        Thanks for helping me with this problem.

        I downloaded and installed Moodle 2.3+ (Build: 20120701) as a .zip file again as you suggested. I uploaded moodle-latest-23.zip to my dedicated server and unziped it there.

        I logged in as Admin and opened /Site Administration/Users/Permissions/Define roles/ and selected "Student" from the Roles column. I get the same error message "Coding error detected, it must be fixed by a programmer: Attempt to require a JavaScript file that does not exist." SEE attached screenshot – define_roles.png

        I can't find any link to list the roles and edit the permissions. In the Moodle Docs it says:

        To edit a role:

        Go to Settings > Site administration > Users > Permissions > Define roles.
        Click the edit icon opposite the role you want to edit e.g. student.
        On the edit role page, change permissions as required for each capability.

        If I follow these instructions, I get the same coding error message and it doesn't list the permissions. SEE attached screenshot – edit_student_role.png

        Some time ago I edited the Student permissions so they could not send messages to each other. I have changed my mind about this and need to change the messaging permissions. Now I can't find a way to edit the permissions.

        In /Site Administration/Users/Permissions/Define roles/Student/ I clicked the EDIT tab but it doesn't list the permissions for the Student Role. SEE attached screenshot – edit_roles.png

        I tried to reset the Student permissions to the defaults but it doesn't change the messaging permission either.

        From /My home/My profile/Messages/ I see the users in my contact list. When I click on the user's name, it doesn't open the Message window to write a message. SEE attached screenshot – send_message.png. The "Send Message"

        When I click a user's name in the Online Users block, it opens the user's profile but it doesn't show the "Send Message" button. SEE attached screenshot – Profile-send_message.png. The "Send Message"

        I assume this missing JavaScript file is the problem.

        Please let me know if you can suggest a solution to this problem.

        Thanks,
        Clarence Prudhoe

        Show
        Clarence Prudhoe added a comment - Hello Petr, Thanks for helping me with this problem. I downloaded and installed Moodle 2.3+ (Build: 20120701) as a .zip file again as you suggested. I uploaded moodle-latest-23.zip to my dedicated server and unziped it there. I logged in as Admin and opened /Site Administration/Users/Permissions/Define roles/ and selected "Student" from the Roles column. I get the same error message "Coding error detected, it must be fixed by a programmer: Attempt to require a JavaScript file that does not exist." SEE attached screenshot – define_roles.png I can't find any link to list the roles and edit the permissions. In the Moodle Docs it says: To edit a role: Go to Settings > Site administration > Users > Permissions > Define roles. Click the edit icon opposite the role you want to edit e.g. student. On the edit role page, change permissions as required for each capability. If I follow these instructions, I get the same coding error message and it doesn't list the permissions. SEE attached screenshot – edit_student_role.png Some time ago I edited the Student permissions so they could not send messages to each other. I have changed my mind about this and need to change the messaging permissions. Now I can't find a way to edit the permissions. In /Site Administration/Users/Permissions/Define roles/Student/ I clicked the EDIT tab but it doesn't list the permissions for the Student Role. SEE attached screenshot – edit_roles.png I tried to reset the Student permissions to the defaults but it doesn't change the messaging permission either. From /My home/My profile/Messages/ I see the users in my contact list. When I click on the user's name, it doesn't open the Message window to write a message. SEE attached screenshot – send_message.png. The "Send Message" When I click a user's name in the Online Users block, it opens the user's profile but it doesn't show the "Send Message" button. SEE attached screenshot – Profile-send_message.png. The "Send Message" I assume this missing JavaScript file is the problem. Please let me know if you can suggest a solution to this problem. Thanks, Clarence Prudhoe
        Hide
        Clarence Prudhoe added a comment -

        I forgot to mention this this test was done on Moodle right out of the box. There are no non-standard plugins and no code hacks. There are some modifications to the Theme Fusion.

        Thanks,
        Clarence

        Show
        Clarence Prudhoe added a comment - I forgot to mention this this test was done on Moodle right out of the box. There are no non-standard plugins and no code hacks. There are some modifications to the Theme Fusion. Thanks, Clarence
        Hide
        Petr Škoda added a comment - - edited

        The latest zip package works fine for me, the problem is most probably in unzipping or somewhere in your server. Please use moodle.org support forums if you need help with this problem. You should also try the DEBUG_DEVELOPER mode, it should tell you which file exactly causes the problem.

        Show
        Petr Škoda added a comment - - edited The latest zip package works fine for me, the problem is most probably in unzipping or somewhere in your server. Please use moodle.org support forums if you need help with this problem. You should also try the DEBUG_DEVELOPER mode, it should tell you which file exactly causes the problem.
        Hide
        Clarence Prudhoe added a comment -

        Thanks for the push to turn on Debug Mode.

        I found the bug.

        If you rename /moodle/admin/ to another folder name as recommended, the error occurs.

        In /moodle/lib/outputrequirementslib.php on line #462 you will find this code:

        case 'core_role':
        $module = array('name' => 'core_role',
        'fullpath' => '/admin/roles/module.js',
        'requires' => array('node', 'cookie'));
        break;

        /admin/roles/module.js is hard coded so it can't find /myadmin/roles/module.js because I renamed /admin/ as is recommended.

        Hope this helps,
        Clarence

        Show
        Clarence Prudhoe added a comment - Thanks for the push to turn on Debug Mode. I found the bug. If you rename /moodle/admin/ to another folder name as recommended, the error occurs. In /moodle/lib/outputrequirementslib.php on line #462 you will find this code: case 'core_role': $module = array('name' => 'core_role', 'fullpath' => '/admin/roles/module.js', 'requires' => array('node', 'cookie')); break; /admin/roles/module.js is hard coded so it can't find /myadmin/roles/module.js because I renamed /admin/ as is recommended. Hope this helps, Clarence
        Hide
        Petr Škoda added a comment -

        ah! that would explain it, reopening

        Show
        Petr Škoda added a comment - ah! that would explain it, reopening
        Hide
        Petr Škoda added a comment -

        I did not backport this to older branches because most probably nobody else is using it otherwise they would have reported this already, all new installs and upgrades should use 2.3 - it should not cause problems when doing upgrade from 1.9->2.2->2.3

        Thanks for the report!

        Show
        Petr Škoda added a comment - I did not backport this to older branches because most probably nobody else is using it otherwise they would have reported this already, all new installs and upgrades should use 2.3 - it should not cause problems when doing upgrade from 1.9->2.2->2.3 Thanks for the report!
        Hide
        Sam Hemelryk added a comment -

        Thanks Petr, this has been integrated now. I partially cherry-picked to 22 as well as we do still support bug fixes there.

        Cheers
        Sam

        Show
        Sam Hemelryk added a comment - Thanks Petr, this has been integrated now. I partially cherry-picked to 22 as well as we do still support bug fixes there. Cheers Sam
        Hide
        Frédéric Massart added a comment -

        Hi guys, I have tested this issue and the changes work fine. However, I accidentally clicked on another link and the site just crashed. I then grep'd for '/admin/' and noticed that it was used in many other places. Should this be fixed as part of this issue or a new one? (Waiting for your answer to finalize the test).

        Show
        Frédéric Massart added a comment - Hi guys, I have tested this issue and the changes work fine. However, I accidentally clicked on another link and the site just crashed. I then grep'd for '/admin/' and noticed that it was used in many other places. Should this be fixed as part of this issue or a new one? (Waiting for your answer to finalize the test).
        Hide
        Petr Škoda added a comment -

        "site crashed" means what? yes, there are supposed to be tons of /admin/ in source code because it is automatically translated to $CFG->admin in moodle_url class

        Show
        Petr Škoda added a comment - "site crashed" means what? yes, there are supposed to be tons of /admin/ in source code because it is automatically translated to $CFG->admin in moodle_url class
        Hide
        Frédéric Massart added a comment -

        Sorry, should have given more information. It actually fails because of a require() error. See /admin/mnet/peers.php

        Warning: require_once(/home/fred/www/repositories/testing_master/moodle/admin/mnet/peer_forms.php): failed to open stream: No such file or directory in /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php on line 33 Call Stack: 0.0006 794584 1. {main}() /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php:0 Fatal error: require_once(): Failed opening required '/home/fred/www/repositories/testing_master/moodle/admin/mnet/peer_forms.php' (include_path='/home/fred/www/repositories/testing_master/moodle/lib/zend:/home/fred/www/repositories/testing_master/moodle/lib/pear:.:/usr/share/php:/usr/share/pear') in /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php on line 33 Call Stack: 0.0006 794584 1. {main}() /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php:0 
        
        Show
        Frédéric Massart added a comment - Sorry, should have given more information. It actually fails because of a require() error. See /admin/mnet/peers.php Warning: require_once(/home/fred/www/repositories/testing_master/moodle/admin/mnet/peer_forms.php): failed to open stream: No such file or directory in /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php on line 33 Call Stack: 0.0006 794584 1. {main}() /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php:0 Fatal error: require_once(): Failed opening required '/home/fred/www/repositories/testing_master/moodle/admin/mnet/peer_forms.php' (include_path='/home/fred/www/repositories/testing_master/moodle/lib/zend:/home/fred/www/repositories/testing_master/moodle/lib/pear:.:/usr/share/php:/usr/share/pear') in /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php on line 33 Call Stack: 0.0006 794584 1. {main}() /home/fred/www/repositories/testing_master/moodle/bdmin/mnet/peers.php:0
        Hide
        Petr Škoda added a comment -

        both branches updated, integrators please merge, thanks for the report

        Show
        Petr Škoda added a comment - both branches updated, integrators please merge, thanks for the report
        Hide
        Dan Poltawski added a comment -

        I've merged the two fixes. thanks

        Show
        Dan Poltawski added a comment - I've merged the two fixes. thanks
        Hide
        Frédéric Massart added a comment - - edited

        Hi guys, I discovered a new issue. Going to the Registration page fails with an exception. I guess that'd be an inclusion error as the class exists.

        Coding error detected, it must be fixed by a programmer: Request for an unknown renderer class core_register_renderer
        
        More information about this error
        Stack trace:
        
            line 219 of /lib/outputfactories.php: coding_exception thrown
            line 1073 of /lib/outputlib.php: call to standard_renderer_factory->get_renderer()
            line 648 of /lib/pagelib.php: call to theme_config->get_renderer()
            line 39 of /fmcorz/registration/index.php: call to moodle_page->get_renderer()
        
        Show
        Frédéric Massart added a comment - - edited Hi guys, I discovered a new issue. Going to the Registration page fails with an exception. I guess that'd be an inclusion error as the class exists. Coding error detected, it must be fixed by a programmer: Request for an unknown renderer class core_register_renderer More information about this error Stack trace: line 219 of /lib/outputfactories.php: coding_exception thrown line 1073 of /lib/outputlib.php: call to standard_renderer_factory->get_renderer() line 648 of /lib/pagelib.php: call to theme_config->get_renderer() line 39 of /fmcorz/registration/index.php: call to moodle_page->get_renderer()
        Hide
        Sam Hemelryk added a comment -

        Hmm that definitely looks like a separate issue to me.
        The changes Petr made didn't go near the registration area, did you spot anything else btw Fred or was that it.

        Thinking if that was it we can mark this passed and open an issue for the registration bug.

        Show
        Sam Hemelryk added a comment - Hmm that definitely looks like a separate issue to me. The changes Petr made didn't go near the registration area, did you spot anything else btw Fred or was that it. Thinking if that was it we can mark this passed and open an issue for the registration bug.
        Hide
        Petr Škoda added a comment - - edited

        Registration is a separate problem, it uses hardcoded /admin/ also on the registration server which would need to be fixed/updated too, also at the same time it should be move to /admin/tool/ once the exact script location is sent to the server.

        +1 to create new issue for registration.

        Show
        Petr Škoda added a comment - - edited Registration is a separate problem, it uses hardcoded /admin/ also on the registration server which would need to be fixed/updated too, also at the same time it should be move to /admin/tool/ once the exact script location is sent to the server. +1 to create new issue for registration.
        Hide
        Frédéric Massart added a comment -

        +1 too then.
        No other problems detected. Test can be passed!

        Show
        Frédéric Massart added a comment - +1 too then. No other problems detected. Test can be passed!
        Hide
        Dan Poltawski added a comment -

        Passing the test, as discussed.

        Show
        Dan Poltawski added a comment - Passing the test, as discussed.
        Hide
        Dan Poltawski added a comment -

        Congratulations!

        You've made it into the weekly release!

        Thanks for your contribution - here are some random drummers to keep you inspired for the next week!
        http://www.youtube.com/watch?v=_QhpHUmVCmY

        Show
        Dan Poltawski added a comment - Congratulations! You've made it into the weekly release! Thanks for your contribution - here are some random drummers to keep you inspired for the next week! http://www.youtube.com/watch?v=_QhpHUmVCmY

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: