diff --git a/class.tx_realurl.php b/class.tx_realurl.php index 9336b67..faa0406 100644 --- a/class.tx_realurl.php +++ b/class.tx_realurl.php @@ -965,6 +965,11 @@ public function decodeSpURL($params) { // relative to work properly. $speakingURIpath = $this->pObj->siteScript{0} == '/' ? substr($this->pObj->siteScript, 1) : $this->pObj->siteScript; + if ($this->isURIpathContainingAnProtocolWrapper($speakingURIpath)) { + header('Location:'.$this->getURIpathWithoutProtocolWrapper($speakingURIpath), TRUE, 301); + exit(); + } + // Call hooks if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'])) { foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'] as $userFunc) { @@ -2863,7 +2868,12 @@ public function getRetrievedPreGetVar($key) { * @return mixed string with url or false */ private function checkForExternalPageAndGetTarget($id) { - $where = "uid=\"" . intval($id) . "\""; + if (TRUE === is_numeric($id)) { + $where = 'uid="' . intval($id) . '"'; + } else { + $where = 'alias="' . trim($id) . '"'; + } + $query = $GLOBALS['TYPO3_DB']->exec_SELECTquery("uid,pid,url,doktype,urltype", "pages", $where); if ($query) { $result = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query); @@ -2899,6 +2909,40 @@ private function checkForExternalPageAndGetTarget($id) { } } + /** + * get URI-path without protocol-wrapper + * + * Otherwise the following PHP-warning will appear in the TYPO3-DB-table 'sys_log', after the static method 't3lib_div::split_fileref' was called: + * PHP Warning: is_dir(): Unable to find the wrapper "ttp" + * + * Example: + * The URI-path '/my-uri-pathttp://www.google.de' or '/my-uri-pathhttp://www.google.de' will be fixed to '/my-uri-path' + * + * @param string $uriPath + * @return string + */ + private function getURIpathWithoutProtocolWrapper($uriPath) { + $fixedUriPath = preg_replace('/(ttp|http)[s]?\:\/\/.*$/i', '', $uriPath); + $fixedUriPath = '/' . ltrim($fixedUriPath, '/'); + return $fixedUriPath; + } + + /** + * check, if URI-path contains a protocol-wrapper (this is an indicator, that the URI-path maybe contain another URL) + * + * Example: + * The URI-path '/my-uri-pathhttp://www.google.de' contains another URL + * + * @param string $uriPath + * @return boolean + */ + private function isURIpathContainingAnProtocolWrapper($uriPath) { + if (FALSE === strpos($uriPath, '://')) { + return FALSE; + } + return TRUE; + } + /** * Returns the detected language (decoding only). Language is detected * from preVars or _DOMAINS feature. diff --git a/class.tx_realurl_cachemgmt.php b/class.tx_realurl_cachemgmt.php index 0951649..5b1f856 100644 --- a/class.tx_realurl_cachemgmt.php +++ b/class.tx_realurl_cachemgmt.php @@ -267,7 +267,7 @@ function _readCacheForPath($pagePath, $ignoreUid = null) { * @return string unique path in cache **/ function _readHistoryCacheForPath($pagePath) { - $where = "path=\"" . $this->dbObj->fullQuoteStr($pagePath, 'tx_realurl_cachehistory') . '"' . $this->_getAddCacheWhere(TRUE); + $where = 'path=' . $this->dbObj->fullQuoteStr($pagePath, 'tx_realurl_cachehistory') . $this->_getAddCacheWhere(TRUE); $res = $this->dbObj->exec_SELECTquery("*", "tx_realurl_cachehistory", $where); if ($res) $result = $this->dbObj->sql_fetch_assoc($res); diff --git a/class.tx_realurl_crawler.php b/class.tx_realurl_crawler.php index 9314ba3..1651e75 100644 --- a/class.tx_realurl_crawler.php +++ b/class.tx_realurl_crawler.php @@ -81,7 +81,7 @@ function insertPageIncache(&$pObj, $timeOutTime) { * * @author Michael Klapper */ - public function headerNoCache($params, $tsfe) { + public function headerNoCache(&$params, $tsfe) { if ( t3lib_extMgm::isLoaded('crawler') @@ -90,8 +90,8 @@ public function headerNoCache($params, $tsfe) { ) { $params['pObj']->applicationData['tx_crawler']['log'][] = 'Force page generation (realurl - rebuild)'; - // force fresh page generation without using cache data - $tsfe->all = ''; + // Disables a look-up for cached page data - thus resulting in re-generation of the page even if cached. + $params['disableAcquireCacheData'] = true; } } } diff --git a/ext_autoload.php b/ext_autoload.php index e1d4b26..89173cf 100644 --- a/ext_autoload.php +++ b/ext_autoload.php @@ -18,4 +18,5 @@ 'tx_realurl_modfunc1' => $extensionPath . 'modfunc1/class.tx_realurl_modfunc1.php', 'tx_realurl_pagebrowser' => $extensionPath . 'modfunc1/class.tx_realurl_pagebrowser.php', 'tx_realurl_configurationservice_testcase' => $extensionPath . 'tests/class.tx_realurl_configurationService_testcase.php', + 'tx_realurl_abstractdatabase_testcase' => $extensionPath . 'tests/class.tx_realurl_abstractDatabase_testcase.php' ); diff --git a/ext_tables.php b/ext_tables.php index 6e52620..fec09b1 100755 --- a/ext_tables.php +++ b/ext_tables.php @@ -62,24 +62,16 @@ ); $TCA['pages']['ctrl']['requestUpdate'] .= ',tx_realurl_exclude'; - +$TCA['pages']['ctrl']['shadowColumnsForNewPlaceholders'] .= + ',tx_realurl_pathsegment,tx_realurl_exclude,tx_realurl_pathoverride,tx_realurl_nocache'; $TCA['pages']['palettes']['137'] = array( 'showitem' => 'tx_realurl_pathoverride' ); -if (t3lib_div::compat_version('4.3')) { - t3lib_extMgm::addFieldsToPalette('pages', '3', 'tx_realurl_nocache', 'after:cache_timeout'); -} -if (t3lib_div::compat_version('4.2')) { - // For 4.2 or new add fields to advanced page only - t3lib_extMgm::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '1', 'after:nav_title'); - t3lib_extMgm::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '4,199,254', 'after:title'); -} -else { - // Put it for standard page - t3lib_extMgm::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '2', 'after:nav_title'); - t3lib_extMgm::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '1,5,4,199,254', 'after:title'); -} + +// Put it for standard page +t3lib_extMgm::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '2', 'after:nav_title'); +t3lib_extMgm::addToAllTCAtypes('pages', 'tx_realurl_pathsegment;;137;;,tx_realurl_exclude', '1,5,4,199,254', 'after:title'); t3lib_extMgm::addLLrefForTCAdescr('pages','EXT:realurl/locallang_csh.xml'); diff --git a/ext_tables.sql b/ext_tables.sql index 16458ed..11886f2 100755 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -63,7 +63,7 @@ CREATE TABLE tx_realurl_urldecodecache ( tstamp int(11) DEFAULT '0' NOT NULL, PRIMARY KEY (url_hash), - KEY page_id (page_id), + KEY page_id (page_id) ) ENGINE=InnoDB; # @@ -154,7 +154,7 @@ CREATE TABLE tx_realurl_cache ( languageid int(11) DEFAULT '0' NOT NULL, pageid int(11) DEFAULT '0' NOT NULL, path text NOT NULL, - dirty tinyint(3) DEFAULT '0' NOT NULL + dirty tinyint(3) DEFAULT '0' NOT NULL, PRIMARY KEY (pageid,workspace,rootpid,languageid), KEY `path_k` (path(100)), diff --git a/tests/class.tx_realurl_abstractDatabase_testcase.php b/tests/class.tx_realurl_abstractDatabase_testcase.php new file mode 100644 index 0000000..8fb0051 --- /dev/null +++ b/tests/class.tx_realurl_abstractDatabase_testcase.php @@ -0,0 +1,60 @@ +debugOutput = true; + $GLOBALS['TSFE']->id = 1; + //caching + $cacheConfig = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']; + $cacheTags = array('extbase_reflection', 'extbase_object', 'extbase_typo3dbbackend_tablecolumns', 'cache_rootline'); + foreach ($cacheTags as $tag) { + $cacheConfig[$tag] = array('backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend'); + } + $cacheManager = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager'); + $cacheManager->setCacheConfigurations($cacheConfig); + $this->createDatabase(); + $this->useTestDatabase(); + + // create DB-tables of some needed extensions: + $extList = array ('core','frontend','realurl'); + $extOptList = array ('templavoila', 'aoe_templavoila', 'languagevisibility', 'aoe_localizeshortcut', 'devlog'); + foreach ($extOptList as $ext) { + if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($ext)) { + $extList [] = $ext; + } + } + $this->importExtensions($extList); + // make sure addRootlineFields has the right content - otherwise we experience DB-errors within test-database + $this->rootlineFields = $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']; + $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] = 'tx_realurl_pathsegment,tx_realurl_pathoverride,tx_realurl_exclude'; + + // reset pageoverlay fields + $this->globalPageOverlayFields = $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']; + $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = 'uid,title,subtitle,nav_title,media,keywords,description,abstract,author,author_email,url,urltype,shortcut,shortcut_mode,tx_realurl_pathsegment,tx_realurl_exclude,tx_realurl_pathoverride'; + + } + + /** + * drop test-database + */ + public function tearDown() { + $this->cleanDatabase(); + $this->dropDatabase(); + $this->switchToTypo3Database(); + + $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] = $this->rootlineFields; + $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = $this->globalPageOverlayFields; + } +} diff --git a/tests/class.tx_realurl_cachemgmt_testcase.php b/tests/class.tx_realurl_cachemgmt_testcase.php index 0e241e9..4d76454 100644 --- a/tests/class.tx_realurl_cachemgmt_testcase.php +++ b/tests/class.tx_realurl_cachemgmt_testcase.php @@ -2,7 +2,7 @@ /*************************************************************** * Copyright notice * - * (c) 2008 AOE media GmbH + * (c) 2008 AOE GmbH * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -32,45 +32,17 @@ */ require_once (t3lib_extMgm::extPath ( "realurl" ) . 'class.tx_realurl_cachemgmt.php'); //require_once (t3lib_extMgm::extPath('phpunit').'class.tx_phpunit_test.php'); -require_once (PATH_t3lib . 'class.t3lib_tcemain.php'); - -class tx_realurl_cachemgmt_testcase extends tx_phpunit_database_testcase { - - private $rootlineFields; +class tx_realurl_cachemgmt_testcase extends tx_realurl_abstractDatabase_testcase { + /** + * setUp test-database + */ public function setUp() { - $GLOBALS['TYPO3_DB']->debugOutput = true; - $this->createDatabase(); - $db = $this->useTestDatabase(); - $this->importStdDB(); - - // make sure addRootlineFields has the right content - otherwise we experience DB-errors within testdb - $this->rootlineFields = $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']; - $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] = 'tx_realurl_pathsegment,tx_realurl_pathoverride,tx_realurl_exclude'; - - //create relevant tables: - $extList = array('cms','realurl'); - $extOptList = array('templavoila','languagevisibility','aoe_webex_tableextensions','aoe_localizeshortcut'); - foreach($extOptList as $ext) { - if(t3lib_extMgm::isLoaded($ext)) { - $extList[] = $ext; - } - } - $this->importExtensions($extList); + parent::setUp(); + // create/import DB-records $this->importDataSet ( dirname ( __FILE__ ) . '/fixtures/page-livews.xml' ); $this->importDataSet ( dirname ( __FILE__ ) . '/fixtures/page-ws.xml' ); - - if (!is_object($GLOBALS['TSFE']->csConvObj)) { - $GLOBALS['TSFE']->csConvObj=t3lib_div::makeInstance('t3lib_cs'); - } - } - - public function tearDown() { - $this->cleanDatabase(); - $this->dropDatabase(); - $GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db); - $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] = $this->rootlineFields; } /** @@ -294,11 +266,10 @@ public function canStoreAndGetFromHistory() { $dummy = array (); $pidOrFalse = $cache->checkCacheWithDecreasingPath ( array ('sample', 'path1new' ), $dummy ); $this->assertEquals ( $pidOrFalse, '9990', ' 9990 should be the path' ); + //now check history - $this->markTestIncomplete('Test fail for unknown reason'); $pidOrFalse = $cache->checkHistoryCacheWithDecreasingPath ( array ('sample', 'path1' ), $dummy ); $this->assertEquals ( $pidOrFalse, '9990', ' 9990 should be the pid in history' ); - } } ?> \ No newline at end of file diff --git a/tests/class.tx_realurl_pathgenerator_testcase.php b/tests/class.tx_realurl_pathgenerator_testcase.php index 02a781f..69257a8 100644 --- a/tests/class.tx_realurl_pathgenerator_testcase.php +++ b/tests/class.tx_realurl_pathgenerator_testcase.php @@ -2,7 +2,7 @@ /*************************************************************** * Copyright notice * - * (c) 2008 AOE media GmbH + * (c) 2008 AOE GmbH * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -33,8 +33,7 @@ //TODO: add testdatabase xml //require_once (t3lib_extMgm::extPath ( "realurl" ) . 'class.tx_realurl_pathgenerator.php'); // require_once (t3lib_extMgm::extPath('phpunit').'class.tx_phpunit_test.php'); -require_once (PATH_t3lib . 'class.t3lib_tcemain.php'); -class tx_realurl_pathgenerator_testcase extends tx_phpunit_database_testcase { +class tx_realurl_pathgenerator_testcase extends tx_realurl_abstractDatabase_testcase { /** * Enter description here... @@ -42,28 +41,11 @@ class tx_realurl_pathgenerator_testcase extends tx_phpunit_database_testcase { * @var tx_realurl_pathgenerator */ private $pathgenerator; - private $rootlineFields; public function setUp() { - $GLOBALS ['TYPO3_DB']->debugOutput = true; - $this->createDatabase (); - $db = $this->useTestDatabase (); - $this->importStdDB (); - - // make sure addRootlineFields has the right content - otherwise we experience DB-errors within testdb - $this->rootlineFields = $GLOBALS ['TYPO3_CONF_VARS'] ['FE'] ['addRootLineFields']; - $GLOBALS ['TYPO3_CONF_VARS'] ['FE'] ['addRootLineFields'] = 'tx_realurl_pathsegment,tx_realurl_pathoverride,tx_realurl_exclude'; - - //create relevant tables: - $extList = array ('cms', 'realurl' ); - $extOptList = array ('templavoila', 'languagevisibility', 'aoe_webex_tableextensions', 'aoe_localizeshortcut' ); - foreach ( $extOptList as $ext ) { - if (t3lib_extMgm::isLoaded ( $ext )) { - $extList [] = $ext; - } - } - $this->importExtensions ( $extList ); + parent::setUp(); + // create/import DB-records $this->importDataSet ( dirname ( __FILE__ ) . '/fixtures/page-livews.xml' ); $this->importDataSet ( dirname ( __FILE__ ) . '/fixtures/overlay-livews.xml' ); $this->importDataSet ( dirname ( __FILE__ ) . '/fixtures/page-ws.xml' ); @@ -75,13 +57,7 @@ public function setUp() { if (! is_object ( $GLOBALS ['TSFE']->csConvObj )) { $GLOBALS ['TSFE']->csConvObj = t3lib_div::makeInstance ( 't3lib_cs' ); } - } - - public function tearDown() { - $this->cleanDatabase (); - $this->dropDatabase (); - $GLOBALS ['TYPO3_DB']->sql_select_db ( TYPO3_db ); - $GLOBALS ['TYPO3_CONF_VARS'] ['FE'] ['addRootLineFields'] = $this->rootlineFields; + $GLOBALS ['TSFE']->defaultCharSet = 'utf8'; } /** @@ -123,7 +99,6 @@ public function canBuildStandardPaths() { * @test */ public function canBuildPathsWithExcludeAndOverride() { - // page root->excludefrommiddle->subpage(with pathsegment) $result = $this->pathgenerator->build ( 85, 0, 0 ); $this->assertEquals ( $result ['path'], 'subpagepathsegment', 'wrong path build: should be subpage' ); diff --git a/tests/fixtures/page-ws.xml b/tests/fixtures/page-ws.xml index 43d80b9..e17cba1 100644 --- a/tests/fixtures/page-ws.xml +++ b/tests/fixtures/page-ws.xml @@ -26,7 +26,6 @@ 0 0 0 - -1 85 0 @@ -50,7 +49,6 @@ 0 0 0 - -1 1000 0 @@ -74,7 +72,6 @@ 0 0 0 - -1 1002 0