Skip to content

Commit

Permalink
Correction for new installs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wilpig committed May 26, 2023
1 parent 4b82b96 commit b9e7656
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
34 changes: 21 additions & 13 deletions config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions rightscheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<table>
<tr>
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b9e7656

Please sign in to comment.