How to run console script?

ELGG 1.8

Hello.
I have a problem.
I need to run the console task, which is importing loads of objects into elgg's entities.
Here are some code strings:

 

require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");

elgg_set_context('main');

$entityGuid = create_entity('object', 'objects_subtype', 1, get_default_access(), 1, 1);

var_dump($entityGuid);

 

Result is: bool(false) and there are no errors.

Help!

 

  •  

    $ent = new ElggObject();
    $ent->subtype = 'object';
    $ent->subtype = 'object_subtype';
    $ent->title = 'title';
    $ent->description = 'description';
    $ent->access_id = ACCESS_PUBLIC;
    $ent->owner_guid = 1;
    $ent->container_guid = 1;
    $ent->site_guid = 1;
    $ent->save();

    This works.  But I've got a message: "Unable to save new object's base entity information!"

    It seems that I have to be logged in, but how can I log in through console? 

     

  • Two things:

    1. $ent->subtype is set twice. This doesn't matter, but I don't think it's what you meant. Note that you can't go $ent->type = 'type'; The type is controlled by the class. ElggObject is type 'object'.
    2. You need to disable access control with elgg_set_ignore_access(true);