Frank Vèssia Posted May 14, 2013 Share Posted May 14, 2013 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 More sharing options...
Wanze Posted May 14, 2013 Share Posted May 14, 2013 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 More sharing options...
Frank Vèssia Posted May 14, 2013 Author Share Posted May 14, 2013 @wanze, thanks but of course I know that... the problem is not here...before changing hard disk the code worked good... Link to comment Share on other sites More sharing options...
Wanze Posted May 15, 2013 Share Posted May 15, 2013 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. 1 Link to comment Share on other sites More sharing options...
Pete Posted June 2, 2013 Share Posted June 2, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now