Commit 3a941b893e5 for woocommerce
commit 3a941b893e5fe133fc2b079cfd998a1af1bd382d
Author: Alba Rincón <albarin@users.noreply.github.com>
Date: Thu May 14 13:18:15 2026 +0200
Fix early textdomain loading regression in GraphQL API (#64881)
* Fix early textdomain loading regression in GraphQL API
* Add changefile(s) from automation for the following project(s): woocommerce
* Add changefile(s) from automation for the following project(s): woocommerce
* Reschedule OPcache cleanup on cache hits, not just writes
* Use finally to ensure cleanup reschedule on cache read
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/64881-fix-graphql-early-textdomain-regression b/plugins/woocommerce/changelog/64881-fix-graphql-early-textdomain-regression
new file mode 100644
index 00000000000..b677279faf1
--- /dev/null
+++ b/plugins/woocommerce/changelog/64881-fix-graphql-early-textdomain-regression
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Prevent a `_load_textdomain_just_in_time` notice from firing on every request when the GraphQL API feature is registered.
\ No newline at end of file
diff --git a/plugins/woocommerce/src/Internal/Api/Main.php b/plugins/woocommerce/src/Internal/Api/Main.php
index 8a249e7253c..48c2d30d70c 100644
--- a/plugins/woocommerce/src/Internal/Api/Main.php
+++ b/plugins/woocommerce/src/Internal/Api/Main.php
@@ -174,9 +174,7 @@ class Main {
$settings = wc_get_container()->get( Settings::class );
$settings->register();
- if ( self::is_enabled() ) {
- add_action( OpcacheFileExpiry::ACTION_HOOK, array( OpcacheFileExpiry::class, 'handle_cleanup_action' ) );
- }
+ add_action( OpcacheFileExpiry::ACTION_HOOK, array( OpcacheFileExpiry::class, 'handle_cleanup_action' ) );
}
/**
diff --git a/plugins/woocommerce/src/Internal/Api/OpcacheFileExpiry.php b/plugins/woocommerce/src/Internal/Api/OpcacheFileExpiry.php
index 228933fbaa8..d8480a66e05 100644
--- a/plugins/woocommerce/src/Internal/Api/OpcacheFileExpiry.php
+++ b/plugins/woocommerce/src/Internal/Api/OpcacheFileExpiry.php
@@ -62,13 +62,17 @@ class OpcacheFileExpiry {
* Action Scheduler callback: delete expired files and reschedule.
*
* Immediate reschedule when files were deleted (drain the backlog), 24h
- * otherwise.
+ * otherwise. Skipped when the feature is disabled.
*
* @internal
*/
public static function handle_cleanup_action(): void {
$interval = self::delete_expired_files() > 0 ? 1 : DAY_IN_SECONDS;
+ if ( ! Main::is_enabled() ) {
+ return;
+ }
+
if ( function_exists( 'as_schedule_single_action' ) ) {
as_schedule_single_action( time() + $interval, self::ACTION_HOOK, array(), self::ACTION_GROUP );
}
@@ -77,8 +81,10 @@ class OpcacheFileExpiry {
/**
* Schedule the cleanup if it isn't already scheduled.
*
- * Called from {@see QueryCache::write_to_opcache()} so the first run is
- * triggered by the first write — no separate bootstrap step.
+ * Called from {@see QueryCache::write_to_opcache()} and
+ * {@see QueryCache::read_from_opcache()} so the cleanup is rescheduled
+ * after a feature-disable/re-enable cycle even when every request hits a
+ * cached file (no writes).
*/
public static function ensure_scheduled(): void {
if ( wp_cache_get( self::SCHEDULED_CACHE_KEY, QueryCache::CACHE_GROUP ) ) {
diff --git a/plugins/woocommerce/src/Internal/Api/QueryCache.php b/plugins/woocommerce/src/Internal/Api/QueryCache.php
index 72805547aad..8b0f34ed127 100644
--- a/plugins/woocommerce/src/Internal/Api/QueryCache.php
+++ b/plugins/woocommerce/src/Internal/Api/QueryCache.php
@@ -370,6 +370,8 @@ class QueryCache {
return AST::fromArray( $data );
} catch ( \Throwable $e ) {
return false;
+ } finally {
+ OpcacheFileExpiry::ensure_scheduled();
}
}