You've already forked wp-fedistream
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a41eddbc49 | |||
| eb85870909 |
24
CHANGELOG.md
24
CHANGELOG.md
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.4.6] - 2026-02-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Page template loading lock** - Block ALL shortcode rendering during page template loading
|
||||||
|
- Added `$loading_page_template` flag in TemplateLoader
|
||||||
|
- template-wrapper.php now sets this flag before loading theme header/footer
|
||||||
|
- Shortcodes::render_template() checks this flag and returns early if set
|
||||||
|
- This prevents any recursion triggered by theme components, widgets, or other plugins during page template loading
|
||||||
|
- Main template rendering still works (uses Plugin::render() directly, not through Shortcodes)
|
||||||
|
|
||||||
|
## [0.4.5] - 2026-02-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Multi-layer recursion protection** - Added additional safeguards against infinite Twig rendering
|
||||||
|
- Added render depth tracking in `Plugin::render()` with max depth of 5
|
||||||
|
- Strip shortcodes from content when in shortcode context (prevents any later `do_shortcode()` calls from triggering recursion)
|
||||||
|
- This addresses the Twig StagingExtension.php recursion error
|
||||||
|
|
||||||
## [0.4.4] - 2026-02-02
|
## [0.4.4] - 2026-02-02
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -234,7 +254,9 @@ Initial release of WP FediStream - a WordPress plugin for streaming music over A
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[Unreleased]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.4...HEAD
|
[Unreleased]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.6...HEAD
|
||||||
|
[0.4.6]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.5...v0.4.6
|
||||||
|
[0.4.5]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.4...v0.4.5
|
||||||
[0.4.4]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.3...v0.4.4
|
[0.4.4]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.3...v0.4.4
|
||||||
[0.4.3]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.2...v0.4.3
|
[0.4.3]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.2...v0.4.3
|
||||||
[0.4.2]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.1...v0.4.2
|
[0.4.2]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.1...v0.4.2
|
||||||
|
|||||||
@@ -552,6 +552,12 @@ class Shortcodes {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function render_template( string $template, array $context ): string {
|
private function render_template( string $template, array $context ): string {
|
||||||
|
// Block shortcode rendering while loading page template to prevent recursion.
|
||||||
|
// This catches any shortcodes triggered by theme header/footer, widgets, etc.
|
||||||
|
if ( TemplateLoader::is_loading_page_template() ) {
|
||||||
|
return '<!-- FediStream: shortcode blocked during page template loading -->';
|
||||||
|
}
|
||||||
|
|
||||||
// Check for unlicensed mode.
|
// Check for unlicensed mode.
|
||||||
if ( $this->unlicensed_mode ) {
|
if ( $this->unlicensed_mode ) {
|
||||||
return $this->get_unlicensed_message();
|
return $this->get_unlicensed_message();
|
||||||
|
|||||||
@@ -44,6 +44,42 @@ class TemplateLoader {
|
|||||||
*/
|
*/
|
||||||
private static int $shortcode_context_depth = 0;
|
private static int $shortcode_context_depth = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag indicating we're currently loading a FediStream page template.
|
||||||
|
* This completely blocks any nested FediStream shortcode rendering.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static bool $loading_page_template = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter page template loading mode.
|
||||||
|
* This blocks ALL shortcode rendering during page template loading.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function enter_page_template_loading(): void {
|
||||||
|
self::$loading_page_template = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exit page template loading mode.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function exit_page_template_loading(): void {
|
||||||
|
self::$loading_page_template = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we're loading a page template.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function is_loading_page_template(): bool {
|
||||||
|
return self::$loading_page_template;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter shortcode rendering context.
|
* Enter shortcode rendering context.
|
||||||
* Call this before rendering shortcode content to prevent recursive shortcode processing.
|
* Call this before rendering shortcode content to prevent recursive shortcode processing.
|
||||||
@@ -270,10 +306,19 @@ class TemplateLoader {
|
|||||||
$excerpt = get_the_excerpt( $post );
|
$excerpt = get_the_excerpt( $post );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When skipping content filter, also strip shortcodes to prevent them from
|
||||||
|
// being processed by anything else that might call do_shortcode on the output.
|
||||||
|
if ( $skip_content_filter ) {
|
||||||
|
$content = strip_shortcodes( $post->post_content );
|
||||||
|
$content = wp_kses_post( $content );
|
||||||
|
} else {
|
||||||
|
$content = apply_filters( 'the_content', $post->post_content );
|
||||||
|
}
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'id' => $post->ID,
|
'id' => $post->ID,
|
||||||
'title' => get_the_title( $post ),
|
'title' => get_the_title( $post ),
|
||||||
'content' => $skip_content_filter ? wp_kses_post( $post->post_content ) : apply_filters( 'the_content', $post->post_content ),
|
'content' => $content,
|
||||||
'excerpt' => $excerpt,
|
'excerpt' => $excerpt,
|
||||||
'permalink' => get_permalink( $post ),
|
'permalink' => get_permalink( $post ),
|
||||||
'thumbnail' => get_the_post_thumbnail_url( $post->ID, 'large' ),
|
'thumbnail' => get_the_post_thumbnail_url( $post->ID, 'large' ),
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
use WP_FediStream\Plugin;
|
use WP_FediStream\Plugin;
|
||||||
use WP_FediStream\Frontend\TemplateLoader;
|
use WP_FediStream\Frontend\TemplateLoader;
|
||||||
|
|
||||||
// Enter shortcode context to prevent recursive shortcode processing in post content.
|
// Enter page template loading mode - this completely blocks nested FediStream rendering.
|
||||||
|
TemplateLoader::enter_page_template_loading();
|
||||||
|
|
||||||
|
// Also enter shortcode context to prevent recursive shortcode processing in post content.
|
||||||
TemplateLoader::enter_shortcode_context();
|
TemplateLoader::enter_shortcode_context();
|
||||||
|
|
||||||
// Get template context.
|
// Get template context.
|
||||||
@@ -78,7 +81,8 @@ get_header();
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Exit shortcode context.
|
// Exit shortcode context and page template loading mode.
|
||||||
TemplateLoader::exit_shortcode_context();
|
TemplateLoader::exit_shortcode_context();
|
||||||
|
TemplateLoader::exit_page_template_loading();
|
||||||
|
|
||||||
get_footer();
|
get_footer();
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ final class Plugin {
|
|||||||
*/
|
*/
|
||||||
private ?\Twig\Environment $twig = null;
|
private ?\Twig\Environment $twig = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current Twig render depth to prevent infinite recursion.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private static int $render_depth = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum allowed Twig render depth.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private const MAX_RENDER_DEPTH = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post type instances.
|
* Post type instances.
|
||||||
*
|
*
|
||||||
@@ -843,7 +857,20 @@ final class Plugin {
|
|||||||
* @return string Rendered template.
|
* @return string Rendered template.
|
||||||
*/
|
*/
|
||||||
public function render( string $template, array $context = array() ): string {
|
public function render( string $template, array $context = array() ): string {
|
||||||
return $this->twig->render( $template . '.twig', $context );
|
// Prevent infinite recursion in Twig rendering.
|
||||||
|
if ( self::$render_depth >= self::MAX_RENDER_DEPTH ) {
|
||||||
|
return '<!-- FediStream: render depth exceeded -->';
|
||||||
|
}
|
||||||
|
|
||||||
|
++self::$render_depth;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = $this->twig->render( $template . '.twig', $context );
|
||||||
|
} finally {
|
||||||
|
--self::$render_depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: WP FediStream
|
* Plugin Name: WP FediStream
|
||||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-fedistream
|
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-fedistream
|
||||||
* Description: Stream music over ActivityPub - Build your own music streaming platform for Musicians and Labels.
|
* Description: Stream music over ActivityPub - Build your own music streaming platform for Musicians and Labels.
|
||||||
* Version: 0.4.4
|
* Version: 0.4.6
|
||||||
* Requires at least: 6.4
|
* Requires at least: 6.4
|
||||||
* Requires PHP: 8.3
|
* Requires PHP: 8.3
|
||||||
* Author: Marco Graetsch
|
* Author: Marco Graetsch
|
||||||
@@ -26,7 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
define( 'WP_FEDISTREAM_VERSION', '0.4.4' );
|
define( 'WP_FEDISTREAM_VERSION', '0.4.6' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin file path.
|
* Plugin file path.
|
||||||
|
|||||||
Reference in New Issue
Block a user