* Fixed bug #11358: typoLink() perfomance improvement (thanks to Vladimir Podkovanov)
authorRupert Germann <rupi@gmx.li>
Sun, 21 Jun 2009 09:31:21 +0000 (09:31 +0000)
committerRupert Germann <rupi@gmx.li>
Sun, 21 Jun 2009 09:31:21 +0000 (09:31 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5602 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_page.php

index c77d49f..c9ab415 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-21  Rupert Germann  <rupi@gmx.li>
+
+       * Fixed bug #11358: typoLink() perfomance improvement (thanks to Vladimir Podkovanov)
+
 2009-05-18  Benjamin Mack  <benni@typo3.org>
 
        * Fixed bug / Feature #11293: Login page is not translatable
index 4804ac0..2f488a6 100644 (file)
@@ -125,6 +125,8 @@ class t3lib_pageSelect {
                // Internal caching
        protected $cache_getRootLine = array();
        protected $cache_getPage = array();
+       protected $cache_getPage_noCheck = array();
+       protected $cache_getPageIdFromAlias = array();
        protected $cache_getMountPointInfo = array();
 
        /**
@@ -210,20 +212,26 @@ class t3lib_pageSelect {
         * Return the $row for the page with uid = $uid WITHOUT checking for ->where_hid_del (start- and endtime or hidden). Only "deleted" is checked!
         *
         * @param       integer         The page id to look up
-        * @return      array           The page row with overlayed localized fields. Empty it no page.
+        * @return      array           The page row with overlayed localized fields. Empty array if no page.
         * @see getPage()
         */
        function getPage_noCheck($uid)  {
+               if ($this->cache_getPage_noCheck[$uid]) {
+                       return $this->cache_getPage_noCheck[$uid];
+               }
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($uid).$this->deleteClause('pages'));
                $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                if ($row)       {
                        $this->versionOL('pages',$row);
                        if (is_array($row))     {
-                               return $this->getPageOverlay($row);
+                               $row = $this->getPageOverlay($row);
+                               $this->cache_getPage_noCheck[$uid] = $row;
+                               return $row;
                        }
                }
-               return Array();
+               $this->cache_getPage_noCheck[$uid] = array();
+               return array();
        }
 
        /**
@@ -256,12 +264,17 @@ class t3lib_pageSelect {
         */
        function getPageIdFromAlias($alias)     {
                $alias = strtolower($alias);
+               if ($this->cache_getPageIdFromAlias[$alias]) {
+                       return $this->cache_getPageIdFromAlias[$alias];
+               }
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'alias='.$GLOBALS['TYPO3_DB']->fullQuoteStr($alias, 'pages').' AND pid>=0 AND pages.deleted=0');  // "AND pid>=0" because of versioning (means that aliases sent MUST be online!)
                $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                if ($row)       {
+                       $this->cache_getPageIdFromAlias[$alias] = $row['uid'];
                        return $row['uid'];
                }
+               $this->cache_getPageIdFromAlias[$alias] = 0;
                return 0;
        }