Plugin Directory

Changeset 3232537


Ignore:
Timestamp:
01/31/2025 10:35:33 AM (14 months ago)
Author:
axeptio
Message:

version 2.5.9 release

Location:
axeptio-sdk-integration
Files:
1501 added
4 edited

Legend:

Unmodified
Added
Removed
  • axeptio-sdk-integration/trunk/axeptio-wordpress-plugin.php

    r3231218 r3232537  
    44    Plugin URI: https://www.axeptio.eu/
    55    Description: Axeptio allows you to make your website compliant with GDPR.
    6     Version: 2.5.8
     6    Version: 2.5.9
    77    Author: axeptio
    88    License: GPLv3
     
    1212 **/
    1313
    14 define( 'XPWP_VERSION', '2.5.8' );
     14define( 'XPWP_VERSION', '2.5.9' );
    1515define( 'XPWP_URL', plugin_dir_url( __FILE__ ) );
    1616define( 'XPWP_PATH', plugin_dir_path( __FILE__ ) );
  • axeptio-sdk-integration/trunk/includes/classes/frontend/class-hook-modifier.php

    r3231218 r3232537  
    120120        }
    121121
    122         Search_Callback_File_Location::initialize_cache();
    123 
    124122        $this->process_shortcode_tags();
    125123        $this->process_wp_filter();
     
    240238        }
    241239
    242         // Write the cache to a file after processing all shortcode tags.
    243         Search_Callback_File_Location::write_cache_to_file();
    244 
    245240        return $stats;
    246241    }
     
    513508            }
    514509        }
    515 
    516         // Write the cache to a file after processing all hooks.
    517         Search_Callback_File_Location::write_cache_to_file();
    518510
    519511        return $stats;
  • axeptio-sdk-integration/trunk/includes/classes/utils/class-search-callback-file-location.php

    r3231218 r3232537  
    3232
    3333    /**
    34      * Calculate the dynamic cache limit based on WordPress memory limits.
    35      *
    36      * @return int
    37      */
    38     private static function calculate_dynamic_cache_limit_wp(): int {
    39         $availableMemory = wp_memory_limit_in_bytes();
    40         $safeMemory = $availableMemory * 0.05; // Utiliser 10 % de la mémoire disponible
    41         $averageEntrySize = 200; // Taille moyenne estimée d'une entrée (en octets)
    42 
    43         // Calculer le nombre maximum d'entrées
    44         return (int) floor($safeMemory / $averageEntrySize);
    45     }
    46 
    47     /**
    48      * Initialize the callback file locations from cache.
    49      *
    50      * @return void
    51      */
    52     public static function initialize_cache() {
    53         if (self::$callback_file_locations !== null) {
    54             return;
    55         }
    56 
    57         self::$max_callbacks = self::calculate_dynamic_cache_limit_wp();
    58 
    59         $cache_file = self::get_cache_file_path();
    60 
    61         if (file_exists($cache_file) && (time() - filemtime($cache_file)) < self::CACHE_EXPIRATION) {
    62             $fileContent = file_get_contents($cache_file);
    63             if ($fileContent !== false && str_contains($fileContent, '// SIGNATURE: CACHE_FILE_END')) {
    64                 self::$callback_file_locations = (array) include $cache_file;
    65             } else {
    66                 self::$callback_file_locations = array();
    67                 error_log('Le fichier cache est invalide ou incomplet (signature absente).');
    68             }
    69         } else {
    70             self::$callback_file_locations = array();
    71         }
    72 
    73         // Store the initial state for later comparison
    74         self::$initial_callback_file_locations = self::$callback_file_locations;
    75     }
    76 
    77     /**
    7834     * Get the plugin where a callback function is defined.
    7935     *
     
    8541     */
    8642    public static function get_plugin( $callback_function, ?string $name = null, ?string $filter = null, ?int $priority = null ): ?string {
    87         self::initialize_cache();
    88 
    89         $cache_key = self::generate_cache_key( $callback_function, $name, $filter, $priority );
    90 
    91         // Check if the filename is already in the temporary storage.
    92         if ( isset( self::$callback_file_locations[ $cache_key ] ) ) {
    93             return self::$callback_file_locations[ $cache_key ];
    94         }
    95 
    9643        $filename = self::find_filename( $callback_function, $name, $filter, $priority );
    97         $plugin = self::extract_plugin_name($filename);
    98 
    99         // Store the result in the temporary storage.
    100         if (count(self::$callback_file_locations) < self::$max_callbacks) {
    101             self::$callback_file_locations[ $cache_key ] = $plugin;
    102         }
    103 
    104         return $plugin;
     44        return self::extract_plugin_name($filename);
    10545    }
    10646
     
    12363        return null;
    12464    }
    125 
    126 
    127     /**
    128      * Write the callback file locations to a PHP file.
    129      *
    130      * @return void
    131      */
    132     public static function write_cache_to_file(): void
    133     {
    134         // Sort both arrays to ensure they are in the same order for comparison
    135         ksort(self::$callback_file_locations);
    136         ksort(self::$initial_callback_file_locations);
    137 
    138         // Only write to the file if the data has changed
    139         if (self::$callback_file_locations === self::$initial_callback_file_locations) {
    140             return;
    141         }
    142 
    143         $cache_file = self::get_cache_file_path();
    144 
    145         // Check if the directory exists, if not, create it.
    146         self::ensure_cache_directory_exists();
    147 
    148         // Prepare the content with a signature
    149         $content = "<?php\nreturn " . var_export(self::$callback_file_locations, true) . ";\n\n// SIGNATURE: CACHE_FILE_END\n";
    150 
    151         file_put_contents($cache_file, $content);
    152     }
    15365
    15466    /**
     
    18092                return $reflection->getFileName();
    18193            }
    182 
    183             if (is_string($name) && is_string($filter)) {
    184                 return self::handle_wp_specific_cases($name, $filter, $priority);
    185             }
    18694        } catch (\ReflectionException $e) {
    18795            // Log the exception or handle it as needed.
     
    19098
    19199        return null;
    192     }
    193 
    194     /**
    195      * Generate a unique cache key for the given parameters.
    196      *
    197      * @param mixed $callback_function The callback function.
    198      * @param string|null $name The name of the callback.
    199      * @param string|null $filter The filter name.
    200      * @param int|null $priority The priority of the hook.
    201      * @return string
    202      * @throws \ReflectionException
    203      */
    204     private static function generate_cache_key( $callback_function, ?string $name, ?string $filter, ?int $priority ): string {
    205         $key_parts = array(
    206             self::get_callback_identifier( $callback_function ),
    207             $name,
    208             $filter,
    209             $priority,
    210         );
    211 
    212         return md5( implode( '|', array_filter( $key_parts ) ) );
    213     }
    214 
    215     /**
    216      * Get a unique identifier for the callback function.
    217      *
    218      * @param mixed $callback_function The callback function.
    219      * @return string A unique identifier for the callback.
    220      * @throws \ReflectionException
    221      */
    222     private static function get_callback_identifier( $callback_function ): string {
    223         if ( is_string( $callback_function ) ) {
    224             return $callback_function;
    225         }
    226         if ( is_array( $callback_function ) && count( $callback_function ) === 2 ) {
    227             if ( is_object( $callback_function[0] ) ) {
    228                 return get_class( $callback_function[0] ) . '::' . $callback_function[1];
    229             }
    230             return $callback_function[0] . '::' . $callback_function[1];
    231         }
    232         if ( $callback_function instanceof \Closure ) {
    233             $reflection = new \ReflectionFunction( $callback_function );
    234             return 'closure:' . $reflection->getFileName() . ':' . $reflection->getStartLine();
    235         }
    236         if ( is_object( $callback_function ) ) {
    237             return get_class( $callback_function ) . '::__invoke';
    238         }
    239         return 'unknown';
    240     }
    241 
    242     /**
    243      * Handle WordPress-specific callback cases.
    244      *
    245      * @param string   $name The name of the callback.
    246      * @param string   $filter The filter name.
    247      * @param int|null $priority The priority of the hook.
    248      * @return string|null The filename or null if not found.
    249      */
    250     private static function handle_wp_specific_cases( string $name, string $filter, ?int $priority ): ?string {
    251         global $wp_filter;
    252 
    253         if ( isset( $wp_filter[ $filter ] ) ) {
    254             $hooks = $wp_filter[ $filter ];
    255             if ( null !== $priority && isset( $hooks->callbacks[ $priority ][ $name ] ) ) {
    256                 $callback = $hooks->callbacks[ $priority ][ $name ]['function'];
    257                 return self::get_filename( $callback );
    258             } else {
    259                 foreach ( $hooks->callbacks as $prio => $callbacks ) {
    260                     if ( isset( $callbacks[ $name ] ) ) {
    261                         $callback = $callbacks[ $name ]['function'];
    262                         return self::get_filename( $callback );
    263                     }
    264                 }
    265             }
    266         }
    267 
    268         return null;
    269     }
    270 
    271     /**
    272      * Get the cache file path.
    273      *
    274      * @return string
    275      */
    276     private static function get_cache_file_path(): string {
    277         $upload_dir = wp_upload_dir();
    278         return $upload_dir['basedir'] . '/axeptio/callback_file_cache.php';
    279     }
    280 
    281     /**
    282      * Ensure the cache directory exists.
    283      *
    284      * @return void
    285      */
    286     private static function ensure_cache_directory_exists() {
    287         $cache_dir = dirname(self::get_cache_file_path());
    288         if (!file_exists($cache_dir)) {
    289             wp_mkdir_p($cache_dir);
    290         }
    291100    }
    292101
  • axeptio-sdk-integration/trunk/readme.txt

    r3231218 r3232537  
    44Requires at least: 5.0
    55Tested up to: 6.5.5
    6 Stable tag: 2.5.8
     6Stable tag: 2.5.9
    77Requires PHP: 7.4
    88License: GPLv3
     
    8383All informations here : [Axeptio customization](https://support.axeptio.eu/hc/en-gb/articles/4402985038225-Customize-my-widget-s-aspect)
    8484
     85### 🔄 2.5.9 🔄 ###
     86
     87**Temporary Removal of WordPress Hook Caching System**
     88We have identified that the WordPress hook caching system could cause issues on certain site configurations.
     89To ensure optimal compatibility for all users, we have temporarily disabled this feature while we work on a more robust solution.
     90
    8591### 🚀 2.5.8 🚀 ###
    8692
Note: See TracChangeset for help on using the changeset viewer.