← All changes
|
classes/importer/batch-process/class-cartflows-batch-process.php
+31
-2
3.0.1
→
3.3.0
View file →
| @@ -644,13 +644,14 @@ | ||
| 644 | 644 | |
| 645 | 645 | if ( defined( 'WP_CLI' ) ) { |
| 646 | 646 | Cartflows_Batch_Processing_Sync_Library::get_instance()->import_sites( $page, $templates ); |
| 647 | 647 | } else { |
| 648 | + // Queue only scalar data. The queue is the body of the async dispatch request, | |
| 649 | + // and an object in it trips a PHP 8.4+ ArrayIterator deprecation in Requests. | |
| 648 | 650 | self::$process_site_importer->push_to_queue( |
| 649 | 651 | array( |
| 650 | 652 | 'page' => $page, |
| 651 | 653 | 'template' => $templates, |
| 652 | - 'instance' => Cartflows_Batch_Processing_Sync_Library::get_instance(), | |
| 653 | 654 | 'method' => 'import_sites', |
| 654 | 655 | ) |
| 655 | 656 | ); |
| 656 | 657 | } |
| @@ -683,12 +684,40 @@ | ||
| 683 | 684 | * @return void |
| 684 | 685 | */ |
| 685 | 686 | public static function set_is_wcf_template_import( $bool = false ) { |
| 686 | 687 | if ( $bool ) { |
| 687 | - set_transient( 'cartflows_is_wcf_template_import', $bool, HOUR_IN_SECONDS ); | |
| 688 | + /* | |
| 689 | + * The flag is only meant to cover the request doing the import. It used to be | |
| 690 | + * stored for an hour, so an import that died between the true and the false | |
| 691 | + * left SVG/XML uploads enabled long after the import was over. Clear it on | |
| 692 | + * shutdown — which still runs after a fatal — and keep the TTL only as the | |
| 693 | + * backstop for a request the server kills outright. | |
| 694 | + * | |
| 695 | + * The TTL still has to outlast the import request itself: a large funnel | |
| 696 | + * sideloading many images on a slow host can run for several minutes, and an | |
| 697 | + * expiry reached mid-import would start rejecting SVG/XML while the import is | |
| 698 | + * still going. Shutdown is the real guard, so this is set clear of that. | |
| 699 | + */ | |
| 700 | + set_transient( 'cartflows_is_wcf_template_import', $bool, 15 * MINUTE_IN_SECONDS ); | |
| 701 | + | |
| 702 | + if ( ! has_action( 'shutdown', array( __CLASS__, 'clear_is_wcf_template_import' ) ) ) { | |
| 703 | + add_action( 'shutdown', array( __CLASS__, 'clear_is_wcf_template_import' ) ); | |
| 704 | + } | |
| 688 | 705 | } else { |
| 689 | 706 | delete_transient( 'cartflows_is_wcf_template_import' ); // Delete the option if $bool is false. |
| 690 | 707 | } |
| 708 | + } | |
| 709 | + | |
| 710 | + /** | |
| 711 | + * Clear the import flag at the end of the request. | |
| 712 | + * | |
| 713 | + * Registered on 'shutdown' by set_is_wcf_template_import() so an aborted import | |
| 714 | + * cannot leave the extra upload mime types enabled for later requests. | |
| 715 | + * | |
| 716 | + * @return void | |
| 717 | + */ | |
| 718 | + public static function clear_is_wcf_template_import() { | |
| 719 | + delete_transient( 'cartflows_is_wcf_template_import' ); | |
| 691 | 720 | } |
| 692 | 721 | } |
| 693 | 722 | |
| 694 | 723 | /** |