Best way to republish node from PHP, weird search behavior

Author Message

Piotrek Karaƛ

Wednesday 04 March 2009 7:12:16 am

Hi all,

I have an extension which consists of two major parts: a datatype which stands an interface into my own DB model, and a cronjob that updates that model and refreshes the website state. It is easy enough to find content objects based on my custom datatype.

So I put together the following code, whose task is to:
- find the list of objects of interest, and for each object:
- republish the object
- clear its cache
- update the search index

Here's the code:

(...)
foreach( $contentObjectIDList as $contentObjectID )
{
    $contentObject = eZContentObject::fetch( $contentObjectID );
    if( is_object( $contentObject ) )
    {
        $nodeObject = $contentObject->mainNode();
        if( is_object( $nodeObject ) )
        {
            if ( !$isQuiet )
            {
                $cli->output( 'Republish and clear cache for content object ID: ' . $contentObjectID );
            }
            $db->begin();
            $contentObjectVersion = $contentObject->createNewVersion();
            eZOperationHandler::execute( 'content', 'publish', array(
                'object_id' => $contentObjectID,
                'version' => $contentObjectVersion->Version,
            ) );
            $db->commit();
            eZContentOperationCollection::registerSearchObject( $contentObjectID, $contentObjectVersion->Version );
            eZContentCacheManager::clearContentCacheIfNeeded( $contentObject );
        }
    }
}
(...)

Now, this seems to be working fine, but each time I run this script, I end up with some additional rows in the ezsearch_word DB table. For example:
1) I truncate ezsearch_word and ezsearch_object_word_link tables,
2) I run my script. It results in ~1300 rows in the ezsearch_word table.
3) I run my script again. Now it adds up to ~1700 rows in the ezsearch_word table.
4) I run my script again. Now it adds up to ~2100 rows in the ezsearch_word table.
And so on... and still operating on the same object...

Is the above script at fault? Or could this be a problem of the search engine?
I wasn't able to reproduce this row count behavior with standard publish process...

Also, would you carry out the task of republishing the object differently?

I'd be grateful for any thoughts on these issues.

Cheers,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 03:37:30
Script start
Timing: Jan 19 2025 03:37:30
Module start 'layout'
Timing: Jan 19 2025 03:37:30
Module start 'content'
Timing: Jan 19 2025 03:37:31
Module end 'content'
Timing: Jan 19 2025 03:37:31
Script end

Main resources:

Total runtime0.6120 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 589.4141152.6563
Module start 'layout' 0.00500.0027 742.070339.5078
Module start 'content' 0.00770.6029 781.5781477.4063
Module end 'content' 0.61060.0014 1,258.98448.0938
Script end 0.6120  1,267.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.5082160.0002
Check MTime0.00130.2127160.0001
Mysql Total
Database connection0.00080.129410.0008
Mysqli_queries0.569993.1077460.0124
Looping result0.00040.0635440.0000
Template Total0.584895.620.2924
Template load0.00190.314220.0010
Template processing0.582995.237320.2914
Template load and register function0.00010.020310.0001
states
state_id_array0.00070.114610.0007
state_identifier_array0.00130.214820.0007
Override
Cache load0.00160.2640250.0001
Sytem overhead
Fetch class attribute can translate value0.00050.073710.0005
Fetch class attribute name0.00070.115220.0004
XML
Image XML parsing0.00050.079910.0005
class_abstraction
Instantiating content class attribute0.00000.000820.0000
General
dbfile0.00100.1709170.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs