Review main Ready for review

98106[BUGFIX] Keep command name when found by which

Markus Hofmann CR 0 V 0 Easy +27 −4 updated 11/27/26, 12:42

Commit message

CommandUtility::checkCommand() first looks for a command in its
search paths (SYS/binPath, SYS/binSetup, /usr/bin/, /usr/local/bin/).
If the command is not found there, it falls back to "which". That
fallback overwrote the requested command name with the output of
"which" and stored the entry under the full path, e.g.
"/opt/bin/identify" instead of "identify".

As a result, checkCommand('identify') reported the command as
available, but getCommand('identify') afterwards looked up the
entry under the requested name, did not find it, triggered the PHP
warnings "Undefined array key" and "Trying to access array offset
on null", and returned an empty string instead of the command.
Because the entry was never found again, "which" ran again on every
call and the warnings were logged each time. Even under the right
key, the stored values would have resulted in a duplicated path, as
"app" held the full path and "path" its directory.

The fallback is reached for every command that is available on
PATH, but not in one of the search paths. This is typically the case
with open_basedir in effect, where the regular is_executable() check
of the search paths fails, e.g. for ImageMagick on shared hosting.
Since #70869 the fallback relies on the exit code of "which" instead
of is_executable(), so it is used under open_basedir as well.

The result of "which" is now stored under the requested command
name, split into the directory as "path" and the file name as "app",
and only if "which" returned a path.
Show more Show less

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 1
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/06/98106/1 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/06/98106/1 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 1

Issues 3

Files 2

Review log 12

  1. Markus Hofmann uploaded patch set 1 11/27/26, 12:33

  2. core-ci voted on patch set 1 V +1 11/27/26, 12:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115731