Skip to content

Commit 5f8a81f

Browse files
committed
Some more TYPO3 9 compatibility fixes, typo3db_legacy is required
1 parent 864b8c6 commit 5f8a81f

6 files changed

Lines changed: 26 additions & 43 deletions

File tree

Classes/Controller/LinkFixController.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@
3131
*/
3232
class LinkFixController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
3333

34+
private $db;
35+
3436
/**
3537
* @var \TYPO3\CMS\Core\DataHandling\DataHandler
3638
*/
3739
protected $dataHandler;
3840

41+
function __construct() {
42+
$this->db = \Bednarik\Cooluri\Core\DB::getInstance();
43+
}
44+
45+
3946
/**
4047
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler
4148
*
@@ -52,19 +59,23 @@ public function listAction($url = NULL) {
5259
$this->view->assign('url',$url);
5360

5461
if (!empty($url)) {
55-
$urls = $this->getUrls($url);
56-
foreach ($urls as $u) {
57-
$u['parameters'] = http_build_query (unserialize($u['params']));
62+
$q = $this->getUrls($url);
63+
$urls = [];
64+
if ($q !== false) {
65+
while (($u = $this->db->fetch($q)) != null) {
66+
$u['parameters'] = http_build_query (unserialize($u['params']));
67+
$urls[] = $u;
68+
}
69+
$this->view->assign('urls', $urls);
5870
}
59-
$this->view->assign('urls', $urls);
6071
}
6172
}
6273

6374
/**
6475
* @param int $id
6576
*/
6677
public function deleteAction($id) {
67-
$GLOBALS['TYPO3_DB']->exec_DELETEquery('link_cache','id = '.(int)$id);
78+
$this->db->query('DELETE FROM link_cache WHERE id='.(int)$id.' LIMIT 1');
6879
$this->dataHandler->start(NULL,NULL);
6980
$this->dataHandler->clear_cacheCmd('all');
7081
$this->addFlashMessage('A link has been removed from cache, please reload page where the link is present (not the page itself, but e.g. parent page with this link in menu) in order to generate it again.');
@@ -75,8 +86,6 @@ private function getUrls($url) {
7586
if (!empty($url)) {
7687
$parsedUrl = parse_url($url);
7788
if ($parsedUrl) {
78-
$parsedUrl['path'] = $GLOBALS['TYPO3_DB']->quoteStr($parsedUrl['path'],null);
79-
$parsedUrl['host'] = $GLOBALS['TYPO3_DB']->quoteStr($parsedUrl['host'],null);
8089
$possibleMatches = Array();
8190
$possibleMatches[] = $parsedUrl['path'];
8291
$possibleMatches[] = $parsedUrl['host'].'@'.$parsedUrl['path'];
@@ -93,7 +102,7 @@ private function getUrls($url) {
93102
$possibleMatches[] = $parsedUrl['host'].'@'.substr($parsedUrl['path'],1,strlen($parsedUrl['path'])-1);
94103
}
95104
$where = "(url = '".implode("' OR url='",$possibleMatches)."')";
96-
return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','link_cache',$where);
105+
return $this->db->query('SELECT * FROM link_cache WHERE ' .$where);
97106
}
98107
}
99108
return false;

Classes/Core/DBLayer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function escape($string, $tp = 'link_')
6060
return $this->conn->quote($string);
6161
}
6262

63+
public function quoteIdentifier($string)
64+
{
65+
return $this->conn->quoteIdentifier($string);
66+
}
67+
6368
public function error()
6469
{
6570
return $this->conn->errorCode();
@@ -75,5 +80,4 @@ public function affected_rows(\Doctrine\DBAL\Driver\Statement $res)
7580
return $res->rowCount();
7681
}
7782

78-
7983
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
],
1010
"type": "typo3-cms-extension",
1111
"require": {
12-
"typo3/cms-core": "^9.5"
12+
"typo3/cms-core": "^9.5",
13+
"friendsoftypo3/typo3db-legacy": "^1.1"
1314
},
1415
"replace": {
1516
"cooluri": "self.version",

ext_emconf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'constraints' => array(
1111
'depends' => array(
1212
'typo3' => '9.5.0-9.9.99',
13+
'typo3db_legacy' => '1.1.1-1.1.99'
1314
),
1415
),
1516
);

ext_tables.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@
3636

3737
}
3838

39-
$TCA['pages']['columns']['tx_realurl_pathsegment'] = array(
40-
'label' => 'LLL:EXT:cooluri/locallang_db.php:pages.tx_cooluri_pathsegment',
41-
'exclude' => 1,
42-
'config' => Array(
43-
'type' => 'input',
44-
'size' => '50',
45-
'max' => '255',
46-
'eval' => 'trim,nospace,lower,uniqueInPid'
47-
)
48-
);
49-
5039
$TCA['pages']['columns']['tx_cooluri_exclude'] = array(
5140
'label' => 'LLL:EXT:cooluri/locallang_db.php:pages.tx_cooluri_exclude',
5241
'exclude' => 1,
@@ -65,16 +54,4 @@
6554
)
6655
);
6756

68-
$TCA['pages_language_overlay']['columns']['tx_realurl_pathsegment'] = array(
69-
'label' => 'LLL:EXT:cooluri/locallang_db.php:pages.tx_cooluri_pathsegment',
70-
'exclude' => 1,
71-
'config' => Array(
72-
'type' => 'input',
73-
'size' => '50',
74-
'max' => '255',
75-
'eval' => 'trim,nospace,lower,uniqueInPid'
76-
)
77-
);
78-
79-
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment,tx_cooluri_exclude,tx_cooluri_excludealways', '1,2,5,4,254', 'after:nav_title');
80-
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages_language_overlay', 'tx_realurl_pathsegment', '1,2,5,4,254', 'after:nav_title');
57+
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_cooluri_exclude,tx_cooluri_excludealways', '1,2,5,4,254', 'after:nav_title');

ext_tables.sql

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@
22
# Table structure for table "pages"
33
#
44
CREATE TABLE pages (
5-
tx_realurl_pathsegment varchar(255) default '',
65
tx_cooluri_exclude tinyint(1) unsigned default '0',
76
tx_cooluri_excludealways tinyint(1) unsigned default '0'
87
);
98

10-
#
11-
# Table structure for table "pages_language_overlay"
12-
#
13-
CREATE TABLE pages_language_overlay (
14-
tx_realurl_pathsegment varchar(255) DEFAULT '' NOT NULL
15-
);
16-
17-
189
CREATE TABLE link_cache (
1910
id int(10) unsigned NOT NULL auto_increment,
2011
params blob,

0 commit comments

Comments
 (0)