Skip to content

Commit

Permalink
[FEATURE] Add compatibility to TYPO3 9.4
Browse files Browse the repository at this point in the history
Unfortunately this means to drop support for TYPO3 7.6 as Doctrine Api
needs to be used.
  • Loading branch information
IchHabRecht committed Sep 12, 2018
1 parent cbc9758 commit 7887ac8
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 95 deletions.
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ script:
jobs:
fast_finish: true
include:
- stage: test
php: 7.2
env: TYPO3=^9.4
- stage: test
php: 7.2
env: TYPO3=^8.7
Expand All @@ -77,12 +80,6 @@ jobs:
- stage: test
php: 7.0
env: TYPO3=^8.7
- stage: test
php: 5.6
env: TYPO3=^7.6
- stage: test
php: 5.5
env: TYPO3=^7.6

- stage: 🚢 to ter
if: tag IS present AND env(TYPO3_ORG_USERNAME) IS present AND env(TYPO3_ORG_PASSWORD) IS present
Expand Down Expand Up @@ -122,7 +119,7 @@ jobs:
script:
- >
if [ -d "Tests" ]; then
for TYPO3 in "^7.6" "^8.7"; do
for TYPO3 in "^8.7" "^9.4"; do
echo;
echo "Running TYPO3 version $TYPO3";
Expand Down
30 changes: 13 additions & 17 deletions Classes/Hooks/ResetMissingFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* LICENSE file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;

class ResetMissingFiles
Expand All @@ -33,21 +34,16 @@ public function processDatamap_afterDatabaseOperations($status, $table, $id)
) {
return;
}
$databaseConnection = $this->getDatabaseConnection();
$databaseConnection->exec_UPDATEquery(
'sys_file',
'storage=' . (int)$id . ' AND missing=1',
[
'missing' => 0,
]
);
}

/**
* @return DatabaseConnection
*/
protected function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file');
$expressionBuilder = $queryBuilder->expr();
$queryBuilder->update('sys_file')
->where(
$expressionBuilder->eq(
'storage',
$queryBuilder->createNamedParameter((int)$id, \PDO::PARAM_INT)
)
)
->set('missing', 0)
->execute();
}
}
53 changes: 28 additions & 25 deletions Classes/Resource/Domain/DomainResourceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* LICENSE file that was distributed with this source code.
*/

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class DomainResourceRepository
Expand All @@ -28,38 +28,41 @@ public function findAll()
{
$domainResources = [];

$databaseConnection = $this->getDatabaseConnection();

$orderBy = '';
$orderBy = [];
if (!empty($GLOBALS['TCA']['sys_domain']['ctrl']['sortby'])) {
$orderBy = $GLOBALS['TCA']['sys_domain']['ctrl']['sortby'] . ' ASC';
$orderBy = [[$GLOBALS['TCA']['sys_domain']['ctrl']['sortby'], 'ASC']];
} elseif (!empty($GLOBALS['TCA']['sys_domain']['ctrl']['default_sortby'])) {
$orderBy = $databaseConnection->stripOrderBy($GLOBALS['TCA']['sys_domain']['ctrl']['default_sortby']);
$orderBy = QueryHelper::parseOrderBy($GLOBALS['TCA']['sys_domain']['ctrl']['default_sortby']);
}

$result = $databaseConnection->exec_SELECTquery(
'domainName',
'sys_domain',
'domainName!=' . $databaseConnection->fullQuoteStr(GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'), 'sys_domain')
. ' AND redirectTo=' . $databaseConnection->fullQuoteStr('', 'sys_domain')
. BackendUtility::deleteClause('sys_domain'),
'',
$orderBy
);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_domain');
$expressionBuilder = $queryBuilder->expr();
$queryBuilder->select('domainName')
->from('sys_domain')
->where(
$expressionBuilder->neq(
'domainName',
$queryBuilder->createNamedParameter(GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'), \PDO::PARAM_STR)
)
);
if (version_compare(TYPO3_version, '<', '9')) {
$queryBuilder->andWhere(
$expressionBuilder->eq(
'redirectTo',
$queryBuilder->createNamedParameter('', \PDO::PARAM_STR)
)
);
}
foreach ($orderBy as $orderByAndDirection) {
$queryBuilder->addOrderBy(...$orderByAndDirection);
}
$result = $queryBuilder->execute();

while ($row = $result->fetch_assoc()) {
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
$url = 'http://' . $row['domainName'];
$domainResources[] = GeneralUtility::makeInstance(DomainResource::class, $url);
}

return $domainResources;
}

/**
* @return DatabaseConnection
*/
protected function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
}
33 changes: 17 additions & 16 deletions Classes/Resource/Placeholder/PlaceholderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

use IchHabRecht\Filefill\Resource\RemoteResourceInterface;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceFactory;
Expand Down Expand Up @@ -74,13 +74,22 @@ public function hasFile($fileIdentifier, $filePath)
return false;
}
} else {
$databaseConnection = $this->getDatabaseConnection();
$databaseRow = $databaseConnection->exec_SELECTgetSingleRow(
'*',
'sys_file_processedfile',
'storage = ' . (int)$storage->getUid() .
' AND identifier = ' . $databaseConnection->fullQuoteStr($fileIdentifier, 'sys_file_processedfile')
);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_processedfile');
$expressionBuilder = $queryBuilder->expr();
$databaseRow = $queryBuilder->select('*')
->from('sys_file_processedfile')
->where(
$expressionBuilder->eq(
'storage',
$queryBuilder->createNamedParameter((int)$storage->getUid(), \PDO::PARAM_INT)
),
$expressionBuilder->eq(
'identifier',
$queryBuilder->createNamedParameter($fileIdentifier, \PDO::PARAM_STR)
)
)
->execute()
->fetch(\PDO::FETCH_ASSOC);
if (empty($databaseRow)) {
static::$fileIdentifierCache[$fileIdentifier] = false;

Expand Down Expand Up @@ -139,12 +148,4 @@ public function getFile(

return $content;
}

/**
* @return DatabaseConnection
*/
protected function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
}
57 changes: 30 additions & 27 deletions Classes/UserFunc/CheckMissingFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* LICENSE file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -24,59 +24,62 @@
class CheckMissingFiles
{
/**
* @param array $parameterArray
* @var LanguageService
*/
protected $languageService;

public function __construct(LanguageService $languageService = null)
{
$this->languageService = $languageService ?: $GLOBALS['LANG'];
}

/**
* @return string
*/
public function render(array $parameterArray)
{
$databaseConnection = $this->getDatabaseConnection();
$count = $databaseConnection->exec_SELECTcountRows(
'*',
'sys_file',
'storage=' . (int)$parameterArray['row']['uid'] . ' AND missing=1'
);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file');
$expressionBuilder = $queryBuilder->expr();
$count = $queryBuilder->count('*')
->from('sys_file')
->where(
$expressionBuilder->eq(
'storage',
$queryBuilder->createNamedParameter((int)$parameterArray['row']['uid'], \PDO::PARAM_INT)
),
$expressionBuilder->eq(
'missing',
$queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)
)
)
->execute()
->fetchColumn(0);

$html = [];
$html[] = '<div class="form-control-wrap">';

if ($count === 0) {
$html[] = '<span class="badge badge-success">'
. $this->getLanguageService()->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.no_missing')
. $this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.no_missing')
. '</span>';
} else {
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$html[] = '<span class="badge badge-danger">'
. sprintf(
$this->getLanguageService()->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.missing_files'),
$this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.missing_files'),
$count
)
. '</span>';
$html[] = '</div>';
$html[] = '<div class="form-control-wrap t3js-module-docheader">';
$html[] = '<a class="btn btn-default t3js-editform-submitButton" data-name="_save_tx_filefill_missing" data-form="EditDocumentController" data-value="1">';
$html[] = $iconFactory->getIcon('actions-database-reload', Icon::SIZE_SMALL);
$html[] = ' ' . $this->getLanguageService()->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.reset');
$html[] = ' ' . $this->languageService->sL('LLL:EXT:filefill/Resources/Private/Language/locallang_db.xlf:sys_file_storage.filefill.reset');
$html[] = '</a>';
}

$html[] = '</div>';

return implode('', $html);
}

/**
* @return DatabaseConnection
*/
protected function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"typo3/cms-core": "^7.6 || ^8.7"
"typo3/cms-core": "^8.7 || >=9.4 <9.5"
},
"autoload": {
"psr-4": {
Expand All @@ -35,6 +35,9 @@
"bin-dir": ".Build/bin"
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"typo3/cms": {
"extension-key": "filefill",
"cms-package-dir": "{$vendor-dir}/typo3/cms",
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
array (
'depends' =>
array (
'typo3' => '7.6.0-8.7.99',
'typo3' => '8.7.0-9.4.99',
),
'conflicts' =>
array (
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey=filefill
sonar.projectName=ichhabrecht/filefill
sonar.projectVersion=1.x
sonar.projectVersion=2.x
sonar.sources=.
sonar.exclusions=.Build/**, Tests/**

Expand Down

0 comments on commit 7887ac8

Please sign in to comment.