Null-safety: Title and getContent() in FileUploadCheck and SearchCheck#3
Open
Null-safety: Title and getContent() in FileUploadCheck and SearchCheck#3
Conversation
- FileUploadCheck: guard newFromText() result before newFile(); skip attempt if title is null and try second UUID - SearchCheck: guard newMainPage() and getContent(); fallback 'MediaWiki' for main page, empty string for content before getWikitextForTransclusion() Co-authored-by: Cursor <cursoragent@cursor.com>
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
PHP 8 null-safety in two checks:
FileUploadCheck:
TitleFactory::newFromText()can return null; code passed the result tonewFile( $title )and used it without a check. We now only create the file and return when the title is non-null; if both UUID attempts yield null titles we return null (existing collision handling).SearchCheck:
TitleFactory::newMainPage()can return null;WikiPage::getContent()can return null. We now guard both: fallback to'MediaWiki'when there is no main page title, and use empty string when content is null before callinggetWikitextForTransclusion().Changes
$titleand$title2afternewFromText(); only callnewFile()and use the pair when non-null.newMainPage()(return'MediaWiki'); null-checkgetContent()(use''for content before getWikitextForTransclusion).Testing
php -lon both files passes.Jira: create SLOP task(s) and add comment (summary, PR link, scores, humorous paragraph, "Work was performed by AI / Cursor Agent").
Work performed by AI / Cursor Agent.