From 8ef1ead6aca014e7f23c79c1b11441a0f8a436b7 Mon Sep 17 00:00:00 2001 From: Christopher Speck Date: Mon, 5 Feb 2024 19:26:48 -0500 Subject: [PATCH] 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 --- src/filesystem/Filesystem.php | 6 +++--- src/workingcopyidentity/ArcanistWorkingCopyIdentity.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php index 981d4feb..dd6e984a 100644 --- a/src/filesystem/Filesystem.php +++ b/src/filesystem/Filesystem.php @@ -275,7 +275,7 @@ final class Filesystem extends Phobject { $trap->destroy(); if (!$ok) { - if (strlen($err)) { + if ($err !== null && strlen($err)) { throw new FilesystemException( $to, pht( @@ -307,7 +307,7 @@ final class Filesystem extends Phobject { * @task file */ public static function remove($path) { - if (!strlen($path)) { + if ($path == null || !strlen($path)) { // Avoid removing PWD. throw new Exception( pht( @@ -673,7 +673,7 @@ final class Filesystem extends Phobject { } // 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); $mime_type = $type; } diff --git a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php index d2c86fd0..82a98cbb 100644 --- a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php +++ b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php @@ -289,7 +289,7 @@ final class ArcanistWorkingCopyIdentity extends Phobject { } public function readLocalArcConfig() { - if (strlen($this->localMetaDir)) { + if ($this->localMetaDir !== null && strlen($this->localMetaDir)) { $local_path = Filesystem::resolvePath('arc/config', $this->localMetaDir); $console = PhutilConsole::getConsole();