PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/s3/Aws/ClientSideMonitoring/AbstractMonitoringMiddleware.php +19 -1 1.2.21.4.1 View file →
@@ -171,8 +171,26 @@
171 171 }
172 172 return $event;
173 173 }
174 174 /**
175 + * Checks if the socket is created. If PHP version is greater or equals to 8 then,
176 + * it will check if the var is instance of \Socket otherwise it will check if is
177 + * a resource.
178 + *
179 + * @return bool Returns true if the socket is created, false otherwise.
180 + */
181 + private function isSocketCreated() : bool
182 + {
183 + // Before version 8, sockets are resources
184 + // After version 8, sockets are instances of Socket
185 + if (\PHP_MAJOR_VERSION >= 8) {
186 + $socketClass = '\\Socket';
187 + return self::$socket instanceof $socketClass;
188 + } else {
189 + return \is_resource(self::$socket);
190 + }
191 + }
192 + /**
175 193 * Creates a UDP socket resource and stores it with the class, or retrieves
176 194 * it if already instantiated and connected. Handles error-checking and
177 195 * re-connecting if necessary. If $forceNewConnection is set to true, a new
178 196 * socket will be created.
@@ -181,9 +199,9 @@
181 199 * @return Resource
182 200 */
183 201 private function prepareSocket($forceNewConnection = \false)
184 202 {
185 - if (!\is_resource(self::$socket) || $forceNewConnection || \socket_last_error(self::$socket)) {
203 + if (!$this->isSocketCreated() || $forceNewConnection || \socket_last_error(self::$socket)) {
186 204 self::$socket = \socket_create(\AF_INET, \SOCK_DGRAM, \SOL_UDP);
187 205 \socket_clear_error(self::$socket);
188 206 \socket_connect(self::$socket, $this->getHost(), $this->getPort());
189 207 }