Commit bdaf7133 authored by Carsten  Rose's avatar Carsten Rose
Browse files

QfqController.php: E_NOTICE Errors are by default not catched by T3. For QFQ...

QfqController.php: E_NOTICE Errors are by default not catched by T3. For QFQ E_NOTICE will throw exceptions from now on
report/Log.php: unused variables commented out.
report/Variables.php: more detailed isset check.
AbstractBuildForm.php: rendering of 'subrecord delete links' broken if column 'id' is missing. Code, which switches from 'id' to '_id' have been already prepared, but was not completely implemented. Exception if neither 'id' nor '_id' exist in subrecord query.
parent 4ac6c6b6
......@@ -19,6 +19,12 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
try {
$contentObject = $this->configurationManager->getContentObject();
// By T3 default 'E_NOTICE' is unset. E.g. 'Undefined Index' will throw an exception.
// QFQ like to see those 'E_NOTICE'
$origErrorReporting = error_reporting();
error_reporting($origErrorReporting | E_NOTICE);
$qfq = new \qfq\QuickFormQuery($contentObject->data);
$html = $qfq->process();
......@@ -34,6 +40,9 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
$html = "Generic Exception: " . $e->getMessage();
}
// Restore has to be outside of try/catch - E_NOTICE needs to unset for further T3 handling after an QFQ Exception.
error_reporting($origErrorReporting);
$this->view->assign('qfqOutput', $html);
return $this->view->render();
}
......
......@@ -1426,7 +1426,8 @@ abstract class AbstractBuildForm {
}
if ($flagDelete) {
$s = $this->createDeleteUrl($targetTableName, $row['id'], RETURN_SIP);
// $s = $this->createDeleteUrl($targetTableName, $row[$nameColumnId], RETURN_SIP);
$s = $this->createDeleteUrl($targetTableName, $row[$nameColumnId], RETURN_SIP);
$rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete btn btn-default' data-sip='$s'>", '<span class="glyphicon ' . GLYPH_ICON_DELETE . '"></span>'));
}
......@@ -1449,6 +1450,7 @@ abstract class AbstractBuildForm {
* Prepare Subrecord:
* - check if the current record has an recordId>0. If not, subrecord can't be edited. Return a message.
* - check if there is an SELECT statement for the subrecords.
* - determine &$nameColumnId
*
* @param $formElement
* @param $primaryRecord
......@@ -1474,9 +1476,16 @@ abstract class AbstractBuildForm {
return true;
}
if (!isset($formElement['sql1'][0][$nameColumnId]))
// Check if $nameColumnId column exist.
if (!isset($formElement['sql1'][0][$nameColumnId])) {
// no: try fallback.
$nameColumnId = '_id';
if (!isset($formElement['sql1'][0][$nameColumnId])) {
throw new UserFormException('Missing column \'id\' or \'_id\' in subrecord query', ERROR_SUBRECORD_MISSING_COLUMN_ID);
}
}
if (!isset($formElement['sql1'][0][$nameColumnId])) {
throw new UserFormException('Missing column \'id\' (or "_id") in \'sql1\' Query', ERROR_DB_MISSING_COLUMN_ID);
}
......
......@@ -148,6 +148,9 @@ const ERROR_MISSING_MESSAGE_FAIL = 1063;
const ERROR_MISSING_TABLE_NAME = 1064;
const ERROR_RECORD_NOT_FOUND = 1065;
// Subrecord
const ERROR_SUBRECORD_MISSING_COLUMN_ID = 1066;
// Store
const ERROR_STORE_VALUE_ALREADY_CODPIED = 1100;
const ERROR_STORE_KEY_EXIST = 1101;
......
......@@ -13,6 +13,7 @@ class ErrorHandler {
public static function exception_error_handler($severity, $message, $file, $line) {
if (!(error_reporting() & $severity)) {
// This error code is not included in error_reporting
return false;
......
......@@ -61,42 +61,16 @@ class Log {
* @throws \Exception
*/
public function __construct(array $tmp_config) {
global $TYPO3_CONF_VARS;
$this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['sql']);
$this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['mail']);
$this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['error']);
$this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['browser']);
// global $TYPO3_CONF_VARS;
// $this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['sql']);
// $this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['mail']);
// $this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['error']);
// $this->prepare_log_file_dir($TYPO3_CONF_VARS[EXTKEY]['log']['browser']);
$this->config = $tmp_config;
} // __construct()
/**
* Check if path of logfile exists. No: create it.
* Check if path of logfile is writeable.
*
* @param string $filename Name of logfile
* @throws \Exception
*/
private function prepare_log_file_dir($filename) {
$this->logFile = $filename;
// extract optional path component
$path = dirname($filename);
// If there is a path: check if directories really exist and are writeable.
if ($path) {
if (file_exists($path)) {
// Directory already exists: check if it is writeable.
if (!is_writable($path)) throw new \Exception ("Failed: directory '$path' of Logfile '$filename' is not writeable.");
} else {
// Directoy doesn't exist: create it.
if (!mkdir($path, 0775, true))
throw new \Exception ("Failed to create directory '$path' for Logfile '$filename'");
}
}
}
/**
* Set Array fr_error: setter function to set most recent values.
* Will be shown in log messages.
......@@ -107,7 +81,7 @@ class Log {
*/
public function set_fr_error(array $fr_error) {
$this->fr_error = $fr_error;
} // prepare_log_file_dir()
}
/**
* log_sql: wrapper for log_do() for sql logging
......@@ -135,7 +109,7 @@ class Log {
$text .= "[$sql]";
$this->log_do('sql', $status, $origin, $text);
} // log_do()
} // prepare_log_file_dir()
/**
* log_do: format log entries, build fix part, append dynamic part, write.
......@@ -179,7 +153,7 @@ class Log {
// Write whole entry
$this->log_write($filename, $text);
} // log_sql()
} // log_do()
/**
* Logs every email (failed or successfull)
......@@ -209,6 +183,32 @@ class Log {
$this->log_do('mail', $status, $origin, $text);
} // log_sql()
/**
* Check if path of logfile exists. No: create it.
* Check if path of logfile is writeable.
*
* @param string $filename Name of logfile
* @throws \Exception
*/
private function prepare_log_file_dir($filename) {
$this->logFile = $filename;
// extract optional path component
$path = dirname($filename);
// If there is a path: check if directories really exist and are writeable.
if ($path) {
if (file_exists($path)) {
// Directory already exists: check if it is writeable.
if (!is_writable($path)) throw new \Exception ("Failed: directory '$path' of Logfile '$filename' is not writeable.");
} else {
// Directoy doesn't exist: create it.
if (!mkdir($path, 0775, true))
throw new \Exception ("Failed to create directory '$path' for Logfile '$filename'");
}
}
} // log_mail()
}
......@@ -143,8 +143,9 @@ class Variables {
// database aliases can be used in form sql queries (e.g. select * from "{{global.t3_name}}".fe_users...)
// localconf can be used to configure an application
$tmp = array();
if (isset($GLOBALS['TYPO3_CONF_VARS']))
if (isset($GLOBALS['TYPO3_CONF_VARS'][FORMREPORT])) {
$this->linearizeArray($GLOBALS['TYPO3_CONF_VARS'][FORMREPORT], $tmp);
}
// remove anything that contains "_password" "_username" in the key to prevent the webmaster from doing something stupid
foreach ($tmp as $key => $value) {
......
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