Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API change causes endless loop? #7

Open
spacelama opened this issue May 10, 2015 · 1 comment · May be fixed by #8
Open

API change causes endless loop? #7

spacelama opened this issue May 10, 2015 · 1 comment · May be fixed by #8

Comments

@spacelama
Copy link

According to
https://www.flickr.com/services/api/explore/flickr.photos.search
if I set a page number greater than the number of pages, then it still returns results. Hence this now never finishes (it did when I last ran my backup a few months ago):

   if (count($photos['photo']) == 0) {

Fix appears to be (I'm not a php coder by a long stretch):

diff --git a/Offlickr2.php b/Offlickr2.php
index 6a97958..2d00451 100755
--- a/Offlickr2.php
+++ b/Offlickr2.php
@@ -396,8 +396,13 @@ class Offlickr2 {
if (count($photos['photo']) == 0) {
break;
}

  •  if ($page > $photos['pages']) {
    
  •    printf ("debug: past the end of pages? $page > %s\n", $photos['pages']);
    
  •    break;
    
  •  }
    
    foreach ($photos['photo'] as $photo) {
    array_push($this->photo_list, $photo['id']);
  •    printf ("debug: %s %d\n", $photo['id'], $page);
    
    }
    $retrieved = count($this->photo_list);
    $this->dialog->info(2, "Total so far: " . $retrieved . " photo(s)");

P.S. why do I need this in my local version to stave off php warnings?
diff --git a/LocalStorage.php b/LocalStorage.php
index 0eb009c..4e8b221 100644
--- a/LocalStorage.php
+++ b/LocalStorage.php
@@ -18,6 +18,8 @@ abstract class LocalItem {
}

function setup_temporary_dir() {

  • $path="/tmp";
  • $prefix="offlickr2.";
    // FIXME: Not atomic
    $tempname = tempnam($path,$prefix);
    if (!$tempname) {
    @@ -329,4 +331,4 @@ class LocalStorage {

}

-?>
\ No newline at end of file
+?>

@hugoh
Copy link
Owner

hugoh commented Jun 14, 2015

Thanks. Do you mind sending a pull request?

@spacelama spacelama linked a pull request Jul 11, 2015 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants