Jump to content

error after changing server HD


Frank Vèssia
 Share

Recommended Posts

Today i changed the hd on my server, from a sata2 to an SSD.
Now I'm experiencing some errors from PW likes:
 

Error    Call to a member function size() on a non-object


coming from this code:
 

 
<? $others=$pages->find("template=profile,sort=-created,limit=8");
        foreach($others as $p){
            if(!$p instanceof NullPage){
                $thumb = $p->images->first()->size(104,104)->url;
                echo "<a href='/{$p->name}/' class='profilemini' rel='nofollow' style='margin:6px'>";
                echo "<img src='{$thumb}'rel='tooltip' /></a>";
            }
        } ?>


I tried to check the php config but I really don't know why i got this error....the only thing changed is the php version from 5.2 to 5.4...

edit: mmm making some test i figure out the problem is here "sort=-created". With this, the result of the query is null for this reason inside the loop i got the error. Some database issue??

Link to comment
Share on other sites

You have to make sure that there are images.

If you get a page with no images, the error is throwed because ->first() does not return a Pageimage object.

So:

// Alternative way I prefer to check for not having a Nullpage
if ($p->id) {
  if (count($p->images)) {
    //.. generate thumb
  }  
}
Link to comment
Share on other sites

Well, the error clearly states that you don't have an image in one of your pages.

The additional if will fix the error.

I don't think this has something to do with your harddisk, but maybe an image was not copied over or got corrupt?

You could check the pages and make sure all the images are still ok.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Pretty sure it's not a PW issue - I develop on my local SSD and upload to servers all the time, and vice versa - so would assume it's maybe a corrupt image like Wanze says.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...