Skip to content

Commit

Permalink
Update APII.php
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberpower678 committed May 25, 2023
1 parent c5d26f5 commit 12c2d23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/src/Core/APII.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ private static function makeHTTPRequest( $url, $query = [], $usePOST = false, $u
self::$metricsHandler->createEntry( microtime( true ), $tmpMetrics );

if( $curlData['http_code'] == 429 ) {
if( $maxAttempts > 0 && $metricsArray['aggregation_fields']['ra'] >= $maxAttempts ) return null;
if( $maxAttempts > 0 && (int) $metricsArray['aggregation_fields']['ra'] >= $maxAttempts ) return null;

if( !empty( $curlLastHeaders['retry-after'] ) ) {
sleep( $curlLastHeaders['retry-after'][0] );
Expand All @@ -597,7 +597,7 @@ private static function makeHTTPRequest( $url, $query = [], $usePOST = false, $u
return self::makeHTTPRequest( $url, $query, $usePOST, $useOAuth, $keys, $headers, $metricsArray );
}
if( $curlData['http_code'] >= 500 || in_array( $curlData['http_code'], [ 400, 408, 409 ] ) ) {
if( $maxAttempts > 0 && $metricsArray['aggregation_fields']['ra'] >= $maxAttempts ) return null;
if( $maxAttempts > 0 && (int) $metricsArray['aggregation_fields']['ra'] >= $maxAttempts ) return null;

sleep( 1 );

Expand Down Expand Up @@ -2383,7 +2383,7 @@ public static function WikiwixExists( $url ) {

]
];
$data = self::makeHTTPRequest( $queryURL, [], false, false, [], [], $metricsArray );
$data = self::makeHTTPRequest( $queryURL, [], false, false, [], [], $metricsArray, 10 );
if( $data == "cant connect db" ) return false;
$data = json_decode( $data, true );

Expand Down Expand Up @@ -4653,7 +4653,7 @@ public static function resolveWikiwixURL( $url, $force ) {

]
];
$data = self::makeHTTPRequest( $returnArray['archive_url'], [], false, false, [], [], $metricsArray );
$data = self::makeHTTPRequest( $returnArray['archive_url'], [], false, false, [], [], $metricsArray, 10 );
if( $data == "can't connect db" ) return [];
$data = json_decode( $data, true );

Expand Down

0 comments on commit 12c2d23

Please sign in to comment.