/** * Get the queue of documents for processing * */ public function getDocumentProcessingQueue($max = null) { global $default; $max = empty($max) ? 20 : $max; // Cleanup the queue Indexer::clearoutDeletedFromProcessor(); $date = date('Y-m-d H:i:s'); // identify the indexers that must run // mysql specific limit! $sql = "SELECT\n \t\t\tpq.document_id, mt.filetypes, mt.mimetypes\n\t\t\t\tFROM\n\t\t\t\t\tprocess_queue pq\n\t\t\t\t\tINNER JOIN documents d ON pq.document_id=d.id\n\t\t\t\t\tINNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id\n\t\t\t\t\tINNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id\n\t\t\t\t\tINNER JOIN mime_types mt ON dcv.mime_id=mt.id\n \t\t\t\tWHERE\n \t\t\t\t\t(pq.date_processed IS NULL or pq.date_processed < date_sub('{$date}', interval 1 day)) AND dmv.status_id=1\n\t\t\t\tORDER BY date_added\n \t\t\t\t\tLIMIT {$max}"; $result = DBUtil::getResultArray($sql); if (PEAR::isError($result)) { $default->log->error('Processing queue: stopping - db error: ' . $result->getMessage()); return; } // bail if no work to do if (count($result) == 0) { $default->log->debug('Processing queue: stopping - no work to be done'); return; } return $result; }