Changeset 3225736
- Timestamp:
- 01/20/2025 05:12:44 PM (15 months ago)
- Location:
- on-demand-revalidation
- Files:
-
- 10 edited
- 1 copied
-
tags/1.2.5 (copied) (copied from on-demand-revalidation/trunk)
-
tags/1.2.5/on-demand-revalidation.php (modified) (1 diff)
-
tags/1.2.5/readme.txt (modified) (3 diffs)
-
tags/1.2.5/src/Revalidation.php (modified) (4 diffs)
-
tags/1.2.5/vendor/composer/InstalledVersions.php (modified) (3 diffs)
-
tags/1.2.5/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/on-demand-revalidation.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Revalidation.php (modified) (4 diffs)
-
trunk/vendor/composer/InstalledVersions.php (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
on-demand-revalidation/tags/1.2.5/on-demand-revalidation.php
r3073886 r3225736 7 7 * GitHub Plugin URI: https://github.com/dexerto/on-demand-revalidation 8 8 * Description: Next.js On-Demand Revalidation on the post update, revalidate specific paths, tags on the post update. 9 * Version: 1.2. 49 * Version: 1.2.5 10 10 * Author: Dexerto 11 11 * Author URI: https://dexerto.com -
on-demand-revalidation/tags/1.2.5/readme.txt
r3073886 r3225736 3 3 Tags: nextjs, ssg, revalidation, on-demand 4 4 Requires at least: 4.7 5 Tested up to: 6. 5.26 Stable tag: 1.2. 45 Tested up to: 6.7.1 6 Stable tag: 1.2.5 7 7 Requires PHP: 8.0 8 8 License: GPL-3 … … 13 13 Next.js On-Demand Revalidation for Wordpress on the post update, revalidate specific paths and tags on the post update. 14 14 15 Feel free to create a PR to [plugin Github repo](https://github.com/ gdidentity/on-demand-revalidation).15 Feel free to create a PR to [plugin Github repo](https://github.com/Dexerto/on-demand-revalidation). 16 16 17 17 == Installation == … … 20 20 2. Click the “Install Now” button, followed by "Activate". 21 21 3. Add Next.js URL and Revalidate Secret Key in the Settings -> Next.js On-Demand Revalidation 22 4. In your Next.js project add a new file `/pages/api/revalidate.ts` with a code snippet, you'll find [here](https://github.com/gdidentity/on-demand-revalidation).22 4. In your Next.js project add a new file `/pages/api/revalidate.ts` or `/app/api/revalidate/route.ts` with a code snippet, you'll find [here](https://github.com/Dexerto/on-demand-revalidation). 23 23 5. Add `REVALIDATE_SECRET_KEY` env variable to your Next.js with Revalidate Secret Key value you added in the Plugin Settings. 24 24 25 25 26 26 == Changelog == 27 = 1.2.5 = 28 - feat: prevent revalidate functions from running more than once within a single save_post request from @MuhammedAO 29 - fix: tags array populated by paths filter from @cavemon 30 - fix: paths array empty if `revalidate_paths` is not defined from @cavemon 31 - fix: better error handling from @humet 27 32 = 1.2.4 = 28 33 - fix: do not send non-replaced string if term is not there -
on-demand-revalidation/tags/1.2.5/src/Revalidation.php
r3073849 r3225736 78 78 return; 79 79 } 80 81 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { 82 return; 83 } 80 84 81 85 self::revalidate_post( $post ); … … 158 162 $revalidate_paths = preg_split( '/\r\n|\n|\r/', $revalidate_paths ); 159 163 $revalidate_paths = Helpers::rewrite_placeholders( $revalidate_paths, $post ); 160 } else {161 $paths = array();162 164 } 163 165 … … 180 182 181 183 $paths = apply_filters( 'on_demand_revalidation_paths', $paths, $post ); 182 $tags = apply_filters( 'on_demand_revalidation_ paths', $tags, $post );184 $tags = apply_filters( 'on_demand_revalidation_tags', $tags, $post ); 183 185 184 186 $data = array( … … 212 214 $response_data = ( ! is_wp_error( $response ) ) ? $body : $response; 213 215 216 if ( is_wp_error( $response ) ) { 217 return new WP_Error( 'revalidate_error', $response->get_error_message(), array( 'status' => 403 ) ); 218 } 219 220 if ( ! is_array( $response_data ) || ! isset( $response_data['revalidated'] ) ) { 221 return new WP_Error( 222 'revalidate_error', 223 'Invalid response from revalidation endpoint', 224 array( 'status' => 403 ) 225 ); 226 } 227 228 if ( ! $response_data['revalidated'] ) { 229 $error_message = isset( $response_data['message'] ) ? $response_data['message'] : 'Revalidation failed'; 230 return new WP_Error( 'revalidate_error', $error_message, array( 'status' => 403 ) ); 231 } 214 232 215 233 if ( class_exists( 'CPurgeCache' ) ) { 216 234 \CPurgeCache\Purge::purge( $post ); 217 }218 219 220 if ( ! $response_data['revalidated'] ) {221 return new WP_Error( 'revalidate_error', $response['message'], array( 'status' => 403 ) );222 235 } 223 236 -
on-demand-revalidation/tags/1.2.5/vendor/composer/InstalledVersions.php
r2922407 r3225736 323 323 324 324 $installed = array(); 325 $copiedLocalDir = false; 325 326 326 327 if (self::$canGetVendors) { … … 331 332 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 332 333 $required = require $vendorDir.'/composer/installed.php'; 333 $installed[] = self::$installedByVendor[$vendorDir] = $required; 334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 335 self::$installed = $installed[count($installed) - 1]; 334 self::$installedByVendor[$vendorDir] = $required; 335 $installed[] = $required; 336 if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 337 self::$installed = $required; 338 $copiedLocalDir = true; 336 339 } 337 340 } … … 351 354 } 352 355 353 if (self::$installed !== array() ) {356 if (self::$installed !== array() && !$copiedLocalDir) { 354 357 $installed[] = self::$installed; 355 358 } -
on-demand-revalidation/tags/1.2.5/vendor/composer/installed.php
r3073886 r3225736 2 2 'root' => array( 3 3 'name' => 'gdidentity/on-demand-revalidation', 4 'pretty_version' => '1.2. 4',5 'version' => '1.2. 4.0',4 'pretty_version' => '1.2.5', 5 'version' => '1.2.5.0', 6 6 'reference' => null, 7 7 'type' => 'wordpress-plugin', … … 12 12 'versions' => array( 13 13 'gdidentity/on-demand-revalidation' => array( 14 'pretty_version' => '1.2. 4',15 'version' => '1.2. 4.0',14 'pretty_version' => '1.2.5', 15 'version' => '1.2.5.0', 16 16 'reference' => null, 17 17 'type' => 'wordpress-plugin', -
on-demand-revalidation/trunk/on-demand-revalidation.php
r3073886 r3225736 7 7 * GitHub Plugin URI: https://github.com/dexerto/on-demand-revalidation 8 8 * Description: Next.js On-Demand Revalidation on the post update, revalidate specific paths, tags on the post update. 9 * Version: 1.2. 49 * Version: 1.2.5 10 10 * Author: Dexerto 11 11 * Author URI: https://dexerto.com -
on-demand-revalidation/trunk/readme.txt
r3073886 r3225736 3 3 Tags: nextjs, ssg, revalidation, on-demand 4 4 Requires at least: 4.7 5 Tested up to: 6. 5.26 Stable tag: 1.2. 45 Tested up to: 6.7.1 6 Stable tag: 1.2.5 7 7 Requires PHP: 8.0 8 8 License: GPL-3 … … 13 13 Next.js On-Demand Revalidation for Wordpress on the post update, revalidate specific paths and tags on the post update. 14 14 15 Feel free to create a PR to [plugin Github repo](https://github.com/ gdidentity/on-demand-revalidation).15 Feel free to create a PR to [plugin Github repo](https://github.com/Dexerto/on-demand-revalidation). 16 16 17 17 == Installation == … … 20 20 2. Click the “Install Now” button, followed by "Activate". 21 21 3. Add Next.js URL and Revalidate Secret Key in the Settings -> Next.js On-Demand Revalidation 22 4. In your Next.js project add a new file `/pages/api/revalidate.ts` with a code snippet, you'll find [here](https://github.com/gdidentity/on-demand-revalidation).22 4. In your Next.js project add a new file `/pages/api/revalidate.ts` or `/app/api/revalidate/route.ts` with a code snippet, you'll find [here](https://github.com/Dexerto/on-demand-revalidation). 23 23 5. Add `REVALIDATE_SECRET_KEY` env variable to your Next.js with Revalidate Secret Key value you added in the Plugin Settings. 24 24 25 25 26 26 == Changelog == 27 = 1.2.5 = 28 - feat: prevent revalidate functions from running more than once within a single save_post request from @MuhammedAO 29 - fix: tags array populated by paths filter from @cavemon 30 - fix: paths array empty if `revalidate_paths` is not defined from @cavemon 31 - fix: better error handling from @humet 27 32 = 1.2.4 = 28 33 - fix: do not send non-replaced string if term is not there -
on-demand-revalidation/trunk/src/Revalidation.php
r3073849 r3225736 78 78 return; 79 79 } 80 81 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { 82 return; 83 } 80 84 81 85 self::revalidate_post( $post ); … … 158 162 $revalidate_paths = preg_split( '/\r\n|\n|\r/', $revalidate_paths ); 159 163 $revalidate_paths = Helpers::rewrite_placeholders( $revalidate_paths, $post ); 160 } else {161 $paths = array();162 164 } 163 165 … … 180 182 181 183 $paths = apply_filters( 'on_demand_revalidation_paths', $paths, $post ); 182 $tags = apply_filters( 'on_demand_revalidation_ paths', $tags, $post );184 $tags = apply_filters( 'on_demand_revalidation_tags', $tags, $post ); 183 185 184 186 $data = array( … … 212 214 $response_data = ( ! is_wp_error( $response ) ) ? $body : $response; 213 215 216 if ( is_wp_error( $response ) ) { 217 return new WP_Error( 'revalidate_error', $response->get_error_message(), array( 'status' => 403 ) ); 218 } 219 220 if ( ! is_array( $response_data ) || ! isset( $response_data['revalidated'] ) ) { 221 return new WP_Error( 222 'revalidate_error', 223 'Invalid response from revalidation endpoint', 224 array( 'status' => 403 ) 225 ); 226 } 227 228 if ( ! $response_data['revalidated'] ) { 229 $error_message = isset( $response_data['message'] ) ? $response_data['message'] : 'Revalidation failed'; 230 return new WP_Error( 'revalidate_error', $error_message, array( 'status' => 403 ) ); 231 } 214 232 215 233 if ( class_exists( 'CPurgeCache' ) ) { 216 234 \CPurgeCache\Purge::purge( $post ); 217 }218 219 220 if ( ! $response_data['revalidated'] ) {221 return new WP_Error( 'revalidate_error', $response['message'], array( 'status' => 403 ) );222 235 } 223 236 -
on-demand-revalidation/trunk/vendor/composer/InstalledVersions.php
r2922407 r3225736 323 323 324 324 $installed = array(); 325 $copiedLocalDir = false; 325 326 326 327 if (self::$canGetVendors) { … … 331 332 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 332 333 $required = require $vendorDir.'/composer/installed.php'; 333 $installed[] = self::$installedByVendor[$vendorDir] = $required; 334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 335 self::$installed = $installed[count($installed) - 1]; 334 self::$installedByVendor[$vendorDir] = $required; 335 $installed[] = $required; 336 if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 337 self::$installed = $required; 338 $copiedLocalDir = true; 336 339 } 337 340 } … … 351 354 } 352 355 353 if (self::$installed !== array() ) {356 if (self::$installed !== array() && !$copiedLocalDir) { 354 357 $installed[] = self::$installed; 355 358 } -
on-demand-revalidation/trunk/vendor/composer/installed.php
r3073886 r3225736 2 2 'root' => array( 3 3 'name' => 'gdidentity/on-demand-revalidation', 4 'pretty_version' => '1.2. 4',5 'version' => '1.2. 4.0',4 'pretty_version' => '1.2.5', 5 'version' => '1.2.5.0', 6 6 'reference' => null, 7 7 'type' => 'wordpress-plugin', … … 12 12 'versions' => array( 13 13 'gdidentity/on-demand-revalidation' => array( 14 'pretty_version' => '1.2. 4',15 'version' => '1.2. 4.0',14 'pretty_version' => '1.2.5', 15 'version' => '1.2.5.0', 16 16 'reference' => null, 17 17 'type' => 'wordpress-plugin',
Note: See TracChangeset
for help on using the changeset viewer.