Ignore:
Timestamp:
Dec 27, 2022, 7:50:23 PM (17 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package to latest version.
  • Modified: Fixes related to PHP 8.x.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Update.php

    r880 r888  
    33class UpdateManager
    44{
    5   var $Revision;
    6   var $Trace;
    7   var $VersionTable;
    8   /* @var Database */
    9   var $Database;
    10   var $InstallMethod;
     5  public int $Revision;
     6  public array $Trace;
     7  public string $VersionTable;
     8  public Database $Database;
     9  public string $InstallMethod;
    1110
    1211  function __construct()
     
    1918  }
    2019
    21   function GetDbVersion()
     20  function GetDbVersion(): ?int
    2221  {
    2322    $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1');
     
    2625  }
    2726
    28   function IsInstalled()
     27  function IsInstalled(): bool
    2928  {
    3029    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
     
    3231  }
    3332
    34   function IsUpToDate()
     33  function IsUpToDate(): bool
    3534  {
    3635    return $this->Revision <= $this->GetDbVersion();
    3736  }
    3837
    39   function Upgrade()
     38  function Upgrade(): string
    4039  {
    4140    $DbRevision = $this->GetDbVersion();
     
    4342    while ($this->Revision > $DbRevision)
    4443    {
     44      if (!array_key_exists($DbRevision, $this->Trace))
     45        die('Missing upgrade trace for revision '.$DbRevision);
    4546      $TraceItem = $this->Trace[$DbRevision];
    4647      $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>';
     
    5758  }
    5859
    59   function Install()
     60  function Install(): void
    6061  {
    6162    $InstallMethod = $this->InstallMethod;
    6263    $InstallMethod($this);
    63     $this->Update();
    6464  }
    6565
    66   function Uninstall()
     66  function Uninstall(): void
    6767  {
    68 
    6968  }
    7069
    71   function InsertSampleData()
     70  function InsertSampleData(): void
    7271  {
    7372    $InstallMethod = $this->InsertSampleDataMethod;
     
    7574  }
    7675
    77   function Execute($Query)
     76  function Execute(string $Query): DatabaseResult
    7877  {
    7978    echo($Query.';<br/>');
Note: See TracChangeset for help on using the changeset viewer.