PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
← All changes | src/Campaigns/Actions/AllowGiveRolesToEditCampaignPages.php +15 -2 4.15.3 → 4.17.0 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace Give\Campaigns\Actions;
4 4
5 5 use Give\Campaigns\ValueObjects\CampaignPageMetaKeys;
6 +use Give\Framework\Database\DB;
6 7 use WP_User;
7 8
8 9 /**
9 10 * Allow users with Give roles to edit and publish campaign landing pages.
@@ -112,8 +113,9 @@
112 113
113 114 /**
114 115 * Check if a post is a campaign page (with caching).
115 116 *
117 + * @since 4.16.7 Read the campaign ID meta directly instead of through get_post_meta().
116 118 * @since 4.14.0
117 119 */
118 120 private function isCampaignPage(int $postId): bool
119 121 {
@@ -123,13 +125,24 @@
123 125
124 126 $post = get_post($postId);
125 127 if (!$post || $post->post_type !== 'page') {
126 128 self::$campaignPageCache[$postId] = false;
129 +
127 130 return false;
128 131 }
129 132
130 - $campaignId = get_post_meta($postId, CampaignPageMetaKeys::CAMPAIGN_ID, true);
131 - self::$campaignPageCache[$postId] = !empty($campaignId);
133 + /*
134 + * get_post_meta() fires the get_post_metadata filter, which third parties hook to run
135 + * capability checks. Those re-enter this action through map_meta_cap and recurse until
136 + * the call stack is exhausted, so read the meta without going through the filter.
137 + */
138 + $campaignPageMeta = DB::table('postmeta')
139 + ->select('meta_value')
140 + ->where('post_id', $postId)
141 + ->where('meta_key', CampaignPageMetaKeys::CAMPAIGN_ID)
142 + ->get();
143 +
144 + self::$campaignPageCache[$postId] = !empty($campaignPageMeta->meta_value);
132 145
133 146 return self::$campaignPageCache[$postId];
134 147 }
135 148