]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/app/mediawiki.py
Set admin e-mail address properly on MediaWiki >= 1.18.0
[wizard.git] / wizard / app / mediawiki.py
index 4ab86287f5baa6a1a03678e8fe6f2118a4caf296..5194d712f8d76b18c74e086248f1b12a497e8ad3 100644 (file)
@@ -59,10 +59,12 @@ class Application(app.Application):
     def install(self, version, options):
         php.ini_replace_vars()
         if version >= distutils.version.LooseVersion("1.17.0"):
-            self.install_1_17_0(options)
+            # The --email option was added in 1.16.3 and removed in 1.18.0
+            has_email = version < distutils.version.LooseVersion("1.18.0")
+            self.install_1_17_0(options, has_email)
         else:
             self.install_old(options)
-    def install_1_17_0(self, options):
+    def install_1_17_0(self, options, has_email):
         util.soft_unlink("LocalSettings.php")
         if os.path.exists("math"):
             with util.ChangeDirectory("math"):
@@ -75,20 +77,32 @@ class Application(app.Application):
             os.write(out_fd, options.admin_password)
             os.close(out_fd)
 
-            result = shell.eval(
-                    "php", "-c", ".", "maintenance/install.php",
-                    "--dbname", options.dsn.database,
-                    "--dbpassfile", "php://fd/%d" % (dbpass_fd,),
-                    "--dbserver", options.dsn.host,
-                    "--dbuser", options.dsn.username,
+            args = (
+                "php", "-c", ".", "maintenance/install.php",
+                "--dbname", options.dsn.database,
+                "--dbpassfile", "php://fd/%d" % (dbpass_fd,),
+                "--dbserver", options.dsn.host,
+                "--dbuser", options.dsn.username,
+                "--passfile", "php://fd/%d" % (pass_fd,),
+                "--server", "https://" + options.web_host,
+                "--scriptpath", options.web_path,
+            )
+            if has_email:
+                args += (
                     "--email", options.email,
-                    "--passfile", "php://fd/%d" % (pass_fd,),
-                    "--server", "https://" + options.web_host,
-                    "--scriptpath", options.web_path,
-                    options.title, options.admin_name,
+                )
+            args += (options.title, options.admin_name,)
+            result = shell.eval(
+                *args,
+                log=True,
+                close_fds=False)
+            if not has_email:
+                shell.eval(
+                    "php", "-c", ".", "maintenance/resetUserEmail.php",
+                    "--no-reset-password",
+                    options.admin_name, options.email,
                     log=True,
-                    close_fds=False,
-            )
+                )
         except shell.CallError as e:
             raise app.RecoverableInstallFailure(["Install script returned non-zero exit code\nSTDOUT: %s\nSTDERR: %s" % (e.stdout, e.stderr)])
         logging.debug("Install script output:\n\n" + result)