|  | @@ -75,7 +75,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 75 | 75 |          if (!$this->log_attivo && $level === 'info') { | 
                                                                                                            
                                                            | 76 | 76 |              return; | 
                                                                                                            
                                                            | 77 | 77 |          } | 
                                                                                                            
                                                            | 78 |  | -        $this->$level(now()->toDateTimeString() . ' Shard[' . $this->shardId . '] Priority[' . $this->priority . '] Connection[' . $this->connection_name . '] : ' . PHP_EOL . $message); | 
                                                                                                            
                                                            |  | 78 | +        $this->$level(now()->toDateTimeString().' Shard['.$this->shardId.'] Priority['.$this->priority.'] Connection['.$this->connection_name.'] : '.PHP_EOL.$message); | 
                                                                                                            
                                                            | 79 | 79 |      } | 
                                                                                                            
                                                            | 80 | 80 |   | 
                                                                                                            
                                                            | 81 | 81 |      protected function processEvents(): void | 
                                                                                                                                                        
                                                        |  | @@ -83,7 +83,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 83 | 83 |          $processingStartTime = now(); | 
                                                                                                            
                                                            | 84 | 84 |          // Recupero gli eventi da invalidare | 
                                                                                                            
                                                            | 85 | 85 |          $events = $this->getEventsToInvalidate($processingStartTime); | 
                                                                                                            
                                                            | 86 |  | -        $this->logIf('Trovati ' . count($events) . ' Eventi da invalidare'); | 
                                                                                                            
                                                            |  | 86 | +        $this->logIf('Trovati '.count($events).' Eventi da invalidare'); | 
                                                                                                            
                                                            | 87 | 87 |          if (count($events) === 0) { | 
                                                                                                            
                                                            | 88 | 88 |              return; | 
                                                                                                            
                                                            | 89 | 89 |          } | 
                                                                                                                                                        
                                                        |  | @@ -92,7 +92,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 92 | 92 |          $unique_events = []; | 
                                                                                                            
                                                            | 93 | 93 |   | 
                                                                                                            
                                                            | 94 | 94 |          foreach ($events as $event) { | 
                                                                                                            
                                                            | 95 |  | -            $key = $event->type . ':' . $event->identifier; // Chiave univoca per type + identifier | 
                                                                                                            
                                                            |  | 95 | +            $key = $event->type.':'.$event->identifier; // Chiave univoca per type + identifier | 
                                                                                                            
                                                            | 96 | 96 |              $event->event_time = \Illuminate\Support\Carbon::parse($event->event_time); | 
                                                                                                            
                                                            | 97 | 97 |              // Quando la chiave non esiste o il nuovo valore ha un event_time più vecchio, lo sostituisco così a parità di tag ho sempre quello più vecchio e mi baso su quello per verificare la finestra | 
                                                                                                            
                                                            | 98 | 98 |              if (!isset($unique_events[$key]) || $event->event_time <= $unique_events[$key]->event_time) { | 
                                                                                                                                                        
                                                        |  | @@ -102,12 +102,12 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 102 | 102 |   | 
                                                                                                            
                                                            | 103 | 103 |          $unique_events = array_values($unique_events); | 
                                                                                                            
                                                            | 104 | 104 |   | 
                                                                                                            
                                                            | 105 |  | -        $this->logIf('Eventi unici ' . count($unique_events)); | 
                                                                                                            
                                                            |  | 105 | +        $this->logIf('Eventi unici '.count($unique_events)); | 
                                                                                                            
                                                            | 106 | 106 |          // Quando il numero di eventi unici è inferiore al batchSize e quello più vecchio aspetta da almeno due minuti, mando l'invalidazione. | 
                                                                                                            
                                                            | 107 | 107 |          // Questo serve per i siti piccoli che hanno pochi eventi, altrimenti si rischia di attendere troppo per invalidare i tags | 
                                                                                                            
                                                            | 108 | 108 |          // In questo caso invalido i tag/key "unici" e setto a processed = 1 tutti quelli recuperati | 
                                                                                                            
                                                            | 109 | 109 |          if (count($unique_events) < $this->tagBatchSize && $processingStartTime->diffInSeconds($unique_events[0]->event_time) >= 120) { | 
                                                                                                            
                                                            | 110 |  | -            $this->logIf('Il numero di eventi unici è inferiore al batchSize ( ' . $this->tagBatchSize . ' ) e sono passati più di due minuti, procedo'); | 
                                                                                                            
                                                            |  | 110 | +            $this->logIf('Il numero di eventi unici è inferiore al batchSize ( '.$this->tagBatchSize.' ) e sono passati più di due minuti, procedo'); | 
                                                                                                            
                                                            | 111 | 111 |              $this->processBatch($events, $unique_events); | 
                                                                                                            
                                                            | 112 | 112 |   | 
                                                                                                            
                                                            | 113 | 113 |              return; | 
                                                                                                                                                        
                                                        |  | @@ -127,7 +127,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 127 | 127 |              // altrimenti aggiungo l'evento a quelli da processare | 
                                                                                                            
                                                            | 128 | 128 |              $eventsToUpdate[] = $event; | 
                                                                                                            
                                                            | 129 | 129 |              // e recupero tutti gli ID che hanno quel tag/key | 
                                                                                                            
                                                            | 130 |  | -            $eventsAll[] = array_filter($events, function ($event) use ($typeFilter, $identifierFilter) { | 
                                                                                                            
                                                            |  | 130 | +            $eventsAll[] = array_filter($events, function($event) use ($typeFilter, $identifierFilter) { | 
                                                                                                            
                                                            | 131 | 131 |                  return $event->type === $typeFilter && $event->identifier === $identifierFilter; | 
                                                                                                            
                                                            | 132 | 132 |              }); | 
                                                                                                            
                                                            | 133 | 133 |          } | 
                                                                                                                                                        
                                                        |  | @@ -149,15 +149,15 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 149 | 149 |          foreach ($eventsToInvalidate as $item) { | 
                                                                                                            
                                                            | 150 | 150 |              switch ($item->type) { | 
                                                                                                            
                                                            | 151 | 151 |                  case 'key': | 
                                                                                                            
                                                            | 152 |  | -                    $keys[] = $item->identifier . '§' . $item->connection_name; | 
                                                                                                            
                                                            |  | 152 | +                    $keys[] = $item->identifier.'§'.$item->connection_name; | 
                                                                                                            
                                                            | 153 | 153 |                      break; | 
                                                                                                            
                                                            | 154 | 154 |                  case 'tag': | 
                                                                                                            
                                                            | 155 |  | -                    $tags[] = $item->identifier . '§' . $item->connection_name; | 
                                                                                                            
                                                            |  | 155 | +                    $tags[] = $item->identifier.'§'.$item->connection_name; | 
                                                                                                            
                                                            | 156 | 156 |                      break; | 
                                                                                                            
                                                            | 157 | 157 |              } | 
                                                                                                            
                                                            | 158 | 158 |          } | 
                                                                                                            
                                                            | 159 | 159 |   | 
                                                                                                            
                                                            | 160 |  | -        $this->logIf('Invalido ' . count($keys) . ' chiavi e ' . count($tags) . ' tags' . ' per un totale di ' . count($allEvents) . ' events_ID'); | 
                                                                                                            
                                                            |  | 160 | +        $this->logIf('Invalido '.count($keys).' chiavi e '.count($tags).' tags'.' per un totale di '.count($allEvents).' events_ID'); | 
                                                                                                            
                                                            | 161 | 161 |   | 
                                                                                                            
                                                            | 162 | 162 |          if (!empty($keys)) { | 
                                                                                                            
                                                            | 163 | 163 |              $this->invalidateKeys($keys); | 
                                                                                                                                                        
                                                        |  | @@ -165,7 +165,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 165 | 165 |   | 
                                                                                                            
                                                            | 166 | 166 |          if (!empty($tags)) { | 
                                                                                                            
                                                            | 167 | 167 |              // Escludo i tag fullpage | 
                                                                                                            
                                                            | 168 |  | -            $tags = array_filter($tags, function ($item) { | 
                                                                                                            
                                                            |  | 168 | +            $tags = array_filter($tags, function($item) { | 
                                                                                                            
                                                            | 169 | 169 |                  return !str_contains($item, 'fullpage'); | 
                                                                                                            
                                                            | 170 | 170 |              }); | 
                                                                                                            
                                                            | 171 | 171 |              $this->invalidateTags($tags); | 
                                                                                                                                                        
                                                        |  | @@ -209,7 +209,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 209 | 209 |                  continue; | 
                                                                                                            
                                                            | 210 | 210 |              } | 
                                                                                                            
                                                            | 211 | 211 |              // oppure di default uso Laravel | 
                                                                                                            
                                                            | 212 |  | -            $storeName =  $this->getStoreFromConnectionName($connection_name); | 
                                                                                                            
                                                            |  | 212 | +            $storeName = $this->getStoreFromConnectionName($connection_name); | 
                                                                                                            
                                                            | 213 | 213 |   | 
                                                                                                            
                                                            | 214 | 214 |              if ($storeName === null) { | 
                                                                                                            
                                                            | 215 | 215 |                  continue; | 
                                                                                                                                                        
                                                        |  | @@ -246,7 +246,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 246 | 246 |              return; | 
                                                                                                            
                                                            | 247 | 247 |          } | 
                                                                                                            
                                                            | 248 | 248 |          foreach ($groupByConnection as $connection_name => $arrTags) { | 
                                                                                                            
                                                            | 249 |  | -            $storeName =  $this->getStoreFromConnectionName($connection_name); | 
                                                                                                            
                                                            |  | 249 | +            $storeName = $this->getStoreFromConnectionName($connection_name); | 
                                                                                                            
                                                            | 250 | 250 |              if ($storeName === null) { | 
                                                                                                            
                                                            | 251 | 251 |                  continue; | 
                                                                                                            
                                                            | 252 | 252 |              } | 
                                                                                                                                                        
                                                        |  | @@ -267,13 +267,13 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 267 | 267 |          $tagBatchSize = $this->option('tag-batch-size') ?? config('super_cache_invalidate.tag_batch_size'); | 
                                                                                                            
                                                            | 268 | 268 |          $this->tagBatchSize = (int) $tagBatchSize; | 
                                                                                                            
                                                            | 269 | 269 |          $this->connection_name = $this->option('connection_name') ?? config('super_cache_invalidate.default_connection_name'); | 
                                                                                                            
                                                            | 270 |  | -        $this->log_attivo = $this->option('log_attivo') && (int)$this->option('log_attivo') === 1; | 
                                                                                                            
                                                            |  | 270 | +        $this->log_attivo = $this->option('log_attivo') && (int) $this->option('log_attivo') === 1; | 
                                                                                                            
                                                            | 271 | 271 |          $this->invalidation_window = (int) config('super_cache_invalidate.invalidation_window'); | 
                                                                                                            
                                                            | 272 | 272 |          $lockTimeout = (int) config('super_cache_invalidate.lock_timeout'); | 
                                                                                                            
                                                            | 273 | 273 |   | 
                                                                                                            
                                                            | 274 | 274 |          // Acquisisco il lock in modo da essere sicura che le esecuzioni non si accavallino | 
                                                                                                            
                                                            | 275 | 275 |          // $lockValue = $this->helper->acquireShardLock($this->shardId, $this->priority, $lockTimeout, $this->connection_name); | 
                                                                                                            
                                                            | 276 |  | -        $this->logIf('Starting Elaborazione ...' . $this->invalidation_window); | 
                                                                                                            
                                                            |  | 276 | +        $this->logIf('Starting Elaborazione ...'.$this->invalidation_window); | 
                                                                                                            
                                                            | 277 | 277 |          // if (!$lockValue) { | 
                                                                                                            
                                                            | 278 | 278 |          //    return; | 
                                                                                                            
                                                            | 279 | 279 |          // } | 
                                                                                                                                                        
                                                        |  | @@ -290,6 +290,6 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 290 | 290 |              ), 'error'); | 
                                                                                                            
                                                            | 291 | 291 |          } | 
                                                                                                            
                                                            | 292 | 292 |          $executionTime = (microtime(true) - $startTime) * 1000; | 
                                                                                                            
                                                            | 293 |  | -        $this->logIf('Fine Elaborazione - Tempo di esecuzione: ' . $executionTime . ' millisec.'); | 
                                                                                                            
                                                            |  | 293 | +        $this->logIf('Fine Elaborazione - Tempo di esecuzione: '.$executionTime.' millisec.'); | 
                                                                                                            
                                                            | 294 | 294 |      } | 
                                                                                                            
                                                            | 295 | 295 |  } |