Thank you for your explanation. I see that the main Omeka index.php is similar. You must have worked hard to discover that calling run() was not needed.
I just tried out a minimal version to run a batch script based on the code at github, and was not successful.
I took out the references to the extra zoom functions, and made only a simple database call, to get this script.
Note that it is changed so that it is located in the top level Omeka install folder, where bootstrap.php exists.
<?php
/**
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
* @author Sylvain Machefert - Bordeaux 3
*/
require_once dirname(__FILE__).'/bootstrap.php';
$application = new Omeka_Application(APPLICATION_ENV);
$application->getBootstrap()->setOptions(array(
'resources' => array(
'theme' => array(
'basePath' => THEME_DIR,
'webBasePath' => WEB_THEME
)
)
));
$application->initialize();
$db = get_db();
$sql = " SELECT count(*) FROM {$db->Item} items ";
$result = $db->fetchAll($sql);
print "Items count: $result \n";
exit;
?>
The php code is in file test.php and is run with command line:
php test.php
It gets a warning message on stdout before showing the html reporting a fatal error:
Warning: ini_set(): Cannot change zlib.output_compression - headers already sent in D:\xampp\xampp\htdocs\omeka\bootstrap.php on line 127
It gets a fatal error message and stack trace in the error.log file:
2013-10-10T13:22:13-07:00 ERR (3): exception 'Zend_Session_Exception' with message 'Session must be started before any output has been sent to the browser; output started in D:\xampp\xampp\htdocs\omeka\test.php/2' in D:\xampp\xampp\htdocs\omeka\application\libraries\Zend\Session.php:451
Stack trace:
#0 D:\xampp\xampp\htdocs\omeka\application\libraries\Zend\Session\Namespace.php(143): Zend_Session::start(true)
:
#18 D:\xampp\xampp\htdocs\omeka\application\libraries\Omeka\Application.php(51): Zend_Application->bootstrap()
#19 D:\xampp\xampp\htdocs\omeka\test.php(21): Omeka_Application->initialize()
#20 {main}
In case it is the warning message that is causing the fatal error, another version of the test is run.
bootstrap.php is changed to comment out the lines causing the warning message:
// Set the zlib config values if the extension has been loaded.
if (extension_loaded('zlib')) {
// ini_set('zlib.output_compression', true);
// ini_set('zlib.output_compression_level', '5');
}
Running this version of the test.php also fails.
The warning message is not output but the same fatal error and stack trace is in the error.log file.
Sylvain, what did you do to avoid the warning message from line 127 in bootstrap.php?
And what did you do to avoid the fatal error in Session.php line 451?
Thanks for any pointers.
Having the ability to run an Omeka batch script is a powerful tool to have available. That is clear when seeing your code to create zoom tiles in a batch process. I want to learn how to run batch files that use Omeka's helper functions.