jorisdugue / h5p-bundle

A bundle to integrate h5p into your Symfony project.
MIT License
11 stars 16 forks source link

Uncaught TypeError: Cannot read properties of undefined (reading 'name') - h5peditor.js?=1.24:437 #47

Closed bwebdevro closed 1 year ago

bwebdevro commented 1 year ago

Hey guys,

I have tried to use the Interactive Video library but I get the following error:

Uncaught TypeError: Cannot read properties of undefined (reading 'name')
    at ns.processSemanticsChunk (h5peditor.js?=1.24:437:15)
    at new MetadataForm (h5peditor-metadata.js?=1.24:293:15)
    at ns.Form.processSemantics (h5peditor-form.js?=1.24:422:25)
    at h5peditor-library-selector.js?=1.24:281:17
    at h5peditor.js?=1.24:238:13
    at h5peditor.js?=1.24:156:15
    at h5peditor.js?=1.24:90:34
    at Array.forEach (<anonymous>)
    at script.onload (h5peditor.js?=1.24:90:20)

Before that I get the following error on /h5p/new path: Uncaught (in promise) Error: Unable to load levels metadata. at h5p-hub-client.js?=1.24:54:49845 and same for languages, licenses and disciplines metadata. I don't know if the issues are related.

I copied the files for h5p-core and h5p-editor from public directory from another project (with Symfony 5) because the files were not generated on my current project.

jorisdugue commented 1 year ago

Hey, can you provide some code that allows you to reproduce this problem, I can't seem to reproduce it.

For information, the php bin/console asset:install command should work

bwebdevro commented 1 year ago

@jorisdugue For the first error Uncaught TypeError: Cannot read properties of undefined (reading 'name') the problem is from h5peditor.js and it seems that the field variable is undefined but I can't figure why:

for (var i = 0; i < semanticsChunk.length; i++) {
    var field = semanticsChunk[i];

    // Check generic field properties.
    if (field.name === undefined) {
      throw ns.t('core', 'missingProperty', {':index': i, ':property': 'name'});
    }
...
}

Another thing I saw is that when I ran the command php bin/console asset:install the files (assets) from /public/bundles/studith5p/h5p/h5p-core and /public/bundles/studith5p/h5p/h5p-editor are missing so i have to move those files from another project with symfony 5 but I don't thing they are compatible with symfony 6. And in dev.log file I receive the following error: request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET http://localhost/server-status"" at /var/www/h5p_symfony/app/vendor/symfony/http-kernel/EventListener/RouterListener.php line 128 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET http://localhost/server-status\" at /var/www/h5p_symfony/app/vendor/symfony/http-kernel/EventListener/RouterListener.php:128)\n[previous exception] [object] (Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): No routes found for \"/server-status/\". at /var/www/h5p_symfony/app/vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherTrait.php:74)"} []

jorisdugue commented 1 year ago

Ok after researching and fixing several issues (in the dev version)

I started developing the new version from dev h5p-library for prevent this problem. At this moment no version has been released on H5P for php however there is one for moodle and drupal knowing that drupal being a symfony base we can very well use it to continue for the moment I am going to the dev branch with a commit reference to avoid any future problems (a BC for example)

To avoid this issue, you can upgrade to version https://github.com/jorisdugue/h5p-bundle/releases/tag/v2.0.2

jorisdugue commented 1 year ago

Hey,

The dev version of h5p also fixes the problem you encountered :)

You can install it with the dev version of this bundle if you want to do a test also it should be noted that some changes have been made to the tables this absolutely implies a database migration :)