Skip to content

Replace curl #6

Description

@mkuniej

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
inc/class-file-locker.php (1)
577-597: Avoid hard dependency on cURL extension

Calling curl_init() fatals on hosts where the cURL extension is missing. The plugin never required cURL before, so this new method can white-screen sites. Use the WP HTTP API (it gracefully falls back to available transports) or at least guard for cURL availability, keeping redirects disabled so you can still detect the 302.

-	$curl = curl_init();
-
-	curl_setopt_array(
-		$curl,
-		array(
-			CURLOPT_URL           => $file_url,
-			CURLOPT_NOBODY        => true,
-			CURLOPT_CUSTOMREQUEST => 'GET',
-		)
-	);
-
-	curl_exec( $curl );
-	$httpcode = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
-	curl_close( $curl );
-
-	if ( 302 === $httpcode ) {
-		return true;
-	}
-
-	return false;
+	$response = wp_remote_head(
+		$file_url,
+		array(
+			'redirection' => 0,
+			'timeout'     => 5,
+		)
+	);
+
+	if ( is_wp_error( $response ) ) {
+		return false;
+	}
+
+	$status_code = wp_remote_retrieve_response_code( $response );
+
+	return 302 === $status_code;

📜 Review details
Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions