Skip to content

API change causes endless loop? #7

@spacelama

Description

@spacelama

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
+?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions