Ticket #9936: 9936.4.patch
| File 9936.4.patch, 4.0 KB (added by , 16 years ago) |
|---|
-
wp-admin/includes/class-wp-upgrader.php
720 720 return $this->__construct($args); 721 721 } 722 722 function __construct($args = array()) { 723 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '' );723 $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); 724 724 $this->options = wp_parse_args($args, $defaults); 725 725 } 726 726 … … 734 734 735 735 function request_filesystem_credentials($error = false) { 736 736 $url = $this->options['url']; 737 $context = $this->options['context']; 737 738 if ( !empty($this->options['nonce']) ) 738 739 $url = wp_nonce_url($url, $this->options['nonce']); 739 return request_filesystem_credentials($url, '', $error ); //Possible to bring inline, Leaving as0is for now.740 return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now. 740 741 } 741 742 742 743 function header() { -
wp-admin/includes/file.php
583 583 * @param unknown_type $args 584 584 * @return unknown 585 585 */ 586 function WP_Filesystem( $args = false ) {586 function WP_Filesystem( $args = false, $context = false ) { 587 587 global $wp_filesystem; 588 588 589 589 require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); 590 590 591 $method = get_filesystem_method($args );591 $method = get_filesystem_method($args, $context); 592 592 593 593 if ( ! $method ) 594 594 return false; … … 623 623 * @since unknown 624 624 * 625 625 * @param unknown_type $args 626 * @param string $context Full path to the directory that is tested for being writable. 626 627 * @return unknown 627 628 */ 628 function get_filesystem_method($args = array() ) {629 function get_filesystem_method($args = array(), $context = false) { 629 630 $method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets' 630 631 631 632 if( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){ 632 $temp_file_name = ABSPATH . '.' . time(); 633 if ( !$context ) 634 $context = WP_CONTENT_DIR; 635 $temp_file_name = $context . '.write-test-' . time(); 633 636 $temp_handle = @fopen($temp_file_name, 'w'); 634 637 if ( $temp_handle ) { 635 638 if ( getmyuid() == fileowner($temp_file_name) ) … … 655 658 * @param unknown_type $error 656 659 * @return unknown 657 660 */ 658 function request_filesystem_credentials($form_post, $type = '', $error = false ) {659 $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error );661 function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false) { 662 $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error, $context); 660 663 if ( '' !== $req_cred ) 661 664 return $req_cred; 662 665 663 666 if ( empty($type) ) 664 $type = get_filesystem_method( );667 $type = get_filesystem_method(array(), $context); 665 668 666 669 if ( 'direct' == $type ) 667 670 return true; -
wp-admin/update-core.php
142 142 else 143 143 $url = 'update-core.php?action=do-core-upgrade'; 144 144 $url = wp_nonce_url($url, 'upgrade-core'); 145 if ( false === ($credentials = request_filesystem_credentials($url )) )145 if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) ) 146 146 return; 147 147 148 148 $version = isset( $_POST['version'] )? $_POST['version'] : false; … … 152 152 return; 153 153 154 154 155 if ( ! WP_Filesystem($credentials ) ) {156 request_filesystem_credentials($url, '', true ); //Failed to connect, Error and request again155 if ( ! WP_Filesystem($credentials, ABSPATH) ) { 156 request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again 157 157 return; 158 158 } 159 159 ?>