Ticket #2933: ping.patch

File ping.patch, 2.9 KB (added by c960657, 6 years ago)
  • wp-includes/comment.php

     
    635635} 
    636636 
    637637function generic_ping($post_id = 0) { 
     638        $errors = get_option('ping_errors'); 
     639        if ( !is_array($errors) ) 
     640                $errors = array(); 
    638641        $services = get_settings('ping_sites'); 
    639642        $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines 
    640643        $services = trim($services); 
    641644        if ( '' != $services ) { 
    642645                $services = explode("\n", $services); 
    643646                foreach ($services as $service) { 
    644                         weblog_ping($service); 
     647                        $error = weblog_ping($service); 
     648                        if ( $error ) { 
     649                                if ( !isset($errors[$service]) ) 
     650                                        $errors[$service] = array('count' => 0); 
     651                                $errors[$service]['count']++; 
     652                                $errors[$service]['last_message'] = $error; 
     653                        } else { 
     654                        unset($errors[$service]); 
     655                        } 
    645656                } 
    646657        } 
     658        update_option('ping_errors', $errors); 
    647659 
    648660        return $post_id; 
    649661} 
     
    791803        $home = trailingslashit( get_option('home') ); 
    792804        if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping 
    793805                $client->query('weblogUpdates.ping', get_settings('blogname'), $home); 
     806 
     807        $error = false; 
     808        if ( $client->isError() ) { 
     809                $error = $client->getErrorMessage(); 
     810        } else { 
     811                $response = $client->getResponse(); 
     812                if ( !isset($response['flerror']) || $response['flerror'] ) { 
     813                        $error = isset($response['message']) && $response['message'] 
     814                            ? $response['message'] : 'Invalid response'; 
     815                } 
     816        } 
     817        return $error; 
    794818} 
    795819 
    796820?> 
  • wp-admin/options-writing.php

     
    9999<p><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service URIs with line breaks.') ?></p> 
    100100 
    101101<textarea name="ping_sites" id="ping_sites" style="width: 98%;" rows="3" cols="50"><?php form_option('ping_sites'); ?></textarea> 
     102 
     103<?php 
     104$min_ping_error_count = 3; 
     105?> 
     106<p><?php _e('These update services has failed the last ' . $min_ping_error_count . ' times or more. You should consider removing these services from the list above.') ?></p> 
     107<dl> 
     108<?php 
     109$has_errors = false; 
     110$services = get_option('ping_sites'); 
     111foreach (get_option('ping_errors') as $service => $error) : 
     112if ($error['count'] >= $min_ping_error_count && strpos($services, $service) !== false) : 
     113echo "<dt>" . htmlspecialchars($service) . "<dt>"; 
     114echo "<dd>" . htmlspecialchars($error['last_message']) . "<dd>"; 
     115$has_errors = true; 
     116endif; 
     117endforeach; 
     118 
     119if (!$has_errors) : 
     120echo "<dd><em>" . __('No errors') . "</em></dd>"; 
     121endif; 
     122?> 
     123</dl> 
    102124</fieldset> 
    103125 
    104126<p class="submit">