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

It's possible to break site JS

    XMLWordPrintable

Details

    • MOODLE_401_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-78157-401
    • MDL-78157-402
    • MDL-78157-master
    • Hide
      1. Run npx grunt watch
      2. Create a new file in lib/amd/src/mdl78379.js with content:

        // This file is part of Moodle - <http://moodle.org/>
        //
        // Moodle is free software: you can redistribute it and/or modify
        // it under the terms of the GNU General Public License as published by
        // the Free Software Foundation, either version 3 of the License, or
        // (at your option) any later version.
        //
        // Moodle is distributed in the hope that it will be useful,
        // but WITHOUT ANY WARRANTY; without even the implied warranty of
        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        // GNU General Public License for more details.
        //
        // You should have received a copy of the GNU General Public License
        // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
         
        /**
         
        * Empty JS file to help with testing MDL-78379.
        *
        * @module     local_mdl_helper/empty
        * @copyright  2023 Mikhail Golenkov <mikhailgolenkov@catalyst-au.net>
        * @license    <http://www.gnu.org/copyleft/gpl.html> GNU GPL v3 or later
         */
        

        1. Confirm that the file built
      3. Ensure that $CFG->cachejs is false by either:
        1. running mdk run dev if you use mdk
        2. setting $CFG->cachejs = false; in your config.php
        3. Navigating to Site admin -> Administration -> Appearance -> AJAX and Javascript -> Cache Javascript = false
      4. Navigate to any page
      5. In your browser console run:

        require(['core/mdl78379']);
        

        1. Confirm that there was no error about an "Uncaught syntax error" or similar (for example):

          Uncaught SyntaxError: Unexpected token '*' (at mdl78379.js:2:2)
          

          NOTE: There is still a warning that is expected:

          Uncaught Error: No define call for core/mdl78379
          

      Show
      Run npx grunt watch Create a new file in lib/amd/src/mdl78379.js with content: // This file is part of Moodle - <http://moodle.org/> // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>.   /**   * Empty JS file to help with testing MDL-78379. * * @module local_mdl_helper/empty * @copyright 2023 Mikhail Golenkov <mikhailgolenkov@catalyst-au.net> * @license <http://www.gnu.org/copyleft/gpl.html> GNU GPL v3 or later */ Confirm that the file built Ensure that $CFG->cachejs is false by either: running mdk run dev if you use mdk setting $CFG->cachejs = false; in your config.php Navigating to Site admin -> Administration -> Appearance -> AJAX and Javascript -> Cache Javascript = false Navigate to any page In your browser console run: require(['core/mdl78379']); Confirm that there was no error about an "Uncaught syntax error" or similar (for example): Uncaught SyntaxError: Unexpected token '*' (at mdl78379.js:2:2) NOTE: There is still a warning that is expected: Uncaught Error: No define call for core/mdl78379

    Description

      After MDL-78157 landed to core, it's possible to break site JS. 

      It looks like we had a staled minified file (existing resultsvalidatedbutton.min.js without actual resultsvalidatedbuttonjs) in our code base that gave us following error (attached scheenshot) on a test instance after applying MDL-78157.

       

      Attachments

        1. (I) Passed -- (Master)MDL-78379.png
          (I) Passed -- (Master)MDL-78379.png
          121 kB
        2. screenshot-1.png
          screenshot-1.png
          88 kB
        3. screenshot-2.png
          screenshot-2.png
          71 kB
        4. screenshot-3.png
          screenshot-3.png
          84 kB

        Issue Links

          Activity

            People

              mikhailgolenkov Misha Golenkov
              dmitriim Dmitrii Metelkin
              Dmitrii Metelkin Dmitrii Metelkin
              Andrew Lyons Andrew Lyons
              Kim Jared Lucas Kim Jared Lucas
              Votes:
              0 Vote for this issue
              Watchers:
              5 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, 32 minutes
                  1h 32m

                  Clockify

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