Commit e6a7f746 authored by Marc Egger's avatar Marc Egger

Refs #10120 Dirty.php: remove form import since it breaks unittests and it is not important

parent 966bace2
Pipeline #3646 failed with stages
in 7 minutes and 52 seconds
......@@ -113,21 +113,18 @@ class Dirty {
throw new \CodeException("Missing 'form' in SIP. There might be something broken.", ERROR_DIRTY_MISSING_FORM_IN_SIP);
}
// Connect to Database
$this->store = Store::getInstance();
$this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
$this->dbIndexData = empty($sipVars[PARAM_DB_INDEX_DATA]) ? $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM) : $sipVars[PARAM_DB_INDEX_DATA];
$this->doDbArray($this->dbIndexData, $this->dbIndexQfq);
// import form file. If it was changed, throw exception.
FormAsFile::importForm($sipVars[SIP_FORM], $this->dbArray[$this->dbIndexQfq]);
$recordId = empty($sipVars[SIP_RECORD_ID]) ? 0 : $sipVars[SIP_RECORD_ID];
if ($recordId == 0) {
// For r=0 (new) , 'dirty' will always succeed.
return [API_STATUS => 'success', API_MESSAGE => ''];
}
$this->store = Store::getInstance();
$this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
$this->dbIndexData = empty($sipVars[PARAM_DB_INDEX_DATA]) ? $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM) : $sipVars[PARAM_DB_INDEX_DATA];
$this->doDbArray($this->dbIndexData, $this->dbIndexQfq);
$tableVars = $this->dbArray[$this->dbIndexQfq]->sql("SELECT `tableName`, `primaryKey`, `dirtyMode`, `recordLockTimeoutSeconds` FROM `Form` WHERE `name`=?", ROW_EXPECT_1, [$sipVars[SIP_FORM]], "Form not found: '" . $sipVars[SIP_FORM] . "'");
if (empty($tableVars[F_PRIMARY_KEY])) {
$tableVars[F_PRIMARY_KEY] = F_PRIMARY_KEY_DEFAULT;
......
......@@ -18,7 +18,7 @@ use IMATHUZH\Qfq\Core\Helper\SqlQuery;
// TODO: Carsten Fragen: ZUERST NOCHMAL GENAU NACHTEILE PRUEFEN: In doForm koennte man auch einfach pauschal importAllForms(enforce writeable=true) und exportAllForms() machen, wenn der geladene record ein Form/Formelement ist. Bei vielen forms koennte es langsam sein. ansonsten sehe ich gerade keine klaren nachteile.
// TODO: Carsten Fragen: Kann es sein, dass records in Dirty tabelle nicht mehr richtig abegraeumt werden, weil forms die ID wechseln?
// TODO: Carsten Fragen: Exceptions werden teilweise ohne Developer message angezeigt (API). Deshalb habe ich die Message teilweise in User message getan.
// TODO: Carsten Fragen: PHP version von gitlab runner hochstellen, damit ?string type syntax fuer funktionen erlaubt ist? verhindert einige fehler
// TODO: Carsten Fragen: PHP version von gitlab runner hochstellen, damit ?string und void type syntax fuer funktionen erlaubt ist? verhindert einige fehler
// TODO: BEFOORE PRUDUCTION
// TODO: add Exception hint as hint instead of in main message?
......@@ -213,7 +213,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
public static function exportForm(string $formName, Database $database)
public static function exportForm(string $formName, Database $database) // : void
{
// Get form from DB
$FORM = TABLE_NAME_FORM; // can't use constants in strings directly
......@@ -291,7 +291,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
public static function importFormRecordId(int $recordId, string $tableName, Database $database)
public static function importFormRecordId(int $recordId, string $tableName, Database $database) // : ?string
{
$recordFormName = self::formNameFromFormRelatedRecord($recordId, $tableName, $database);
if ($recordFormName !== null) {
......@@ -315,7 +315,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
public static function deleteFormFile($formName, Database $database)
public static function deleteFormFile($formName, Database $database) // : void
{
self::enforceFormFileWritable($formName, $database);
$pathFileName = self::formPathFileName($formName, $database);
......@@ -356,7 +356,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
public static function enforceFormFileWritable(string $formName, Database $database)
public static function enforceFormFileWritable(string $formName, Database $database) // : void
{
$pathFileName = self::formPathFileName($formName, $database);
if (file_exists($pathFileName)) {
......@@ -389,7 +389,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
public static function formNameFromFormRelatedRecord(int $recordId, string $recordTable, Database $database)
public static function formNameFromFormRelatedRecord(int $recordId, string $recordTable, Database $database) // : ?string
{
if ($recordId === 0) {
return null;
......@@ -450,7 +450,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
public static function importAllForms(Database $database, bool $enforceWritable = false, bool $deleteFromDB = false)
public static function importAllForms(Database $database, bool $enforceWritable = false, bool $deleteFromDB = false) // : void
{
// Import all form files
$formFileNames = self::formFileNames($database);
......@@ -481,7 +481,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
public static function exportAllForms(Database $database, bool $deleteFiles = false)
public static function exportAllForms(Database $database, bool $deleteFiles = false) // : void
{
$formNamesDB = self::queryAllFormNames($database);
foreach ($formNamesDB as $formNameDB) {
......@@ -535,7 +535,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
private static function deleteFormDB(string $formName, Database $database)
private static function deleteFormDB(string $formName, Database $database) // : void
{
$F_ID = F_ID; // can't use constants in strings directly
$F_NAME = F_NAME; // can't use constants in strings directly
......@@ -556,7 +556,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
private static function deleteFormDBWithId(int $formId, Database $database)
private static function deleteFormDBWithId(int $formId, Database $database) // : void
{
$F_ID = F_ID; // can't use constants in strings directly
$TABLE_NAME_FORM = TABLE_NAME_FORM; // can't use constants in strings directly
......@@ -573,7 +573,7 @@ class FormAsFile
* @throws \DbException
* @throws \UserFormException
*/
private static function deleteFormElementsDBWithFormId(int $formId, Database $database)
private static function deleteFormElementsDBWithFormId(int $formId, Database $database) // : void
{
$TABLE_NAME_FORM_ELEMENT = TABLE_NAME_FORM_ELEMENT; // can't use constants in strings directly
$FE_FORM_ID = FE_FORM_ID; // can't use constants in strings directly
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment