Forums / Developer / Problem with kernel classes in an external php script

Problem with kernel classes in an external php script

Author Message

Nicolas R

Thursday 12 February 2009 6:00:00 am

Hello,

I have the following php script in extension\myext\modules\mymodule\classes\a.php

<?php
include_once 'autoload.php';

$cli = eZCLI::instance();
$script = eZScript::instance( array( 'description' => ( "eZ Publish Script Executor\n\n"),
                                     'use-session' => false,
                                     'use-modules' => true,
                                     'use-extensions' => true ) );
$script->startup();
$options = $script->getOptions( "","[scriptfile]",array() );
$script->initialize();

$node = eZFunctionHandler::execute( 'content', 'list', array( 'parent_node_id' => 2 ) );
echo "RES ".$node."\n";

$script->shutdown();

?>

If I run this script in the root directory of eZPublish (ie. in which there are the directories bin, kernel, settings, etc.) it works perfectly but I run it into my module directory, it does not work.
I have the following error:
Warning: in_array(): Wrong datatype for second argument in C:\wamp\www\ezpub401\kernel\classes\ezscript.php on line 1063

Any idea ?
Thank you !

André R.

Thursday 12 February 2009 8:04:07 am

ezpublish scripts / classes / code needs to be run from root, so either run your script from the root or fake it by setting the current working dir in php to the root of the install before you include anything. (not tested the last part)

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom