HTTP to HTTPS converter for external content

Re: HTTP to HTTPS converter for external content

by Tomasz Muras -
Number of replies: 3
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators
Hello,

At Enovation we have created a script for changing hardcoded urls in the Moodle database. Our approach is a bit different than the options above. We edit records directly in the database but we use whitelist for columns and tables. This is basically to make sure we know exactly what we edit. This alone could leave some content unchanged, so in the next step script does a search for hardcoded URLs across the whole database this time with blacklist. When records are found you can add them to wishlist and replace or decide to ignore them and add to search blacklist.

When changing this kind of data you also need to consider base64 encoded and url-encoded data and handle it appropriately. You want base64 search to be efficient - that is work using database query and not have to decode each record.

Finally our script works as a CLI but it's not Moodle admin tool - we wanted it to work even with old 1.9 Moodles.

We would be happy to share it publicly on github if you're interested. You can obviously use it to change url like http://example.com into https://example.com.

Cheers,
Tomek
Average of ratings: Useful (1)
In reply to Tomasz Muras

Re: HTTP to HTTPS converter for external content

by John Okely -

Sounds like a good solution. It would be great to see that code, thanks!

In reply to John Okely

Re: HTTP to HTTPS converter for external content

by Tomasz Muras -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators
Our script is here: https://github.com/enovation/moodle-url_change . If you decide to do Moodle admin tool for 2.8 it may be worth moving some code into a shared library to share the code - as we will definitely want to use it across all Moodle versions.


cheers
In reply to Tomasz Muras

Re: HTTP to HTTPS converter for external content

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

How does your proposed tool differ from tool_replace in standard Moodle? Wouldn't it be better to improve that tool than to build a separate add-on?