From 3f90dc2f580481c82376f068b4c0cc60f7fb4c18 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 26 Jun 2008 22:39:57 +0000 Subject: [PATCH] More informative error message when remote publishing is disabled. Don't disable if upgrading. Props josephscott. see #7157 git-svn-id: http://svn.automattic.com/wordpress/trunk@8202 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/schema.php | 4 ++-- wp-admin/includes/upgrade.php | 14 +++++++++----- wp-admin/install.php | 7 +------ wp-app.php | 6 +++++- wp-includes/version.php | 2 +- xmlrpc.php | 35 ++++++++++++++--------------------- 6 files changed, 32 insertions(+), 36 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 0038776b91..0e25f3e100 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -254,8 +254,8 @@ function populate_options() { // 2.6 add_option('avatar_default', 'mystery'); - add_option('enable_app',0); - add_option('enable_xmlrpc',0); + add_option('enable_app', 0); + add_option('enable_xmlrpc', 0); // Delete unused options $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins'); diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 9f37efb414..2db6680d7e 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -6,7 +6,7 @@ require_once(ABSPATH . 'wp-admin/includes/admin.php'); require_once(ABSPATH . 'wp-admin/includes/schema.php'); if ( !function_exists('wp_install') ) : -function wp_install($blog_title, $user_name, $user_email, $public, $remote) { +function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') { global $wp_rewrite; wp_check_mysql_version(); @@ -18,8 +18,6 @@ function wp_install($blog_title, $user_name, $user_email, $public, $remote) { update_option('blogname', $blog_title); update_option('admin_email', $user_email); update_option('blog_public', $public); - update_option('enable_app',$remote); - update_option('enable_xmlrpc',$remote); $guessurl = wp_guess_url(); @@ -206,7 +204,7 @@ function upgrade_all() { if ( $wp_current_db_version < 7935 ) upgrade_252(); - if ( $wp_current_db_version < 8000 ) + if ( $wp_current_db_version < 8201 ) upgrade_260(); maybe_disable_automattic_widgets(); @@ -744,7 +742,13 @@ function upgrade_252() { } function upgrade_260() { - populate_roles_260(); + if ( $wp_current_db_version < 8000 ) + populate_roles_260(); + + if ( $wp_current_db_version < 8201 ) { + update_option('enable_app', 1); + update_option('enable_xmlrpc', 1); + } } // The functions we use to actually do stuff diff --git a/wp-admin/install.php b/wp-admin/install.php index 63d0b871e8..ff232126e4 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -53,10 +53,6 @@ switch($step) { - - - - @@ -72,7 +68,6 @@ switch($step) { $weblog_title = stripslashes($_POST['weblog_title']); $admin_email = stripslashes($_POST['admin_email']); $public = (int) $_POST['blog_public']; - $remote = (int) $_POST['enable_remotepublishing']; // check e-mail address if (empty($admin_email)) { // TODO: poka-yoke @@ -83,7 +78,7 @@ switch($step) { } $wpdb->show_errors(); - $result = wp_install($weblog_title, 'admin', $admin_email, $public, $remote); + $result = wp_install($weblog_title, 'admin', $admin_email, $public); extract($result, EXTR_SKIP); ?> diff --git a/wp-app.php b/wp-app.php index b8559a79ab..35fff3a275 100644 --- a/wp-app.php +++ b/wp-app.php @@ -195,6 +195,10 @@ class AtomServer { $this->redirect($this->get_service_url()); } + // check to see if AtomPub is enabled + if( !get_option( 'enable_app' ) ) + $this->not_allowed( 'AtomPub services are disabled on this blog. An admin user can enable them at ' . admin_url('options-writing.php') ); + // dispatch foreach($this->selectors as $regex => $funcs) { if(preg_match($regex, $path, $matches)) { @@ -1187,4 +1191,4 @@ EOD; $server = new AtomServer(); $server->handle_request(); -?> \ No newline at end of file +?> diff --git a/wp-includes/version.php b/wp-includes/version.php index e7b8220642..265f6b229a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -15,6 +15,6 @@ $wp_version = '2.6-beta1'; * * @global int $wp_db_version */ -$wp_db_version = 8134; +$wp_db_version = 8201; ?> diff --git a/xmlrpc.php b/xmlrpc.php index 5e2d675626..a9da86c1cd 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -39,14 +39,11 @@ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); http://wordpress.org/ - - " /> - @@ -111,7 +108,7 @@ if ( isset($HTTP_RAW_POST_DATA) ) class wp_xmlrpc_server extends IXR_Server { function wp_xmlrpc_server() { - $xmlrpc_methods = array( + $this->methods = array( // WordPress API 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs', 'wp.getPage' => 'this:wp_getPage', @@ -167,10 +164,8 @@ class wp_xmlrpc_server extends IXR_Server { 'mt.supportedMethods' => 'this:mt_supportedMethods', 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', - 'mt.publishPost' => 'this:mt_publishPost' - ); - - $xmlrpc_functions = array ( + 'mt.publishPost' => 'this:mt_publishPost', + // PingBack 'pingback.ping' => 'this:pingback_ping', 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', @@ -179,13 +174,6 @@ class wp_xmlrpc_server extends IXR_Server { 'demo.addTwoNumbers' => 'this:addTwoNumbers' ); - if ( get_option('enable_xmlrpc') ) - { - $this->methods = array_merge($xmlrpc_methods,$xmlrpc_functions); - } else { - $this->methods = $xmlrpc_functions; - } - $this->initialise_blog_option_info( ); $this->methods = apply_filters('xmlrpc_methods', $this->methods); $this->IXR_Server($this->methods); @@ -202,6 +190,11 @@ class wp_xmlrpc_server extends IXR_Server { } function login_pass_ok($user_login, $user_pass) { + if ( !get_option( 'enable_xmlrpc' ) ) { + $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); + return false; + } + if (!user_pass_ok($user_login, $user_pass)) { $this->error = new IXR_Error(403, __('Bad login/pass combination.')); return false; @@ -845,7 +838,7 @@ class wp_xmlrpc_server extends IXR_Server { $post_id = (int) $args[3]; if( !$this->login_pass_ok( $username, $password ) ) { - return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); + return $this->error; } set_current_user( 0, $username ); @@ -873,7 +866,7 @@ class wp_xmlrpc_server extends IXR_Server { $password = $args[2]; if( !$this->login_pass_ok( $username, $password ) ) { - return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); + return $this->error; } set_current_user( 0, $username ); @@ -895,7 +888,7 @@ class wp_xmlrpc_server extends IXR_Server { $password = $args[2]; if( !$this->login_pass_ok( $username, $password ) ) { - return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); + return $this->error; } set_current_user( 0, $username ); @@ -916,7 +909,7 @@ class wp_xmlrpc_server extends IXR_Server { $password = $args[2]; if( !$this->login_pass_ok( $username, $password ) ) { - return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); + return $this->error; } set_current_user( 0, $username ); @@ -939,7 +932,7 @@ class wp_xmlrpc_server extends IXR_Server { $options = (array) $args[3]; if( !$this->login_pass_ok( $username, $password ) ) - return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); + return $this->error; $user = set_current_user( 0, $username ); @@ -978,7 +971,7 @@ class wp_xmlrpc_server extends IXR_Server { $options = (array) $args[3]; if( !$this->login_pass_ok( $username, $password ) ) - return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); + return $this->error; $user = set_current_user( 0, $username ); if( !current_user_can( 'manage_options' ) )