Plugin Directory

Changeset 3225736


Ignore:
Timestamp:
01/20/2025 05:12:44 PM (15 months ago)
Author:
dexerto
Message:

Update to version 1.2.5 from GitHub

Location:
on-demand-revalidation
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • on-demand-revalidation/tags/1.2.5/on-demand-revalidation.php

    r3073886 r3225736  
    77 * GitHub Plugin URI:   https://github.com/dexerto/on-demand-revalidation
    88 * Description:         Next.js On-Demand Revalidation on the post update, revalidate specific paths, tags on the post update.
    9  * Version:             1.2.4
     9 * Version:             1.2.5
    1010 * Author:              Dexerto
    1111 * Author URI:          https://dexerto.com
  • on-demand-revalidation/tags/1.2.5/readme.txt

    r3073886 r3225736  
    33Tags: nextjs, ssg, revalidation, on-demand
    44Requires at least: 4.7
    5 Tested up to: 6.5.2
    6 Stable tag: 1.2.4
     5Tested up to: 6.7.1
     6Stable tag: 1.2.5
    77Requires PHP: 8.0
    88License: GPL-3
     
    1313Next.js On-Demand Revalidation for Wordpress on the post update, revalidate specific paths and tags on the post update.
    1414
    15 Feel free to create a PR to [plugin Github repo](https://github.com/gdidentity/on-demand-revalidation).
     15Feel free to create a PR to [plugin Github repo](https://github.com/Dexerto/on-demand-revalidation).
    1616
    1717== Installation ==
     
    20202. Click the “Install Now” button, followed by "Activate".
    21213. 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).
     224. 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).
    23235. Add `REVALIDATE_SECRET_KEY` env variable to your Next.js with Revalidate Secret Key value you added in the Plugin Settings.
    2424
    2525
    2626== 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
    2732= 1.2.4 =
    2833- fix: do not send non-replaced string if term is not there
  • on-demand-revalidation/tags/1.2.5/src/Revalidation.php

    r3073849 r3225736  
    7878            return;
    7979        }
     80
     81        if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
     82            return;
     83        }
    8084       
    8185        self::revalidate_post( $post );
     
    158162            $revalidate_paths = preg_split( '/\r\n|\n|\r/', $revalidate_paths );
    159163            $revalidate_paths = Helpers::rewrite_placeholders( $revalidate_paths, $post );
    160         } else {
    161             $paths = array();
    162164        }
    163165
     
    180182
    181183        $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 );
    183185
    184186        $data = array(
     
    212214        $response_data = ( ! is_wp_error( $response ) ) ? $body : $response;
    213215
     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        }
    214232
    215233        if ( class_exists( 'CPurgeCache' ) ) {
    216234            \CPurgeCache\Purge::purge( $post );
    217         }
    218 
    219 
    220         if ( ! $response_data['revalidated'] ) {
    221             return new WP_Error( 'revalidate_error', $response['message'], array( 'status' => 403 ) );
    222235        }
    223236
  • on-demand-revalidation/tags/1.2.5/vendor/composer/InstalledVersions.php

    r2922407 r3225736  
    323323
    324324        $installed = array();
     325        $copiedLocalDir = false;
    325326
    326327        if (self::$canGetVendors) {
     
    331332                    /** @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 */
    332333                    $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;
    336339                    }
    337340                }
     
    351354        }
    352355
    353         if (self::$installed !== array()) {
     356        if (self::$installed !== array() && !$copiedLocalDir) {
    354357            $installed[] = self::$installed;
    355358        }
  • on-demand-revalidation/tags/1.2.5/vendor/composer/installed.php

    r3073886 r3225736  
    22    'root' => array(
    33        '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',
    66        'reference' => null,
    77        'type' => 'wordpress-plugin',
     
    1212    'versions' => array(
    1313        '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',
    1616            'reference' => null,
    1717            'type' => 'wordpress-plugin',
  • on-demand-revalidation/trunk/on-demand-revalidation.php

    r3073886 r3225736  
    77 * GitHub Plugin URI:   https://github.com/dexerto/on-demand-revalidation
    88 * Description:         Next.js On-Demand Revalidation on the post update, revalidate specific paths, tags on the post update.
    9  * Version:             1.2.4
     9 * Version:             1.2.5
    1010 * Author:              Dexerto
    1111 * Author URI:          https://dexerto.com
  • on-demand-revalidation/trunk/readme.txt

    r3073886 r3225736  
    33Tags: nextjs, ssg, revalidation, on-demand
    44Requires at least: 4.7
    5 Tested up to: 6.5.2
    6 Stable tag: 1.2.4
     5Tested up to: 6.7.1
     6Stable tag: 1.2.5
    77Requires PHP: 8.0
    88License: GPL-3
     
    1313Next.js On-Demand Revalidation for Wordpress on the post update, revalidate specific paths and tags on the post update.
    1414
    15 Feel free to create a PR to [plugin Github repo](https://github.com/gdidentity/on-demand-revalidation).
     15Feel free to create a PR to [plugin Github repo](https://github.com/Dexerto/on-demand-revalidation).
    1616
    1717== Installation ==
     
    20202. Click the “Install Now” button, followed by "Activate".
    21213. 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).
     224. 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).
    23235. Add `REVALIDATE_SECRET_KEY` env variable to your Next.js with Revalidate Secret Key value you added in the Plugin Settings.
    2424
    2525
    2626== 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
    2732= 1.2.4 =
    2833- fix: do not send non-replaced string if term is not there
  • on-demand-revalidation/trunk/src/Revalidation.php

    r3073849 r3225736  
    7878            return;
    7979        }
     80
     81        if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
     82            return;
     83        }
    8084       
    8185        self::revalidate_post( $post );
     
    158162            $revalidate_paths = preg_split( '/\r\n|\n|\r/', $revalidate_paths );
    159163            $revalidate_paths = Helpers::rewrite_placeholders( $revalidate_paths, $post );
    160         } else {
    161             $paths = array();
    162164        }
    163165
     
    180182
    181183        $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 );
    183185
    184186        $data = array(
     
    212214        $response_data = ( ! is_wp_error( $response ) ) ? $body : $response;
    213215
     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        }
    214232
    215233        if ( class_exists( 'CPurgeCache' ) ) {
    216234            \CPurgeCache\Purge::purge( $post );
    217         }
    218 
    219 
    220         if ( ! $response_data['revalidated'] ) {
    221             return new WP_Error( 'revalidate_error', $response['message'], array( 'status' => 403 ) );
    222235        }
    223236
  • on-demand-revalidation/trunk/vendor/composer/InstalledVersions.php

    r2922407 r3225736  
    323323
    324324        $installed = array();
     325        $copiedLocalDir = false;
    325326
    326327        if (self::$canGetVendors) {
     
    331332                    /** @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 */
    332333                    $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;
    336339                    }
    337340                }
     
    351354        }
    352355
    353         if (self::$installed !== array()) {
     356        if (self::$installed !== array() && !$copiedLocalDir) {
    354357            $installed[] = self::$installed;
    355358        }
  • on-demand-revalidation/trunk/vendor/composer/installed.php

    r3073886 r3225736  
    22    'root' => array(
    33        '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',
    66        'reference' => null,
    77        'type' => 'wordpress-plugin',
     
    1212    'versions' => array(
    1313        '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',
    1616            'reference' => null,
    1717            'type' => 'wordpress-plugin',
Note: See TracChangeset for help on using the changeset viewer.