eZ Community » Forums » Developer » Fatal Error on Publish using REST-API
expandshrink

Fatal Error on Publish using REST-API

Fatal Error on Publish using REST-API

Wednesday 02 July 2014 1:34:30 am - 1 reply

Hi Everyone,

I hope I'm on the right place for this.

 

I'm currently having an issue when publishing a contents version using the REST-API.
My first thought was about the instance I'm working with (maybe a misconfiguration) but it turned out that this error is probably on all 2014.03-instances i have access to.

As I try to publish content using the REST-API the returned status-code is 500.
According to the documentation it should be 204 for successfully published.

 

I nailed down the problem to the Closure dispatching a signal to the legacy-stack.
This signal is supposed to update/create the index for this content in search (solr in this case).

 vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/SignalSlot/Slot/AbstractLegacySlot.php    
     protected function getLegacyKernel()
    {
        if ( $this->legacyKernel instanceof ezpKernelHandler )
            return $this->legacyKernel;
 
        $legacyKernelClosure = $this->legacyKernel;
        return $legacyKernelClosure();
    }

This method requires "$this->legacyKernel" to be instance of ezpKernelHandler.
As in the constructor of the class described (it is Closure otherwise).

So its not instance of ezpKernelHandler and is getting called as a regular Function.
Every instance I found is going to its knees with status 500.

 

This error does not occur on using the Public-API to publish content.

The content gets published without any issues, but the solr-index is not generated when using publish via REST-API.
I just searched for this issue but found nothing about it.

 

Is there a fix to it?

Sorry, that I'm not too much into this Closure-Stuff and so don't know how it does exactly work.

Monday 07 July 2014 3:44:49 am

I used the publish-command as defined in the documentation for the REST-API.

https://github.com/ezsystems/ezpublish-kernel/blob/master/doc/specifications/rest/REST-API-V2.rst#publish-a-content-version

There obviously is a problem at this.
It neither tells you to use the Accept-Header nor does it to use the Content-Type-Header.

It even tells you to use the freaking X-HTTP-Method-Override-Header with a post.

Well here are the problems.

  1. It actually requires the Accept-Header or the Content-Type-Header.
    It will crash when emitting to legacy if you do not is it!
  2. The X-HTTP-Method-Override should (currently) not be used with this function of the REST-API.
    Its easy to tell why.
    To use it, you use POST which is secured by eZXFormToken and guess what. You can't have it.
    It does only work and give you the desired 204 if you do not use POST.

I know you guys are busy deploying the new version but the documentation really is crap.
Sorry for that, i really like eZ and the directs its going in. You guys do a great job.

The first point has to be added to the documentation asap.

The second one needs to be fixed. x-form-token should not activate itself if X-HTTP-Method-Override is set you something different than POST.
This has to be implemented to all post-requests though.
I can feel it will take a while and is not a thing anyone can do within 8 hours or so.

Anyway, if you concern the bugs mentioned above, you will be able to publish content (with indexing to solr or the basic search) without any problems.
That is if your server recognizes the PUBLISH correctly.

Thanks.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from