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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.