1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 22:32:41 +01:00

T15064: Several arcanist PHP 8.1 compat issues on Windows

Summary:
Ran into `strlen`/`strpos` issues while using Arcanist on Windows:
- Running `arc version` when not in a project/repository directory blew up (may not be specific to Windows).
- Determining mime type of binary file in repository fails.

Refs T15064

Test Plan: Ran diff including a binary file. Ran `arc version` when not in a project/repository directory.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15064

Differential Revision: https://we.phorge.it/D25534
This commit is contained in:
Christopher Speck 2024-02-05 19:26:48 -05:00
parent 6c7caf3572
commit 8ef1ead6ac
2 changed files with 4 additions and 4 deletions

View file

@ -275,7 +275,7 @@ final class Filesystem extends Phobject {
$trap->destroy(); $trap->destroy();
if (!$ok) { if (!$ok) {
if (strlen($err)) { if ($err !== null && strlen($err)) {
throw new FilesystemException( throw new FilesystemException(
$to, $to,
pht( pht(
@ -307,7 +307,7 @@ final class Filesystem extends Phobject {
* @task file * @task file
*/ */
public static function remove($path) { public static function remove($path) {
if (!strlen($path)) { if ($path == null || !strlen($path)) {
// Avoid removing PWD. // Avoid removing PWD.
throw new Exception( throw new Exception(
pht( pht(
@ -673,7 +673,7 @@ final class Filesystem extends Phobject {
} }
// If we come back with an encoding, strip it off. // If we come back with an encoding, strip it off.
if (strpos($mime_type, ';') !== false) { if ($mime_type !== null && strpos($mime_type, ';') !== false) {
list($type, $encoding) = explode(';', $mime_type, 2); list($type, $encoding) = explode(';', $mime_type, 2);
$mime_type = $type; $mime_type = $type;
} }

View file

@ -289,7 +289,7 @@ final class ArcanistWorkingCopyIdentity extends Phobject {
} }
public function readLocalArcConfig() { public function readLocalArcConfig() {
if (strlen($this->localMetaDir)) { if ($this->localMetaDir !== null && strlen($this->localMetaDir)) {
$local_path = Filesystem::resolvePath('arc/config', $this->localMetaDir); $local_path = Filesystem::resolvePath('arc/config', $this->localMetaDir);
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();