Forums / Developer / Problems with "eZOperationHandler::execute()"

Problems with "eZOperationHandler::execute()"

Author Message

Tobias Schirski

Wednesday 29 October 2008 11:54:48 am

Hi everybody,

this is my first post here, so hi! I´m Tobi from Germany ;-)

No coming back to my little problem:

I´m trying to import data from a remote database into ezPublish. Everythings fine so far, except for the publishing-process.

Everytime I call

eZOperationHandler::execute

, I get the following warning:

PHP-Error (E_WARNING): array_map() [<a href='function.array-map'>function.array-map</a>]: Argument #2 should be an array in <b>/kernel/classes/clusterfilehandlers/ezfsfilehandler.php</b> on line <b>690</b>

The publishing works, but I´m no friends of warnings, so it would be great if you cold help me getting this error out of my way.

Bye,
Tobi

André R.

Thursday 30 October 2008 12:50:23 am

Hi Tobi and welcome to the community!

When you got problems it's an advantage if you give as much information as possible(within reasonable limits of course, posting ~100 lines of code and asking what your doing wrong would not help you much :) ).

* First of all what eZ Publish version are you using?
* And how are you using it?
In this case:
Is this a custom script?
Are you running it from ezp root?
If ezp 4.0.x, have you set 'use-modules' => true and 'use-extensions' => true in "eZScript::instance" and included autoload.php like all other scripts does?
* When you see references to line numbers like the one above:
Post the code on that line, line numbers change between versions, so posting the line in question on your install with two lines above and bellow would really help..

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

Tobias Schirski

Thursday 30 October 2008 3:06:47 am

Hi André,

thanks for your kind reply.

Here you go with (hopefully) all needed informations:

First of all, I´m using ez Publish <b>4.0.1</b>

I´ve built an ezP-Module, which is used to administrate certain data, which cannot be handled by the ezP-Backend.

So this function will be called within a running ezP-Enviroment, which means, I guess, that I don´t have to bother with eZScript and eZCli and all that stuff. At least, I hope so.

So this is, what I do in my module:

//Get Draft-Object with ID 183
$draft = eZContentObject::fetch(183);
		
//Copy Draft-Object to new Object
$newObject = $draft->copy(false);
$newObject->setAttribute( 'remote_id', $remoteId);
$newObject->store();
		
// Assign new object to node 180
$nodeAssignment = eZNodeAssignment::create(
		    array(
		        'contentobject_id'		=> $newObject->attribute( 'id' ),
		        'contentobject_version'	=> 1,
		        'parent_node' => 180,
		        'is_main' => 1
		        )
		    );

//Store this Node-Assignment
if( $nodeAssignment )
{
	$nodeAssignment->store();
}
		
	
//Get the objects Version
$objectVersion = $newObject->currentVersion();
		

//Now set the Attribute 'name' to a new Value
$attributes = $objectVersion->attribute('data_map');
		
		
$name = $attributes['name'];
$name->fromString('New Value!');
$name->store();
		
//Store object again
$newObject->store();
		

//Publish new Object
$result = eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute( 'id' ), 'version' =>  $objectVersion->attribute('version')));

Now this code always produces the above stated Error-Message. The Object, however, will be published and everything seems fine, so far.

Here´s the function, the Error-Message references to (to be found in ezfsfilehandler.php):

    function fileDeleteByDirList( $dirList, $commonPath, $commonSuffix )
    {
        $dirs = implode( ',', $dirList );
        $wildcard = $commonPath .'/{' . $dirs . '}/' . $commonSuffix . '*';

        eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileDeleteByDirList( '$dirList', '$commonPath', '$commonSuffix' )" );

        eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
        array_map( 'unlink', eZSys::globBrace( $wildcard ) );
        eZDebug::accumulatorStop( 'dbfile' );
    }

Now, I hope, this is all information you need.

Thank you again and bye!

Tobias

André R.

Thursday 30 October 2008 1:51:53 pm

Do you get any other warnings/errors?
Seems like eZSys::globBrace( $wildcard ) returns something else then a array.

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

Tobias Schirski

Friday 31 October 2008 9:02:40 am

This is what I thought either, but the funny thing is, that I dont get this error anywhere else.

André R.

Friday 31 October 2008 3:03:42 pm

Try adding this just above the line:

       eZDebug::writeDebug( $wildcard, 'ezfsfilehandler::fileDeleteByDirList $wildcard' );

and this if it looks ok:

       eZDebug::writeDebug( (defined( 'GLOB_BRACE' ) ? 'true' : 'false'), 'ezfsfilehandler::fileDeleteByDirList GLOB_BRACE' );

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

Tobias Schirski

Monday 17 November 2008 2:15:24 am

Hi André,

sorry, that it took so long, but I tested your code.

Here are the responses:

The First line is returning a String like this:

"var/siteroot/cache/content/{siteaccess1,siteaccess2,siteaccess3}/3/349-*" 

The second line returns TRUE, so GLOB_BRACE should be working, right?

What can I do now?

Edit:
Alright, I checked again, and the glob()-Function is returning FALSE. Thats definetly no array. So what should be my next steps?

Bye and again, thanks for your help,
Tobias

Tobias Schirski

Monday 17 November 2008 2:35:37 am

Ok,

new revelations:

There are simply no files, that match the pattern. All Cache-Files begin with somewhat lower than "349", so glob()-Simply doesnt match, and doesnt return an empty array, but false.

This is, what the PHP-Documenation has to say:

Warning: On some systems it is impossible to distinguish between empty match and an error. 

eZPublish should consider this in future versions.

For now, I will ignore this error, but will open an issue for this problem.

Thank you again,
Tobias

eZ debug

Timing: Jan 31 2025 06:19:02
Script start
Timing: Jan 31 2025 06:19:02
Module start 'content'
Timing: Jan 31 2025 06:19:02
Module end 'content'
Timing: Jan 31 2025 06:19:02
Script end

Main resources:

Total runtime0.2660 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.0625180.8125
Module start 'content' 0.00680.0061 768.8750106.0547
Module end 'content' 0.01290.2530 874.9297534.8750
Script end 0.2659  1,409.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00331.2259200.0002
Check MTime0.00130.4766200.0001
Mysql Total
Database connection0.00090.322610.0009
Mysqli_queries0.219982.65361410.0016
Looping result0.00140.51961390.0000
Template Total0.252695.010.2526
Template load0.00080.316110.0008
Template processing0.251794.633910.2517
Override
Cache load0.00050.203010.0005
Sytem overhead
Fetch class attribute can translate value0.00070.262410.0007
XML
Image XML parsing0.00020.084610.0002
General
dbfile0.00722.6961200.0004
String conversion0.00000.002630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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