Guard against edge-case crashes in bot.php - #42
Open
somethingwithproof wants to merge 3 commits into
Open
Conversation
somethingwithproof
force-pushed
the
fix-edge-case-crashes
branch
from
February 13, 2026 22:47
7a90a0d to
ec54545
Compare
Author
|
Stripped the CI workflow changes per the feedback on bot#45 — this PR now only contains the bot.php defensive fixes. |
- Reduce CI permissions from write to read-only for lint jobs - Pin GitHub Actions to specific SHAs to prevent supply chain attacks - Add composer audit step for dependency vulnerability scanning Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Init $header before use in splitintosections() — pages starting with a heading would leave it unset, writing null into the page - Return null from namespacetoid() for unknown namespaces instead of hitting an undefined array key - Check $rev is set after the revision-walking foreach, since an empty API response leaves it undefined - Cap the archive-size while loop at 1000 iterations so it can't spin forever if every archive page is over the limit - Skip malformed transformheader entries missing the === delimiter instead of reading past the end of the explode result - Use non-greedy match in strip_comments so multiple HTML comments on one line don't eat the text between them
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
DamianZaremba
force-pushed
the
fix-edge-case-crashes
branch
from
April 10, 2026 15:37
baa3d1a to
92593a5
Compare
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
Ran into a few spots where unexpected input from the API or wiki templates
can crash the bot or silently corrupt page content. All fixes are defensive
checks on existing code — no new features, no behavioral changes to the
normal archiving path.
splitintosections(): initialize$headerso pages that start with asection heading don't write null into the archived page
namespacetoid(): return null for namespaces not in the lookup tableinstead of triggering an undefined array key warning
doarchive(): guard$revaccess after the revision-walking foreach,since an empty API response skips the loop body and leaves it unset
doarchive(): cap the archive-size search loop at 1000 iterations —previously it could spin forever if every archive page exceeded the limit
doarchive(): skip malformedtransformheaderentries that are missingthe
===delimiter instead of reading an undefined offsetTest plan
vendor/bin/phpuniton the full suite (pending — depends on Fix bugs in bot.php and add PHPUnit test suite #41 for test harness)