Giter Club home page Giter Club logo

Comments (20)

erusev avatar erusev commented on July 18, 2024

Yeah, I did notice this earlier. It's quite weird. It seems like an issue with hhvm.

from parsedown-extra.

GrahamCampbell avatar GrahamCampbell commented on July 18, 2024

We should skip that check if we're on hhvm so that we can still run parsedown. It's causing my entire test suite to crash atm. :(

from parsedown-extra.

GrahamCampbell avatar GrahamCampbell commented on July 18, 2024

Does #43 look like a quick fix for now?

from parsedown-extra.

erusev avatar erusev commented on July 18, 2024

I'd rather have the part of the test that causes the warning removed. Perhaps, we should also report the issue to the hhvm team.

from parsedown-extra.

GrahamCampbell avatar GrahamCampbell commented on July 18, 2024

I think they know about it already. They haven't implemented those methods yet, that's all.

from parsedown-extra.

erusev avatar erusev commented on July 18, 2024

Another option would be to not support hhvm until the issue is resolved.

from parsedown-extra.

GrahamCampbell avatar GrahamCampbell commented on July 18, 2024

If you did that, people would just move away from your library, inc me. moving my laravel wrapper.

from parsedown-extra.

GrahamCampbell avatar GrahamCampbell commented on July 18, 2024

This might never be resolved in hhvm btw. They might be choosing not to support this.

from parsedown-extra.

erusev avatar erusev commented on July 18, 2024

Ok, I'll see what I can do.

from parsedown-extra.

GrahamCampbell avatar GrahamCampbell commented on July 18, 2024

Also, I just tried out my "fix", and it doesn't work.

from parsedown-extra.

daftspunk avatar daftspunk commented on July 18, 2024

We are having these problems reported over at OctoberCMS too. Correct me if I'm wrong here guys, but a text node (DOMText) shouldn't contain attributes anyway.

if ($DOMDocument->documentElement->hasAttributes() && $DOMDocument->documentElement->getAttribute('markdown') === '1')

Checking if said element "hasAttributes()" first might be a more logical fix? Also, the next else expression would be wise to check for child nodes too.

elseif ($DOMDocument->documentElement->hasChildNodes())

Full method is here.

If HHVM are being really conservative, they might not have included hasAttributes() on a DOMText node either, because "Duh it's a text node" so this can also be tested:

if ((!$DOMDocument->documentElement instanceof \DOMText) && $DOMDocument->documentElement->getAttribute('markdown') === '1')

from parsedown-extra.

hkdobrev avatar hkdobrev commented on July 18, 2024

@daftspunk Could you create a pull request?

from parsedown-extra.

daftspunk avatar daftspunk commented on July 18, 2024

@hkdobrev Can you confirm that any of these proposals work first? I am unaffected by this issue and am unable to confirm.

from parsedown-extra.

keiosweb avatar keiosweb commented on July 18, 2024

I have this issue with OctoberCMS, I have tried solutions proposed by daftspunk. After a bit of research I've found out what follows:

  1. adding hasAttributes() check does not help, hhvm paradoxically returns true for text nodes, so I get same error, no getAttribute method on DOMText,
  2. adding:
if (method_exists($DOMDocument->documentElement, 'getAttributes') && $DOMDocument->documentElement->getAttribute('markdown') === '1')) 

or

if ((!$DOMDocument->documentElement instanceof \DOMText) && $DOMDocument->documentElement->getAttribute('markdown') === '1')

check helps with missing DOMText::getAttribute, but causes new error:

"Cannot access property on non-object" on line 473 of /srv/www/workbench/october/vendor/erusev/parsedown-extra/ParsedownExtra.php

which is

$DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild);

Commenting out this line causes stack overflow on line 496:

$elementText .= $this->processTag($nodeMarkup);

Adding elseif ($DOMDocument->documentElement->hasChildNodes()) check proposed by daftspunk does not seem to help. Even doing something as stupid as:

if (property_exists($DOMDocument, 'firstChild') && property_exists($DOMDocument->firstChild, 'firstChild') && property_exists($DOMDocument->firstChild->firstChild, 'firstChild')) {
        $DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild);
    } 

does not help with this loop. HHVM 3.5.1 here.

from parsedown-extra.

daftspunk avatar daftspunk commented on July 18, 2024

Thanks @keiosweb, the issue appears to be more complex than I thought. Might need attention from the author or from someone with more intimate knowledge of the logic.

from parsedown-extra.

erusev avatar erusev commented on July 18, 2024

@keiosweb Thanks for the comment. It's an important issue. I'll look into it as soon as can. Hopefully, later this month.

from parsedown-extra.

daftspunk avatar daftspunk commented on July 18, 2024

Did this end up fixed?

from parsedown-extra.

GrahamCampbell avatar GrahamCampbell commented on July 18, 2024

No idea. I've lost interest.

from parsedown-extra.

erusev avatar erusev commented on July 18, 2024

@daftspunk It probably is - HHVM should be quite mature by now - I'd guess it has "learned" to execute the code without producing an error.

from parsedown-extra.

codedgift avatar codedgift commented on July 18, 2024

@keiosweb where can i add this
if (method_exists($DOMDocument->documentElement, 'getAttributes') && $DOMDocument->documentElement->getAttribute('markdown') === '1'))

i am having the same issue please... am using codeigniter

from parsedown-extra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.