We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26401
    • 247 Posts
    Removing one link, removes all links (not just the two slave-master and master-slave).


    I'm using the latest minishop2 and referring to this code here

    https://github.com/bezumkin/miniShop2/raw/master/core/components/minishop2/processors/mgr/product/productlink/remove.class.php

    I've added this code
    var_dump($q);
    return '';
    



    before
    $q->stmt->execute();


    this is the ajax request
    action:mgr/product/productlink/remove
    link:2
    master:130
    slave:179


    but this is the resulting query I see from the dump
    DELETE FROM `modx_ms2_product_links`
    WHERE  ( `modx_ms2_product_links`.`link` = 2 AND  ( `modx_ms2_product_links`.`master` = 179 OR `modx_ms2_product_links`.`slave` = 179 )  )


    there is nothing telling it to delete only items where the ids are both 179 AND 130.


    Is this inteded functionality, something I missed in the settings, or a bug in the code? I'm wondering if I did something wrong before I go and try to edit the code of another plugin.
      • 26401
      • 247 Posts
      replaced the query code
      case 'many_to_many':
      case 'one_to_one':
      	$q->where(array('master' => $slave, 'OR:slave:=' => $slave));
      break;


      with:
      case 'many_to_many':
      	$q->where(array('master' => $slave, 'OR:slave:=' => $slave));
      break;
      
      case 'one_to_one':
      	$q->where(array(array('master' => $master, 'AND:slave:=' => $slave),array('master' => $slave, 'AND:slave:=' => $master) ),xPDOQuery::SQL_OR );
      break;


      Only worried about the one-to-one, many-to-many seems fine, but not using it so I don't know