Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Fixed Locking, part of #16
Browse files Browse the repository at this point in the history
  • Loading branch information
kimbtech committed Nov 22, 2018
1 parent 840a548 commit fe60e17
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions core/JSONReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct( $filename, $lockex = false){
$isfile = is_file( $this->filepath );

// file lock
$this->filehandler = fopen( $this->filepath, 'c+' );
$this->filehandler = fopen( $this->filepath . '.lock', 'c+' );
if( !flock( $this->filehandler, $lockex ? LOCK_EX : LOCK_SH ) ){
//Fehler
throw new Exception('Unable to lock file!');
Expand Down Expand Up @@ -136,13 +136,15 @@ private function write_content(){
//schreiben
$re = file_put_contents( $this->filepath, $json );
//Hash anpassen?
if( $re ){
if( $re !== false ){
$this->datahash = $nowhash;
}
//Rückgabe
return $re;
}
return false;
}
return true;
}
return false;
}
Expand Down Expand Up @@ -314,4 +316,4 @@ private function setValueHelper( $index, $value, $data ){
}
}

?>
?>
2 changes: 2 additions & 0 deletions core/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private function taskNew(){
$alert = new Template( 'alert' );
$this->includetemp->includeTemplate($alert);
$alert->setContent( 'ALERTMESSAGE', $capok ? ( $einwill ? $pollcreator->errorMessage() : LanguageManager::getTranslation('EinwillErr') ) : Captcha::getError() );
http_response_code(400);
}
}
$this->includetemp->setContent( 'FORMDEST', URL::generateLink('new') );
Expand Down Expand Up @@ -172,6 +173,7 @@ private function taskPoll(){
$alert = new Template( 'alert' );
$this->includetemp->includeTemplate($alert);
$alert->setContent( 'ALERTMESSAGE', $poll->getError() );
http_response_code(400);
}
//else { template done in saveSendData }
}
Expand Down
2 changes: 1 addition & 1 deletion core/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Utilities{
/**
* The system's Version
*/
const SYS_VERSION = 'v1.0.7alpha';
const SYS_VERSION = 'v1.0.8alpha';

/**
* Possible chars for:
Expand Down

0 comments on commit fe60e17

Please sign in to comment.