Changeset 49034
- Timestamp:
- 09/22/2020 06:35:10 PM (5 years ago)
- Location:
- trunk/src/wp-includes/PHPMailer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/PHPMailer/PHPMailer.php
r48045 r49034 442 442 * 443 443 * @var bool 444 * 445 * @deprecated 6.0.0 PHPMailer isn't a mailing list manager! 444 446 */ 445 447 public $SingleTo = false; … … 746 748 * @var string 747 749 */ 748 const VERSION = '6.1. 6';750 const VERSION = '6.1.7'; 749 751 750 752 /** … … 1308 1310 } 1309 1311 if (is_callable($patternselect)) { 1310 return $patternselect($address);1312 return call_user_func($patternselect, $address); 1311 1313 } 1312 1314 //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 … … 1402 1404 $errorcode = 0; 1403 1405 if (defined('INTL_IDNA_VARIANT_UTS46')) { 1404 // phpcs:ignore PHPCompatibility.ParameterValues.NewIDNVariantDefault.NotSet1405 1406 $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46); 1406 1407 } elseif (defined('INTL_IDNA_VARIANT_2003')) { … … 2979 2980 $name = $filename; 2980 2981 } 2981 2982 2982 if (!$this->validateEncoding($encoding)) { 2983 2983 throw new Exception($this->lang('encoding') . $encoding); … … 3994 3994 * @param string $basedir Absolute path to a base directory to prepend to relative paths to images 3995 3995 * @param bool|callable $advanced Whether to use the internal HTML to text converter 3996 * or your own custom converter @return string $message The transformed message Body 3996 * or your own custom converter 3997 * @return string The transformed message body 3997 3998 * 3998 3999 * @throws Exception … … 4118 4119 { 4119 4120 if (is_callable($advanced)) { 4120 return $advanced($html);4121 return call_user_func($advanced, $html); 4121 4122 } 4122 4123 -
trunk/src/wp-includes/PHPMailer/SMTP.php
r48033 r49034 35 35 * @var string 36 36 */ 37 const VERSION = '6.1. 6';37 const VERSION = '6.1.7'; 38 38 39 39 /** … … 312 312 public function connect($host, $port = null, $timeout = 30, $options = []) 313 313 { 314 static $streamok;315 //This is enabled by default since 5.0.0 but some providers disable it316 //Check this once and cache the result317 if (null === $streamok) {318 $streamok = function_exists('stream_socket_client');319 }320 314 // Clear errors to avoid confusion 321 315 $this->setError(''); … … 336 330 self::DEBUG_CONNECTION 337 331 ); 332 333 $this->smtp_conn = $this->getSMTPConnection($host, $port, $timeout, $options); 334 335 if ($this->smtp_conn === false) { 336 //Error info already set inside `getSMTPConnection()` 337 return false; 338 } 339 340 $this->edebug('Connection: opened', self::DEBUG_CONNECTION); 341 342 // Get any announcement 343 $this->last_reply = $this->get_lines(); 344 $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); 345 346 return true; 347 } 348 349 /** 350 * Create connection to the SMTP server. 351 * 352 * @param string $host SMTP server IP or host name 353 * @param int $port The port number to connect to 354 * @param int $timeout How long to wait for the connection to open 355 * @param array $options An array of options for stream_context_create() 356 * 357 * @return false|resource 358 */ 359 protected function getSMTPConnection($host, $port = null, $timeout = 30, $options = []) 360 { 361 static $streamok; 362 //This is enabled by default since 5.0.0 but some providers disable it 363 //Check this once and cache the result 364 if (null === $streamok) { 365 $streamok = function_exists('stream_socket_client'); 366 } 367 338 368 $errno = 0; 339 369 $errstr = ''; … … 341 371 $socket_context = stream_context_create($options); 342 372 set_error_handler([$this, 'errorHandler']); 343 $ this->smtp_conn = stream_socket_client(373 $connection = stream_socket_client( 344 374 $host . ':' . $port, 345 375 $errno, … … 357 387 ); 358 388 set_error_handler([$this, 'errorHandler']); 359 $ this->smtp_conn = fsockopen(389 $connection = fsockopen( 360 390 $host, 361 391 $port, … … 366 396 restore_error_handler(); 367 397 } 398 368 399 // Verify we connected properly 369 if (!is_resource($ this->smtp_conn)) {400 if (!is_resource($connection)) { 370 401 $this->setError( 371 402 'Failed to connect to server', … … 382 413 return false; 383 414 } 384 $this->edebug('Connection: opened', self::DEBUG_CONNECTION); 415 385 416 // SMTP server can take longer to respond, give longer timeout for first read 386 417 // Windows does not have support for this timeout function 387 418 if (strpos(PHP_OS, 'WIN') !== 0) { 388 $max = (int) 419 $max = (int)ini_get('max_execution_time'); 389 420 // Don't bother if unlimited 390 421 if (0 !== $max && $timeout > $max) { 391 422 @set_time_limit($timeout); 392 423 } 393 stream_set_timeout($this->smtp_conn, $timeout, 0); 394 } 395 // Get any announcement 396 $announce = $this->get_lines(); 397 $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER); 398 399 return true; 424 stream_set_timeout($connection, $timeout, 0); 425 } 426 427 return $connection; 400 428 } 401 429 … … 1167 1195 while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { 1168 1196 //Must pass vars in here as params are by reference 1169 if (!stream_select($selR, $selW, $selW, $this->Timelimit)) { 1197 //solution for signals inspired by https://github.com/symfony/symfony/pull/6540 1198 set_error_handler([$this, 'errorHandler']); 1199 $n = stream_select($selR, $selW, $selW, $this->Timelimit); 1200 restore_error_handler(); 1201 1202 if ($n === false) { 1203 $message = $this->getError()['detail']; 1204 1205 $this->edebug( 1206 'SMTP -> get_lines(): select failed (' . $message . ')', 1207 self::DEBUG_LOWLEVEL 1208 ); 1209 1210 //stream_select returns false when the `select` system call is interrupted by an incoming signal, try the select again 1211 if (stripos($message, 'interrupted system call') !== false) { 1212 $this->edebug( 1213 'SMTP -> get_lines(): retrying stream_select', 1214 self::DEBUG_LOWLEVEL 1215 ); 1216 $this->setError(''); 1217 continue; 1218 } 1219 1220 break; 1221 } 1222 1223 if (!$n) { 1170 1224 $this->edebug( 1171 1225 'SMTP -> get_lines(): select timed-out in (' . $this->Timelimit . ' sec)', … … 1174 1228 break; 1175 1229 } 1230 1176 1231 //Deliberate noise suppression - errors are handled afterwards 1177 1232 $str = @fgets($this->smtp_conn, self::MAX_REPLY_LENGTH);
Note: See TracChangeset
for help on using the changeset viewer.