4

I'm getting this error from several RSS feed joomla modules. (below is an example from one of them, LightRSSFeedReader, but I'm getting the issue on the others I have tried)

Strict Standards: Non-static method DOMDocument::load() should not be called statically in /mnt/data/vhosts/casite-395567.cloudaccess.net/httpdocs/modules/mod_LightRSSFeedReader/tmpl/default.php on line 40

Notice: Trying to get property of non-object in /mnt/data/vhosts/casite-395567.cloudaccess.net/httpdocs/modules/mod_LightRSSFeedReader/tmpl/default.php on line 48

Line 40 reads: $rss = DOMDocument::load("$rss_feed_url");

There is some discussion on the web to use "->" instead of "::" but simply changing it (in an override of course), but that just creates more errors.

There is also something about getting the right code from http://php.net/manual/en/domdocument.load.php but I'm at a loss as to how that plays with the "$rss" variable.

As you can tell, I'm not a PHP coder.

Any help is widely appreciated.

Paeon
  • 85
  • 1
  • 8
  • Sounds like LightRSSFeedReader was carelessly developed without E_STRICT under account. Newer versions of PHP include strict warnings in the E_ALL error reporting setting, which is likely why this was never a problem for them. – Michael Berkowski Feb 19 '15 at 17:30
  • 1
    It is probably fixable by declaring the object, then calling `load()` on it as in `$dom = new DOMDocument(); $rss = $dom->load($rss_feed_url);` – Michael Berkowski Feb 19 '15 at 17:31
  • If your 3rd party code is throwing a lot of `E_STRICT` warnings, you may just need to lower the error reporting threshold to exclude them http://stackoverflow.com/questions/9983286/disabling-strict-standards-in-php-5-4, as it is impractical to fix. – Michael Berkowski Feb 19 '15 at 17:47
  • Thanks. I will try disabling the E_Strict warnings first, as that seems simple enough....and it worked! But I will try with your first solution after the site launch. Thanks again. – Paeon Feb 19 '15 at 18:07
  • is your problem solved now? If the answer is correct, you might consider accepting the answer... – Chris Maes Feb 24 '15 at 10:48

1 Answers1

5

There is an example on the exact page you are referring to:

<?php
$doc = new DOMDocument();
$doc->load('book.xml');
echo $doc->saveXML();
?>

you can only call the "load" method on an instance; so you first need to create a DOMDocument instant, and then apply load on it.

In short, as @MichaelBerkowski proposed: use

$dom = new DOMDocument();
$rss = $dom->load($rss_feed_url);
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
  • 2
    What I find unusual - the [`DOMDocument::load()` docs](http://php.net/manual/en/domdocument.load.php) actually suggest calling it statically, with a warning. _This method may be called statically, but will issue an E_STRICT error._ That suggestion should go away in the PHP 5.4+ era where `E_STRICT` is more commonly adhered to. – Michael Berkowski Feb 19 '15 at 18:12