PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / ArchiveProcessor / LoaderLock.php
matomo / app / core / ArchiveProcessor Last commit date
ArchivingStatus.php 5 months ago Loader.php 4 months ago LoaderLock.php 1 year ago Parameters.php 6 months ago PluginsArchiver.php 1 year ago PluginsArchiverException.php 2 years ago Record.php 3 months ago RecordBuilder.php 3 months ago Rules.php 3 months ago
LoaderLock.php
56 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\ArchiveProcessor;
10
11 use Piwik\Db;
12 use Piwik\SettingsPiwik;
13 class LoaderLock
14 {
15 public const MAX_LEN_LOCK_NAME = 64;
16 public const MAX_LOCK_TIME = 60;
17 //in seconds
18 protected $id;
19 /**
20 * @param string $id
21 * @throws \Exception
22 */
23 public function __construct($id)
24 {
25 // instanceId is needed for multi tenant database solution
26 $id = SettingsPiwik::getPiwikInstanceId() . $id;
27 if (mb_strlen($id) >= self::MAX_LEN_LOCK_NAME) {
28 //convert ot prefix and md5 full length
29 $id = mb_substr($id, 0, 32) . md5($id);
30 }
31 $this->id = $id;
32 }
33 public function setLock()
34 {
35 Db::fetchOne('SELECT GET_LOCK(?,?)', array($this->id, self::MAX_LOCK_TIME));
36 }
37 public function unLock()
38 {
39 Db::query('SELECT RELEASE_LOCK(?)', array($this->id));
40 }
41 public function getId()
42 {
43 return $this->id;
44 }
45 /**
46 * @description check if the lock is available to user
47 * @param string $key
48 * @return bool
49 * @throws \Exception
50 */
51 public static function isLockAvailable($key)
52 {
53 return (bool) Db::fetchOne('SELECT IS_FREE_LOCK(?)', [$key]);
54 }
55 }
56