Share
dragfyre 6:20am, 6 April 2007
this bug in lib.phpFlickr.php is causing me problems:

// BUG:
// Have no idea why these next two lines are necessary, but it appears that responses
// are getting clobbered together... possibly by CURL
//
$lines = explode("\n", $this->response);
if (count($lines) > 0) $this->response = array_pop($lines); // just take the last line

any progress on squashing it?
dragfyre Posted 14 years ago. Edited by dragfyre (member) 14 years ago
hey,
so anyway, as you can tell, I was up late last night trying to debug this problem. this bug seems to be the reason why the plugin isn't recognizing people's photosets, and keeps returning an error saying "Please create at least one flickr photo set".

what basically happens is this: a request goes out to the flickr API for a list of photosets, and then a response comes back with a serialized list which then gets parsed and built into a fully php-usable array of photosets. somehow, the reponse from the flickr API gets chopped into several pieces by curl (which manages internet communication for the plugin). this might be happening in cases where the response is so big (i.e. the number of photosets is very large) that curl can't fit it into one HTTP request, and so splits it into several.

the code currently included in the lib.phpFlickr.php wasn't designed to concatenate several HTTP requests, so it takes the easy way out and only keeps the last request—but if the list of photosets spans several requests, that means that only an incomplete list of photosets is retrieved. phpFlickr can't unserialize the list (i.e. it can't transform it into a php-usable array), so it throws out the response. it signals its failure to the plugin, which assumes that there must be no photosets at all (which isn't the case).

I'm not an expert on curl or concatenating HTTP requests—and I'm so-so with PHP anyway—but if I can help out in any way, I'd be glad to.
datasage 14 years ago
More specifically, the two lines are breaking valid requests. Some requests may have new lines in the response from newlines in a photoset description. But the code is splitting the response and returning only the last line, which is incomplete and cannot be unserialized.

Those two lines don't work with my photos sets, but commenting it out fixes it for me. It would be nice to know why exactly they are needed in the first place. The way i think it was written, using trim would be a better solution.
datasage 14 years ago
I have investigated this issue as much as I can. Those two lines seem to be completely unnecessary. The reason why they had been added in the first place may be linked to a specific version of libcurl where there was a issue with post requests getting clobbered. Either that, there is a bit of code that is concatenating responses rather than clearing the variable for the next request. Which could be specific to a certain version of curl.
dragfyre 14 years ago
found a fix!

replace the above lines with the following:

// BUG:
// Have no idea why these next few lines are necessary, but it
appears that responses
// are getting clobbered together... possibly by CURL
//
$http_clobber_check = explode("HTTP/1.1", $this->response);
if (count($http_clobber_check) > 1) {
$lines = explode("\n", $this->response);
if (count($lines) > 0) $this->response = array_pop($lines); // just take the last line
} // otherwise, we do NOTHING :P
dragfyre Posted 14 years ago. Edited by dragfyre (member) 14 years ago
@datasage: apparently, the code worked fine that way within the Photos tab. As you say, though, every time you tried to load a list of photosets in which one or more set descriptions included carriage returns, it broke the request there - rendering it useless (potentially) for retrieving set lists.
datasage 14 years ago
It would have broken any request with carriage returns. Even if it wasn't in the photosets request.

But it looks like certain versions of curl or php are combining multiple requests. Thus making some kind of fix necessary.
buffalo2wheeler Posted 14 years ago. Edited by buffalo2wheeler (member) 14 years ago
I tried this solution as an attempt to fix this problem:
www.flickr.com/groups/tantannoodles/discuss/7215760008036...

and it works!

One feature I wish the plugin had though is "toggle album hiding" just like "toggle group hiding", but that's no biggie.
Thanks,
Thomas
www.thisiswhatisee.net//
Chris&Susan Posted 14 years ago. Edited by Chris&Susan (member) 14 years ago
Bah, when I replace those lines, all I get is a blank options page.

What am I doing wrong? I've updated to WP 2.1.3 and flickrplugin .91

Any ideas?

EDIT: Ah, I see the problem now- the code above inserted a line break where it shouldn't have. It's working now! Yay!
Chris&Susan 14 years ago
Well, phooey- now my album page works, but the insert photo pane in the 'write' page is busted. When you click the 'photos' or 'album' links, it waits a few seconds, then displays a blank space.

Bah.

Any suggestions?
illustrious produce [deleted] 14 years ago
AND IT WORKS... however, when I replaced the code and uploaded the new lib.phpflickr.php file, and I went to the admin page, it told me that line 238 was in error. I had added an extra line break as well.

Thanks for the fix!!!

typingwithlight.com
Digimom13 14 years ago
Okay, I tried removing all of the breaks but that didn't work. Unless I missed some. So I'm going to try the code bit. I see the file. I know how to edit it. But where exactly do I put these lines of code?

TIA!
Digimom13 14 years ago
Okay, nevermind... I think I've got it. Yay! You guys are geniuses!
Arthur Ivanov 14 years ago
same problem

Thanks for the fix!!!
AJamison 14 years ago
Thanks for the fix!
scrytch 14 years ago
Just happened to me today when I went to refresh my cache... all my photosets disappeared with no real clear error, but this has fixed it thanks.

Regards,
Shane.
letterknit Posted 14 years ago. Edited by letterknit (member) 14 years ago
I tried copying and pasting the fix you have above in lib.phpFlickr.php but got this error (when I deactivated and re-activated the plugin):

Parse error: syntax error, unexpected T_STRING in /home/lettbye6/public_html/wp-content/plugins/silaspartners/flickr/lib.phpFlickr.php on line 235

Do you know what that error means?

I pasted this:
// BUG:
// Have no idea why these next few lines are necessary, but it
appears that responses
// are getting clobbered together... possibly by CURL
//
$http_clobber_check = explode("HTTP/1.1", $this->response);
if (count($http_clobber_check) > 1) {
$lines = explode("\n", $this->response);
if (count($lines) > 0) $this->response = array_pop($lines); // just take the last line
} // otherwise, we do NOTHING :P
datasage 14 years ago
Yeah, you probably have a line break where there shouldn't be one. The comment lines that start with // should be just one line, no line breaks in between. Flickr wraps some of the lines incorrectly on this forum.
aidansmac 14 years ago
I tried the fix and my sets showed up under the photo albums section in admin but not in my gallery. When I tried to refresh the cache, I got the same "you need to create sets" error.

Can anyone help? Can anyone help in easy layman terms?

Thanks
Apertome 14 years ago
Thank you very much! This appeared to fix my problems with the photos tab when writing a post, and with albums working.
GinnyRED57 14 years ago
Yes, it now recognizes the one set I created after installing the latest version of this plugin, and after some struggle with fixes posted in various threads, my husband got it to at least recognize all of my sets on the admin page, but they don't show up on the photos page. Plus, he followed the instructions for manually clearing cache, which worked on the groups section, but not on the sets section.

Hints? Anyone? We're running PHP5 here, and my husband can deal with technical explanations and code. And other stuff besides.
GinnyRED57 14 years ago
Wups! Spoke too soon. They're visible, but the issue was that due to CSS issues, the older sets were being pushed down below the level of the two side columns on this particular theme.

Yay! A CSS issue I can deal with, and my husband can now relax.

www.blogula-rasa.com/photos/
ourladyofwisdom 14 years ago
This worked!! THANK YOU SO MUCH!!
JamMarz 14 years ago
Thanks for the fix! worked for me.
www.adventurecub.com
ivice 14 years ago
Thank you very much for the fix! worked for me as well.
Gadget Virtuoso 14 years ago
OK this fixed the error buteverytime it makes a new subfolder under cace-flickr it gives it permissions 660 and I have to go in and give them 777 to work correctly.

Also I noticed that it is not keeping photos marked for friends and family for only friends and family. Basically displaying all photos as if they are public when they are not.
Groups Beta