Skip to content

Null-safety: Title and getContent() in FileUploadCheck and SearchCheck#3

Open
tosfos wants to merge 1 commit intomasterfrom
fix-null-safety-fileupload-search
Open

Null-safety: Title and getContent() in FileUploadCheck and SearchCheck#3
tosfos wants to merge 1 commit intomasterfrom
fix-null-safety-fileupload-search

Conversation

@tosfos
Copy link

@tosfos tosfos commented Feb 14, 2026

Summary

PHP 8 null-safety in two checks:

  1. FileUploadCheck: TitleFactory::newFromText() can return null; code passed the result to newFile( $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).

  2. 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 calling getWikitextForTransclusion().

Changes

  • src/Checks/FileUploadCheck.php: Null-check $title and $title2 after newFromText(); only call newFile() and use the pair when non-null.
  • src/Checks/SearchCheck.php: Null-check newMainPage() (return 'MediaWiki'); null-check getContent() (use '' for content before getWikitextForTransclusion).

Testing

  • php -l on 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.

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

1 participant