mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
PHP8.1 fix for DiffusionServeController serveRequest()
Summary: When a 'git pull' is done to an https git URL, the $_SERVER variables PHP_AUTH_USER and PHP_AUTH_PW will be unset, causing PHP 8.1 to throw strlen(null) errors. This update fixes the issue by defaulting the values to '', which results in $have_user and $have_pass having false values as desired. Fixes T15520 Test Plan: arc unit Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15520 Differential Revision: https://we.phorge.it/D25327
This commit is contained in:
parent
5e48e16f77
commit
9bf5e17352
3 changed files with 25 additions and 2 deletions
|
@ -1052,6 +1052,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSSHWorkflow' => 'applications/diffusion/ssh/DiffusionSSHWorkflow.php',
|
'DiffusionSSHWorkflow' => 'applications/diffusion/ssh/DiffusionSSHWorkflow.php',
|
||||||
'DiffusionSearchQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionSearchQueryConduitAPIMethod.php',
|
'DiffusionSearchQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionSearchQueryConduitAPIMethod.php',
|
||||||
'DiffusionServeController' => 'applications/diffusion/controller/DiffusionServeController.php',
|
'DiffusionServeController' => 'applications/diffusion/controller/DiffusionServeController.php',
|
||||||
|
'DiffusionServeControllerTestCase' => 'applications/diffusion/controller/__tests__/DiffusionServeControllerTestCase.php',
|
||||||
'DiffusionServiceRef' => 'applications/diffusion/ref/DiffusionServiceRef.php',
|
'DiffusionServiceRef' => 'applications/diffusion/ref/DiffusionServiceRef.php',
|
||||||
'DiffusionSetPasswordSettingsPanel' => 'applications/diffusion/panel/DiffusionSetPasswordSettingsPanel.php',
|
'DiffusionSetPasswordSettingsPanel' => 'applications/diffusion/panel/DiffusionSetPasswordSettingsPanel.php',
|
||||||
'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php',
|
'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php',
|
||||||
|
@ -7103,6 +7104,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
'DiffusionSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
||||||
'DiffusionSearchQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
'DiffusionSearchQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||||
'DiffusionServeController' => 'DiffusionController',
|
'DiffusionServeController' => 'DiffusionController',
|
||||||
|
'DiffusionServeControllerTestCase' => 'PhabricatorTestCase',
|
||||||
'DiffusionServiceRef' => 'Phobject',
|
'DiffusionServiceRef' => 'Phobject',
|
||||||
'DiffusionSetPasswordSettingsPanel' => 'PhabricatorSettingsPanel',
|
'DiffusionSetPasswordSettingsPanel' => 'PhabricatorSettingsPanel',
|
||||||
'DiffusionSetupException' => 'Exception',
|
'DiffusionSetupException' => 'Exception',
|
||||||
|
|
|
@ -183,8 +183,8 @@ final class DiffusionServeController extends DiffusionController {
|
||||||
// won't prompt users who provide a username but no password otherwise.
|
// won't prompt users who provide a username but no password otherwise.
|
||||||
// See T10797 for discussion.
|
// See T10797 for discussion.
|
||||||
|
|
||||||
$have_user = strlen(idx($_SERVER, 'PHP_AUTH_USER'));
|
$have_user = strlen(idx($_SERVER, 'PHP_AUTH_USER', ''));
|
||||||
$have_pass = strlen(idx($_SERVER, 'PHP_AUTH_PW'));
|
$have_pass = strlen(idx($_SERVER, 'PHP_AUTH_PW', ''));
|
||||||
if ($have_user && $have_pass) {
|
if ($have_user && $have_pass) {
|
||||||
$username = $_SERVER['PHP_AUTH_USER'];
|
$username = $_SERVER['PHP_AUTH_USER'];
|
||||||
$password = new PhutilOpaqueEnvelope($_SERVER['PHP_AUTH_PW']);
|
$password = new PhutilOpaqueEnvelope($_SERVER['PHP_AUTH_PW']);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionServeControllerTestCase extends PhabricatorTestCase {
|
||||||
|
protected function getPhabricatorTestCaseConfiguration() {
|
||||||
|
return array(
|
||||||
|
self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHandleRequest() {
|
||||||
|
$aphront_request = new AphrontRequest('example.com', '/');
|
||||||
|
$diffusion_serve_controller = new DiffusionServeController();
|
||||||
|
|
||||||
|
$diffusion_serve_controller->setRequest($aphront_request);
|
||||||
|
$result = $diffusion_serve_controller->handleRequest($aphront_request);
|
||||||
|
$this->assertTrue(true, 'handleRequest did not throw an error');
|
||||||
|
$this->assertTrue($result instanceof PhabricatorVCSResponse,
|
||||||
|
'handleRequest() returns PhabricatorVCSResponse object');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue