Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Svn.php

function Svn::executeWithAuthRetry

Parameters

non-empty-list<string> $svnCommand:

2 calls to Svn::executeWithAuthRetry()
Svn::execute in vendor/composer/composer/src/Composer/Util/Svn.php
Execute an SVN remote command and try to fix up the process with credentials if necessary.
Svn::executeLocal in vendor/composer/composer/src/Composer/Util/Svn.php
Execute an SVN local command and try to fix up the process with credentials if necessary.

File

vendor/composer/composer/src/Composer/Util/Svn.php, line 129

Class

Svn
@author Till Klampaeckel <till@php.net> @author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Util

Code

private function executeWithAuthRetry(array $svnCommand, ?string $cwd, string $url, ?string $path, bool $verbose) : ?string {
    // Regenerate the command at each try, to use the newly user-provided credentials
    $command = $this->getCommand($svnCommand, $url, $path);
    $output = null;
    $io = $this->io;
    $handler = static function ($type, $buffer) use (&$output, $io, $verbose) {
        if ($type !== 'out') {
            return null;
        }
        if (strpos($buffer, 'Redirecting to URL ') === 0) {
            return null;
        }
        $output .= $buffer;
        if ($verbose) {
            $io->writeError($buffer, false);
        }
    };
    $status = $this->process
        ->execute($command, $handler, $cwd);
    if (0 === $status) {
        return $output;
    }
    $errorOutput = $this->process
        ->getErrorOutput();
    $fullOutput = trim(implode("\n", [
        $output,
        $errorOutput,
    ]));
    // the error is not auth-related
    if (false === stripos($fullOutput, 'Could not authenticate to server:') && false === stripos($fullOutput, 'authorization failed') && false === stripos($fullOutput, 'svn: E170001:') && false === stripos($fullOutput, 'svn: E215004:')) {
        throw new \RuntimeException($fullOutput);
    }
    if (!$this->hasAuth()) {
        $this->doAuthDance();
    }
    // try to authenticate if maximum quantity of tries not reached
    if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
        // restart the process
        return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
    }
    throw new \RuntimeException('wrong credentials provided (' . $fullOutput . ')');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal