Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.2 dynamic properties ErrorException #354

Open
iaian7 opened this issue Dec 28, 2022 · 0 comments
Open

PHP 8.2 dynamic properties ErrorException #354

iaian7 opened this issue Dec 28, 2022 · 0 comments

Comments

@iaian7
Copy link

iaian7 commented Dec 28, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant