Moodle
  1. Moodle
  2. MDL-28161

admin/purgecaches.php incorrectly complains directory does not exist

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1, 2.2
    • Fix Version/s: 2.0.4, 2.1.1
    • Component/s: Libraries
    • Labels:
    • Environment:
      moodle.org
    • Rank:
      17861

      Description

      I get the following PHP Warnings in error_log and in browser (debug mode on) when purging caches:

      PHP Warning:  Base directory /var/www/vhosts/moodle.org/data/cache/htmlpurifier does not exist,\n                    please create or change using %Cache.SerializerPath in /var/www/vhosts/moodle.org/html/lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php on line 133, referer: http://moodle.org/admin/purgecaches.php

      However this directory exists and is read & writable by the Apache user id.

      # ls -hld /var/www/vhosts/moodle.org/data/cache/htmlpurifier
      drwxrwxr-x 3 apache apache 4.0K Jul  3 13:46 /var/www/vhosts/moodle.org/data/cache/htmlpurifier
      
      # ls -hl /var/www/vhosts/moodle.org/data/cache/htmlpurifier
      total 4.0K
      drwxrwxr-x 2 apache apache 4.0K Jul  3 13:46 HTML

        Activity

        Hide
        Eloy Lafuente (stronk7) added a comment -

        Integrated (20_STABLE, 21_STABLE and master), thanks!

        Plz don't include unrelated (sloopy) whitespace fixes, it raises conflict chances.

        Show
        Eloy Lafuente (stronk7) added a comment - Integrated (20_STABLE, 21_STABLE and master), thanks! Plz don't include unrelated (sloopy) whitespace fixes, it raises conflict chances.
        Hide
        Andrew Davis added a comment - - edited

        The testing instructions aren't quite up to scratch. What exactly is a bogus theme and how do I go about adding one?

        And what is meant by forcing full debug mode? I'm assuming you're talking about setting the below in config.php

        $CFG->debug = 38911;
        $CFG->debugdisplay = true;
        

        In future it would be better to have things like this explained more explicitly (ie force full debug mode by putting this in your config.php) as not all of the integration testers will have your knowledge of Moodle.

        Show
        Andrew Davis added a comment - - edited The testing instructions aren't quite up to scratch. What exactly is a bogus theme and how do I go about adding one? And what is meant by forcing full debug mode? I'm assuming you're talking about setting the below in config.php $CFG->debug = 38911; $CFG->debugdisplay = true ; In future it would be better to have things like this explained more explicitly (ie force full debug mode by putting this in your config.php) as not all of the integration testers will have your knowledge of Moodle.
        Hide
        Andrew Davis added a comment - - edited

        I spoke to Jordan and he seems to think Petr is referring to a 1.9 system with a 1.9 theme that was then upgraded to 2.0/2.1. I have the theme that apparently original exposed the bug. I will try with that.

        Show
        Andrew Davis added a comment - - edited I spoke to Jordan and he seems to think Petr is referring to a 1.9 system with a 1.9 theme that was then upgraded to 2.0/2.1. I have the theme that apparently original exposed the bug. I will try with that.
        Hide
        Andrew Davis added a comment - - edited

        Ok. I followed the testing instructions with the theme from Jordan and received the following.

        Plugin "theme_moodleorangeTest" is defective or outdated, can not continue, sorry.

        More information about this error
        Debug info: Invalid plugin directory name.
        Stack trace:

        • line 280 of /lib/upgradelib.php: plugin_defective_exception thrown
        • line 1460 of /lib/upgradelib.php: call to upgrade_plugins()
        • line 317 of /admin/index.php: call to upgrade_noncore()

        Presumably this is what I want to happen but I don't know. I'm passing this as I don't think there is a code problem here but these testing instructions are really vague. Its not even clear why the bug is about purging caches but the testing instructions are about an installation problem. This should not have been integrated with these testing instructions.

        Show
        Andrew Davis added a comment - - edited Ok. I followed the testing instructions with the theme from Jordan and received the following. Plugin "theme_moodleorangeTest" is defective or outdated, can not continue, sorry. More information about this error Debug info: Invalid plugin directory name. Stack trace: line 280 of /lib/upgradelib.php: plugin_defective_exception thrown line 1460 of /lib/upgradelib.php: call to upgrade_plugins() line 317 of /admin/index.php: call to upgrade_noncore() Presumably this is what I want to happen but I don't know. I'm passing this as I don't think there is a code problem here but these testing instructions are really vague. Its not even clear why the bug is about purging caches but the testing instructions are about an installation problem. This should not have been integrated with these testing instructions.
        Hide
        Jordan Tomkinson added a comment -

        I'm not quite sure myself Andrew

        The error about the directory not existing (when it does) is thrown when accessing /admin/purgecaches.php at any point - not during the upgrade..

        Confused...

        Show
        Jordan Tomkinson added a comment - I'm not quite sure myself Andrew The error about the directory not existing (when it does) is thrown when accessing /admin/purgecaches.php at any point - not during the upgrade.. Confused...
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Andrew, "This should not have been integrated with these testing instructions". 100% agree.

        BUT, then, I think you should not have passed this at all!

        So I'm reopening this for testing. Petr, could you plz specify a bit better how this needs to be tested and which are the expected results? Andrew, could you re-test this once that's provided?

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Andrew, "This should not have been integrated with these testing instructions". 100% agree. BUT, then, I think you should not have passed this at all! So I'm reopening this for testing. Petr, could you plz specify a bit better how this needs to be tested and which are the expected results? Andrew, could you re-test this once that's provided? TIA and ciao
        Hide
        Petr Škoda added a comment -

        For testing find any place that purges caches and then does something that requires htmlpurifier. I did not spend much time trying to reproduce it with the purgecaches script because it was doing the same in install/upgrades where we purge the caches too. You can try it with/without the patch.

        Please note testing the purgecaches script is tricky because there is a redirect that might obscure the error message.

        Show
        Petr Škoda added a comment - For testing find any place that purges caches and then does something that requires htmlpurifier. I did not spend much time trying to reproduce it with the purgecaches script because it was doing the same in install/upgrades where we purge the caches too. You can try it with/without the patch. Please note testing the purgecaches script is tricky because there is a redirect that might obscure the error message.
        Hide
        David Mudrak added a comment -

        I was trying to reproduce this using the following script:

        <?php
        
        require('config.php');
        $CFG->enablehtmlpurifier = 1;
        
        $PAGE->set_context(get_system_context());
        $PAGE->set_url('/test.php');
        
        echo $OUTPUT->header();
        
        echo purify_html('A');
        purge_all_caches();
        echo purify_html('B');
        
        echo $OUTPUT->footer();
        

        but I can't get the error. For some reason, the second call of purify_html() does not call HTMLPurifier_DefinitionCache_Serializer::_prepareDir() which would throw the error...

        Show
        David Mudrak added a comment - I was trying to reproduce this using the following script: <?php require('config.php'); $CFG->enablehtmlpurifier = 1; $PAGE->set_context(get_system_context()); $PAGE->set_url('/test.php'); echo $OUTPUT->header(); echo purify_html('A'); purge_all_caches(); echo purify_html('B'); echo $OUTPUT->footer(); but I can't get the error. For some reason, the second call of purify_html() does not call HTMLPurifier_DefinitionCache_Serializer::_prepareDir() which would throw the error...
        Hide
        Sam Hemelryk added a comment -

        I've also tried to replicate this issue and haven't been able to.
        Certainly the changes are fine, no errors etc as they are.

        Perhaps time to just pass this?

        Show
        Sam Hemelryk added a comment - I've also tried to replicate this issue and haven't been able to. Certainly the changes are fine, no errors etc as they are. Perhaps time to just pass this?
        Hide
        Eloy Lafuente (stronk7) added a comment -

        +1

        Show
        Eloy Lafuente (stronk7) added a comment - +1
        Hide
        Jordan Tomkinson added a comment -

        Once this goes into core I will test on moodle.org and re-open this issue if needed

        Show
        Jordan Tomkinson added a comment - Once this goes into core I will test on moodle.org and re-open this issue if needed
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Moodle's git/cvs repositories have been updated with this piece of art! Thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Moodle's git/cvs repositories have been updated with this piece of art! Thanks!
        Hide
        Petr Škoda added a comment -

        The patch fixed my problem in install/upgrade, hopefully it will fix the moodle.org issue too. Thanks everybody!

        Show
        Petr Škoda added a comment - The patch fixed my problem in install/upgrade, hopefully it will fix the moodle.org issue too. Thanks everybody!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: