Problem/Motivation

Currently deleting of entities isn't implemented as method in salsa_api.inc and just supported by the function salsa_api_query().

Proposed resolution

Implement delete method similar to other methods.

Comments

berdir’s picture

Priority: Normal » Major

This would also allow us to nicely ignore the problem that delete returns an invalid response at the moment

devlada’s picture

Status: Active » Needs review
StatusFileSize
new1.39 KB

Regarding to invalid response, are you referring to something like

null --> table_key 53160816

<?xml version="1.0"?>
	<response><success table="supporter" key="53160816">Deleted entry 53160816</success>
</response>

The first line looks like debug message, and these have been affected supporter and donation objects as I can see, and probably some others. I can remove simplexml_load_string() part, but we will left without any information about deleted records. I'm not sure whether we need to deal with it, in salsa_entity to check whether the objects are removed or not before we proceed any further.

berdir’s picture

Status: Needs review » Needs work

Yes, remove the parsing/loading. Or explicitly comment it out and add a @todo and explain that the page currently returns debug messages that break the parsing.

devlada’s picture

Status: Needs work » Needs review
StatusFileSize
new1.12 KB
new1.77 KB

Updated patch (commented parsing / loading).

berdir’s picture

Status: Needs review » Needs work
+++ b/salsa_api.inc
@@ -74,6 +74,40 @@ class SalsaAPI implements SalsaAPIInterface {
+  public function delete($object, array $keys = array()) {
+    if (!empty($keys)) {
+      $query[] = 'xml';

I'm not sure why you made $keys an optional argument? Just make it required and you don't need this check/exception?

berdir’s picture

+++ b/salsa_api.inc
@@ -493,6 +518,21 @@ interface SalsaAPIInterface {
+   * @param $object
+   *   Salsa entity object / table.
+   * @param $keys
+   *   Primary key value.

let's follow the new coding standards. So include a type, like @param string $object and @param array $keys.

devlada’s picture

Status: Needs work » Needs review
StatusFileSize
new2.43 KB
new1.61 KB

Updates related to #5 and #6.

  • Berdir committed 85d6b8b on 7.x-1.x
    Issue #2382439 by devlada, Berdir: Implement delete method in new API
    
berdir’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Patch (to be ported)

Thanks, made a few comment/documentation improvements (no need for return value) and committed.