Re: Theme CSS Not building

Re: Theme CSS Not building

by Pawan Pandey -
Number of replies: 1

Hi there!

We have migrated system from Moodle 3.4+ to Moodle 3.5.9+ running on Ubuntu 16.* system, and Mysql database.

When we are trying to build theme (default cron job), we are experience following errors


Execute adhoc task: core\task\build_installed_themes_task
... started 11:39:41. Current memory use 47.3MB.
Default exception handler: Exception - Call to undefined method Sabberworm\CSS\Value\Size::getListComponents() Debug:
Error code: generalexceptionmessage
* line 273 of /lib/rtlcss/RTLCSS.php: Error thrown
* line 223 of /lib/rtlcss/RTLCSS.php: call to MoodleHQ\RTLCSS\RTLCSS->processRule()
* line 55 of /lib/classes/rtlcss.php: call to MoodleHQ\RTLCSS\RTLCSS->processDeclaration()
* line 192 of /lib/rtlcss/RTLCSS.php: call to core_rtlcss->processDeclaration()
* line 63 of /lib/rtlcss/RTLCSS.php: call to MoodleHQ\RTLCSS\RTLCSS->processBlock()
* line 1964 of /lib/outputlib.php: call to MoodleHQ\RTLCSS\RTLCSS->flip()
* line 1942 of /lib/outputlib.php: call to theme_config->rtlize()
* line 1148 of /lib/outputlib.php: call to theme_config->post_process()
* line 208 of /lib/outputlib.php: call to theme_config->get_css_content()
* line 52 of /lib/classes/task/build_installed_themes_task.php: call to theme_build_css_for_themes()
* line 185 of /lib/cronlib.php: call to core\task\build_installed_themes_task->execute()
* line 74 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
* line 61 of /admin/cli/cron.php: call to cron_run()

!!! Exception - Call to undefined method Sabberworm\CSS\Value\Size::getListComponents() !!!
!!
Error code: generalexceptionmessage !!
!! Stack trace: * line 273 of /lib/rtlcss/RTLCSS.php: Error thrown
* line 223 of /lib/rtlcss/RTLCSS.php: call to MoodleHQ\RTLCSS\RTLCSS->processRule()
* line 55 of /lib/classes/rtlcss.php: call to MoodleHQ\RTLCSS\RTLCSS->processDeclaration()
* line 192 of /lib/rtlcss/RTLCSS.php: call to core_rtlcss->processDeclaration()
* line 63 of /lib/rtlcss/RTLCSS.php: call to MoodleHQ\RTLCSS\RTLCSS->processBlock()
* line 1964 of /lib/outputlib.php: call to MoodleHQ\RTLCSS\RTLCSS->flip()
* line 1942 of /lib/outputlib.php: call to theme_config->rtlize()
* line 1148 of /lib/outputlib.php: call to theme_config->post_process()
* line 208 of /lib/outputlib.php: call to theme_config->get_css_content()
* line 52 of /lib/classes/task/build_installed_themes_task.php: call to theme_build_css_for_themes()
* line 185 of /lib/cronlib.php: call to core\task\build_installed_themes_task->execute()
* line 74 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
* line 61 of /admin/cli/cron.php: call to cron_run()
 !!
PHP Fatal error:  Uncaught coding_exception: Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
/var/www/html/scdiamond/lib/classes/task/manager.php on line 461

 Code should look like:

 $factory = \core\lock\lock_config::get_lock_factory('type');
 $lock = $factory->get_lock(Resource id #3104);
 $lock->release();  // Locks must ALWAYS be released like this.

 in /var/www/html/scdiamond/lib/classes/lock/lock.php:117
Stack trace:
#0 [internal function]: core\lock\lock->__destruct()
#1 {main}
  thrown in /var/www/html/scdiamond/lib/classes/lock/lock.php on line 117

Fatal error: Uncaught coding_exception: Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
/var/www/html/scdiamond/lib/classes/task/manager.php on line 461

 Code should look like:

 $factory = \core\lock\lock_config::get_lock_factory('type');
 $lock = $factory->get_lock(Resource id #3104);
 $lock->release();  // Locks must ALWAYS be released like this.

 in /var/www/html/scdiamond/lib/classes/lock/lock.php:117
Stack trace:
#0 [internal function]: core\lock\lock->__destruct()
#1 {main}
  thrown in /var/www/html/scdiamond/lib/classes/lock/lock.php on line 117


From the above error we realize that theme is looking for function Sabberworm\CSS\Value\Size::getListComponents() which should be located in /lib/php-css-parser/Value/Size.php.

But we dont find any appropriate defination in the file which is as below

/********************/lib/php-css-parser/Value/Size.php ******************************/

<?php

namespace Sabberworm\CSS\Value;

class Size extends PrimitiveValue {

    const ABSOLUTE_SIZE_UNITS = 'px/cm/mm/mozmm/in/pt/pc/vh/vw/vm/vmin/vmax/rem'; //vh/vw/vm(ax)/vmin/rem are absolute insofar as they don’t scale to the immediate parent (only the viewport)
    const RELATIVE_SIZE_UNITS = '%/em/ex/ch/fr';
    const NON_SIZE_UNITS = 'deg/grad/rad/s/ms/turns/Hz/kHz';

    private $fSize;
    private $sUnit;
    private $bIsColorComponent;

    public function __construct($fSize, $sUnit = null, $bIsColorComponent = false, $iLineNo = 0) {
        parent::__construct($iLineNo);
        $this->fSize = floatval($fSize);
        $this->sUnit = $sUnit;
        $this->bIsColorComponent = $bIsColorComponent;
    }

    public function setUnit($sUnit) {
        $this->sUnit = $sUnit;
    }

    public function getUnit() {
        return $this->sUnit;
    }

    public function setSize($fSize) {
        $this->fSize = floatval($fSize);
    }

    public function getSize() {
        return $this->fSize;
    }

    public function isColorComponent() {
        return $this->bIsColorComponent;
    }

    /**
     * Returns whether the number stored in this Size really represents a size (as in a length of something on screen).
     * @return false if the unit an angle, a duration, a frequency or the number is a component in a Color object.
     */
    public function isSize() {
        if (in_array($this->sUnit, explode('/', self::NON_SIZE_UNITS))) {
            return false;
        }
        return !$this->isColorComponent();
    }

    public function isRelative() {
        if (in_array($this->sUnit, explode('/', self::RELATIVE_SIZE_UNITS))) {
            return true;
        }
        if ($this->sUnit === null && $this->fSize != 0) {
            return true;
        }
        return false;
    }

    public function __toString() {
        return $this->render(new \Sabberworm\CSS\OutputFormat());
    }

    public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
        $l = localeconv();
        $sPoint = preg_quote($l['decimal_point'], '/');
        return preg_replace(array("/$sPoint/", "/^(-?)0\./"), array('.', '$1.'), $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit);
    }

}




Average of ratings: -
In reply to Pawan Pandey

Re: Theme CSS Not building

by Pawan Pandey -

Actually we identify the issue:

thanks to Rlorenzo

he fixed the same issue like this issue. The reason is as follows:

Moodle's RTLCSS script fails to properly parse the following CSS:

border-radius: 0 100% 100% 0 / 50%;

Thus create new  lines that follow that should produce the same results as above.

To duplicate the error run the following script:

php admin/cli/build_theme_css.php

On our Moodle 3.4.4 system we got the following errors:

php admin/cli/build_theme_css.php
== Build theme css ==
Default exception handler: Exception - Call to undefined method Sabberworm\CSS\Value\Size::getListComponents() Debug:


Average of ratings: Useful (1)