Change siteaccess in eZ CLI PHP script

Author Message

Fabio Carissimi

Monday 10 July 2006 2:03:40 am

Hi,

I am using CLI scripts to import or update objects in EZPublish like explained in this post :
http://ez.no/community/forum/developer/importing_update_entry_if_it_already_exists

What I want to do is read an object in one site (one siteaccess, one db) and update the object in another
site (other siteaccess, other db). But I can't change the siteaccess within the script.

I use a script object and when I want to change the siteaccess, it does not work :

$script =& eZScript::instance(...);
$script->setUseSiteAccess('siteaccess1');

I also tried with the method in EzPublish's index.php :

include_once( "access.php" );
$access = array('name'=> 'siteaccess1',"type"=> EZ_ACCESS_TYPE_HTTP_HOST);
$access = changeAccess( $access );
eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'current siteaccess' );
$GLOBALS['eZCurrentAccess'] =& $access;

and I tried also with 2 eZScript instances :

$script2 =& eZScript::instance(...);
$script2->setUseSiteAccess('siteaccess2');

but always no success
my first question is : is it possible ?
if it is, does somebody did it and can help me ? if not, does somebody knows a workaround ?

Thanks for help

Kristof Coomans

Monday 10 July 2006 2:17:34 am

Hello Fabio

Calling <i>$script->setUseSiteAccess('siteaccess1');</i> only works before <i>$script->initialize();</i>.

Have you tried the second method you mentioned with EZ_ACCESS_TYPE_STATIC instead of EZ_ACCESS_TYPE_HTTP_HOST?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Fabio Carissimi

Monday 10 July 2006 3:04:37 am

Hello,

I knew that and take care of calling $script->setUseSiteAccess('siteaccess1'); before $script->initialize();.
I tried every available access method from 1 to 8 (see access.php for details)

It seems that when siteaccess is selected, it can't be changed in the script ... ???

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 21 2025 04:22:57
Script start
Timing: Jan 21 2025 04:22:57
Module start 'layout'
Timing: Jan 21 2025 04:22:57
Module start 'content'
Timing: Jan 21 2025 04:22:58
Module end 'content'
Timing: Jan 21 2025 04:22:58
Script end

Main resources:

Total runtime1.3139 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 589.6328151.2266
Module start 'layout' 0.00690.0031 740.859436.6641
Module start 'content' 0.01001.3029 777.5234563.2109
Module end 'content' 1.31290.0010 1,340.734411.8438
Script end 1.3138  1,352.5781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2378160.0002
Check MTime0.00140.1038160.0001
Mysql Total
Database connection0.00140.107210.0014
Mysqli_queries1.264296.2170570.0222
Looping result0.00070.0514550.0000
Template Total1.281897.620.6409
Template load0.00200.154520.0010
Template processing1.279897.403420.6399
Template load and register function0.00020.015510.0002
states
state_id_array0.00030.024410.0003
state_identifier_array0.00240.179620.0012
Override
Cache load0.00170.1278280.0001
Sytem overhead
Fetch class attribute can translate value0.00070.057020.0004
Fetch class attribute name0.00100.077140.0003
XML
Image XML parsing0.00170.132720.0009
class_abstraction
Instantiating content class attribute0.00000.000840.0000
General
dbfile0.00090.0719160.0001
String conversion0.00000.000940.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs