Moodle – Exception – Call to undefined function xml_parser_create()

Symptoms

The following error message occurs during moodle upgrade attempt whether it be on command line or admin back end:

# php moodle/admin/cli/upgrade.php 
Default exception handler: Exception - Call to undefined function xml_parser_create() Debug: 
Error code: generalexceptionmessage
* line 76 of /lib/xmlize.php: Error thrown
* line 307 of /lib/environmentlib.php: call to xmlize()
* line 355 of /lib/environmentlib.php: call to load_environment_xml()
* line 101 of /lib/environmentlib.php: call to get_latest_version_available()
* line 116 of /admin/cli/upgrade.php: call to check_moodle_environment()

!!! Exception - Call to undefined function xml_parser_create() !!!
!! 
Error code: generalexceptionmessage !!
!! Stack trace: * line 76 of /lib/xmlize.php: Error thrown
* line 307 of /lib/environmentlib.php: call to xmlize()
* line 355 of /lib/environmentlib.php: call to load_environment_xml()
* line 101 of /lib/environmentlib.php: call to get_latest_version_available()
* line 116 of /admin/cli/upgrade.php: call to check_moodle_environment()
 !!

Solution

Your system is missing php XML library. Install a relevant XML php package for your distribution and PHP version. For example on Ubuntu 16.04 Xenial Xerus with the Apache webserver run:

# apt-get install php7.0-xml
# service apache2 restart

Re-attempt the moodle upgrade:

# php moodle/admin/cli/upgrade.php 
== Upgrading Moodle database from version 3.1 (Build: 20160523) (2016052300) to 3.1+ (Build: 20160603) (2016052300.02) ==

Your Moodle files have been changed, and you are about to automatically
upgrade your server to this version:

3.1+ (BUILD: 20160603) (2016052300.02)

Once you do this you can not go back again. Please note that this process
can take a long time.

Are you sure you want to upgrade this server to this version?

type y (means yes) or n (means no)
: y
-->System
++ Success ++


Comments and Discussions
Linux Forum