publish object with php

Author Message

Sebastian Sprenger

Wednesday 24 September 2003 5:45:55 am

Hi!
I try to publish an object in an extension (using php).
With
$object->setAttribute( "is_published", "1" );
$object->store();
I can set the object to 'IsPublished', but in the database (table ezcontentobject_tree) the object is still unpublished (contentobject_is_published = 0).
What can I do?

After the publishing an 'wait until date' event should start, but now even the publish doesn't work...

Thanks for your help,
Sebastian

Wenyue Yu

Wednesday 24 September 2003 6:38:20 am

Hi,

Try the following code:

include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
'version' => $contentObjectVersion ) );

wenyue

Sebastian Sprenger

Thursday 25 September 2003 1:14:21 am

Thanks, seems to work.
But I always have to run the command twice. First time nothing happens, no error.
After reloading the page the object is published.
Any idea why I have to run it twice??
Sebastian

Sergiy Pushchin

Thursday 25 September 2003 2:16:10 am

It seems like operation is halted by workflow and continued next time you run operation (when you reload). try to disconect workflow from publish trigger and see if it will be published from the first time.
--SP

Sebastian Sprenger

Thursday 25 September 2003 2:34:37 am

Sorry, even with no trigger connected the object isn't published from the first time.

Any more ideas? Thanks!

Sergiy Pushchin

Thursday 25 September 2003 4:19:01 am

Can you dump the $operationResult variable and show me the result? From the first and from the second run...

Sebastian Sprenger

Thursday 25 September 2003 4:38:22 am

$operationResult is: array(1) { ["status"]=> int(1) }
First and second time.

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 31 2025 06:11:43
Script start
Timing: Jan 31 2025 06:11:43
Module start 'layout'
Timing: Jan 31 2025 06:11:43
Module start 'content'
Timing: Jan 31 2025 06:11:43
Module end 'content'
Timing: Jan 31 2025 06:11:43
Script end

Main resources:

Total runtime0.0168 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 588.1016151.1953
Module start 'layout' 0.00550.0026 739.296936.6172
Module start 'content' 0.00810.0073 775.914194.0938
Module end 'content' 0.01530.0014 870.007837.9922
Script end 0.0167  908.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002514.9037140.0002
Check MTime0.00116.3039140.0001
Mysql Total
Database connection0.00063.748010.0006
Mysqli_queries0.002213.164730.0007
Looping result0.00000.089510.0000
Template Total0.00106.110.0010
Template load0.00074.402910.0007
Template processing0.00031.649510.0003
Override
Cache load0.00052.921110.0005
General
dbfile0.002615.679580.0003
String conversion0.00000.054040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs