kendraio / kendra_hub

Kendra Hub
https://www.kendra.io/kendra-hub
GNU General Public License v2.0
4 stars 1 forks source link

Exclude an asset from its own sample list and stop recursive infinite loops #34

Closed BBGuy closed 10 years ago

BBGuy commented 10 years ago

Exclude an asset from its own sample list to stop circular relationships. The simple case If you create a new |asset called "Song 1" and click 'Embed a Sample' the sample view you get should exclude "Song 1" we may be able to extract this from the url http://hub2.kendra.org/sample/?destination=node/106 using php in a contextual argument. Possible use rules link and I think we are storing the id in the session. to do:

Indirect sample case Song 2 has a sample of song 1. User samples song 2 into song 1. This will create a circular relationship of song 1 to itself via song 2

BBGuy commented 10 years ago

for the first issue added a contextual filter on the nid with default value using PHP code:

$p = drupal_get_query_parameters();
if (empty($p['destination'])) {
    $nid = -1;  
}
else {
  $nid = str_replace('node/', '', $p['destination']);
}
return $nid;

In the more options set to Exclude

BBGuy commented 10 years ago

It will be difficult to stop the second case from happening (but can be done with more effort)
I have added rough code to stop assets going into a recursive infinite loop. However we may hit this issue again as we may have other code or use cases that will trigger this issue. we can look at this again in the future Created two assets for testing: http://hub2.kendra.org/content/recursive-asset http://hub2.kendra.org/content/recursive-asset-b