Repository navigation
Conversation
listFolderTree() computed the relative name of every folder with the CMS constant JPATH_ROOT, so outside the CMS it failed with "Undefined constant JPATH_ROOT" as soon as it found a folder. Without the constant the names are now relative to the listed path. The running id is passed by reference to a private helper instead of being kept in $GLOBALS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
The CI failures are unrelated to this change and occur on
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Folder::listFolderTree()computed each folder'srelnamewithstr_replace(JPATH_ROOT, '', $fullName). Outside the Joomla CMS the constant does not exist, so the method failed withError: Undefined constant "Joomla\Filesystem\JPATH_ROOT"as soon as it found a folder. It also kept its running id in$GLOBALS['_JFolder_folder_tree_index'].relnamenow stripsJPATH_ROOTwhen that constant is defined (unchanged behaviour in the CMS) and the listed$pathotherwise. The recursion moved to a private helper that passes the id counter by reference, so no global state is left behind. The public signature is unchanged.Testing Instructions
FolderTest::testListFolderTreeWithoutJpathRootlists a temporarya/btree in a separate PHP process withoutJPATH_ROOT. Before:Fatal error: Uncaught Error: Undefined constant "Joomla\Filesystem\JPATH_ROOT"inFolder.php. After:1 0 /a,2 1 /a/b, and$GLOBALS['_JFolder_folder_tree_index']is not set. The existingtestListFolderTree*tests pass unchanged.Documentation Changes Required
docs/overview.mdgets a "Folder trees" section describing the entries and howrelnameis computed.#88 rewrites
docs/overview.md; whichever of the two is merged second has to resolve the conflict there. In #88's "Things to know before you build on this", the paragraph "Folder::listFolderTree(),Path::removeRoot()andStream::getStream()needJPATH_ROOT" has to dropFolder::listFolderTree().Related to #90 and #91 (the same problem in
Path::removeRoot()andStream::getStream(); expect a trivial conflict indocs/overview.md, where each PR adds a section at the end).🤖 Generated with Claude Code