Project

General

Profile

Actions

Bug #16753

closed

Indexed search displayes deleted and hidden pages.

Added by Michael Fritz almost 18 years ago. Updated over 17 years ago.

Status:
Closed
Priority:
Should have
Category:
Communication
Target version:
-
Start date:
2006-11-30
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.0
PHP Version:
4
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

class.crawler.php (33.6 KB) class.crawler.php Administrator Admin, 2007-01-05 18:09
bug_4592.diff (3.5 KB) bug_4592.diff Administrator Admin, 2007-01-05 20:32

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #16978: deleteFromIndex method in indexed_search/class.crawler.php fails on deleting/hiding non-indexed pagesClosedMichael Stucki2007-02-12

Actions
Actions #1

Updated by Michael Stucki almost 18 years ago

Wrong attempt. The index should be cleaned up while the page is being deleted.

Actions #2

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);
}
}
}
}
Actions #3

Updated by Michael Fritz almost 18 years ago

Hello Michael,

i cannot add the bugfix by myself. Who is doing this?

cheers, Michi

Actions #4

Updated by Michael Stucki almost 18 years ago

Please upload a patch, then I will take care of this.

Actions #5

Updated by Michael Stucki almost 18 years ago

For details about this, see here: http://typo3.org/teams/bug-fixing/diff-and-patch/

Actions #6

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")

Actions #7

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.

Actions #8

Updated by Michael Stucki almost 18 years ago

Fixed in SVN. Thanks Michael!

Actions

Also available in: Atom PDF