Make WordPress Core

Changeset 19935 for trunk/wp-app.php


Ignore:
Timestamp:
02/17/2012 12:02:42 AM (14 years ago)
Author:
nacin
Message:

Deprecate ancient "debugging" tools.

  • logIO() and the global $xmlrpc_logging in XML-RPC.
  • log_app() and the global $app_logging in APP.
  • debug_fwrite(), debug_fopen(), debug_fclose(), and $debug.

see #20051.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-app.php

    r19926 r19935  
    2323
    2424$_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] );
    25 
    26 /**
    27  * Whether to enable Atom Publishing Protocol Logging.
    28  *
    29  * @name app_logging
    30  * @var int|bool
    31  */
    32 $app_logging = 0;
    3325
    3426/**
     
    4537 *
    4638 * @since 2.2.0
    47  * @uses $app_logging
    48  * @package WordPress
    49  * @subpackage Logging
     39 * @deprecated 3.4.0
     40 * @deprecated Use error_log()
     41 * @link http://www.php.net/manual/en/function.error-log.php
    5042 *
    5143 * @param string $label Type of logging
    5244 * @param string $msg Information describing logging reason.
    5345 */
    54 function log_app($label,$msg) {
    55         global $app_logging;
    56         if ($app_logging) {
    57                 $fp = fopen( 'wp-app.log', 'a+');
    58                 $date = gmdate( 'Y-m-d H:i:s' );
    59                 fwrite($fp, "\n\n$date - $label\n$msg\n");
    60                 fclose($fp);
    61         }
     46function log_app( $label, $msg ) {
     47        _deprecated_function( __FUNCTION__, '3.4', 'error_log()' );
     48        if ( ! empty( $GLOBALS['app_logging'] ) )
     49                error_log( $label . ' - ' . $message );
    6250}
    6351
     
    269257                $method = $_SERVER['REQUEST_METHOD'];
    270258
    271                 log_app('REQUEST',"$method $path\n================");
    272 
    273259                $this->process_conditionals();
    274260                //$this->process_conditionals();
     
    320306         */
    321307        function get_service() {
    322                 log_app('function','get_service()');
    323 
    324308                if ( !current_user_can( 'edit_posts' ) )
    325309                        $this->auth_required( __( 'Sorry, you do not have the right to access this site.' ) );
     
    361345         */
    362346        function get_categories_xml() {
    363                 log_app('function','get_categories_xml()');
    364 
    365347                if ( !current_user_can( 'edit_posts' ) )
    366348                        $this->auth_required( __( 'Sorry, you do not have the right to access this site.' ) );
     
    397379
    398380                $entry = array_pop($parser->feed->entries);
    399 
    400                 log_app('Received entry:', print_r($entry,true));
    401381
    402382                $catnames = array();
     
    452432
    453433                $this->escape($post_data);
    454                 log_app('Inserting Post. Data:', print_r($post_data,true));
    455434
    456435                $postID = wp_insert_post($post_data);
     
    471450                $output = $this->get_entry($postID);
    472451
    473                 log_app('function',"create_post($postID)");
    474452                $this->created($postID, $output);
    475453        }
     
    490468                $this->set_current_entry($postID);
    491469                $output = $this->get_entry($postID);
    492                 log_app('function',"get_post($postID)");
    493470                $this->output($output);
    494471
     
    512489
    513490                $parsed = array_pop($parser->feed->entries);
    514 
    515                 log_app('Received UPDATED entry:', print_r($parsed,true));
    516491
    517492                // check for not found
     
    547522                do_action( 'atompub_put_post', $ID, $parsed );
    548523
    549                 log_app('function',"put_post($postID)");
    550524                $this->ok();
    551525        }
     
    576550                        }
    577551
    578                         log_app('function',"delete_post($postID)");
    579552                        $this->ok();
    580553                }
     
    598571                        $this->set_current_entry($postID);
    599572                        $output = $this->get_entry($postID, 'attachment');
    600                         log_app('function',"get_attachment($postID)");
    601573                        $this->output($output);
    602574                }
     
    633605                $file = wp_upload_bits( $slug, null, $bits);
    634606
    635                 log_app('wp_upload_bits returns:',print_r($file,true));
    636 
    637607                $url = $file['url'];
    638608                $file = $file['file'];
     
    659629
    660630                $this->created($postID, $output, 'attachment');
    661                 log_app('function',"create_attachment($postID)");
    662631        }
    663632
     
    704673                        $this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
    705674
    706                 log_app('function',"put_attachment($postID)");
    707675                $this->ok();
    708676        }
     
    716684         */
    717685        function delete_attachment($postID) {
    718                 log_app('function',"delete_attachment($postID). File '$location' deleted.");
    719 
    720686                // check for not found
    721687                global $entry;
     
    740706                        $this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
    741707
    742                 log_app('function',"delete_attachment($postID). File '$location' deleted.");
    743708                $this->ok();
    744709        }
     
    786751                }
    787752
    788                 log_app('function',"get_file($postID)");
    789753                exit;
    790754        }
     
    844808                wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $location ) );
    845809
    846                 log_app('function',"put_file($postID)");
    847810                $this->ok();
    848811        }
     
    955918                $url = $this->app_base . $this->ENTRY_PATH . "/$postID";
    956919
    957                 log_app('function',"get_entry_url() = $url");
    958920                return $url;
    959921        }
     
    986948                $url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID";
    987949
    988                 log_app('function',"get_media_url() = $url");
    989950                return $url;
    990951        }
     
    1010971        function set_current_entry($postID) {
    1011972                global $entry;
    1012                 log_app('function',"set_current_entry($postID)");
    1013973
    1014974                if (!isset($postID)) {
     
    1034994         */
    1035995        function get_posts($page = 1, $post_type = 'post') {
    1036                         log_app('function',"get_posts($page, '$post_type')");
    1037996                        $feed = $this->get_feed($page, $post_type);
    1038997                        $this->output($feed);
     
    10481007         */
    10491008        function get_attachments($page = 1, $post_type = 'attachment') {
    1050                 log_app('function',"get_attachments($page, '$post_type')");
    10511009                $GLOBALS['post_type'] = $post_type;
    10521010                $feed = $this->get_feed($page, $post_type);
     
    10651023        function get_feed($page = 1, $post_type = 'post') {
    10661024                global $post, $wp, $wp_query, $posts, $wpdb, $blog_id;
    1067                 log_app('function',"get_feed($page, '$post_type')");
    10681025                ob_start();
    10691026
     
    10851042                $wpdb = $GLOBALS['wpdb'];
    10861043                $blog_id = (int) $GLOBALS['blog_id'];
    1087                 log_app('function',"query_posts(# " . print_r($wp_query, true) . "#)");
    1088 
    1089                 log_app('function',"total_count(# $wp_query->max_num_pages #)");
     1044
    10901045                $last_page = $wp_query->max_num_pages;
    10911046                $next_page = (($page + 1) > $last_page) ? null : $page + 1;
     
    11321087         */
    11331088        function get_entry($postID, $post_type = 'post') {
    1134                 log_app('function',"get_entry($postID, '$post_type')");
    11351089                ob_start();
    11361090                switch($post_type) {
     
    11481102                                the_post();
    11491103                                $this->echo_entry();
    1150                                 log_app('$post',print_r($GLOBALS['post'],true));
    11511104                                $entry = ob_get_contents();
    11521105                                break;
     
    11551108                ob_end_clean();
    11561109
    1157                 log_app('get_entry returning:',$entry);
    11581110                return $entry;
    11591111        }
     
    12061158         */
    12071159        function ok() {
    1208                 log_app('Status','200: OK');
    12091160                header('Content-Type: text/plain');
    12101161                status_header('200');
     
    12181169         */
    12191170        function no_content() {
    1220                 log_app('Status','204: No Content');
    12211171                header('Content-Type: text/plain');
    12221172                status_header('204');
     
    12331183         */
    12341184        function internal_error($msg = 'Internal Server Error') {
    1235                 log_app('Status','500: Server Error');
    12361185                header('Content-Type: text/plain');
    12371186                status_header('500');
     
    12461195         */
    12471196        function bad_request() {
    1248                 log_app('Status','400: Bad Request');
    12491197                header('Content-Type: text/plain');
    12501198                status_header('400');
     
    12581206         */
    12591207        function length_required() {
    1260                 log_app('Status','411: Length Required');
    12611208                header("HTTP/1.1 411 Length Required");
    12621209                header('Content-Type: text/plain');
     
    12711218         */
    12721219        function invalid_media() {
    1273                 log_app('Status','415: Unsupported Media Type');
    12741220                header("HTTP/1.1 415 Unsupported Media Type");
    12751221                header('Content-Type: text/plain');
     
    12831229         */
    12841230        function forbidden($reason='') {
    1285                 log_app('Status','403: Forbidden');
    12861231                header('Content-Type: text/plain');
    12871232                status_header('403');
     
    12961241         */
    12971242        function not_found() {
    1298                 log_app('Status','404: Not Found');
    12991243                header('Content-Type: text/plain');
    13001244                status_header('404');
     
    13081252         */
    13091253        function not_allowed($allow) {
    1310                 log_app('Status','405: Not Allowed');
    13111254                header('Allow: ' . join(',', $allow));
    13121255                status_header('405');
     
    13201263         */
    13211264        function redirect($url) {
    1322 
    1323                 log_app('Status','302: Redirect');
    13241265                $escaped_url = esc_attr($url);
    13251266                $content = <<<EOD
     
    13501291         */
    13511292        function client_error($msg = 'Client Error') {
    1352                 log_app('Status','400: Client Error');
    13531293                header('Content-Type: text/plain');
    13541294                status_header('400');
     
    13641304         */
    13651305        function created($post_ID, $content, $post_type = 'post') {
    1366                 log_app('created()::$post_ID',"$post_ID, $post_type");
    13671306                $edit = $this->get_entry_url($post_ID);
    13681307                switch($post_type) {
     
    13911330         */
    13921331        function auth_required($msg) {
    1393                 log_app('Status','401: Auth Required');
    13941332                nocache_headers();
    13951333                header('WWW-Authenticate: Basic realm="WordPress Atom Protocol"');
     
    14321370                        if ($this->do_output)
    14331371                                echo $xml;
    1434                         log_app('function', "output:\n$xml");
    14351372                        exit;
    14361373        }
     
    14651402         */
    14661403        function authenticate() {
    1467                 log_app("authenticate()",print_r($_ENV, true));
    1468 
    14691404                // if using mod_rewrite/ENV hack
    14701405                // http://www.besthostratings.com/articles/http-auth-php-cgi.html
     
    14811416                // If Basic Auth is working...
    14821417                if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    1483                         log_app("Basic Auth",$_SERVER['PHP_AUTH_USER']);
    1484 
    14851418                        $user = wp_authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
    14861419                        if ( $user && !is_wp_error($user) ) {
    14871420                                wp_set_current_user($user->ID);
    1488                                 log_app("authenticate()", $user->user_login);
    14891421                                return true;
    14901422                        }
     
    15151447                list($type,$subtype) = explode('/',$type);
    15161448                list($subtype) = explode(";",$subtype); // strip MIME parameters
    1517                 log_app("get_accepted_content_type", "type=$type, subtype=$subtype");
    15181449
    15191450                foreach($types as $t) {
Note: See TracChangeset for help on using the changeset viewer.