GithubHelp home page GithubHelp logo

Comments (7)

mudrd8mz avatar mudrd8mz commented on June 4, 2024

The actual error message is not probably relevant here. I believe there is some other error/exception raised that kills PHP, and this message "A lock was created but not released" is just a consequence.

from moodle-tool_lockstats.

mudrd8mz avatar mudrd8mz commented on June 4, 2024

I am getting somewhere. As I suspected, there was another exception thrown which was silently swallowed and not reported - or better it was overruled by the lock exception . After I applied the following change:

diff --git a/lib/classes/lock/lock.php b/lib/classes/lock/lock.php
index 7b117c3..6ee1380 100644
--- a/lib/classes/lock/lock.php
+++ b/lib/classes/lock/lock.php
@@ -114,6 +114,7 @@ class lock {
         if (!$this->released && defined('PHPUNIT_TEST')) {
             $key = $this->key;
             $this->release();
+            return;
             throw new \coding_exception("A lock was created but not released at:\n" .
                                         $this->caller . "\n\n" .
                                         " Code should look like:\n\n" .

and attempted to run a task, I finally got

Default exception handler: Exception - Call to undefined function tool_lockstats\posix_getpid() Debug: 
Error code: generalexceptionmessage
* line 234 of /admin/tool/lockstats/classes/proxy_lock_factory.php: Error thrown
* line 148 of /admin/tool/lockstats/classes/proxy_lock_factory.php: call to tool_lockstats\proxy_lock_factory->log_lock()
* line 127 of /admin/tool/task/cli/schedule_task.php: call to tool_lockstats\proxy_lock_factory->get_lock()

which I was able to confirm - the site's PHP was built without the POSIX functions.

However, I think it reveals a problem in the Moodle core code as it hides the real cause why an exception was thrown.

from moodle-tool_lockstats.

mudrd8mz avatar mudrd8mz commented on June 4, 2024

Indeed. It checks defined('PHPUNIT_TEST') which is always true. Going to fix this upstream.

from moodle-tool_lockstats.

mudrd8mz avatar mudrd8mz commented on June 4, 2024

https://tracker.moodle.org/browse/MDL-59546

from moodle-tool_lockstats.

brendanheywood avatar brendanheywood commented on June 4, 2024

thanks @mudrd8mz - although it still seems like there is probably something missing re posix_getpid()

Is the posix extension something we can assume moodle requires (it isn't in core admin/environment.xml) or should I declare that in my environment.xml ?

from moodle-tool_lockstats.

mudrd8mz avatar mudrd8mz commented on June 4, 2024

As per http://php.net/manual/en/posix.installation.php POSIX functions are enabled by default in PHP. But yeah, they can be still disabled so it may be wise to put them into environment.xml. Although there is still https://tracker.moodle.org/browse/MDL-52319

Maybe in this particular case, you can simply check if function exists before calling it. And if it is not available, just store an empty value (and then display as a dash or question mark) instead of PID? As I understood it, it is an information for the admin only, not essential for the plugin functionality.

from moodle-tool_lockstats.

brendanheywood avatar brendanheywood commented on June 4, 2024

Cool, I'll reopen this and remove that hard dependancy

from moodle-tool_lockstats.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.