eZ Publish  [4.0]
indexcontent.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Created on: <18-Mar-2004 17:12:43 dr>
00004 //
00005 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00006 // SOFTWARE NAME: eZ Publish
00007 // SOFTWARE RELEASE: 4.0.x
00008 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00009 // SOFTWARE LICENSE: GNU General Public License v2.0
00010 // NOTICE: >
00011 //   This program is free software; you can redistribute it and/or
00012 //   modify it under the terms of version 2.0  of the GNU General
00013 //   Public License as published by the Free Software Foundation.
00014 //
00015 //   This program is distributed in the hope that it will be useful,
00016 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //   GNU General Public License for more details.
00019 //
00020 //   You should have received a copy of version 2.0 of the GNU General
00021 //   Public License along with this program; if not, write to the Free
00022 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00023 //   MA 02110-1301, USA.
00024 //
00025 //
00026 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00027 //
00028 
00029 /*! \file indexcontent.php
00030 */
00031 
00032 //include_once( 'kernel/classes/ezsearch.php' );
00033 //include_once( 'kernel/classes/ezcontentobject.php' );
00034 //include_once( 'lib/ezdb/classes/ezdb.php' );
00035 
00036 if ( !$isQuiet )
00037 {
00038     $cli->output( "Starting processing pending search engine modifications" );
00039 }
00040 
00041 $contentObjects = array();
00042 $db = eZDB::instance();
00043 
00044 $offset = 0;
00045 $limit = 50;
00046 
00047 while( true )
00048 {
00049     $entries = $db->arrayQuery( "SELECT param FROM ezpending_actions WHERE action = 'index_object'",
00050                                 array( 'limit' => $limit,
00051                                        'offset' => $offset ) );
00052 
00053     if ( is_array( $entries ) && count( $entries ) != 0 )
00054     {
00055         $objectIDList = array();
00056         $db->begin();
00057         foreach ( $entries as $entry )
00058         {
00059             $objectID = (int)$entry['param'];
00060             $objectIDList[] = "'$objectID'";
00061 
00062             $cli->output( "\tIndexing object ID #$objectID" );
00063             $object = eZContentObject::fetch( $objectID );
00064             if ( $object )
00065             {
00066                 eZSearch::removeObject( $object );
00067                 eZSearch::addObject( $object );
00068             }
00069         }
00070 
00071         $paramInSQL = $db->generateSQLInStatement( $objectIDList, 'param' );
00072 
00073         $db->query( "DELETE FROM ezpending_actions WHERE action = 'index_object' AND $paramInSQL" );
00074         $db->commit();
00075     }
00076     else
00077     {
00078         break; // No valid result from ezpending_actions
00079     }
00080 }
00081 
00082 if ( !$isQuiet )
00083 {
00084     $cli->output( "Done" );
00085 }
00086 
00087 ?>