Revert "[TASK] Rebuild the calcAge functionality"
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / Classes / Indexer.php
index 88414b0..0623160 100644 (file)
@@ -1,31 +1,18 @@
 <?php
 namespace TYPO3\CMS\IndexedSearch;
 
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2001-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *  A copy is found in the textfile GPL.txt and important notices to the license
- *  from the author is found in LICENSE.txt distributed with these scripts.
+/**
+ * This file is part of the TYPO3 CMS project.
  *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
  *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
  *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
+ * The TYPO3 project - inspiring people to share!
+ */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -258,7 +245,7 @@ class Indexer {
                        if (!$indexerConfig['disableFrontendIndexing'] || $this->crawlerActive) {
                                if (!$pObj->page['no_search']) {
                                        if (!$pObj->no_cache) {
-                                               if (!strcmp($pObj->sys_language_uid, $pObj->sys_language_content)) {
+                                               if ((int)$pObj->sys_language_uid === (int)$pObj->sys_language_content) {
                                                        // Setting up internal configuration from config array:
                                                        $this->conf = array();
                                                        // Information about page for which the indexing takes place
@@ -674,7 +661,7 @@ class Indexer {
         */
        public function convertHTMLToUtf8($content, $charset = '') {
                // Find charset:
-               $charset = $charset ? $charset : $this->getHTMLcharset($content);
+               $charset = $charset ?: $this->getHTMLcharset($content);
                $charset = $this->csObj->parse_charset($charset);
                // Convert charset:
                if ($charset && $charset !== 'utf-8') {
@@ -767,9 +754,9 @@ class Indexer {
                        // Decode entities:
                        if ($linkInfo['localPath']) {
                                // localPath means: This file is sent by a download script. While the indexed URL has to point to $linkInfo['href'], the absolute path to the file is specified here!
-                               $linkSource = GeneralUtility::htmlspecialchars_decode($linkInfo['localPath']);
+                               $linkSource = htmlspecialchars_decode($linkInfo['localPath']);
                        } else {
-                               $linkSource = GeneralUtility::htmlspecialchars_decode($linkInfo['href']);
+                               $linkSource = htmlspecialchars_decode($linkInfo['href']);
                        }
                        // Parse URL:
                        $qParts = parse_url($linkSource);
@@ -803,7 +790,7 @@ class Indexer {
                                                                'conf' => $this->conf
                                                        );
                                                        unset($params['conf']['content']);
-                                                       $crawler->addQueueEntry_callBack(0, $params, '&TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController_files', $this->conf['id']);
+                                                       $crawler->addQueueEntry_callBack(0, $params, '&TYPO3\\CMS\\IndexedSearch\\Hook\\CrawlerFilesHook', $this->conf['id']);
                                                        $this->log_setTSlogMessage('media "' . $params['document'] . '" added to "crawler" queue.', 1);
                                                } else {
                                                        $this->indexRegularDocument($linkInfo['href'], FALSE, $linkSource, $ext);
@@ -815,7 +802,7 @@ class Indexer {
                                                                'conf' => $this->conf
                                                        );
                                                        unset($params['conf']['content']);
-                                                       $crawler->addQueueEntry_callBack(0, $params, '&TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController_files', $this->conf['id']);
+                                                       $crawler->addQueueEntry_callBack(0, $params, '&TYPO3\\CMS\\IndexedSearch\\Hook\\CrawlerFilesHook', $this->conf['id']);
                                                        $this->log_setTSlogMessage('media "' . $params['document'] . '" added to "crawler" queue.', 1);
                                                } else {
                                                        $this->indexRegularDocument($linkSource);
@@ -930,7 +917,7 @@ class Indexer {
                $content = GeneralUtility::getUrl($url, 2);
                if (strlen($content)) {
                        // Compile headers:
-                       $headers = GeneralUtility::trimExplode(LF, $content, 1);
+                       $headers = GeneralUtility::trimExplode(LF, $content, TRUE);
                        $retVal = array();
                        foreach ($headers as $line) {
                                if (!strlen(trim($line))) {
@@ -1111,7 +1098,7 @@ class Indexer {
        public function indexRegularDocument($file, $force = FALSE, $contentTmpFile = '', $altExtension = '') {
                // Init
                $fI = pathinfo($file);
-               $ext = $altExtension ? $altExtension : strtolower($fI['extension']);
+               $ext = $altExtension ?: strtolower($fI['extension']);
                // Create abs-path:
                if (!$contentTmpFile) {
                        if (!GeneralUtility::isAbsPath($file)) {
@@ -1128,7 +1115,7 @@ class Indexer {
                // Indexing the document:
                if ($absFile && @is_file($absFile)) {
                        if ($this->external_parsers[$ext]) {
-                               $mtime = filemtime($absFile);
+                               $fileInfo = stat($absFile);
                                $cParts = $this->fileContentParts($ext, $absFile);
                                foreach ($cParts as $cPKey) {
                                        $this->internal_log = array();
@@ -1137,7 +1124,7 @@ class Indexer {
                                        $subinfo = array('key' => $cPKey);
                                        // Setting page range. This is "0" (zero) when no division is made, otherwise a range like "1-3"
                                        $phash_arr = ($this->file_phash_arr = $this->setExtHashes($file, $subinfo));
-                                       $check = $this->checkMtimeTstamp($mtime, $phash_arr['phash']);
+                                       $check = $this->checkMtimeTstamp($fileInfo['mtime'], $phash_arr['phash']);
                                        if ($check > 0 || $force) {
                                                if ($check > 0) {
                                                        $this->log_setTSlogMessage('Indexing needed, reason: ' . $this->reasons[$check], 1);
@@ -1166,10 +1153,8 @@ class Indexer {
                                                                        $this->log_pull();
                                                                        // Submitting page (phash) record
                                                                        $this->log_push('Submitting page', '');
-                                                                       $size = filesize($absFile);
                                                                        // Unfortunately I cannot determine WHEN a file is originally made - so I must return the modification time...
-                                                                       $ctime = filemtime($absFile);
-                                                                       $this->submitFilePage($phash_arr, $file, $subinfo, $ext, $mtime, $ctime, $size, $content_md5h, $contentParts);
+                                                                       $this->submitFilePage($phash_arr, $file, $subinfo, $ext, $fileInfo['mtime'], $fileInfo['ctime'], $fileInfo['size'], $content_md5h, $contentParts);
                                                                        $this->log_pull();
                                                                        // Check words and submit to word list if not there
                                                                        $this->log_push('Check word list and submit words', '');
@@ -1182,7 +1167,7 @@ class Indexer {
                                                                        $this->updateParsetime($phash_arr['phash'], GeneralUtility::milliseconds() - $Pstart);
                                                                } else {
                                                                        // Update the timestamp
-                                                                       $this->updateTstamp($phash_arr['phash'], $mtime);
+                                                                       $this->updateTstamp($phash_arr['phash'], $fileInfo['mtime']);
                                                                        $this->log_setTSlogMessage('Indexing not needed, the contentHash, ' . $content_md5h . ', has not changed. Timestamp updated.');
                                                                }
                                                        } else {
@@ -1466,9 +1451,9 @@ class Indexer {
                        'sys_language_uid' => $this->conf['sys_language_uid'],
                        // Sys language uid of the page. Should reflect which language it DOES actually display!
                        'externalUrl' => 0,
-                       'recordUid' => intval($this->conf['recordUid']),
-                       'freeIndexUid' => intval($this->conf['freeIndexUid']),
-                       'freeIndexSetId' => intval($this->conf['freeIndexSetId'])
+                       'recordUid' => (int)$this->conf['recordUid'],
+                       'freeIndexUid' => (int)$this->conf['freeIndexUid'],
+                       'freeIndexSetId' => (int)$this->conf['freeIndexSetId']
                );
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_phash')) {
                        $GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
@@ -1543,7 +1528,7 @@ class Indexer {
                $fields = array(
                        'phash' => $hash,
                        'phash_t3' => $hash_t3,
-                       'page_id' => intval($this->conf['id'])
+                       'page_id' => (int)$this->conf['id']
                );
                $this->getRootLineFields($fields);
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_section')) {
@@ -1563,12 +1548,12 @@ class Indexer {
                $tableArray = explode(',', 'index_phash,index_section,index_grlist,index_fulltext,index_debug');
                foreach ($tableArray as $table) {
                        if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed($table)) {
-                               $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash=' . intval($phash));
+                               $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash=' . (int)$phash);
                        }
                }
                // Removing all index_section records with hash_t3 set to this hash (this includes such records set for external media on the page as well!). The re-insert of these records are done in indexRegularDocument($file).
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_section')) {
-                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('index_section', 'phash_t3=' . intval($phash));
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('index_section', 'phash_t3=' . (int)$phash);
                }
        }
 
@@ -1595,7 +1580,7 @@ class Indexer {
        public function submitFilePage($hash, $file, $subinfo, $ext, $mtime, $ctime, $size, $content_md5h, $contentParts) {
                // Find item Type:
                $storeItemType = $this->external_parsers[$ext]->ext2itemtype_map[$ext];
-               $storeItemType = $storeItemType ? $storeItemType : $ext;
+               $storeItemType = $storeItemType ?: $ext;
                // Remove any current data for this phash:
                $this->removeOldIndexedFiles($hash['phash']);
                // Split filename:
@@ -1608,7 +1593,7 @@ class Indexer {
                        'contentHash' => $content_md5h,
                        'data_filename' => $file,
                        'item_type' => $storeItemType,
-                       'item_title' => trim($contentParts['title']) ? $contentParts['title'] : basename($file),
+                       'item_title' => trim($contentParts['title']) ?: basename($file),
                        'item_description' => $this->bodyDescription($contentParts),
                        'item_mtime' => $mtime,
                        'item_size' => $size,
@@ -1617,9 +1602,10 @@ class Indexer {
                        'crdate' => $GLOBALS['EXEC_TIME'],
                        'gr_list' => $this->conf['gr_list'],
                        'externalUrl' => $fileParts['scheme'] ? 1 : 0,
-                       'recordUid' => intval($this->conf['recordUid']),
-                       'freeIndexUid' => intval($this->conf['freeIndexUid']),
-                       'freeIndexSetId' => intval($this->conf['freeIndexSetId'])
+                       'recordUid' => (int)$this->conf['recordUid'],
+                       'freeIndexUid' => (int)$this->conf['freeIndexUid'],
+                       'freeIndexSetId' => (int)$this->conf['freeIndexSetId'],
+                       'sys_language_uid' => (int)$this->conf['sys_language_uid']
                );
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_phash')) {
                        $GLOBALS['TYPO3_DB']->exec_INSERTquery('index_phash', $fields);
@@ -1663,7 +1649,7 @@ class Indexer {
        public function submitFile_grlist($hash) {
                // Testing if there is a gr_list record for a non-logged in user and if so, there is no need to place another one.
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_grlist')) {
-                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_grlist', 'phash=' . intval($hash) . ' AND (hash_gr_list=' . \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::md5inthash($this->defaultGrList) . ' OR hash_gr_list=' . \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::md5inthash($this->conf['gr_list']) . ')');
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_grlist', 'phash=' . (int)$hash . ' AND (hash_gr_list=' . \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::md5inthash($this->defaultGrList) . ' OR hash_gr_list=' . \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::md5inthash($this->conf['gr_list']) . ')');
                        if ($count == 0) {
                                $this->submit_grlist($hash, $hash);
                        }
@@ -1680,7 +1666,7 @@ class Indexer {
        public function submitFile_section($hash) {
                // Testing if there is already a section
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_section')) {
-                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_section', 'phash=' . intval($hash) . ' AND page_id=' . intval($this->conf['id']));
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_section', 'phash=' . (int)$hash . ' AND page_id=' . (int)$this->conf['id']);
                        if ($count == 0) {
                                $this->submit_section($hash, $this->hash['phash']);
                        }
@@ -1699,7 +1685,7 @@ class Indexer {
                $tableArray = explode(',', 'index_phash,index_grlist,index_fulltext,index_debug');
                foreach ($tableArray as $table) {
                        if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed($table)) {
-                               $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash=' . intval($phash));
+                               $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'phash=' . (int)$phash);
                        }
                }
        }
@@ -1723,7 +1709,7 @@ class Indexer {
                        // Not indexed (not in index_phash)
                        $result = 4;
                } else {
-                       $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('item_mtime,tstamp', 'index_phash', 'phash=' . intval($phash));
+                       $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('item_mtime,tstamp', 'index_phash', 'phash=' . (int)$phash);
                        // If there was an indexing of the page...:
                        if ($row) {
                                if ($this->tstamp_maxAge && $row['tstamp'] + $this->tstamp_maxAge < $GLOBALS['EXEC_TIME']) {
@@ -1776,7 +1762,7 @@ class Indexer {
                // With this query the page will only be indexed if it's content is different from the same "phash_grouping" -page.
                $result = TRUE;
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_phash')) {
-                       $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('phash', 'index_phash', 'phash_grouping=' . intval($this->hash['phash_grouping']) . ' AND contentHash=' . intval($this->content_md5h));
+                       $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('phash', 'index_phash', 'phash_grouping=' . (int)$this->hash['phash_grouping'] . ' AND contentHash=' . (int)$this->content_md5h);
                        if ($row) {
                                $result = $row;
                        }
@@ -1796,7 +1782,7 @@ class Indexer {
        public function checkExternalDocContentHash($hashGr, $content_md5h) {
                $result = TRUE;
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_phash')) {
-                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'index_phash', 'phash_grouping=' . intval($hashGr) . ' AND contentHash=' . intval($content_md5h));
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'index_phash', 'phash_grouping=' . (int)$hashGr . ' AND contentHash=' . (int)$content_md5h);
                        $result = $count == 0;
                }
                return $result;
@@ -1812,7 +1798,7 @@ class Indexer {
        public function is_grlist_set($phash_x) {
                $result = FALSE;
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_grlist')) {
-                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash_x', 'index_grlist', 'phash_x=' . intval($phash_x));
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash_x', 'index_grlist', 'phash_x=' . (int)$phash_x);
                        $result = $count > 0;
                }
                return $result;
@@ -1829,7 +1815,7 @@ class Indexer {
         */
        public function update_grlist($phash, $phash_x) {
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_grlist')) {
-                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_grlist', 'phash=' . intval($phash) . ' AND hash_gr_list=' . \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::md5inthash($this->conf['gr_list']));
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('phash', 'index_grlist', 'phash=' . (int)$phash . ' AND hash_gr_list=' . \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::md5inthash($this->conf['gr_list']));
                        if ($count == 0) {
                                $this->submit_grlist($phash, $phash_x);
                                $this->log_setTSlogMessage('Inserted gr_list \'' . $this->conf['gr_list'] . '\' for phash \'' . $phash . '\'', 1);
@@ -1851,9 +1837,9 @@ class Indexer {
                                'tstamp' => $GLOBALS['EXEC_TIME']
                        );
                        if ($mtime) {
-                               $updateFields['item_mtime'] = intval($mtime);
+                               $updateFields['item_mtime'] = (int)$mtime;
                        }
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash=' . intval($phash), $updateFields);
+                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash=' . (int)$phash, $updateFields);
                }
        }
 
@@ -1867,9 +1853,9 @@ class Indexer {
        public function updateSetId($phash) {
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_phash')) {
                        $updateFields = array(
-                               'freeIndexSetId' => intval($this->conf['freeIndexSetId'])
+                               'freeIndexSetId' => (int)$this->conf['freeIndexSetId']
                        );
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash=' . intval($phash), $updateFields);
+                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash=' . (int)$phash, $updateFields);
                }
        }
 
@@ -1884,9 +1870,9 @@ class Indexer {
        public function updateParsetime($phash, $parsetime) {
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_phash')) {
                        $updateFields = array(
-                               'parsetime' => intval($parsetime)
+                               'parsetime' => (int)$parsetime
                        );
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash=' . intval($phash), $updateFields);
+                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_phash', 'phash=' . (int)$phash, $updateFields);
                }
        }
 
@@ -1900,7 +1886,7 @@ class Indexer {
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_section')) {
                        $updateFields = array();
                        $this->getRootLineFields($updateFields);
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_section', 'page_id=' . intval($this->conf['id']), $updateFields);
+                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('index_section', 'page_id=' . (int)$this->conf['id'], $updateFields);
                }
        }
 
@@ -1913,12 +1899,12 @@ class Indexer {
         * @todo Define visibility
         */
        public function getRootLineFields(array &$fieldArray) {
-               $fieldArray['rl0'] = intval($this->conf['rootline_uids'][0]);
-               $fieldArray['rl1'] = intval($this->conf['rootline_uids'][1]);
-               $fieldArray['rl2'] = intval($this->conf['rootline_uids'][2]);
+               $fieldArray['rl0'] = (int)$this->conf['rootline_uids'][0];
+               $fieldArray['rl1'] = (int)$this->conf['rootline_uids'][1];
+               $fieldArray['rl2'] = (int)$this->conf['rootline_uids'][2];
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['addRootLineFields'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['addRootLineFields'] as $fieldName => $rootLineLevel) {
-                               $fieldArray[$fieldName] = intval($this->conf['rootline_uids'][$rootLineLevel]);
+                               $fieldArray[$fieldName] = (int)$this->conf['rootline_uids'][$rootLineLevel];
                        }
                }
        }
@@ -1934,9 +1920,9 @@ class Indexer {
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_phash') && \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_grlist')) {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('A.phash', 'index_phash A,index_grlist B', '
                                        A.phash=B.phash
-                                       AND A.phash_grouping=' . intval($this->hash['phash_grouping']) . '
+                                       AND A.phash_grouping=' . (int)$this->hash['phash_grouping'] . '
                                        AND B.hash_gr_list<>' . \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::md5inthash($this->defaultGrList) . '
-                                       AND A.contentHash=' . intval($this->content_md5h));
+                                       AND A.contentHash=' . (int)$this->content_md5h);
                        while ($res && FALSE !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
                                $this->log_setTSlogMessage('The currently indexed page was indexed under no user-login and apparently this page has been indexed under login conditions earlier, but with the SAME content. Therefore the old similar page with phash=\'' . $row['phash'] . '\' are now removed.', 1);
                                $this->removeOldIndexedPages($row['phash']);
@@ -1972,7 +1958,7 @@ class Indexer {
                        if (count($wordListArray)) {
                                $phashArray = array();
                                foreach ($wordListArray as $value) {
-                                       $phashArray[] = intval($value['hash']);
+                                       $phashArray[] = (int)$value['hash'];
                                }
                                $cwl = implode(',', $phashArray);
                                $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('baseword', 'index_words', 'wid IN (' . $cwl . ')');
@@ -2007,13 +1993,13 @@ class Indexer {
         */
        public function submitWords($wordList, $phash) {
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_rel')) {
-                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash=' . intval($phash));
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash=' . (int)$phash);
                        foreach ($wordList as $val) {
                                $insertFields = array(
-                                       'phash' => $phash,
-                                       'wid' => $val['hash'],
-                                       'count' => $val['count'],
-                                       'first' => $val['first'],
+                                       'phash' => (int)$phash,
+                                       'wid' => (int)$val['hash'],
+                                       'count' => (int)$val['count'],
+                                       'first' => (int)$val['first'],
                                        'freq' => $this->freqMap($val['count'] / $this->wordcount),
                                        'flags' => $val['cmp'] & $this->flagBitMask
                                );
@@ -2055,9 +2041,9 @@ class Indexer {
        public function setT3Hashes() {
                //  Set main array:
                $hArray = array(
-                       'id' => (int) $this->conf['id'],
-                       'type' => (int) $this->conf['type'],
-                       'sys_lang' => (int) $this->conf['sys_language_uid'],
+                       'id' => (int)$this->conf['id'],
+                       'type' => (int)$this->conf['type'],
+                       'sys_lang' => (int)$this->conf['sys_language_uid'],
                        'MP' => (string) $this->conf['MP'],
                        'cHash' => $this->cHashParams
                );
@@ -2147,7 +2133,7 @@ class Indexer {
         *
         * @param string $keywordList
         * @return string
-        * @see http://bugs.typo3.org/view.php?id=1436
+        * @see http://forge.typo3.org/issues/14959
         */
        protected function addSpacesToKeywordList($keywordList) {
                $keywords = GeneralUtility::trimExplode(',', $keywordList);
@@ -2155,6 +2141,3 @@ class Indexer {
        }
 
 }
-
-
-?>
\ No newline at end of file