Skip to content

Commit

Permalink
Some more TYPO3 9 compatibility fixes, typo3db_legacy is required
Browse files Browse the repository at this point in the history
  • Loading branch information
bednee committed Dec 15, 2019
1 parent 864b8c6 commit 5f8a81f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 43 deletions.
25 changes: 17 additions & 8 deletions Classes/Controller/LinkFixController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@
*/
class LinkFixController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

private $db;

/**
* @var \TYPO3\CMS\Core\DataHandling\DataHandler
*/
protected $dataHandler;

function __construct() {
$this->db = \Bednarik\Cooluri\Core\DB::getInstance();
}


/**
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler
*
Expand All @@ -52,19 +59,23 @@ public function listAction($url = NULL) {
$this->view->assign('url',$url);

if (!empty($url)) {
$urls = $this->getUrls($url);
foreach ($urls as $u) {
$u['parameters'] = http_build_query (unserialize($u['params']));
$q = $this->getUrls($url);
$urls = [];
if ($q !== false) {
while (($u = $this->db->fetch($q)) != null) {
$u['parameters'] = http_build_query (unserialize($u['params']));
$urls[] = $u;
}
$this->view->assign('urls', $urls);
}
$this->view->assign('urls', $urls);
}
}

/**
* @param int $id
*/
public function deleteAction($id) {
$GLOBALS['TYPO3_DB']->exec_DELETEquery('link_cache','id = '.(int)$id);
$this->db->query('DELETE FROM link_cache WHERE id='.(int)$id.' LIMIT 1');
$this->dataHandler->start(NULL,NULL);
$this->dataHandler->clear_cacheCmd('all');
$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.');
Expand All @@ -75,8 +86,6 @@ private function getUrls($url) {
if (!empty($url)) {
$parsedUrl = parse_url($url);
if ($parsedUrl) {
$parsedUrl['path'] = $GLOBALS['TYPO3_DB']->quoteStr($parsedUrl['path'],null);
$parsedUrl['host'] = $GLOBALS['TYPO3_DB']->quoteStr($parsedUrl['host'],null);
$possibleMatches = Array();
$possibleMatches[] = $parsedUrl['path'];
$possibleMatches[] = $parsedUrl['host'].'@'.$parsedUrl['path'];
Expand All @@ -93,7 +102,7 @@ private function getUrls($url) {
$possibleMatches[] = $parsedUrl['host'].'@'.substr($parsedUrl['path'],1,strlen($parsedUrl['path'])-1);
}
$where = "(url = '".implode("' OR url='",$possibleMatches)."')";
return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','link_cache',$where);
return $this->db->query('SELECT * FROM link_cache WHERE ' .$where);
}
}
return false;
Expand Down
6 changes: 5 additions & 1 deletion Classes/Core/DBLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function escape($string, $tp = 'link_')
return $this->conn->quote($string);
}

public function quoteIdentifier($string)
{
return $this->conn->quoteIdentifier($string);
}

public function error()
{
return $this->conn->errorCode();
Expand All @@ -75,5 +80,4 @@ public function affected_rows(\Doctrine\DBAL\Driver\Statement $res)
return $res->rowCount();
}


}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
],
"type": "typo3-cms-extension",
"require": {
"typo3/cms-core": "^9.5"
"typo3/cms-core": "^9.5",
"friendsoftypo3/typo3db-legacy": "^1.1"
},
"replace": {
"cooluri": "self.version",
Expand Down
1 change: 1 addition & 0 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'constraints' => array(
'depends' => array(
'typo3' => '9.5.0-9.9.99',
'typo3db_legacy' => '1.1.1-1.1.99'
),
),
);
25 changes: 1 addition & 24 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@

}

$TCA['pages']['columns']['tx_realurl_pathsegment'] = array(
'label' => 'LLL:EXT:cooluri/locallang_db.php:pages.tx_cooluri_pathsegment',
'exclude' => 1,
'config' => Array(
'type' => 'input',
'size' => '50',
'max' => '255',
'eval' => 'trim,nospace,lower,uniqueInPid'
)
);

$TCA['pages']['columns']['tx_cooluri_exclude'] = array(
'label' => 'LLL:EXT:cooluri/locallang_db.php:pages.tx_cooluri_exclude',
'exclude' => 1,
Expand All @@ -65,16 +54,4 @@
)
);

$TCA['pages_language_overlay']['columns']['tx_realurl_pathsegment'] = array(
'label' => 'LLL:EXT:cooluri/locallang_db.php:pages.tx_cooluri_pathsegment',
'exclude' => 1,
'config' => Array(
'type' => 'input',
'size' => '50',
'max' => '255',
'eval' => 'trim,nospace,lower,uniqueInPid'
)
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_realurl_pathsegment,tx_cooluri_exclude,tx_cooluri_excludealways', '1,2,5,4,254', 'after:nav_title');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages_language_overlay', 'tx_realurl_pathsegment', '1,2,5,4,254', 'after:nav_title');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', 'tx_cooluri_exclude,tx_cooluri_excludealways', '1,2,5,4,254', 'after:nav_title');
9 changes: 0 additions & 9 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@
# Table structure for table "pages"
#
CREATE TABLE pages (
tx_realurl_pathsegment varchar(255) default '',
tx_cooluri_exclude tinyint(1) unsigned default '0',
tx_cooluri_excludealways tinyint(1) unsigned default '0'
);

#
# Table structure for table "pages_language_overlay"
#
CREATE TABLE pages_language_overlay (
tx_realurl_pathsegment varchar(255) DEFAULT '' NOT NULL
);


CREATE TABLE link_cache (
id int(10) unsigned NOT NULL auto_increment,
params blob,
Expand Down

0 comments on commit 5f8a81f

Please sign in to comment.