Hotfix 1.2.12 — fatal error in the Portfolio widget blanks the front page - #42
Merged
Conversation
…tered The front page of a site using the Portfolio section renders only down to the first project and then stops: no footer, no scripts, half the page missing. wp_get_post_terms() returns a WP_Error when 'jetpack-portfolio-type' is not a registered taxonomy, which is the case whenever Jetpack -- or whatever else supplies the portfolio post type -- is deactivated while portfolio posts remain in the database. ! empty() is true for an object, so the guard passed and implode() received the WP_Error: PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, WP_Error given in inc/widgets/class-shapely-home-portfolio.php:122 Output stops at exactly that point, which is why the page appears to lose its slider, icons and images: none of the footer assets are ever emitted. This became reachable in 1.2.11. The widget registration fix in that release means the Portfolio widget now registers on setups where the previous, broken Jetpack::is_module_active() check had silently suppressed it -- and that suppression had been masking this fault. Confirmed by reverting only the gate: with the old gate the page returns 200, with the new gate it returns 500. Two changes: - The terms result is checked with is_wp_error() before use. - The Portfolio and Testimonials widgets return early when their post type is not registered. WP_Query does not validate post_type, so it was happily returning rows straight out of the database and rendering items whose taxonomy, permalinks and archive links were all broken. Verified against both states on WordPress 7.0.3 / PHP 8.5: with the post type absent the page completes with the section correctly omitted, and with it present the section renders as before. No fatals in either. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
phpcodesniffer-composer-installer is a Composer plugin, and current Composer refuses to execute plugins that are not explicitly allow-listed. The require therefore aborted with "contains a Composer plugin which is blocked by your allow-plugins config" before PHPCS was ever installed, so the job failed on infrastructure rather than on anything in the code. Co-Authored-By: Claude Opus 5 (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.
Regression from 1.2.11. The live demo is currently affected: https://colorlibhub.com/shapely/ renders only down to the first project, then stops — no footer, no scripts, so the slider, icons and images below that point never appear.
Cause
wp_get_post_terms()returns aWP_Errorwhenjetpack-portfolio-typeis not a registered taxonomy — which is the case whenever Jetpack (or whatever supplied the portfolio post type) is deactivated while portfolio posts remain in the database.! empty()is true for an object, so the existing guard passed andimplode()got theWP_Error:Output stops at exactly that line. Everything below — including
wp_footer()and every enqueued script — is never emitted.Why now
This fault is older than 1.2.11, but was unreachable. The widget registration fix in 1.2.11 means the Portfolio widget now registers on setups where the previous, broken
Jetpack::is_module_active()check had silently suppressed it — and that suppression was masking this.Confirmed by reverting only the gate on a reproduction of the demo's state:
I introduced the exposure. The underlying bug was pre-existing.
Fix
is_wp_error()check on the terms result before use.WP_Querydoes not validatepost_type, so it was returning rows straight from the database and rendering items with broken taxonomy, permalinks and archive links.Verified
Reproduced the demo's exact state locally (portfolio posts present,
jetpack_portfoliooption set, taxonomy unregistered) on WordPress 7.0.3 / PHP 8.5:Front-end sweep after the fix: all pages complete,
jQuery.fn.flexslider/owlCarousel/parallaxandShapelyAdminObjectall present, 0 PHP notices, 0 JS errors.Also worth fixing separately: the theme has the same unguarded pattern in
inc/class-shapely-related-posts.php— not fatal there, but it pushed aWP_Errorinto atax_query.🤖 Generated with Claude Code