Partial PHP5 Fix to Rich Boakes “Most Wanted” Plugin

Figured out that if you replace:



$m = new MostWanted();

It gets rid of the annoying PHP-5 error:

Fatal error: Non-static method MostWanted::mostwanted() cannot be called statically in [...]

The only downside is that for me it lists the top-5 twice, for some reason. Oh, that and when I left a comment with the fix for Rich I managed to miss the leading $ in the second line (which is present above).

NB: I’m using this as the widget version, caveat emptor.

4 thoughts on “Partial PHP5 Fix to Rich Boakes “Most Wanted” Plugin

  1. Hello – After upgrading to PHP5, I have tried your fix but it does not work for me.
    Previously I had the following call:-

    I have replaced it by the following call:-
    mostwanted(5,24,false); ?>
    I don’t get the error anymore but no list is being displayed.
    Any idea?

  2. Hey there,

    I’ve been using the Boakes Most Wanted plugin for my blog, and it’s worked great so far with PHP4. But when I upgraded to PHP5, it broke. I looked around and found your article “Partial PHP5 Fix to Rich Boakes “Most Wanted” Plugin”. It was perfect! However, your code printed out two copies of the most popular articles, and you knew it. I played around a bit, and found a fix. All you had to do was remove the second line from your code, so instead of this:

    $m = new MostWanted();

    You should have this:

    $m = new MostWanted();

    And that’s it! I would have posted this comment on the original article, but comments are closed there.

    Hope this helped!


Comments are closed.