From b9e7656365232481a34d986d17e3b5bcd213e824 Mon Sep 17 00:00:00 2001 From: wilpig Date: Thu, 25 May 2023 19:07:33 -0500 Subject: [PATCH] Correction for new installs Correction to rights check to account for the addition of assets/drawings,pictures in the preflight that is throwing a confusing error condition Added an exception handler to the config.inc.php to handle new installs that aren't populated yet so the construct function was erroring and preventing the rest of the sql load from happening --- config.inc.php | 34 +++++++++++++++++++++------------- rightscheck.php | 5 +++-- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/config.inc.php b/config.inc.php index d97731a32..28fd76280 100644 --- a/config.inc.php +++ b/config.inc.php @@ -9,22 +9,30 @@ function __construct(){ //Get parameter value pairs from fac_Config $sql='select Parameter, Value, DefaultVal from fac_Config'; - $sth=$dbh->prepare($sql); - $sth->execute(); - while ($row = $sth->fetch()) { - if ($row['Parameter']== 'ClassList'){ - $List = explode(', ', $row['Value']); - $this->ParameterArray[$row['Parameter']]=$List; - $this->defaults[$row['Parameter']]=$row['DefaultVal']; - }else{ - // this allows us to support quotes in paths for whatever reason - if(preg_match('/.*path$|PDFLogoFile/',$row['Parameter'])){ - $this->ParameterArray[$row['Parameter']]=html_entity_decode($row['Value'],ENT_QUOTES); + $sth=$dbh->prepare($sql); + // this gets called via db.inc on a new install and will throw an exception + // this prevents that and allows the install to continue and call this again + // later and populate correctly + try { + $sth->execute(); + while ($row = $sth->fetch()) { + if ($row['Parameter']== 'ClassList'){ + $List = explode(', ', $row['Value']); + $this->ParameterArray[$row['Parameter']]=$List; + $this->defaults[$row['Parameter']]=$row['DefaultVal']; }else{ - $this->ParameterArray[$row['Parameter']]=$row['Value']; + // this allows us to support quotes in paths for whatever reason + if(preg_match('/.*path$|PDFLogoFile/',$row['Parameter'])){ + $this->ParameterArray[$row['Parameter']]=html_entity_decode($row['Value'],ENT_QUOTES); + }else{ + $this->ParameterArray[$row['Parameter']]=$row['Value']; + } + $this->defaults[$row['Parameter']]=$row['DefaultVal']; } - $this->defaults[$row['Parameter']]=$row['DefaultVal']; } + } catch (PDOException $e) { + $info=$e->getMessage(); + error_log("UpdateConfig::PDO Error: {$info} SQL=$sql"); } return; } diff --git a/rightscheck.php b/rightscheck.php index 3ac7c5d74..7c53653f1 100644 --- a/rightscheck.php +++ b/rightscheck.php @@ -17,7 +17,7 @@ $grpid=exec('id -g'); // The directories we want writable for uploads -$wantedpaths=array('drawings', 'pictures'); +$wantedpaths=array('drawings', 'pictures','assets/drawings','assets/pictures'); print " @@ -107,7 +107,8 @@ function printrow($file,&$wantedpaths,$userid,$grpid){ } # Add in extra paths here that aren't part of the root loop. -printrow('vendor'.DIRECTORY_SEPARATOR.'mpdf'.DIRECTORY_SEPARATOR.'mpdf'.DIRECTORY_SEPARATOR.'ttfontdata',$wantedpaths,$userid,$grpid); +printrow('assets'.DIRECTORY_SEPARATOR.'drawings',$wantedpaths,$userid,$grpid); +printrow('assets'.DIRECTORY_SEPARATOR.'pictures',$wantedpaths,$userid,$grpid); # Handle paths that may or may not be set in the configuration screen for docker # clowns.