Skip to content

Conversation

@dkoo
Copy link
Contributor

@dkoo dkoo commented Nov 12, 2025

All Submissions:

Changes proposed in this Pull Request:

Fixes a fatal error due to referencing a method that moved from the Newspack\Memberships class to Newspack\Content_Gate. Also ensures that GA4 custom events receive the gate_post_id and newspack_popup_id params throughout auth and modal checkout flows by normalizing the param name from memberships_content_gate to gate_post_id (Automattic/newspack-blocks#2121 attempted to do this with Automattic/newspack-blocks@0c5301b#diff-f371eb641807afd155089ce67e2add277c8d7a9dfe029518e977527c7ca015c3R144-R148 but some flows still expected the memberships_content_gate param).

How to test the changes in this Pull Request:

  1. On release for this repo and Newspack Blocks, complete registration, login, and modal checkout flows from a content gate and a Campaigns prompt. Observe that:
  • Some GA4 events drop the gate_post_id and newspack_popup params
  • Upon completing a modal checkout from within a content gate, an error occurs while processing the transaction:
2025-11-11T14:54:12+00:00 Error scheduled action 4317730 (subscription payment) failed to finish processing due to the following exception: Call to undefined method Newspack\Memberships::get_gate_metadata() in /wordpress/plugins/newspack-plugin/6.24.1/includes/data-events/class-memberships.php:211
PHP Fatal error:  Uncaught Error: Class "Newspack\Memberships\Metering" not found in /newspack-repos/newspack-plugin/src/blocks/content-gate/countdown-box/class-content-gate-countdown-box-block.php:48
Stack trace:
#0 /var/www/html/wp-includes/class-wp-block.php(586): Newspack\Content_Gate_Countdown_Box_Block::render_block()
#1 /var/www/html/wp-includes/blocks.php(2359): WP_Block->render()
#2 /var/www/html/wp-includes/blocks.php(2431): render_block()
#3 /var/www/html/wp-includes/class-wp-hook.php(324): do_blocks()
#4 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#5 /var/www/html/wp-includes/post-template.php(256): apply_filters()
#6 /newspack-repos/newspack-theme/newspack-theme/template-parts/content/content-single.php(45): the_content()
#7 /var/www/html/wp-includes/template.php(812): require('...')
#8 /var/www/html/wp-includes/template.php(745): load_template()
#9 /var/www/html/wp-includes/general-template.php(206): locate_template()
#10 /newspack-repos/newspack-theme/newspack-theme/single.php(44): get_template_part()
#11 /var/www/html/wp-includes/template-loader.php(106): include('...')
#12 /var/www/html/wp-blog-header.php(19): require_once('...')
#13 /var/www/html/index.php(17): require('...')
#14 {main}
  thrown in /newspack-repos/newspack-plugin/src/blocks/content-gate/countdown-box/class-content-gate-countdown-box-block.php on line 48
  1. Check out this branch and fix: content gate metadata methods and params newspack-blocks#2249.
  2. Follow instructions from fix(ga4): ensure gate_post_id and newspack_popup_id are passed to activities #3956 and confirm that gate_post_id and newspack_popup_id params are appended to all GA4 events from registration, login, and modal checkout flows originating from a content gate and Campaigns prompt, respectively.
  3. Confirm no fatal error from completing the content gate > modal checkout transaction, and no fatal error when rendering the Countdown block

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo self-assigned this Nov 12, 2025
@dkoo dkoo requested a review from a team as a code owner November 12, 2025 23:18
@dkoo dkoo added the [Status] Needs Review The issue or pull request needs to be reviewed label Nov 12, 2025
@dkoo dkoo changed the base branch from trunk to release November 12, 2025 23:19
Copy link
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests well!

I left a couple of non-blocking comments; feel free to merge after addressing them.


namespace Newspack;

use Newspack\Content_Gate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we're already in Newspack namespace, this and the one below are superfluous.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I didn't check this and just followed the existing pattern 😄


use Newspack\Memberships;
use Newspack\Memberships\Metering;
use Newspack\Metering;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the previous comment, these 3 lines are superfluous

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Nov 13, 2025
Copy link
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to confirm the GA properties.. I still didn't see them. But approving because the PHP fatal is more important

@leogermani leogermani merged commit 96615a1 into release Nov 13, 2025
13 checks passed
@leogermani leogermani deleted the hotfix/gate-post-metadata-nppm-2389 branch November 13, 2025 13:26
matticbot pushed a commit that referenced this pull request Nov 13, 2025
## [6.24.2](v6.24.1...v6.24.2) (2025-11-13)

### Bug Fixes

* content gate metadata methods and params ([d6344b2](d6344b2))
* content gate metadata methods and params [#4306](#4306) from Automattic/hotfix/gate-post-metadata-nppm-2389 ([96615a1](96615a1))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.24.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

dkoo pushed a commit that referenced this pull request Nov 13, 2025
## [6.24.2](v6.24.1...v6.24.2) (2025-11-13)

### Bug Fixes

* content gate metadata methods and params ([d6344b2](d6344b2))
* content gate metadata methods and params [#4306](#4306) from Automattic/hotfix/gate-post-metadata-nppm-2389 ([96615a1](96615a1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants