Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

PHP 8.2 dynamic properties ErrorException #354

@iaian7

Description

@iaian7

Issue

Dynamic properties are no longer supported in PHP 8.2, and line 46 in /plugins/phile/parserMarkdown/Classes/Parser/Markdown.php causes an ErrorException.

Tested using the latest build in issue #347:

Here's a new build with all the deprecated stuff removed: phile-feature-removeDeprecated-head.zip

Originally posted by @Schlaefer in #347 (comment)

Quick Fix

Wrapping line 46 with a property check prevents the error, though perhaps masking a more foundational issue (see below).

if (property_exists($parser, $key)) {
    $parser->{$key} = $value;
}

Potential root issue

The configuration appears to be setting a property within the MarkdownExtra class that does not exist, an uncaught issue before PHP 8.2 since dynamically creating properties was previously allowed. Comparing var_dump($this->config); against https://michelf.ca/projects/php-markdown/configuration/ confirms all but "active" are valid properties.

array(16) {
["empty_element_suffix"]=> string(3) " />" 
["tab_width"]=> int(4) 
["no_markup"]=> bool(false) 
["no_entities"]=> bool(false) 
["predef_urls"]=> array(1) { ["base_url"]=> string(16) "http://temp.test" } 
["predef_titles"]=> array(0) { } 
["fn_id_prefix"]=> string(0) "" 
["fn_link_title"]=> string(0) "" 
["fn_backlink_title"]=> string(0) "" 
["fn_link_class"]=> string(12) "footnote-ref" 
["fn_backlink_class"]=> string(16) "footnote-backref" 
["code_class_prefix"]=> string(0) "" 
["code_attr_on_pre"]=> bool(false) 
["predef_abbr"]=> array(0) { } 
["active"]=> bool(true) }

That last "active" property doesn't show up in /plugins/phile/parserMarkdown/config.php so I'm guessing it's from line 104 in /config/defaults.php where the plugin is enabled...shouldn't that be exclusively internal to the Phile plugin, not passed on to the MarkdownExtra class? And if that's the case, how would it be properly corrected? I'm guessing my quick fix above is probably not the right way to do it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions