backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 38 forks source link

PHP notices on the "Debug information" page #6635

Open findlabnet opened 1 week ago

findlabnet commented 1 week ago

Description of the bug

When visiting admin/reports/debug on site where both version CKEditor module uninstalled, I get PHP notices:

Notice: Undefined index: ckeditor5 in system_get_debug_info() (line 2421 of /core/modules/system/system.admin.inc).

Notice: Trying to access array offset on value of type null in system_get_debug_info() (line 2422 of /core/modules/system/system.admin.inc).

Notice: Trying to access array offset on value of type null in system_get_debug_info() (line 2428 of /core/modules/system/system.admin.inc).

Seems like function filter_formats called from system_get_debug_info() returned wrong (cached?) result.

"Flush all caches" has no effect.

Below is part of var_dump($text_formats) from line 2418:

array(3) {
  ["filtered_html"]=>
  object(stdClass)#52 (8) {
    ["format"]=>
    string(13) "filtered_html"
    ["name"]=>
    string(5) "Basic"
    ["weight"]=>
    int(0)
    ["editor"]=>
    string(9) "ckeditor5"
...

Steps To Reproduce

Visit admin/reports/debug on site where both version CKEditor module uninstalled

Additional information

On an older site I got the same warnings, but about 'ckeditor' instead of 'ckeditor5'.

Add any other information that could help, such as:

indigoxela commented 1 week ago

That's strange - I usually uninstall CKE (4 and 5), as I use TinyMCE, anyway, but I didn't see that nagging (neither in dblog).

Checked some more sites now - no nagging.

The problem seems related to the filtered_html format? Weird that you (still) get ckeditor5 there.

@findlabnet can you check the json config (on admin/config/development/configuration/single/export)? (Configuration group "Text formats".

Does the value "ckeditor5" show up there, too? Are you using another editor or just none for filtered_html?

findlabnet commented 1 week ago

Basic:

{
    "_config_name": "filter.format.filtered_html",
    "format": "filtered_html",
    "name": "Basic",
    "weight": 0,
    "editor": "ckeditor5",
    "editor_settings": {
        "image_upload": {
            "status": 1,
            "dimensions": {
                "max_width": "",
                "max_height": ""
            },
            "max_size": null,
            "scheme": "public",
            "directory": "inline-images"
        }
    },
    "filters": {
        "filter_url": {
            "weight": 0,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_html": {
            "weight": 1,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_autop": {
            "weight": 2,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_image_caption": {
            "weight": 4,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_image_align": {
            "weight": 4,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_htmlcorrector": {
            "weight": 10,
            "status": 1,
            "module": "filter",
            "settings": []
        }
    },
    "cache": true,
    "status": 1
}

Raw HTML:

{
    "_config_name": "filter.format.full_html",
    "format": "full_html",
    "name": "Raw HTML",
    "weight": 1,
    "editor": null,
    "filters": {
        "filter_url": {
            "weight": 0,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_autop": {
            "weight": 1,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_image_caption": {
            "weight": 4,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_image_align": {
            "weight": 4,
            "status": 1,
            "module": "filter",
            "settings": []
        },
        "filter_htmlcorrector": {
            "weight": 10,
            "status": 1,
            "module": "filter",
            "settings": []
        }
    },
    "cache": true,
    "status": 1
}

This site on local dev, without any editors. On the second (old one), BUEditor is used for Full HTML.

indigoxela commented 1 week ago

That's odd - I mean the filtered_html format.

Hm. Shouldn't you also see some nagging on admin/config/content/formats/filtered_html then?

If you save the Basic format, does the nagging go away after that?

My suspicion: you uninstalled the CKEditor module, but the settings for the filtered_html format stayed untouched. I'm not sure, if this is desired behavior, though. Personally, I switch the format setting to Tiny, before I uninstall core's editor module(s).

findlabnet commented 1 week ago

Your suspicion is right, after saving the "Basic" format without any changes, the notices are gone. And the config is now: (roles have also been added)

{
    "_config_name": "filter.format.filtered_html",
    "format": "filtered_html",
    "name": "Basic",
    "weight": 0,
    "editor": "",
    "editor_settings": [],
    "filters": {
        "filter_image_caption": {
            "status": 1,
            "weight": 4,
            "module": "filter",
            "settings": []
        },
        "filter_autop": {
            "status": 1,
            "weight": 2,
            "module": "filter",
            "settings": []
        },
        "filter_url": {
            "status": 1,
            "weight": 0,
            "settings": {
                "filter_url_length": 72
            },
            "module": "filter"
        },
        "filter_htmlcorrector": {
            "status": 1,
            "weight": 10,
            "module": "filter",
            "settings": []
        },
        "filter_html_escape": {
            "status": 0,
            "weight": -10,
            "module": "filter",
            "settings": []
        },
        "filter_image_align": {
            "status": 1,
            "weight": 4,
            "module": "filter",
            "settings": []
        },
        "filter_html": {
            "status": 1,
            "weight": 1,
            "settings": {
                "allowed_html": "<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <p> <br> <img> <figure> <figcaption>"
            },
            "module": "filter"
        }
    },
    "cache": true,
    "status": 1,
    "roles": {
        "anonymous": "anonymous",
        "authenticated": "authenticated",
        "editor": "editor",
        "administrator": "administrator"
    }
}
indigoxela commented 1 week ago

...after saving the "Basic" format without any changes, the notices are gone.

Many thanks for verifying. The big question is now: is that uninstall behavior as expected - or a bug? I mean: when uninstalling the CKEditor(5) module, should there be some format cleanup in an uninstall hook, or not?

findlabnet commented 1 week ago

If the installer set something, the uninstaller should remove it. Shouldn't it?

indigoxela commented 1 week ago

If the installer set something, the uninstaller should remove it. Shouldn't it?

If it were the module (on install) I'd say, yes it has to clean up on uninstall. But the case is a bit trickier here, the format's editor setting ships with the standard profile, not the editor module. And the settings form ships (at least partly) with the Filter module :thinking:

But given, the setting is "dead" without the module. And the only outcome is PHP nagging on some pages... Maybe I have to think that over again, but I'm leaning towards uninstall hook in the ckeditor5 module, that loops over text formats for some (cautious) cleanup.

findlabnet commented 1 week ago

By the way (and for the record) on the old site "ckeditor" was defined for unused input format and was not a problem before core got the new feature (debug info page).