Completed
Push — master ( bc4701...fb78a3 )
by Lars
01:44
created
src/voku/helper/Session2DB.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         // some other defaults
323 323
         $this->set_lock_to_user_agent($lock_to_user_agent);
324 324
         $this->set_lock_to_ip($lock_to_ip);
325
-        $this->set_lock_file_tmp(\sys_get_temp_dir() . \DIRECTORY_SEPARATOR . 'session2db.lock.');
325
+        $this->set_lock_file_tmp(\sys_get_temp_dir().\DIRECTORY_SEPARATOR.'session2db.lock.');
326 326
 
327 327
         // the table to be used by the class
328 328
         $this->set_table_name($table_name);
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 
392 392
         $query_lock = '
393 393
         SELECT lock_time 
394
-        FROM ' . $this->table_name_lock . " 
395
-        WHERE lock_hash = '" . $this->db->escape($look_name) . "'
394
+        FROM ' . $this->table_name_lock." 
395
+        WHERE lock_hash = '" . $this->db->escape($look_name)."'
396 396
         LIMIT 0, 1
397 397
         ";
398 398
         $old_lock_timeout = $this->db->fetchColumn($query_lock, 'lock_time');
@@ -400,18 +400,18 @@  discard block
 block discarded – undo
400 400
         if (!$old_lock_timeout) {
401 401
             $query_lock = '
402 402
             INSERT INTO 
403
-            ' . $this->table_name_lock . "
403
+            ' . $this->table_name_lock."
404 404
             (
405 405
                 lock_hash,
406 406
                 lock_time
407 407
             )
408 408
             VALUES
409 409
             (
410
-                '" . $this->db->escape($look_name) . "',
411
-                '" . $this->db->escape($lock_time) . "'
410
+                '" . $this->db->escape($look_name)."',
411
+                '" . $this->db->escape($lock_time)."'
412 412
             )
413 413
             ON DUPLICATE KEY UPDATE
414
-                lock_time = '" . $this->db->escape($lock_time) . "'
414
+                lock_time = '" . $this->db->escape($lock_time)."'
415 415
             ";
416 416
 
417 417
             if ($this->db->query($query_lock) !== false) {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
      */
430 430
     private function _get_lock_mysql_native($look_name): bool
431 431
     {
432
-        $query_lock = "SELECT GET_LOCK('" . $this->db->escape($look_name) . "', " . $this->db->escape($this->lock_timeout) . ') as result';
432
+        $query_lock = "SELECT GET_LOCK('".$this->db->escape($look_name)."', ".$this->db->escape($this->lock_timeout).') as result';
433 433
         $db_result = $this->db->query($query_lock);
434 434
 
435 435
         return (bool) $db_result->fetchColumn('result');
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     {
446 446
         // init
447 447
         $result_lock = false;
448
-        $lock_file = $this->lock_file_tmp . $look_name;
448
+        $lock_file = $this->lock_file_tmp.$look_name;
449 449
 
450 450
         /** @noinspection PhpUsageOfSilenceOperatorInspection */
451 451
         $fp = @\fopen($lock_file, 'rb');
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
     {
486 486
         // MySQL >=5.7.5 | the new GET_LOCK implementation has a limit on the identifier name
487 487
         // -> https://bugs.mysql.com/bug.php?id=80721
488
-        return 'session_' . \sha1($session_id);
488
+        return 'session_'.\sha1($session_id);
489 489
     }
490 490
 
491 491
     /**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
      */
559 559
     private function _release_lock_php_native(string $look_name): bool
560 560
     {
561
-        $lock_file = $this->lock_file_tmp . $look_name;
561
+        $lock_file = $this->lock_file_tmp.$look_name;
562 562
         if (\file_exists($lock_file) === true) {
563 563
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
564 564
             $result_unlock = @\unlink($lock_file);
@@ -576,8 +576,8 @@  discard block
 block discarded – undo
576 576
      */
577 577
     private function _release_lock_sql_fake(string $look_name): bool
578 578
     {
579
-        $query = 'DELETE FROM ' . $this->table_name_lock . "
580
-            WHERE lock_hash = '" . $this->db->escape($look_name) . "'
579
+        $query = 'DELETE FROM '.$this->table_name_lock."
580
+            WHERE lock_hash = '" . $this->db->escape($look_name)."'
581 581
         ";
582 582
 
583 583
         return (bool) $this->db->query($query);
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
      */
591 591
     private function _release_lock_sql_native(string $look_name): bool
592 592
     {
593
-        $query = "SELECT RELEASE_LOCK('" . $this->db->escape($look_name) . "') as result";
593
+        $query = "SELECT RELEASE_LOCK('".$this->db->escape($look_name)."') as result";
594 594
         $db_result = $this->db->query($query);
595 595
 
596 596
         return (bool) $db_result->fetchColumn('result');
@@ -628,16 +628,16 @@  discard block
 block discarded – undo
628 628
     {
629 629
         // deletes the current locks from the database
630 630
         if ($this->lock_via_mysql === null) {
631
-            $queryLock = 'DELETE FROM ' . $this->table_name_lock . "
632
-                WHERE lock_time < '" . $this->db->escape(\time()) . "'
631
+            $queryLock = 'DELETE FROM '.$this->table_name_lock."
632
+                WHERE lock_time < '" . $this->db->escape(\time())."'
633 633
             ";
634 634
             $this->db->query($queryLock);
635 635
         }
636 636
 
637 637
         // deletes the current session id from the database
638 638
 
639
-        $query = 'DELETE FROM ' . $this->table_name . "
640
-            WHERE session_id = '" . $this->db->escape($session_id) . "'
639
+        $query = 'DELETE FROM '.$this->table_name."
640
+            WHERE session_id = '" . $this->db->escape($session_id)."'
641 641
         ";
642 642
         $result = $this->db->query($query);
643 643
 
@@ -655,16 +655,16 @@  discard block
 block discarded – undo
655 655
     {
656 656
         // deletes expired locks from database
657 657
         if ($this->lock_via_mysql === null) {
658
-            $queryLock = 'DELETE FROM ' . $this->table_name_lock . "
659
-                WHERE lock_time < '" . $this->db->escape(\time()) . "'
658
+            $queryLock = 'DELETE FROM '.$this->table_name_lock."
659
+                WHERE lock_time < '" . $this->db->escape(\time())."'
660 660
             ";
661 661
             $this->db->query($queryLock);
662 662
         }
663 663
 
664 664
         // deletes expired sessions from database
665 665
 
666
-        $query = 'DELETE FROM ' . $this->table_name . "
667
-            WHERE session_expire < '" . $this->db->escape(\time()) . "'
666
+        $query = 'DELETE FROM '.$this->table_name."
667
+            WHERE session_expire < '" . $this->db->escape(\time())."'
668 668
         ";
669 669
 
670 670
         return (int) $this->db->query($query);
@@ -720,10 +720,10 @@  discard block
 block discarded – undo
720 720
         $query = 'SELECT
721 721
             session_data
722 722
         FROM
723
-            ' . $this->table_name . "
724
-        WHERE session_id = '" . $this->db->escape($session_id) . "'
725
-        AND hash = '" . $this->db->escape($hash) . "'
726
-        AND session_expire > '" . $this->db->escape(\time()) . "'
723
+            ' . $this->table_name."
724
+        WHERE session_id = '" . $this->db->escape($session_id)."'
725
+        AND hash = '" . $this->db->escape($hash)."'
726
+        AND session_expire > '" . $this->db->escape(\time())."'
727 727
         LIMIT 1
728 728
         ";
729 729
 
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
         $expire_time = \time() + (int) $this->session_lifetime;
771 771
 
772 772
         $query = 'INSERT INTO
773
-        ' . $this->table_name . "
773
+        ' . $this->table_name."
774 774
         (
775 775
             session_id,
776 776
             hash,
@@ -779,14 +779,14 @@  discard block
 block discarded – undo
779 779
         )
780 780
         VALUES
781 781
         (
782
-            '" . $this->db->escape($session_id) . "',
783
-            '" . $this->db->escape($hash) . "',
784
-            '" . $this->db->escape($session_data) . "',
785
-            '" . $this->db->escape($expire_time) . "'
782
+            '" . $this->db->escape($session_id)."',
783
+            '" . $this->db->escape($hash)."',
784
+            '" . $this->db->escape($session_data)."',
785
+            '" . $this->db->escape($expire_time)."'
786 786
         )
787 787
         ON DUPLICATE KEY UPDATE
788
-            session_data = '" . $this->db->escape($session_data) . "',
789
-            session_expire = '" . $this->db->escape($expire_time) . "'
788
+            session_data = '" . $this->db->escape($session_data)."',
789
+            session_expire = '" . $this->db->escape($expire_time)."'
790 790
         ";
791 791
 
792 792
         // insert OR update session's data
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
         $this->gc($this->session_lifetime);
849 849
 
850 850
         $query = 'SELECT COUNT(session_id) AS count
851
-            FROM ' . $this->table_name . '
851
+            FROM ' . $this->table_name.'
852 852
         ';
853 853
 
854 854
         // counts the rows from the database
@@ -903,10 +903,10 @@  discard block
 block discarded – undo
903 903
 
904 904
         // return them as an array
905 905
         return [
906
-            'session.gc_maxlifetime' => $gc_maxlifetime . ' seconds (' . \round($gc_maxlifetime / 60) . ' minutes)',
906
+            'session.gc_maxlifetime' => $gc_maxlifetime.' seconds ('.\round($gc_maxlifetime / 60).' minutes)',
907 907
             'session.gc_probability' => $gc_probability,
908 908
             'session.gc_divisor'     => $gc_divisor,
909
-            'probability'            => $gc_probability / $gc_divisor * 100 . '%',
909
+            'probability'            => $gc_probability / $gc_divisor * 100.'%',
910 910
         ];
911 911
     }
912 912
 
Please login to merge, or discard this patch.