diff --git a/extension/Classes/Core/Helper/SqlQuery.php b/extension/Classes/Core/Helper/SqlQuery.php index b518b84c3914c7218e6284fc52da04b5eaaa12f2..53e9fafbd0d8e4899faf48b59416b71ef0009a84 100644 --- a/extension/Classes/Core/Helper/SqlQuery.php +++ b/extension/Classes/Core/Helper/SqlQuery.php @@ -37,9 +37,8 @@ class SqlQuery { } /** - * Create SQL query which inserts the values of the given associative arry into the given table. + * Create SQL query which inserts the values of the given associative array into the given table. * Returns prepared INSERT statement together with a parameter array. - * There must be at least one value given. * * @param $tableName * @param array $values array(column => value) @@ -48,12 +47,14 @@ class SqlQuery { */ public static function insertRecord($tableName, array $values): array { - if (count($values) === 0) - throw new \CodeException('No columns given to insert - this should not happen.', ERROR_CODE_SHOULD_NOT_HAPPEN); + if (count($values) === 0) { + $sql = "INSERT INTO `$tableName` VALUES ()"; + return array($sql, []); + } $paramList = str_repeat('?, ', count($values)); $paramList = substr($paramList, 0, strlen($paramList) - 2); $columnList = '`' . implode('`, `', array_keys($values)) . '`'; - $sql = "INSERT INTO `$tableName` ( " . $columnList . " ) VALUES ( " . $paramList . ' )'; + $sql = "INSERT INTO `$tableName` ( $columnList ) VALUES ( $paramList )"; $parameterArray = array_values($values); return array($sql, $parameterArray); } diff --git a/extension/Classes/Core/QuickFormQuery.php b/extension/Classes/Core/QuickFormQuery.php index a6606ce1df88ea05a52cb7d1ce6fca24451f61da..48174ef549da371a49d3762585ac480418bf4a9f 100644 --- a/extension/Classes/Core/QuickFormQuery.php +++ b/extension/Classes/Core/QuickFormQuery.php @@ -456,8 +456,8 @@ class QuickFormQuery { // FormAsFile: Get the new and the old form file name and make sure both files are writable (before DB changes are made) // Note: This can't be done earlier because $formModeNew might be changed in the lines above. - $formNameDB = FormAsFile::formNameFromFormRelatedRecord($recordId, $this->formSpec[F_TABLE_NAME], $this->dbArray[$this->dbIndexQfq]); - switch ($this->formSpec[F_TABLE_NAME]) { + $formNameDB = FormAsFile::formNameFromFormRelatedRecord($recordId, $this->formSpec[F_TABLE_NAME] ?? '', $this->dbArray[$this->dbIndexQfq]); + switch ($this->formSpec[F_TABLE_NAME] ?? '') { case TABLE_NAME_FORM: // cases covered: new form, existing form, existing form but form name changed $formFileName = $this->store->getVar(F_NAME, STORE_FORM, SANITIZE_ALLOW_ALNUMX); $formFileName = $formFileName === false ? $formNameDB : $formFileName; @@ -683,7 +683,7 @@ class QuickFormQuery { FormAsFile::exportForm($formFileName, $this->dbArray[$this->dbIndexQfq]); break; case FORM_DELETE: - if (TABLE_NAME_FORM_ELEMENT === $this->formSpec[F_TABLE_NAME]) { + if (TABLE_NAME_FORM_ELEMENT === ($this->formSpec[F_TABLE_NAME] ?? '')) { FormAsFile::exportForm($formFileName, $this->dbArray[$this->dbIndexQfq]); } else { FormAsFile::deleteFormFile($formFileName, $this->dbArray[$this->dbIndexQfq]); @@ -1743,8 +1743,8 @@ class QuickFormQuery { $beUserLoggedIn = $this->store->getVar(TYPO3_BE_USER, STORE_TYPO3, SANITIZE_ALLOW_ALNUMX); if ($beUserLoggedIn && $this->inlineReport) { - $html .= $this->buildInlineReport($this->t3data[T3DATA_UID], $this->t3data[T3DATA_REPORT_PATH_FILENAME], - $this->t3data[T3DATA_BODYTEXT_RAW], $this->t3data[T3DATA_HEADER]); + $html .= $this->buildInlineReport($this->t3data[T3DATA_UID] ?? null, $this->t3data[T3DATA_REPORT_PATH_FILENAME] ?? null, + $this->t3data[T3DATA_BODYTEXT_RAW] ?? '', $this->t3data[T3DATA_HEADER] ?? ''); } $html .= $report->process($this->t3data[T3DATA_BODYTEXT]); diff --git a/extension/Classes/Core/Save.php b/extension/Classes/Core/Save.php index 0367e48060c977b7a252fef43734c6c2c3831451..6f77468da616e3c179c306362200b1e962202a8a 100644 --- a/extension/Classes/Core/Save.php +++ b/extension/Classes/Core/Save.php @@ -447,7 +447,7 @@ class Save { * @param int $recordId * @param string $primaryKey * - * @return bool|int false if $values is empty, else affectedrows + * @return bool|int false if $values is empty, else affected rows * @throws \CodeException * @throws \DbException * @throws \UserFormException