Bug #16753
closedIndexed search displayes deleted and hidden pages.
0%
Description
Even permanently deleted pages appearing in the indexed_search and those results cannot be deleted from the indexed_search.
Its not a very cool patch but it works.
Patch:
typo3\sysext\indexed_search\pi\class.tx_indexedsearch.php
Line 1192 function checkResume($row) {
//PATCH PATCH PATCH PATCH PATCH MFR
//check, if the found page is still online / existing
if (intval($row['page_id'])>0) {
$pagecheck = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid = '.intval($row['page_id']).' '.$this->cObj->enableFields('pages'),'','',1);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($pagecheck)===0) {
return false;
}
}
//PATCH PATCH PATCH PATCH PATCH MFR
// If the record is indexed by an indexing configuration, just show it.
// At least this is needed for external URLs and files.
// For records we might need to extend this - for instance block display if record is access restricted.
if ($row['freeIndexUid']) {
(issue imported from #M4592)
Files
Updated by Michael Stucki almost 18 years ago
Wrong attempt. The index should be cleaned up while the page is being deleted.
Updated by Michael Fritz almost 18 years ago
New Patch:
typo3/sysext/indexed_search/ext_localconf.php
added Line (on Line 20):
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['tx_indexedsearch'] = 'EXT:indexed_search/class.crawler.php:&tx_indexedsearch_crawler';
typo3/sysext/indexed_search/class.crawler.php
2 Added Methods:
deleteHashsForThisPage
processCmdmap_preProcess (Hook)
1 Changed Method (Hook):
processDatamap_afterDatabaseOperations
On line 809:
/**
* Deletes all data recorded by indexed search for a given page
*
* @param integer Uid of the page to delete all pHash (=indices)
* @return void
* @author Michael Fritz / TARGET-E
*/
function deleteHashsForThisPage ($id) {
$pHashesToDelete_res = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('phash','index_section', 'page_id='.intval($id));
$pHashesToDelete = array();
for ($i=0; $i<count($pHashesToDelete_res); $i++) {
$pHashesToDelete[] = $pHashesToDelete_res[$i]['phash'];
}
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_section', 'phash IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($pHashesToDelete)).')');
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($pHashesToDelete)).')');
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_phash', 'phash IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($pHashesToDelete)).')');
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_grlist', 'phash IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($pHashesToDelete)).')');
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_fulltext', 'phash IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($pHashesToDelete)).')');
$GLOBALS['TYPO3_DB']->exec_DELETEquery('index_debug', 'phash IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($pHashesToDelete)).')');
}
/*************************
*
* Hooks functions for TCEmain (indexing of records)
******************/
/**
* TCEmain hook function for on-the-fly indexing of database records
*
* @param string command "new" or "update"
* @param string Table name
* @param string Record ID. If new record its a string pointing to index inside t3lib_tcemain::substNEWwithIDs
* @param unknown Unknown
* @param object Reference to tcemain calling object
* @return void
* @author Michael Fritz / TARGET-E
*/
function processCmdmap_preProcess($command, $table, $id, $value, $TCEMAIN_this) {
if ($command=='delete' && $table 'pages') {
$this->deleteHashsForThisPage($id);
}
}
/**
* TCEmain hook function for on-the-fly indexing of database records
*
* @param string Status "new" or "update"
* @param string Table name
* @param string Record ID. If new record its a string pointing to index inside t3lib_tcemain::substNEWwithIDs
* @param array Field array of updated fields in the operation
* @param object Reference to tcemain calling object
* @return void
*/
function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, &$pObj) {
// Check if any fields are actually updated:
if (count($fieldArray)) {
// Translate new ids.
if ($status'new') {
$id = $pObj->substNEWwithIDs[$id];
}
//PATCH PATCH PATCH PATCH PATCH PATCH
//if the page should be hidden or not indexed after update, delete index for this page
else if ($table 'pages' && $status'update' && (array_key_exists('hidden',$fieldArray) && $fieldArray['hidden']==1) || (array_key_exists('no_search',$fieldArray) && $fieldArray['no_search']==1)) {
$this->deleteHashsForThisPage($id);
}
//PATCH PATCH PATCH PATCH PATCH PATCH
// Get full record and if exists, search for indexing configurations:
$currentRecord = t3lib_BEfunc::getRecord($table,$id);
if (is_array($currentRecord)) {
// Select all (not running) indexing configurations of type "record" (1) and which points to this table and is located on the same page as the record or pointing to the right source PID
$indexingConfigurations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'*',
'index_config',
'hidden=0
AND (starttime=0 OR starttime<='.time().')
AND set_id=0
AND type=1
AND table2index='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'index_config').'
AND (
(alternative_source_pid='.$GLOBALS['TYPO3_DB']->fullQuoteStr('','index_config').' AND pid='.intval($currentRecord['pid']).')
OR (alternative_source_pid='.$GLOBALS['TYPO3_DB']->fullQuoteStr($currentRecord['pid'],'index_config').')
)
AND records_indexonchange=1
'.t3lib_BEfunc::deleteClause('index_config')
);
foreach($indexingConfigurations as $cfgRec) {
$this->indexSingleRecord($currentRecord,$cfgRec);
}
}
}
}
Updated by Michael Fritz almost 18 years ago
Hello Michael,
i cannot add the bugfix by myself. Who is doing this?
cheers, Michi
Updated by Michael Stucki almost 18 years ago
Please upload a patch, then I will take care of this.
Updated by Michael Stucki almost 18 years ago
For details about this, see here: http://typo3.org/teams/bug-fixing/diff-and-patch/
Updated by Michael Fritz almost 18 years ago
Sorry, I can't do this. My linux-pc doensn't have a "patch" command. I have no clue how to install such a "patch" :-)
"GNU utilities for Win32" is not available anymore..
I uploaded an oldscool patch taken from 4.0.2 (see at "attached files")
Updated by Michael Stucki almost 18 years ago
It's a small task to search for "diff" (not patch) but helps to keep things easy for next time...
I have uploaded a patch (yet untested) and will take care of it.