You've already forked wp-fedistream
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6988e49287 | |||
| 166a5e6f7c |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.4.4] - 2026-02-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Fix excerpt-triggered recursion** - `get_the_excerpt()` internally calls `the_content` filter when generating auto-excerpts
|
||||||
|
- When in shortcode context, now uses raw `$post->post_excerpt` or generates simple excerpt with `wp_trim_words()` instead
|
||||||
|
- This was the remaining recursion path causing memory exhaustion in `class-wp-hook.php`
|
||||||
|
|
||||||
|
## [0.4.3] - 2026-02-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Further memory leak fix** - v0.4.2 fix was still incomplete
|
||||||
|
- Changed `$in_shortcode_context` boolean to `$shortcode_context_depth` counter to properly handle nested shortcodes
|
||||||
|
- Added shortcode context protection to `template-wrapper.php` for single page views
|
||||||
|
- This fixes the remaining recursion path where `the_content` filter was still being applied when viewing single FediStream posts (artists, albums, tracks, playlists)
|
||||||
|
|
||||||
## [0.4.2] - 2026-02-02
|
## [0.4.2] - 2026-02-02
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -217,7 +234,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.2...HEAD
|
[Unreleased]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.4...HEAD
|
||||||
|
[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.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
|
||||||
[0.4.1]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.0...v0.4.1
|
[0.4.1]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.0...v0.4.1
|
||||||
[0.4.0]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.3.0...v0.4.0
|
[0.4.0]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.3.0...v0.4.0
|
||||||
|
|||||||
@@ -36,12 +36,13 @@ class TemplateLoader {
|
|||||||
private const MAX_RECURSION_DEPTH = 3;
|
private const MAX_RECURSION_DEPTH = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether we're currently in a shortcode rendering context.
|
* Shortcode rendering context depth counter.
|
||||||
* When true, the_content filter is skipped to prevent recursive shortcode processing.
|
* When > 0, the_content filter is skipped to prevent recursive shortcode processing.
|
||||||
|
* Using a counter instead of boolean to handle nested shortcodes properly.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var int
|
||||||
*/
|
*/
|
||||||
private static bool $in_shortcode_context = false;
|
private static int $shortcode_context_depth = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter shortcode rendering context.
|
* Enter shortcode rendering context.
|
||||||
@@ -50,7 +51,7 @@ class TemplateLoader {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function enter_shortcode_context(): void {
|
public static function enter_shortcode_context(): void {
|
||||||
self::$in_shortcode_context = true;
|
++self::$shortcode_context_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +61,9 @@ class TemplateLoader {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function exit_shortcode_context(): void {
|
public static function exit_shortcode_context(): void {
|
||||||
self::$in_shortcode_context = false;
|
if ( self::$shortcode_context_depth > 0 ) {
|
||||||
|
--self::$shortcode_context_depth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +72,7 @@ class TemplateLoader {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function is_in_shortcode_context(): bool {
|
public static function is_in_shortcode_context(): bool {
|
||||||
return self::$in_shortcode_context;
|
return self::$shortcode_context_depth > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,13 +256,25 @@ class TemplateLoader {
|
|||||||
// Skip the_content filter if:
|
// Skip the_content filter if:
|
||||||
// 1. We're in a shortcode context (prevents recursive shortcode processing)
|
// 1. We're in a shortcode context (prevents recursive shortcode processing)
|
||||||
// 2. We're at depth > 1 (nested data loading)
|
// 2. We're at depth > 1 (nested data loading)
|
||||||
$skip_content_filter = self::$in_shortcode_context || self::$recursion_depth > 1;
|
$skip_content_filter = self::$shortcode_context_depth > 0 || self::$recursion_depth > 1;
|
||||||
|
|
||||||
|
// When skipping content filter, also use raw excerpt to avoid get_the_excerpt()
|
||||||
|
// triggering the_content filter internally when generating auto-excerpts.
|
||||||
|
if ( $skip_content_filter ) {
|
||||||
|
$excerpt = $post->post_excerpt;
|
||||||
|
if ( empty( $excerpt ) ) {
|
||||||
|
// Generate a simple excerpt without triggering the_content filter.
|
||||||
|
$excerpt = wp_trim_words( wp_strip_all_tags( $post->post_content ), 55, '…' );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$excerpt = get_the_excerpt( $post );
|
||||||
|
}
|
||||||
|
|
||||||
$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' => $skip_content_filter ? wp_kses_post( $post->post_content ) : apply_filters( 'the_content', $post->post_content ),
|
||||||
'excerpt' => get_the_excerpt( $post ),
|
'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' ),
|
||||||
'date' => get_the_date( '', $post ),
|
'date' => get_the_date( '', $post ),
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ 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.
|
||||||
|
TemplateLoader::enter_shortcode_context();
|
||||||
|
|
||||||
// Get template context.
|
// Get template context.
|
||||||
$context = TemplateLoader::get_context();
|
$context = TemplateLoader::get_context();
|
||||||
|
|
||||||
@@ -75,4 +78,7 @@ get_header();
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
// Exit shortcode context.
|
||||||
|
TemplateLoader::exit_shortcode_context();
|
||||||
|
|
||||||
get_footer();
|
get_footer();
|
||||||
|
|||||||
@@ -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.2
|
* Version: 0.4.4
|
||||||
* 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.2' );
|
define( 'WP_FEDISTREAM_VERSION', '0.4.4' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin file path.
|
* Plugin file path.
|
||||||
|
|||||||
Reference in New Issue
Block a user