Functionality for exporting h5p nodes to h5p packages.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gafolini’s picture

Status: Active » Needs review
FileSize
11.66 KB

Patch attatched.

falcon’s picture

Status: Needs review » Needs work

Great work!

I did a brief code review, and it looks good. I find a few things that needs to be checked before I install and test the patch:

1. Library dependencies stored in h5p_nodes_libraries are the dependencies that needs to go into h5p.json. The editor stores the libraries that are actually beeing used by a node here.
2. Requests to the export url will result in an export even if export is turned of. Need to disable the menu path if export is switched off
3. Doesn't seem to handle the difference between preloaded and dynamic dependencies
4. If the node has a language use that language, if not use 'und'
5. The code below needs some comments and variable renaming, I had to read it twice:

$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempPath . DIRECTORY_SEPARATOR));
  // Add files to zip
  foreach ($iterator as $key=>$value) {
  $test = '.';
  if (substr_compare($key, $test, -strlen($test), strlen($test)) !== 0) {
    $boom = explode($tempPath . DIRECTORY_SEPARATOR, $key);
    $zip->addFile($key, $boom[1]);
  }
}
Ellinokon’s picture

FileSize
13.68 KB

A new patch addressing the code review is attached.

Ellinokon’s picture

Status: Needs work » Needs review
FileSize
13.69 KB

Previous patch didn't contain the right code for cleaning up the temp directory. Attached is a new patch with the full code, to replace the one uploaded yesterday.

falcon’s picture

Another quick code review here:

  1. Library dependency issue seems to be fixed. Good!
  2. The wording I used in my last review seems to have resulted in an unfortunate implementation. To disable the menu item you must use access callback. Using variable_get as the access callback and h5p_export and 1 as access arguments will probably work. The way it is now switching on h5p_export won't take effect until the menu cache has been cleared
  3. Preloaded and dynamic is handled well it seems
  4. Language is handled well
  5. The unclear code has been made a lot more readable. Great!
  6. The queries should be optimized. Query #2 and #3 in getExportData should be combined using join. This will boost performance.
  7. There has been some changes to H5P. Make sure you pull the latest code before creating a new patch

When these small adjustments have been made we are good to go.

falcon’s picture

Issue summary: View changes
Status: Needs review » Needs work
gafolini’s picture

Status: Needs work » Needs review
FileSize
13.19 KB

Think we finished the remaining issues.

falcon’s picture

Status: Needs review » Fixed

Great work! Thanks!

I made a few changes and added this feature to the beta16 release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit 61c11b7 on master, 6.x-1.x, 7.x-1.x:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit 61c11b7 on master, 6.x-1.x, 7.x-1.x:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit 61c11b7 on master, 6.x-1.x, 7.x-1.x:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...

  • Commit 61c11b7 on master, 7.x-1.x, 6.x-1.x:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit e1e0175 on 7.x-1.x, 6.x-1.x:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...

  • Commit 61c11b7 on master, 7.x-1.x, 6.x-1.x:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit e1e0175 on 7.x-1.x, 6.x-1.x:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...

  • Commit 61c11b7 on 7.x-1.x, 6.x-1.x, master, tmpM:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit e1e0175 on 7.x-1.x, 6.x-1.x, master, tmpM:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...

  • Commit 61c11b7 on 7.x-1.x, 6.x-1.x, master, tmpM:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit e1e0175 on 7.x-1.x, 6.x-1.x, master, tmpM:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit 61c11b7 on 7.x-1.x, 6.x-1.x, master, tmpM:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit e1e0175 on 7.x-1.x, 6.x-1.x, master, tmpM:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...

  • Commit 61c11b7 on 7.x-1.x, 6.x-1.x, master, tmpM, views-integration:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...
  • Commit e1e0175 on 7.x-1.x, 6.x-1.x, master, tmpM, views-integration:
    Issue #2120227 by gafolini, Ellinokon and falcon: Add export feature to...