Skip to content

Fatal Error - Interrupting execution #20

@BurakBoz

Description

@BurakBoz

Hi Im getting this error. I don't know this is a library error or mine but I think it's library related.
I'm using try catch blocks but it's still interrupts execution.
Any ideas why?

Composer.json require line: "scotteh/php-dom-wrapper": "^1.1",

PHP Fatal error: Uncaught Error: Call to a member function contents() on null in /Applications/MAMP/htdocs/grawler/vendor/scotteh/php-dom-wrapper/src/Traits/ManipulationTrait.php:694
Stack trace:
#0 /Applications/MAMP/htdocs/grawler/vendor/scotteh/php-dom-wrapper/src/Traits/ManipulationTrait.php(723): DOMWrap\NodeList->getHtml()
#1 /Applications/MAMP/htdocs/grawler/inc/Grawler/Site.php(142): DOMWrap\NodeList->html()
#2 /Applications/MAMP/htdocs/grawler/inc/Grawler/Site.php(278): Site->singlePost('http://www.kadi...')
#3 /Applications/MAMP/htdocs/grawler/vendor/scotteh/php-dom-wrapper/src/NodeList.php(161): Site->{closure}(Object(DOMWrap\Element))
#4 /Applications/MAMP/htdocs/grawler/inc/Grawler/Site.php(279): DOMWrap\NodeList->map(Object(Closure))
#5 /Applications/MAMP/htdocs/grawler/grawler.php(34): Site->pagination()
#6 {main}
thrown in /Applications/MAMP/htdocs/grawler/vendor/scotteh/php-dom-wrapper/src/Traits/ManipulationTrait.php on line 694

Shorted code:

private function xPathOrCss($exp)
{
return (($exp{0} == "/" or $exp{0} == "(")? "findXPath" : "find");
}
public function pagination()
{
try
{
$this->post->setSourceUrl($url);
$raw = $this->curl->get($this->post->getSourceUrl());
if ($this->curl->error or empty($raw) or $raw == false)
{
msg_error("Socket error on " . CLASS . "/" . METHOD . "():" . LINE . " {$this->post->getSourceUrl()} with code {$this->curl->errorCode} and '{$this->curl->errorMessage}' message");
return false;
}
$doc = new Document();
$doc->html($raw);
$content = "";
$contentSelector = conf("selectors", "selector_content");
if (!empty($contentSelector))
{
$contentSelector = $doc->{$this->xPathOrCss($contentSelector)}($contentSelector);
LINE 142: if (!is_null($contentSelector) and method_exists($contentSelector, "html") and !empty($contentSelector->html())) $content = $contentSelector->html();
}
$this->post->setContent($content);
unset($content);
}
catch (Exception $e)
{
msg_error("Single Post Exception : " . $e->getMessage());
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions