mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Fix PHP 8.1 PhabricatorEditorURIEngine::newForViewer() trim(NULL) error
Summary: Under PHP 8.1, PhabricatorEditorURIEngine::newForViewer() is throwing a trim(NULL) error when trying to view a diff. This is because it tries to apply string operations to a user setting which will be null by default. Fixes T15518 Test Plan: Unit test added - arc unit Or just view a diff. Eg: https://my.phorge.site/D1234 Reviewers: O1 Blessed Committers, valerio.bozzolan, avivey Reviewed By: O1 Blessed Committers, valerio.bozzolan, avivey Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15518 Differential Revision: https://we.phorge.it/D25324
This commit is contained in:
parent
682fe971a4
commit
65e57fe23d
2 changed files with 18 additions and 1 deletions
|
@ -16,7 +16,7 @@ final class PhabricatorEditorURIEngine
|
||||||
|
|
||||||
$pattern = $viewer->getUserSetting(PhabricatorEditorSetting::SETTINGKEY);
|
$pattern = $viewer->getUserSetting(PhabricatorEditorSetting::SETTINGKEY);
|
||||||
|
|
||||||
if (!strlen(trim($pattern))) {
|
if ($pattern === null || trim($pattern) === '') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
final class PhabricatorEditorURIEngineTestCase
|
final class PhabricatorEditorURIEngineTestCase
|
||||||
extends PhabricatorTestCase {
|
extends PhabricatorTestCase {
|
||||||
|
|
||||||
|
protected function getPhabricatorTestCaseConfiguration() {
|
||||||
|
return array(
|
||||||
|
self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testPatternParsing() {
|
public function testPatternParsing() {
|
||||||
$map = array(
|
$map = array(
|
||||||
'' => array(),
|
'' => array(),
|
||||||
|
@ -129,4 +135,15 @@ final class PhabricatorEditorURIEngineTestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNewForViewer() {
|
||||||
|
$phabricator_user = $this->generateNewTestUser();
|
||||||
|
try {
|
||||||
|
$engine = PhabricatorEditorURIEngine::newForViewer($phabricator_user);
|
||||||
|
$this->assertTrue(true, 'newForViewer did not throw an error');
|
||||||
|
} catch (Throwable $ex) {
|
||||||
|
$this->assertTrue(false,
|
||||||
|
'newForViewer threw an exception:'.$ex->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue