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

mod/lti brings Invalid opcode 153/1/8 with eaccelerator

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide
      1. Install on moodle on eaccelerator
      2. Go to Home > Site administration > Plugins > Activity modules > LTI
      3. Ensure that the page displays correctly
      4. The content under the three tabs was originally organized by filtering the tools by type using an anonymous function. The anonymous function has been removed and now eaccelerator should no longer fail.
      Show
      Install on moodle on eaccelerator Go to Home > Site administration > Plugins > Activity modules > LTI Ensure that the page displays correctly The content under the three tabs was originally organized by filtering the tools by type using an anonymous function. The anonymous function has been removed and now eaccelerator should no longer fail.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull Master Branch:
      MDL-36060-master

      Description

      PHP Fatal error: Invalid opcode 153/1/8. in /var/www/moodle/mod/lti/settings.php on line 69

      the lti setting.php makes moodle unusable for admins in combination with eaccelerator, because eaccelerator does not support anonymous functions.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            salvetore Michael de Raadt added a comment -

            Thanks for reporting that. If you can provide any further information, please do.

            Please feel free to work on this issue with us.

            Show
            salvetore Michael de Raadt added a comment - Thanks for reporting that. If you can provide any further information, please do. Please feel free to work on this issue with us.
            Hide
            wheelie1978 colin wheelhouse added a comment -

            I have just encountered this issue, bizarrely not all admin functions seem to be hindered by this. Shame because the eaccelerator has really improved the speed of the site. It does stop you being able to turn on debugging unless you manually edit the config.php file to display errors.

            Show
            wheelie1978 colin wheelhouse added a comment - I have just encountered this issue, bizarrely not all admin functions seem to be hindered by this. Shame because the eaccelerator has really improved the speed of the site. It does stop you being able to turn on debugging unless you manually edit the config.php file to display errors.
            Hide
            pauper Paul Perger added a comment -

            Well I have the same PHP error on Moodle 2.2.2+, my provider also runs eaccelarator.

            Show
            pauper Paul Perger added a comment - Well I have the same PHP error on Moodle 2.2.2+, my provider also runs eaccelarator.
            Hide
            tomaz20 tomaz turk added a comment - - edited

            It is the same with me on 2.2.4.

            Show
            tomaz20 tomaz turk added a comment - - edited It is the same with me on 2.2.4.
            Hide
            fastenko Ilya Fastenko added a comment - - edited

            Hello. I have this problem on moodle 2.2.7 with php version 5.3.21
            But i don't have it on moodle 2.2.7 with php version 5.3.5

            Problem in script mod/lti/settings.php on lines: 69, 75, 81. Wrong options types in array_filter() php function. If you visit the site php.net, which contains official php documentation, you see recommendations to call this function:
            http://www.php.net/manual/en/function.array-filter.php

            example from php.net:
            function even($var)

            { // returns whether the input integer is even return(!($var & 1)); }

            array_filter($array2, "even");

            If fix in mod/lti/settings.php:
            $configuredtools = array_filter($types, function($value)

            { return $value->state == LTI_TOOL_STATE_CONFIGURED; });

            for example to:
            function lti_tool_state_configured($value){ return $value->state == LTI_TOOL_STATE_CONFIGURED; }

            $configuredtools = array_filter($types, "lti_tool_state_configured");

            moodle works fine.

            Show
            fastenko Ilya Fastenko added a comment - - edited Hello. I have this problem on moodle 2.2.7 with php version 5.3.21 But i don't have it on moodle 2.2.7 with php version 5.3.5 Problem in script mod/lti/settings.php on lines: 69, 75, 81. Wrong options types in array_filter() php function. If you visit the site php.net, which contains official php documentation, you see recommendations to call this function: http://www.php.net/manual/en/function.array-filter.php example from php.net: function even($var) { // returns whether the input integer is even return(!($var & 1)); } array_filter($array2, "even"); If fix in mod/lti/settings.php: $configuredtools = array_filter($types, function($value) { return $value->state == LTI_TOOL_STATE_CONFIGURED; }); for example to: function lti_tool_state_configured($value){ return $value->state == LTI_TOOL_STATE_CONFIGURED; } $configuredtools = array_filter($types, "lti_tool_state_configured"); moodle works fine.
            Hide
            fastenko Ilya Fastenko added a comment -

            little update. I think, functions: lti_tool_state_configured(), lti_tool_state_pending(), lti_tool_state_rejected() are better declare in /mod/lti/locallib.php.

            Show
            fastenko Ilya Fastenko added a comment - little update. I think, functions: lti_tool_state_configured(), lti_tool_state_pending(), lti_tool_state_rejected() are better declare in /mod/lti/locallib.php.
            Hide
            kstokking Kris Stokking added a comment -

            Hi all, I've assigned this ticket to myself as Chris won't have time to work on it.

            I'd like to get a better idea of how to resolve this issue, as anonymous functions are used all over Moodle (at least as of 2.4). Some examples (incomplete list):

            • lib/tcpdf
            • mod/wiki
            • question/type/multianswer
            • question/type/randomsamatch
            • Several highly used Add-Ons (Non-Core contributed plugins)

            The only difference is that "create_function" is used instead of just "function". Does eAccelerator handle anonymous functions in those cases, or does it also complain? If it also causes problems, are there open tickets for those areas as well? The problem does not seem unique to LTI.

            Show
            kstokking Kris Stokking added a comment - Hi all, I've assigned this ticket to myself as Chris won't have time to work on it. I'd like to get a better idea of how to resolve this issue, as anonymous functions are used all over Moodle (at least as of 2.4). Some examples (incomplete list): lib/tcpdf mod/wiki question/type/multianswer question/type/randomsamatch Several highly used Add-Ons (Non-Core contributed plugins) The only difference is that "create_function" is used instead of just "function". Does eAccelerator handle anonymous functions in those cases, or does it also complain? If it also causes problems, are there open tickets for those areas as well? The problem does not seem unique to LTI.
            Hide
            xxxxxxx Gordon Bateson added a comment -

            I have attached a version of "mod/lti/settings.php" which does not use anonymous functions and therefore does not cause problems on servers using eAccelerator.

            The anonymous functions are replaced by the static function "lti_filter_tool_types()". If you search for that function in the "settings.php" file I have attached, you should be able to see how the fix works.

            best regards
            Gordon

            Show
            xxxxxxx Gordon Bateson added a comment - I have attached a version of "mod/lti/settings.php" which does not use anonymous functions and therefore does not cause problems on servers using eAccelerator. The anonymous functions are replaced by the static function "lti_filter_tool_types()". If you search for that function in the "settings.php" file I have attached, you should be able to see how the fix works. best regards Gordon
            Hide
            bushido Mark Nielsen added a comment -

            The fix can be cherry picked to stable branches.

            Show
            bushido Mark Nielsen added a comment - The fix can be cherry picked to stable branches.
            Hide
            xxxxxxx Gordon Bateson added a comment -

            Mark, I just downloaded MOODLE 24 STABLE and I still have get this error. Looking at lti/settings.php, I see that it is still using anonymous functions. What do we need to do to get these fixes into the stable releases?

            Show
            xxxxxxx Gordon Bateson added a comment - Mark, I just downloaded MOODLE 24 STABLE and I still have get this error. Looking at lti/settings.php, I see that it is still using anonymous functions. What do we need to do to get these fixes into the stable releases?
            Hide
            kstokking Kris Stokking added a comment -

            The code is ready, and now it needs to go through the rest of the development process starting with a peer review. These steps take time, but greatly reduce the amount of bugs that are introduced by uncaught problems. In the meantime, you can always cherry pick the fix from git if you have the technical expertise.

            Show
            kstokking Kris Stokking added a comment - The code is ready, and now it needs to go through the rest of the development process starting with a peer review. These steps take time, but greatly reduce the amount of bugs that are introduced by uncaught problems. In the meantime, you can always cherry pick the fix from git if you have the technical expertise.
            Hide
            poltawski Dan Poltawski added a comment -

            Wow. This is absolutely crazy, IMO this makes eaccelerator almost unsupported for Moodle:
            https://github.com/eaccelerator/eaccelerator/issues/12

            Show
            poltawski Dan Poltawski added a comment - Wow. This is absolutely crazy, IMO this makes eaccelerator almost unsupported for Moodle: https://github.com/eaccelerator/eaccelerator/issues/12
            Hide
            poltawski Dan Poltawski added a comment -

            Hi Guys,

            Thanks a lot for the patch and your patience with us reviewing the code.

            Your solution looks good to me. Please could add some basic testing instructions (just how to trigger it with eacelerator) and then i'll send it for integration.

            I really think this eaccerator problem is a showstopper for the future though, so I have created MDL-39430 for us to try and discourage use of it in Moodle.

            Show
            poltawski Dan Poltawski added a comment - Hi Guys, Thanks a lot for the patch and your patience with us reviewing the code. Your solution looks good to me. Please could add some basic testing instructions (just how to trigger it with eacelerator) and then i'll send it for integration. I really think this eaccerator problem is a showstopper for the future though, so I have created MDL-39430 for us to try and discourage use of it in Moodle.
            Hide
            bushido Mark Nielsen added a comment -

            Updated with testing instructions.

            Show
            bushido Mark Nielsen added a comment - Updated with testing instructions.
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks, i've just rebased and put into branches for all the versions for you.

            Show
            poltawski Dan Poltawski added a comment - Thanks, i've just rebased and put into branches for all the versions for you.
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks guys, this has been integrated now.

            Just noting there are other closures within the master branch, I'll create an issue to address them as well.

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks guys, this has been integrated now. Just noting there are other closures within the master branch, I'll create an issue to address them as well.
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Tested and passed during integration review.

            Many thanks
            Sam

            Show
            samhemelryk Sam Hemelryk added a comment - Tested and passed during integration review. Many thanks Sam
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Linked to MDL-39432 to tidy up the closures within the course renderer.

            Show
            samhemelryk Sam Hemelryk added a comment - Linked to MDL-39432 to tidy up the closures within the course renderer.
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks! You're changes are now spread to the world through this git and our source control repositories.

            No time to rest though, we've got days to make 2.5 the best yet!

            ciao

            Show
            poltawski Dan Poltawski added a comment - Thanks! You're changes are now spread to the world through this git and our source control repositories. No time to rest though, we've got days to make 2.5 the best yet! ciao
            Hide
            cmurad Chris Murad added a comment -

            Hello, We ran into this issue on a 2.4.3 site of ours and I applied the upgrade lti mod from the latest 2.4.x
            but we found another anonymous function - it was still throwing Invalid opcode 153/1/8 on an lti instance in courses

            here is the code diff that we did to fix it:

             
            --- /opt/moodle-MOODLE_24_STABLE/mod/lti/locallib.php	2013-05-13 06:38:41.000000000 -0400
            +++ locallib.php	2013-05-15 17:45:32.616329414 -0400
            @@ -671,14 +671,7 @@
                     }
                 }
             
            -    $bestmatch = array_reduce($tools, function($value, $tool) {
            -        if ($tool->_matchscore > $value->_matchscore) {
            -            return $tool;
            -        } else {
            -            return $value;
            -        }
            -
            -    }, (object)array('_matchscore' => -1));
            +    $bestmatch = array_reduce($tools, "bestmatch_callback", (object)array('_matchscore' => -1));
             
                 //None of the tools are suitable for this URL
                 if ($bestmatch->_matchscore <= 0) {
            @@ -688,6 +681,16 @@
                 return $bestmatch;
             }
             
            +//PDW the callback function above
            +function bestmatch_callback($value,$tool) {
            +	if ($tool->_matchscore > $value->_matchscore) {
            +		return $tool;
            +	} else {
            +		return $value;
            +	}
            +}
            +
            +
             function lti_get_shared_secrets_by_key($key) {
                 global $DB;

            Hope this helps

            Show
            cmurad Chris Murad added a comment - Hello, We ran into this issue on a 2.4.3 site of ours and I applied the upgrade lti mod from the latest 2.4.x but we found another anonymous function - it was still throwing Invalid opcode 153/1/8 on an lti instance in courses here is the code diff that we did to fix it:   --- /opt/moodle-MOODLE_24_STABLE/mod/lti/locallib.php 2013-05-13 06:38:41.000000000 -0400 +++ locallib.php 2013-05-15 17:45:32.616329414 -0400 @@ -671,14 +671,7 @@ } } - $bestmatch = array_reduce($tools, function($value, $tool) { - if ($tool->_matchscore > $value->_matchscore) { - return $tool; - } else { - return $value; - } - - }, (object)array('_matchscore' => -1)); + $bestmatch = array_reduce($tools, "bestmatch_callback", (object)array('_matchscore' => -1)); //None of the tools are suitable for this URL if ($bestmatch->_matchscore <= 0) { @@ -688,6 +681,16 @@ return $bestmatch; } +//PDW the callback function above +function bestmatch_callback($value,$tool) { + if ($tool->_matchscore > $value->_matchscore) { + return $tool; + } else { + return $value; + } +} + + function lti_get_shared_secrets_by_key($key) { global $DB; Hope this helps

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/May/13