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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 15:04:21
Script start
Timing: Jan 18 2025 15:04:21
Module start 'layout'
Timing: Jan 18 2025 15:04:21
Module start 'content'
Timing: Jan 18 2025 15:04:22
Module end 'content'
Timing: Jan 18 2025 15:04:22
Script end

Main resources:

Total runtime0.9424 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.1484152.6406
Module start 'layout' 0.00600.0025 740.789139.4766
Module start 'content' 0.00840.9325 780.2656527.4609
Module end 'content' 0.94100.0014 1,307.72668.1250
Script end 0.9424  1,315.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3403160.0002
Check MTime0.00130.1366160.0001
Mysql Total
Database connection0.00140.147410.0014
Mysqli_queries0.896895.1566540.0166
Looping result0.00050.0518520.0000
Template Total0.913797.020.4569
Template load0.00250.263120.0012
Template processing0.911396.692020.4556
Template load and register function0.00020.025610.0002
states
state_id_array0.00080.085610.0008
state_identifier_array0.00100.103020.0005
Override
Cache load0.00200.2111140.0001
Sytem overhead
Fetch class attribute can translate value0.00130.143220.0007
Fetch class attribute name0.00090.097630.0003
XML
Image XML parsing0.00090.097120.0005
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.00070.0777170.0000
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs