Skip to content

test for _wp_check_existing_file_names - #2332

Closed
pbearne wants to merge 16 commits into
WordPress:trunkfrom
pbearne:#53971_wp_check_existing_file_names
Closed

pbearne wants to merge 16 commits into
WordPress:trunkfrom
pbearne:#53971_wp_check_existing_file_names

Conversation

@pbearne

@pbearne pbearne commented Feb 17, 2022 •

Copy link
Copy Markdown

test for _wp_check_existing_file_names

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

@costdev costdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for writing these tests Paul!

I have made some suggestions to improve consistency, readability and coverage in the tests.

'filename' => 'filename.png',
'files' => array( 'filename-rotated.png' ),
'expected' => true,
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There should be two additional datasets:

  • 'a file with no extension' that tests a 'filename' such as filename - expected should be true.
  • 'a file with no filename' that tests a 'filename' such as .htaccess - expected should be false.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

both of these return false
because of this code
// Edge case, file names like .ext.
if ( empty( $fname ) || empty( $ext ) ) {

	return false;
}

Do you feel the code should changed to return true?

pbearne and others added 8 commits February 18, 2022 10:10
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
…mes' into #53971_wp_check_existing_file_names

# Conflicts:
#	tests/phpunit/tests/functions/_wpCheckExistingFileNames.php

@costdev costdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great Paul! Just two suggestions to use a single underscore _ instead of two underscores __ in the method names.

pbearne and others added 2 commits April 30, 2022 10:29
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>

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

There are no active review issues for the change adding filename-conflict test coverage.

No open issues 🎉

What changed in this PR

Adds PHPUnit coverage for _wp_check_existing_file_names(), WordPress’s helper for detecting filename conflicts with generated image variants, in support of Trac ticket #55192.

Changes:

  • Adds data-driven tests for dimension, scaled, and rotated suffixes, plus filenames without a name or extension.
  • Adds a blank line in the helper; production behavior is unchanged.
File Description
tests/​phpunit/​tests/​functions/​_wpCheckExistingFileNames.php Adds ten test cases for filename matching and edge cases.
src/​wp-includes/​functions.php Whitespace-only change in the empty-filename guard.

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.

The requested naming changes are present. All ten cases passed locally in randomized single-site and multisite runs; Copilot also found no active issue.

On the older extensionless-filename question: no production change is needed. filename against filename correctly returns false; filename against filename-1x1 returns true with the current implementation. That latter row would clarify the earlier discussion, but I do not consider it necessary before landing this coverage.

AI review · gpt-6

@lancewillett

Copy link
Copy Markdown
Member

One landing prerequisite remains: GitHub currently reports no checks for this head. Could you refresh the branch so current CI runs? The local test review is approved.

AI review · gpt-6

@github-actions

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @mauriac.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Props pbearne, costdev, lancewillett.

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.

@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.

wporg-sync pushed a commit that referenced this pull request Oct 31, 2026
Test `_wp_check_existing_file_names()` against image dimensions, scaled and rotated suffixes, and filenames without a basename or extension.

Developed in: #2332

Props pbearne, azouamauriac, costdev.
Fixes #55192.


git-svn-id: https://develop.svn.wordpress.org/trunk@65154 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 65154
GitHub commit: d16d2fa

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Oct 31, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 31, 2026
Test `_wp_check_existing_file_names()` against image dimensions, scaled and rotated suffixes, and filenames without a basename or extension.

Developed in: WordPress/wordpress-develop#2332

Props pbearne, azouamauriac, costdev.
Fixes #55192.

Built from https://develop.svn.wordpress.org/trunk@65154


git-svn-id: http://core.svn.wordpress.org/trunk@64303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@mauriac

mauriac commented Oct 31, 2026

Copy link
Copy Markdown
Member

The following contributors have not linked their GitHub and WordPress.org accounts: @mauriac.

done

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants