I set up a custom registration page to my http server (apache) which hosts a number of services, including a wiki. The intended goal is to have the user sign-up at once to all these services including the wiki of course.
For the wiki I'm trying to rearrange the "CreateAndPromote" maintenance script and fit it into my page. By now I came up with this snippet
$path = "/wiki"; putenv("MW_INSTALL_PATH={$path}"); require_once ("/wiki/includes/WebStart.php"); chdir("wiki"); $mediaWiki = new MediaWiki(); $name = $_POST['username']; $pass = $_POST['password']; $user = User::newFromName( $name ); if ( !is_object( $user ) ) { die("Invalid user!\\n"); } $exists = ( 0 !== $user->idForName() ); if ( !$exists ) { $user->addToDatabase(); } try { $user->setPassword( $pass ); } catch ( PasswordError $pwe ) { die("password error:" . $pwe->getText().""); } $user->addGroup("editor"); $user->saveSettings(); $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); $ssu->doUpdate();
But i get
Error: LightnCandy class not defined
MediaWiki 1.25.2 PHP 5.6.12 (apache2handler)
The problem was simple as that: declaring the MW_INSTALL_PATH like that apparently did not work
$path = "/wiki";
putenv("MW_INSTALL_PATH={$path}");
require_once ("/wiki/includes/WebStart.php");
so I had to change dir to the wiki BEFORE requiring the webstart.php
chdir("wiki");
require_once ("/includes/WebStart.php");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.