Author: pb
Date: Thu Nov 27 15:28:15 2008
New Revision: 3375

Log:
- implemented enhancement #013972 Add a customised cronjob script for delayed 
indexing (in part via nfrp)

Added:
    ezfind/ezp4/trunk/extension/ezfind/cronjobs/
    ezfind/ezp4/trunk/extension/ezfind/cronjobs/ezfindexcontent.php   (with 
props)
Added: ezfind/ezp4/trunk/extension/ezfind/cronjobs/ezfindexcontent.php
==============================================================================
--- ezfind/ezp4/trunk/extension/ezfind/cronjobs/ezfindexcontent.php (added)
+++ ezfind/ezp4/trunk/extension/ezfind/cronjobs/ezfindexcontent.php Thu Nov 27 15:28:15 2008
@@ -1,0 +1,101 @@
+<?php
+//
+// Created on: <18-Mar-2004 17:12:43 dr>
+//
+// ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
+// SOFTWARE NAME: eZ Publish
+// SOFTWARE RELEASE: 4.1.x
+// COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
+// SOFTWARE LICENSE: GNU General Public License v2.0
+// NOTICE: >
+//   This program is free software; you can redistribute it and/or
+//   modify it under the terms of version 2.0  of the GNU General
+//   Public License as published by the Free Software Foundation.
+//
+//   This program 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.
+//
+//   You should have received a copy of version 2.0 of the GNU General
+//   Public License along with this program; if not, write to the Free
+//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+//   MA 02110-1301, USA.
+//
+//
+// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
+//
+
+/*! \file indexcontent.php
+*/
+
+require 'autoload.php';
+
+if ( !$isQuiet )
+{
+    $cli->output( "Starting processing pending search engine modifications" );
+}
+
+$contentObjects = array();
+$db = eZDB::instance();
+$eZSolr = new eZSolr();
+
+// @todo: make command line parameters of the following
+$offset = 0;
+$limit = 50;
+$solrCommit = true;
+$solrOptimize = true;
+
+while( true )
+{
+    $entries = $db->arrayQuery( "SELECT param FROM ezpending_actions WHERE action = 'index_object'",
+                                array( 'limit' => $limit,
+                                       'offset' => $offset ) );
+
+    if ( is_array( $entries ) && count( $entries ) != 0 )
+    {
+        $objectIDList = array();
+        $db->begin();
+        foreach ( $entries as $entry )
+        {
+            $objectID = $entry['param'];
+            $objectIDList[] = (int)$objectID;
+
+            $cli->output( "\tIndexing object ID #$objectID" );
+            $object = eZContentObject::fetch( $objectID );
+            if ( $object )
+            {
+                // delay commits with passing false for $commit parameter
+                $eZSolr->addObject( $object, false );
+            }
+        }
+
+        $paramInSQL = $db->generateSQLInStatement( $objectIDList, 'param' );
+
+        $db->query( "DELETE FROM ezpending_actions WHERE action = 'index_object' AND $paramInSQL" );
+        $db->commit();
+
+        // finish up with commit and optimize
+        if ( $solrOptimize )
+        {
+            $eZSolr->optimize( $solrCommit );
+        }
+        elseif ( $solrCommit )
+        {
+            $eZSolr->commit();
+        }
+
+
+    }
+    else
+    {
+        break; // No valid result from ezpending_actions
+    }
+}
+
+if ( !$isQuiet )
+{
+    $cli->output( "Done" );
+}
+
+?>

Propchange: ezfind/ezp4/trunk/extension/ezfind/cronjobs/ezfindexcontent.php
------------------------------------------------------------------------------
    svn:eol-style = native

_______________________________________________
svn-eZFind mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-ezfind

Reply via email to