fileowner example

// This process is inherently difficult to test therefore use a state flag.     $test_authorize = FALSE;
    if (drupal_valid_test_ua()) {
      $test_authorize = \Drupal::state()->get('test_uploaders_via_prompt', FALSE);
    }
    // If the owner of the directory we extracted is the same as the owner of     // our configuration directory (e.g. sites/default) where we're trying to     // install the code, there's no need to prompt for FTP/SSH credentials.     // Instead, we instantiate a Drupal\Core\FileTransfer\Local and invoke     // update_authorize_run_install() directly.     if (fileowner($project_real_location) == fileowner($this->sitePath) && !$test_authorize) {
      $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
      $filetransfer = new Local($this->root, \Drupal::service('file_system'));
      $response = call_user_func_array('update_authorize_run_install', array_merge([$filetransfer]$arguments));
      if ($response instanceof Response) {
        $form_state->setResponse($response);
      }
    }

    // Otherwise, go through the regular workflow to prompt for FTP/SSH     // credentials and invoke update_authorize_run_install() indirectly with     // whatever FileTransfer object authorize.php creates for us.


    /** * Gets the file owner. * * @since 2.7.0 * * @param string $file Path to the file. * @return string|false Username of the owner on success, false on failure. */
    public function owner( $file ) {
        $owneruid = @fileowner( $this->sftp_path( $file ) );

        if ( ! $owneruid ) {
            return false;
        }

        if ( ! function_exists( 'posix_getpwuid' ) ) {
            return $owneruid;
        }

        $ownerarray = posix_getpwuid( $owneruid );

        


    /** * Gets the file owner. * * @since 2.5.0 * * @param string $file Path to the file. * @return string|false Username of the owner on success, false on failure. */
    public function owner( $file ) {
        $owneruid = @fileowner( $file );

        if ( ! $owneruid ) {
            return false;
        }

        if ( ! function_exists( 'posix_getpwuid' ) ) {
            return $owneruid;
        }

        $ownerarray = posix_getpwuid( $owneruid );

        
if ( ! $method ) {

        $temp_file_name = $context . 'temp-write-test-' . str_replace( '.', '-', uniqid( '', true ) );
        $temp_handle    = @fopen( $temp_file_name, 'w' );
        if ( $temp_handle ) {

            // Attempt to determine the file owner of the WordPress files, and that of newly created files.             $wp_file_owner   = false;
            $temp_file_owner = false;
            if ( function_exists( 'fileowner' ) ) {
                $wp_file_owner   = @fileowner( __FILE__ );
                $temp_file_owner = @fileowner( $temp_file_name );
            }

            if ( false !== $wp_file_owner && $wp_file_owner === $temp_file_owner ) {
                /* * WordPress is creating files as the same owner as the WordPress files, * this means it's safe to modify & create new files via PHP. */
                $method                                  = 'direct';
                $GLOBALS['_wp_filesystem_direct_method'] = 'file_owner';
            } elseif ( $allow_relaxed_file_ownership ) {
                
'project' => $project,
          'updater_name' => get_class($updater),
          'local_url' => $project_real_location,
        ];
      }

      // If the owner of the last directory we extracted is the same as the       // owner of our configuration directory (e.g. sites/default) where we're       // trying to install the code, there's no need to prompt for FTP/SSH       // credentials. Instead, we instantiate a Drupal\Core\FileTransfer\Local       // and invoke update_authorize_run_update() directly.       if (fileowner($project_real_location) == fileowner($this->sitePath)) {
        $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize');
        $filetransfer = new Local($this->root, \Drupal::service('file_system'));
        $response = update_authorize_run_update($filetransfer$updates);
        if ($response instanceof Response) {
          $form_state->setResponse($response);
        }
      }
      // Otherwise, go through the regular workflow to prompt for FTP/SSH       // credentials and invoke update_authorize_run_update() indirectly with       // whatever FileTransfer object authorize.php creates for us.       else {
        
Home | Imprint | This part of the site doesn't use cookies.