Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception - Call to a member function get_filename() on null #23

Closed
durzo opened this issue Dec 23, 2020 · 2 comments · Fixed by #25
Closed

Exception - Call to a member function get_filename() on null #23

durzo opened this issue Dec 23, 2020 · 2 comments · Fixed by #25
Labels
bug Something isn't working

Comments

@durzo
Copy link

durzo commented Dec 23, 2020

Since upgrading to version v0.1.3 we started getting this exception on every single migration run.


Migrating ID:1	test	 course:2	h5p test course
test-1.h5p
Database transaction aborted automatically in /admin/tool/migratehvp2h5p/cli/migrate.php
Default exception handler: Exception - Call to a member function get_filename() on null Debug: 
Error code: generalexceptionmessage
* line 465 of /admin/tool/migratehvp2h5p/classes/api.php: Error thrown
* line 301 of /admin/tool/migratehvp2h5p/classes/api.php: call to tool_migratehvp2h5p\api::prepare_draft_file_from_hvp()
* line 98 of /admin/tool/migratehvp2h5p/classes/api.php: call to tool_migratehvp2h5p\api::create_mod_h5pactivity()
* line 168 of /admin/tool/migratehvp2h5p/cli/migrate.php: call to tool_migratehvp2h5p\api::migrate_hvp2h5p()

Looking through the code, I think there is some missing logic.
in function prepare_draft_file_from_hvp of classes/api.php, it inserts a file record with component=draft,filearea=user and then calls $cbfile = $content->get_file(); which in return looks for a file record with component=contentbank,filearea=public

This file record is never created and so does not exist, and throws the exception above.

I can reproduce this every time by creating a new fresh Moodle site, installing the latest mod_hvp and creating an activity of type "Interactive Video" and giving it either a youtube link or uploading an mp4 then running the migration cli.

@sarjona sarjona added the question Further information is requested label Jan 8, 2021
@sarjona
Copy link
Member

sarjona commented Jan 8, 2021

Hi @durzo!
Thanks for reporting this. I've tried to reproduce the error on my local environment using Moodle master and 3.9, with several DB, such as PostgreSQL and MariaDB but it's working for me in all the cases, using clean Moodle instances and following your steps so I guess I'm missing something (because there is another issue which seems exactly the same you mentioned: #24 ).

Could you please give us more details about your environment (Moodle version, DB, PHP...) and the parameters you're using when running the migration tool to see if we can reproduce it? Thanks in advance! :-)

@sarjona
Copy link
Member

sarjona commented Jan 8, 2021

Thanks a lot for your help Jordan!!
I've been able to reproduce this issue in 3.9.0 and 3.9.1. It's related to changes done in https://tracker.moodle.org/browse/MDL-69143), so I've added an extra-check to create manually the file into the contentbank if it's not created :-)

@sarjona sarjona added bug Something isn't working and removed question Further information is requested labels Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants