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

[stable29] fix: prevent warning of fsockopen #4552

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/Handler/CertificateEngine/CfsslHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,15 @@ private function wakeUp(): void {
private function portOpen(): bool {
$host = parse_url($this->getCfsslUri(), PHP_URL_HOST);
$port = parse_url($this->getCfsslUri(), PHP_URL_PORT);
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket) {

set_error_handler(function () { });
$socket = fsockopen($host, $port, $errno, $errstr, 0.1);
restore_error_handler();
if (!$socket || $errno || $errstr) {
return false;
}
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 0, 'usec' => 100000]); // 100ms
socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => 0, 'usec' => 100000]);
return @socket_connect($socket, $host, $port);
fclose($socket);
return true;
}

private function getServerPid(): int {
Expand Down
5 changes: 5 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<code><![CDATA[addServiceListener]]></code>
</InvalidArgument>
</file>
<file src="lib/Handler/CertificateEngine/CfsslHandler.php">
<InvalidArgument>
<code><![CDATA[function () { }]]></code>
</InvalidArgument>
</file>
<file src="lib/Helper/Pagination.php">
<MissingTemplateParam>
<code><![CDATA[Pagination]]></code>
Expand Down
Loading