Commit 6716855e authored by Thomas Löffler's avatar Thomas Löffler

Replaces old styled db connections

parent ef328aa8
Pipeline #1900 passed with stages
in 2 minutes and 12 seconds
......@@ -134,18 +134,18 @@ class tx_ter_helper
*/
public function getValidUser($accountData)
{
global $TYPO3_DB, $TSFE;
global $TSFE;
if (!strlen($accountData->username) || (!strlen($accountData->password))) {
throw new tx_ter_exception_unauthorized ('No user or no password submitted.', TX_TER_ERROR_GENERAL_NOUSERORPASSWORD);
}
$res = $TYPO3_DB->exec_SELECTquery(
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'*', 'fe_users',
'username=' . $TYPO3_DB->fullQuoteStr($accountData->username, 'fe_users') . $TSFE->sys_page->enableFields('fe_users')
'username=' . $this->getDatabaseConnection()->fullQuoteStr($accountData->username, 'fe_users') . $TSFE->sys_page->enableFields('fe_users')
);
if ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
$objPHPass = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($row['password']);
// we do not consider 'C' or 'M' prefixed salted password hashes
// as password strings on typo3.org are not updated ones
......@@ -200,13 +200,13 @@ class tx_ter_helper
$success = false;
} else {
$success = false;
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*', 'fe_users', 'username=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'*', 'fe_users', 'username=' . $this->getDatabaseConnection()->fullQuoteStr(
$accountData->username, 'fe_users'
) . $GLOBALS['TSFE']->sys_page->enableFields('fe_users')
);
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
$objPHPass = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($row['password']);
// we do not consider 'C' or 'M' prefixed salted password hashes
// as password strings on typo3.org are not updated ones
......@@ -217,7 +217,7 @@ class tx_ter_helper
$success = true;
}
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
$this->getDatabaseConnection()->sql_free_result($res);
}
return $success;
......@@ -235,15 +235,13 @@ class tx_ter_helper
*/
public function extensionKeyIsAvailable($extensionKey)
{
global $TYPO3_DB;
$cleanedExtensionKey = str_replace('_', '', $extensionKey);
$isAvailable = true;
$res = $TYPO3_DB->exec_SELECTquery(
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'extensionkey', 'tx_ter_extensionkeys', 'pid=' . intval($this->pluginObj->extensionsPID)
);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
while ($row = $this->getDatabaseConnection()->sql_fetch_row($res)) {
if ($cleanedExtensionKey === str_replace('_', '', $row[0])) {
$isAvailable = false;
}
......@@ -284,14 +282,12 @@ class tx_ter_helper
*/
public function getLatestVersionNumberOfExtension($extensionKey)
{
global $TYPO3_DB;
$res = $TYPO3_DB->exec_SELECTquery(
'version', 'tx_ter_extensions', 'extensionkey=' . $TYPO3_DB->fullQuoteStr($extensionKey, 'tx_ter_extensions') . '
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'version', 'tx_ter_extensions', 'extensionkey=' . $this->getDatabaseConnection()->fullQuoteStr($extensionKey, 'tx_ter_extensions') . '
AND pid=' . intval($this->pluginObj->extensionsPID)
);
$latestVersion = false;
while ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
if (version_compare($row['version'], $latestVersion, '>')) {
$latestVersion = $row['version'];
}
......@@ -330,8 +326,6 @@ class tx_ter_helper
*/
public function writeExtensionIndexfile()
{
global $TYPO3_DB;
GeneralUtility::devLog('writing extension index!', 'tx_ter_helper', 0);
if (!@is_dir($this->pluginObj->repositoryDir)) {
throw new tx_ter_exception_internalServerError(
......@@ -341,27 +335,27 @@ class tx_ter_helper
$trackTime = microtime();
$res = $TYPO3_DB->exec_SELECTquery(
$res = $this->getDatabaseConnection()->exec_SELECTquery(
'uid,tstamp,extensionkey,version,title,description,state,reviewstate,category,downloadcounter,t3xfilemd5',
'tx_ter_extensions', '1'
);
// Read the extension records from the DB:
$extensionsAndVersionsArr = [];
$extensionsTotalDownloadsArr = [];
while ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
$res2 = $TYPO3_DB->exec_SELECTquery(
while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
$res2 = $this->getDatabaseConnection()->exec_SELECTquery(
'ownerusername,downloadcounter', 'tx_ter_extensionkeys',
'extensionkey=' . $TYPO3_DB->fullQuoteStr($row['extensionkey'], 'tx_ter_extensionkeys')
'extensionkey=' . $this->getDatabaseConnection()->fullQuoteStr($row['extensionkey'], 'tx_ter_extensionkeys')
);
$extensionKeyRow = $TYPO3_DB->sql_fetch_assoc($res2);
$extensionKeyRow = $this->getDatabaseConnection()->sql_fetch_assoc($res2);
$row['ownerusername'] = $extensionKeyRow['ownerusername'];
$extensionsTotalDownloadsArr[$row['extensionkey']] = $extensionKeyRow['downloadcounter'];
$res2 = $TYPO3_DB->exec_SELECTquery(
$res2 = $this->getDatabaseConnection()->exec_SELECTquery(
'lastuploaddate,uploadcomment,dependencies,composerinfo,authorname,authoremail,authorcompany',
'tx_ter_extensiondetails', 'extensionuid=' . (int)$row['uid']
);
$detailsRow = $TYPO3_DB->sql_fetch_assoc($res2);
$detailsRow = $this->getDatabaseConnection()->sql_fetch_assoc($res2);
if (is_array($detailsRow)) {
$row = $row + $detailsRow;
}
......
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