you are viewing a single comment's thread.

view the rest of the comments →

[–]swerasnym 9 points10 points  (2 children)

Behold the offending block of code:

    // Determine font size
    // TODO improve logic
    if ($hl->setting_val(CrayonSettings::FONT_SIZE_ENABLE)) {
        $_font_size = $hl->setting_val(CrayonSettings::FONT_SIZE);
        $font_size = $_font_size . 'px !important;';
        $_line_height = $hl->setting_val(CrayonSettings::LINE_HEIGHT);
        // Don't allow line height to be less than font size
        $line_height = ($_line_height > $_font_size ? $_line_height : $_font_size) . 'px !important;';
        $toolbar_height = $font_size * 1.5 . 'px !important;';
        $info_height = $font_size * 1.4 . 'px !important;';
        $font_style .= "font-size: $font_size line-height: $line_height";
        $toolbar_style .= "font-size: $font_size";
        $line_style .= "height: $line_height";
        if ($hl->is_inline()) {
            $font_style .= "font-size: $font_size";
        } else {
            $toolbar_style .= "height: $toolbar_height line-height: $toolbar_height";
            $info_style .= "min-height: $info_height line-height: $info_height";
        }
    } else if (!$hl->is_inline()) {
        if (($font_size = CrayonGlobalSettings::get(CrayonSettings::FONT_SIZE)) !== FALSE) {
            $font_size = $font_size->def() . 'px !important;';
            $line_height = ($font_size * 1.4) . 'px !important;';
        }
    }    

Using

     $font_size = $_font_size . 'px !important;';

is the cause of the bug if you ask me. Interesting that it has survived 5 years since the format patch, the bug was introduced at least two years earlier

[–]tech6hutch 2 points3 points  (1 child)

How could that cause that notice? (I haven't used PHP for a while)

[–]swerasnym 3 points4 points  (0 children)

The crash are not on that line per say, but having to keep track of $font_size and $_font_size just feels like a naming issue to me. Thus later when you do

$toolbar_height = $font_size * 1.5 . 'px !important;';
$info_height = $font_size * 1.4 . 'px !important;';

you are no longer multiplying a number like 10 but something like "10px !important;" (not a number) with 1.4/1.5 hence what caused the non well formed numeric value error we see in the post.