PHP SDK Remove methods not working

Hi,

I cannot remove a row from my collection using any of the methods provided in the php documentation.
I am able to get my row by object and return it, but calling any delete method throws a server error 500.
I have 3 other functions on the same script involving some more advanced object creation and querying which run fine. Here is some sample code

$object = Backendless::$Data->of(“Events”)->findById($objectID);

//data method
//Backendless::$Data->of("Events")->remove($object);


//presistence method
Backendless::$Persistence->of("Events")->remove($object);


//bulk
$event = new Events();
Backendless::$Persistence->of("Events")->removeBulk( $event, "objectId='".$objectID."'" );

Any thoughts? Thank you.

Hi David,

Do you receive any error message? Like “Internal server error with ID XXX”. Also your application ID would help to search the logs for errors.

00750AD9-8347-789A-FF49-87F556EE0500

Internal Server Error 500

Can you also please provide some objectId on which the remove request fails?

sure,

you can use this objectId for a row in Events
60FD196D-8B17-0C84-FF16-363B1BFD1F00.

Please verify, can you remove the same object via the built-in REST console?

Confirmed,

The object was deleted via built in rest console

I couldn’t find any logs on your applications with an error. Could you please try to debug your code and find a line of code where it fails or some more detailed error message?

Any of those Delete Methods are the break points in my code.
I currently call this one and it breaks:
Backendless::$Data->of(“Events”)->remove($object);

I have the object returning right before this call so I know it is retrieved.

You can go into the remove method (our SDK source is available on GitHub) and see where exactly it fails.

I have looked at this method.

If I change your condition here:

if( $object_id == null || $object_id == “” ) {

        throw new BackendlessException( "Missing objectId for remove data", $code );
        
    }else{
        return $object_id;
    }

I get the object id back. If I take that else out it will go into these lines:

$this->cheackTargetTable( $this->extractObjectType( $data ), METHOD ); // if call method of() check target table and table in data structure

    return RequestBuilder::doRequest( 'data', $this->extractObjectType( $data ) . '/' . $object_id, [], 'DELETE' );

This is where the server will break and return error 500

I believe the code still goes further. Please put a breakpoint in RequestBuilder’s doRequest function and check if the request is sent to the server. If yes, then you should receive the full text of the error in RequestBuilder’s handleError function. If the error is sent by the server, it will be of the form “Internal Server Error with ID XXXX”, where XXXX is the ID by which we will be able to find it in the logs and investigate why it happens. Otherwise it may be an error somewhere on the client, and you will still receive the full reason in RequestBuilder class or elsewhere the code goes.

Unfortunately I don’t have the time to look through the functions and debug where this is going wrong. For now I have a quick fix of curling to the rest console for deleting events.
This will work for me.

Hopefully you and your team will find the time to round out the remaining issues in the php sdk.