Repository navigation
Readme: Add header properties that the readme does not have yet - #919
Open
manishsongirkar wants to merge 1 commit into
Open
manishsongirkar wants to merge 1 commit into
manishsongirkar wants to merge 1 commit into
Conversation
CBT_Theme_Readme::add_or_update_prop() read the first match of the property in the readme without checking that there was one. When the readme had no "Requires at least" or "Tested up to" line, PHP logged "Undefined array key 0" and the property was never written, while the save still reported success. readme.txt then disagreed with style.css. When the property is not in the readme, add it at the end of the header, before the first section. A property that is there is updated in place, as before. Add tests for missing properties, for a readme with no header properties, and for properties that must not be duplicated. Fixes WordPress#918 Related to WordPress#916 and WordPress#917
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
CBT_Theme_Readme::add_or_update_prop()reads the first match of a property in the readme without checking that there is one:When the readme has no
Requires at leastorTested up toline, PHP logsUndefined array key 0and the property is never written. The save still reportsTheme Updated., andreadme.txtends up out of step withstyle.css.add_or_update_section()in the same class adds a missing section, but the property function did not add a missing property.Now, when the property is not in the readme, it is added at the end of the header, before the first
== Section ==line. A property that is already there is updated in place, as before.Fixes #918
Related to #916 and #917, the line-ending bug in the same file. The two changes are independent and touch different functions.
Changes
includes/create-theme/theme-readme.php:add_or_update_prop()adds the property to the header whenpreg_match()finds no match. The header is the text before the first line that starts with==. If the readme has no header text, the property starts the file.tests/CbtThemeReadme/missingProps.php(new): three tests through the publicupdate()method:Test plan
Undefined array key 0and pass with this change:npm run test:unit:php:base -- --filter CBT_ThemeReadme_MissingProps.--group readmepasses (16 tests).vendor/bin/phpcs --standard=phpcs.xml.diston the changed files is clean.Requires at least:andTested up to:lines from the theme'sreadme.txt.SUCCESS,readme.txtstill has neither line, and PHP logs twoUndefined array key 0warnings.readme.txtgetsRequires at least: 7.2andTested up to: 7.3-alpha-65850at the end of the header, and PHP logs no warnings.Out of scope
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code (Claude Sonnet 5.5)
Used for: Investigating the issue, implementing the fix, writing the tests, and drafting this description. I reproduced the bug in the editor, ran the tests, and reviewed and tested the change myself.