PMA\libraries\VersionInformation::getLatestVersion PHP 메소드

getLatestVersion() 공개 메소드

Returns information with latest version from phpmyadmin.net
public getLatestVersion ( ) : object
리턴 object JSON decoded object with the data
    public function getLatestVersion()
    {
        if (!$GLOBALS['cfg']['VersionCheck']) {
            return null;
        }
        // Get response text from phpmyadmin.net or from the session
        // Update cache every 6 hours
        if (isset($_SESSION['cache']['version_check']) && time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6) {
            $save = false;
            $response = $_SESSION['cache']['version_check']['response'];
        } else {
            $save = true;
            $file = 'https://www.phpmyadmin.net/home_page/version.json';
            $response = Util::httpRequest($file, "GET");
        }
        $response = $response ? $response : '{}';
        /* Parse response */
        $data = json_decode($response);
        /* Basic sanity checking */
        if (!is_object($data) || empty($data->version) || empty($data->releases) || empty($data->date)) {
            return null;
        }
        if ($save) {
            $_SESSION['cache']['version_check'] = array('response' => $response, 'timestamp' => time());
        }
        return $data;
    }

Usage Example

 /**
  * Test version checking
  *
  * @return void
  *
  * @group large
  */
 public function testGetLatestVersion()
 {
     $GLOBALS['cfg']['ProxyUrl'] = PROXY_URL;
     $GLOBALS['cfg']['ProxyUser'] = PROXY_USER;
     $GLOBALS['cfg']['ProxyPass'] = PROXY_PASS;
     $GLOBALS['cfg']['VersionCheck'] = true;
     $versionInformation = new VersionInformation();
     $version = $versionInformation->getLatestVersion();
     $this->assertNotEmpty($version->version);
     $this->assertNotEmpty($version->date);
 }
All Usage Examples Of PMA\libraries\VersionInformation::getLatestVersion