Fix attachment-page & direct-access fatal errors in osi theme#221
Merged
Conversation
- osi_posted_on(): remove argument-less sprintf() that treated the permalink HTML as a format string. On attachment pages the URL can contain a literal % (e.g. %43), which sprintf read as positional placeholder %43$ and threw ArgumentCountError, white-screening the page. Replaced with plain concatenation (there were no placeholders). - index.php: add defined( 'ABSPATH' ) || exit; guard so direct HTTP requests to the theme file no longer fatal on undefined get_header(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Problem
Two PHP fatal errors reported in the
ositheme:ArgumentCountError: 43 arguments are required, 1 givenininc/template-tags.php:36(osi_posted_on()), triggered when rendering attachment pages (single.php → get_template_part('template-parts/content','attachment') → osi_posted_on()). This is visitor-facing and white-screens the page.Call to undefined function get_header()inindex.php:15, triggered by direct HTTP requests to the theme file (bots/scanners hitting/wp-content/themes/osi/index.php), where WordPress is never bootstrapped. Log noise, not visitor-facing.Root cause
#1 —
osi_posted_on()calledsprintf()with only a format string and no arguments:The "format string" contains the permalink. On attachment pages the URL can contain a literal
%(e.g.%43), whichsprintfinterprets as positional placeholder%43$…→ArgumentCountError. There were never any placeholders to substitute.Fix
sprintf()with plain string concatenation.defined( 'ABSPATH' ) || exit;guard toindex.phpso direct file requests exit cleanly instead of fataling.Both files pass
php -l.🤖 Generated with Claude Code