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5.13.2 5.13.3 5.2.0 5.3.0 5.4.0 5.4.1 5.5.0 5.6.0 5.6.1 5.6.2 5.7.0 5.8.0 5.8.1 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 7.0.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.2 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.2.1 7.2.2 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.4.0 7.4.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.4.9 7.5.0 7.5.1
shortcodes-ultimate / freemius / includes / class-fs-lock.php
shortcodes-ultimate / freemius / includes Last commit date
customizer 2 weeks ago debug 2 weeks ago entities 2 weeks ago managers 2 weeks ago sdk 2 weeks ago supplements 2 weeks ago class-freemius-abstract.php 2 weeks ago class-freemius.php 2 weeks ago class-fs-admin-notices.php 2 weeks ago class-fs-api.php 2 weeks ago class-fs-garbage-collector.php 2 weeks ago class-fs-hook-snapshot.php 2 weeks ago class-fs-lock.php 2 weeks ago class-fs-logger.php 2 weeks ago class-fs-options.php 2 weeks ago class-fs-plugin-updater.php 2 weeks ago class-fs-security.php 2 weeks ago class-fs-storage.php 2 weeks ago class-fs-user-lock.php 2 weeks ago fs-core-functions.php 2 weeks ago fs-essential-functions.php 2 weeks ago fs-html-escaping-functions.php 2 weeks ago fs-plugin-info-dialog.php 2 weeks ago index.php 2 weeks ago l10n.php 2 weeks ago
class-fs-lock.php
110 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 2.5.1
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Class FS_Lock
15 *
16 * @author Vova Feldman (@svovaf)
17 * @since 2.5.1
18 */
19 class FS_Lock {
20 /**
21 * @var int Random ID representing the current PHP thread.
22 */
23 private static $_thread_id;
24 /**
25 * @var string
26 */
27 private $_lock_id;
28
29 /**
30 * @param string $lock_id
31 */
32 function __construct( $lock_id ) {
33 if ( ! fs_starts_with( $lock_id, WP_FS___OPTION_PREFIX ) ) {
34 $lock_id = WP_FS___OPTION_PREFIX . $lock_id;
35 }
36
37 $this->_lock_id = $lock_id;
38
39 if ( ! isset( self::$_thread_id ) ) {
40 self::$_thread_id = mt_rand( 0, 32000 );
41 }
42 }
43
44 /**
45 * Try to acquire lock. If the lock is already set or is being acquired by another locker, don't do anything.
46 *
47 * @param int $expiration
48 *
49 * @return bool TRUE if successfully acquired lock.
50 */
51 function try_lock( $expiration = 0 ) {
52 if ( $this->is_locked() ) {
53 // Already locked.
54 return false;
55 }
56
57 set_site_transient( $this->_lock_id, self::$_thread_id, $expiration );
58
59 if ( $this->has_lock() ) {
60 $this->lock($expiration);
61
62 return true;
63 }
64
65 return false;
66 }
67
68 /**
69 * Acquire lock regardless if it's already acquired by another locker or not.
70 *
71 * @author Vova Feldman (@svovaf)
72 * @since 2.1.0
73 *
74 * @param int $expiration
75 */
76 function lock( $expiration = 0 ) {
77 set_site_transient( $this->_lock_id, true, $expiration );
78 }
79
80 /**
81 * Checks if lock is currently acquired.
82 *
83 * @author Vova Feldman (@svovaf)
84 * @since 2.1.0
85 *
86 * @return bool
87 */
88 function is_locked() {
89 return ( false !== get_site_transient( $this->_lock_id ) );
90 }
91
92 /**
93 * Unlock the lock.
94 *
95 * @author Vova Feldman (@svovaf)
96 * @since 2.1.0
97 */
98 function unlock() {
99 delete_site_transient( $this->_lock_id );
100 }
101
102 /**
103 * Checks if lock is currently acquired by the current locker.
104 *
105 * @return bool
106 */
107 protected function has_lock() {
108 return ( self::$_thread_id == get_site_transient( $this->_lock_id ) );
109 }
110 }