google cse pagination fix, thanks nikolay

This commit is contained in:
2026-07-22 02:02:54 -04:00
parent 54d420f97c
commit 5fc80a3672

View File

@@ -910,11 +910,10 @@ class google_cse{
"image" => [] "image" => []
]; ];
// detect next page // A response can contain a final page of image results while also marking
if( // the cursor as exact/finished. Parse those results before deciding
isset($json["cursor"]["isExactTotalResults"]) || // detects last page // whether another page token should be offered.
!isset($json["cursor"]["pages"]) // detects no results on page if(!isset($json["results"]) || !is_array($json["results"])){
){
return $out; return $out;
} }
@@ -939,6 +938,16 @@ class google_cse{
]; ];
} }
// Only decide whether a following page exists after preserving every
// result returned on this page.
if(
isset($json["cursor"]["isExactTotalResults"]) || // detects last page
!isset($json["cursor"]["pages"]) // detects no results on page
){
return $out;
}
// get next page // get next page
$out["npt"] = $out["npt"] =
$this->backend->store( $this->backend->store(