Skip to content

65654 functions get dirsize - #12570

Open
pbearne wants to merge 9 commits into
WordPress:trunkfrom
pbearne:65654-functions-get_dirsize
Open

pbearne wants to merge 9 commits into
WordPress:trunkfrom
pbearne:65654-functions-get_dirsize

Conversation

@pbearne

@pbearne pbearne commented Jul 16, 2026

Copy link
Copy Markdown

This PR adds unit tests for get_dirsize() and recurse_dirsize() in wp-includes/functions.php.
The implementation uses isolated temporary directories within the test environment to ensure reliable execution across different platforms and Docker setups.
Changes:
•tests/phpunit/tests/functions/getDirsize.php: Covers the high-level get_dirsize() API.
•tests/phpunit/tests/functions/recurseDirsize.php: Covers the recursive logic, including exclusions, filtering, and caching.

Trac ticket: https://core.trac.wordpress.org/ticket/65654

AI Disclosure:
•AI assistance: Yes
•Tool(s): Junie (JetBrains)
•Model(s): gemini-3-flash-preview
•Used for: Code analysis, test implementation, and environment-specific troubleshooting.

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props pbearne, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the added directory-size unit tests.

No open issues 🎉

What changed in this PR

Adds unit tests for WordPress’s directory-size functions for Trac ticket #65654, using isolated temporary directories and cleanup without changing production code.

Changes:

  • Tests get_dirsize() for basic size calculation and nonexistent directories.
  • Tests recurse_dirsize() for recursion, exclusions, filter overrides, and transient caching.
File Description
tests/​phpunit/​tests/​wp-includes/​functions/​GetDirsizeTest.php Adds basic and nonexistent-directory tests for get_dirsize().
tests/​phpunit/​tests/​functions/​recurseDirsize.php Adds recursive size, exclusion, filter, and cache tests.

Review effort: Balanced

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please focus the wrapper test on the main-site exclusion. I removed the /sites exclusion from get_dirsize() locally and the proposed basic test still passed. Adding a three-byte file in a sites/ subdirectory caught that change: multisite counted 18 bytes instead of 15. With the real implementation it passed. That protects a main site from being charged for child-site uploads. The existing multisite test_pre_recurse_dirsize_filter() already covers the short-circuit, so the new copy and its temp directory can go.

AI review · gpt-6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants