Skip to content

fix: handle null code in frontier_decode_template for PHP 8.1+ - #7579

Open
faisalahammad wants to merge 2 commits into
pods-framework:release/3.4.0from
faisalahammad:fix/7249-null-base64-template
Open

fix: handle null code in frontier_decode_template for PHP 8.1+#7579
faisalahammad wants to merge 2 commits into
pods-framework:release/3.4.0from
faisalahammad:fix/7249-null-base64-template

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description

The frontier_decode_template() function receives $code from WordPress shortcode API callbacks, which can pass null when no closing tag is present. base64_decode(null) returns false on PHP 8+, which then gets passed to str_replace() as the $subject parameter, triggering:

Deprecated: str_replace(): Passing null to parameter #3 is deprecated

Cast both the input and the return value to string so that null/false produces an empty string instead, which downstream str_replace() handles safely as a no-op.

Related GitHub issue(s)

Fixes #7249

Testing instructions

  1. Create a Pods Custom Post Type with a text field
  2. Create a Pods Template with [pods field="my_field"] shortcode
  3. Set the template as the single item template for the Pod
  4. Create a post with field values and view the frontend with WP_DEBUG=true
  5. Verify no deprecation warnings appear and field values display correctly

Screenshots / screencast

N/A

Changelog text for these changes

Bug: Fixed PHP 8.1+ deprecation warnings when using Pods shortcodes inside Pods Templates. #7249 (@faisalahammad)

PR checklist

The frontier_decode_template() function receives  from WordPress
shortcode API callbacks, which can pass null when no closing tag is present.
base64_decode(null) returns false on PHP 8+, which then gets passed to
str_replace() as the  parameter, triggering:

  Deprecated: str_replace(): Passing null to parameter pods-framework#3 is deprecated

Cast both the input and the return value to string so that null/false
produces an empty string instead, which downstream str_replace() handles
safely as a no-op.

Fixes pods-framework#7249
@what-the-diff

what-the-diff Bot commented Jul 26, 2026

Copy link
Copy Markdown

PR Summary

  • Improved Template Code Decoding
    The code related to template decoding has been updated. Now, before and after the process where encoded information is turned back into its original form (base64 decoding), this code is deliberately treated as a string. This enhancement ensures efficient and correct processing of data.

@faisalahammad
faisalahammad changed the base branch from main to release/3.4.0 August 18, 2026 11:28
@faisalahammad

Copy link
Copy Markdown
Contributor Author

AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me.

@faisalahammad

Copy link
Copy Markdown
Contributor Author

Review: the change is fine, but it isn't what #7249 reported

Issue #7249 names functions-view_template.php line 723 (preg_match_all() param 2) and line 828 (str_replace() param 3) on Pods 3.0.10. I checked tag 3.0.10 — both of those lines are inside frontier_prefilter_template(), not frontier_decode_template().

That function already has the fix on release/3.4.0:

function frontier_prefilter_template( $code, $template, $pod ) {
	$code = (string) $code;

(line 698, added by commit 37672cd7d, "Fix php warnings with methods that expect string when template code is null"). So #7249 is already resolved on the base branch.

The change itself

frontier_decode_template() is reachable — it's called from frontier_if_block, frontier_template_blocks, frontier_template_once_blocks and frontier_do_subtemplate, all shortcode callbacks that can receive null content. So this is harmless defensive hardening, just not the reported bug.

One small correction: the PR body says base64_decode( null ) returns false. It returns '', so the outer (string) cast is redundant.

Suggestion

Keep the one-liner if you want the hardening, but drop Fixes #7249 and the changelog entry — otherwise the issue closes against a change that didn't fix it. #7249 should be closed against 37672cd7d instead.

Disclosure: this review was produced with AI assistance and verified against the branch code before posting.

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.

Deprecated preg_match_all() in functions-view_template

1 participant