Ticket #2933: 2933.diff
| File 2933.diff, 2.4 KB (added by Denis-de-Bernardy, 3 years ago) |
|---|
-
wp-includes/comment.php
1381 1381 */ 1382 1382 function generic_ping($post_id = 0) { 1383 1383 $services = get_option('ping_sites'); 1384 $update_services = false; 1385 1386 $errors = get_transient('ping_errors'); 1387 $update_errors = false; 1388 1389 if ( false === $errors ) { 1390 $update_errors = true; 1391 $errors = array(); 1392 } 1384 1393 1385 1394 $services = explode("\n", $services); 1386 foreach ( (array) $services as $ service ) {1395 foreach ( (array) $services as $i => $service ) { 1387 1396 $service = trim($service); 1388 if ( '' != $service ) 1389 weblog_ping($service); 1397 if ( '' != $service ) { 1398 if ( !isset($errors[$service]) ) 1399 $errors[$service] = array('count' => 0, 'time' => 0); 1400 $success = weblog_ping($service); 1401 if ( !$success ) { 1402 if ( time() - $errors[$service]['time'] > 86400 ) { // count failures once per day at most 1403 $update_errors = true; 1404 $errors[$service]['time'] = time(); 1405 $errors[$service]['count']++; 1406 // Pings have consistently failed for 14 seperate days 1407 if ( $errors[$services]['count'] > 14 ) { 1408 $update_services = true; 1409 unset($services[$i]); 1410 } 1411 } 1412 } elseif ( $errors[$service]['count'] ) { 1413 // reset counter 1414 $update_errors = true; 1415 $errors[$service]['time'] = time(); 1416 $errors[$service]['count'] = 0; 1417 } 1418 } 1390 1419 } 1420 1421 if ( $update_services ) 1422 update_option('ping_sites', implode("\n", $services)); 1423 1424 if ( $udpate_errors ) { 1425 // the user may remove services from the admin interface, so we filter out invalid ones here 1426 foreach ( array_keys($errors) as $service ) { 1427 if ( !in_array($service, $services) ) 1428 unset($errors[$service]); 1429 } 1430 1431 set_transient('ping_errors', $errors); 1432 } 1391 1433 1392 1434 return $post_id; 1393 1435 } … … 1531 1573 * 1532 1574 * @param string $server Host of blog to connect to. 1533 1575 * @param string $path Path to send the ping. 1576 * @return bool $success Whether the ping was successful 1534 1577 */ 1535 1578 function weblog_ping($server = '', $path = '') { 1536 1579 global $wp_version; … … 1546 1589 $home = trailingslashit( get_option('home') ); 1547 1590 if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping 1548 1591 $client->query('weblogUpdates.ping', get_option('blogname'), $home); 1592 1593 return !$client->isError(); 1549 1594 } 1550 1595 1551 1596 //
