Forums / Developer / Change siteaccess in eZ CLI PHP script

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

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 Exponential 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 Exponential'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 ... ???