mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-07 08:14:42 +03:00
Send instance ID to the updates server
This commit is contained in:
parent
6bf331b355
commit
5af9f92102
@ -151,6 +151,10 @@ class CronWorker
|
|||||||
{
|
{
|
||||||
if (is_null($this->updateChecker)) {
|
if (is_null($this->updateChecker)) {
|
||||||
$this->updateChecker = new UpdateChecker();
|
$this->updateChecker = new UpdateChecker();
|
||||||
|
$id = Settings::get('_instance_id');
|
||||||
|
if ($id) {
|
||||||
|
$this->updateChecker->setInstanceId($id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->updateChecker;
|
return $this->updateChecker;
|
||||||
|
@ -34,6 +34,13 @@ class UpdateChecker
|
|||||||
*/
|
*/
|
||||||
private $url = null;
|
private $url = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique 64 character length ID of the Mibew instance.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $instanceId = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cache for plugins info array.
|
* A cache for plugins info array.
|
||||||
*
|
*
|
||||||
@ -72,6 +79,34 @@ class UpdateChecker
|
|||||||
: $this->url;
|
: $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Unique ID of the Mibew instance.
|
||||||
|
*
|
||||||
|
* @param string $id Unique ID that is 64 characters length at most.
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function setInstanceId($id)
|
||||||
|
{
|
||||||
|
if (strlen($id) > 64) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'The ID is too long. It can be 64 characters length at most.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the ID is always a string.
|
||||||
|
$this->instanceId = $id ?: '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Unique ID of the Mibew instance.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getInstanceId()
|
||||||
|
{
|
||||||
|
return $this->instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves list of errors that took place during update checking process.
|
* Retrieves list of errors that took place during update checking process.
|
||||||
*
|
*
|
||||||
@ -157,10 +192,18 @@ class UpdateChecker
|
|||||||
*/
|
*/
|
||||||
protected function getSystemInfo()
|
protected function getSystemInfo()
|
||||||
{
|
{
|
||||||
return array(
|
$info = array(
|
||||||
'core' => MIBEW_VERSION,
|
'core' => MIBEW_VERSION,
|
||||||
'plugins' => $this->getPluginsInfo(),
|
'plugins' => $this->getPluginsInfo(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Attach Instance ID to the info but only if it's not empty.
|
||||||
|
$id = $this->getInstanceId();
|
||||||
|
if ($id) {
|
||||||
|
$info['uid'] = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user