@@ -453,7 +453,7 @@ private function buildEntryEnvelope(array $payload, string $signature, int $now)
453453 /**
454454 * @param array<string, mixed> $entry
455455 */
456- private function writeEntry (string $ cacheKey , array $ entry ): void
456+ protected function writeEntry (string $ cacheKey , array $ entry ): void
457457 {
458458 $ this ->storeLocal ($ cacheKey , $ entry );
459459 $ this ->writeOpcacheArtifact ($ cacheKey , $ entry );
@@ -489,25 +489,30 @@ protected function queueBackgroundRegeneration(string $cacheKey, string $classNa
489489 }
490490 $ this ->shutdownRegistered = true ;
491491 register_shutdown_function (function (): void {
492- while ($ pair = array_shift (self ::$ regenQueue )) {
493- [$ key , $ className ] = $ pair ;
494- try {
495- if (!class_exists ($ className )) {
496- continue ;
497- }
498- $ reflection = new ReflectionClass ($ className );
499- $ signature = $ this ->sourceSignature ($ reflection );
500- $ payload = $ this ->buildClassBundle ($ reflection );
501- $ entry = $ this ->buildEntryEnvelope ($ payload , $ signature , time ());
502- $ this ->writeEntry ($ key , $ entry );
503- self ::$ stats ['metadata.regen ' ]++;
504- } catch (\Throwable $ exception ) {
505- Logger::log ('[MetadataEngine][SWR] ' . $ exception ->getMessage (), LOG_WARNING );
506- } finally {
507- $ this ->releaseLock ($ key );
492+ $ this ->drainBackgroundRegeneration ();
493+ });
494+ }
495+
496+ protected function drainBackgroundRegeneration (): void
497+ {
498+ while ($ pair = array_shift (self ::$ regenQueue )) {
499+ [$ key , $ className ] = $ pair ;
500+ try {
501+ if (!class_exists ($ className )) {
502+ continue ;
508503 }
504+ $ reflection = new ReflectionClass ($ className );
505+ $ signature = $ this ->sourceSignature ($ reflection );
506+ $ payload = $ this ->buildClassBundle ($ reflection );
507+ $ entry = $ this ->buildEntryEnvelope ($ payload , $ signature , time ());
508+ $ this ->writeEntry ($ key , $ entry );
509+ self ::$ stats ['metadata.regen ' ]++;
510+ } catch (\Throwable $ exception ) {
511+ Logger::log ('[MetadataEngine][SWR] ' . $ exception ->getMessage (), LOG_WARNING );
512+ } finally {
513+ $ this ->releaseLock ($ key );
509514 }
510- });
515+ }
511516 }
512517
513518 protected function readFromOpcacheArtifact (string $ cacheKey ): ?array
0 commit comments