Mediawiki Error: Call to undefined method User::saveToCache()
Mediawiki Error: Call to undefined method User::saveToCache()
我最近将 mediawiki 安装更新到 1.30,现在正在处理更新过程中出现的插件错误。
我最直接的错误是 Mediawiki 的 RadiusAuthPlugin。尝试登录时,页面上显示以下错误但登录成功:
[3d3906e176c5476982ff8037]
/MEDIAWIKI/index.php?title=Spezial:Login&returnto=Mainpage Error from
line 75 of
/usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/extensions/RadiusAuthPlugin/RadiusAuthPlugin.php:
Call to undefined method User::saveToCache()
Backtrace:
#0 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthPluginPrimaryAuthenticationProvider.php(145):
RadiusAuthPlugin->updateUser(User)
#1 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/Hooks.php(177):
MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider->onUserLoggedIn(User)
#2 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/Hooks.php(205):
Hooks::callHook(string, array, array, NULL)
#3 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthManager.php(2388):
Hooks::run(string, array)
#4 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthManager.php(690): MediaWiki\Auth\AuthManager->setSessionDataForUser(User, boolean)
#5 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthManager.php(382): MediaWiki\Auth\AuthManager->continueAuthentication(array)
#6 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/AuthManagerSpecialPage.php(353):
MediaWiki\Auth\AuthManager->beginAuthentication(array, string)
#7 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/AuthManagerSpecialPage.php(482):
AuthManagerSpecialPage->performAuthenticationStep(string, array)
#8 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/htmlform/HTMLForm.php(669):
AuthManagerSpecialPage->handleFormSubmit(array, VFormHTMLForm)
#9 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/AuthManagerSpecialPage.php(416):
HTMLForm->trySubmit()
#10 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/LoginSignupSpecialPage.php(316):
AuthManagerSpecialPage->trySubmit()
#11 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/SpecialPage.php(522):
LoginSignupSpecialPage->execute(NULL)
#12 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/SpecialPageFactory.php(578):
SpecialPage->run(NULL)
#13 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/MediaWiki.php(287):
SpecialPageFactory::executePath(Title, RequestContext)
#14 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/MediaWiki.php(851):
MediaWiki->performRequest()
#15 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/MediaWiki.php(523):
MediaWiki->main()
#16 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/index.php(43):
MediaWiki->run()
#17 {main}
(出于安全原因,我删除了部分路径)
RadiusAuthPlugin.php:
<?php
require_once("$IP/includes/AuthPlugin.php");
require_once("radius.class.php");
require_once("$IP/includes/GlobalFunctions.php");
error_reporting(E_ALL);
class RadiusAuthPlugin extends AuthPlugin
{
function userExists($username)
{
return TRUE;
}
function authenticate($username, $password)
{
global $wgRadiusAuthPluginServers, $wgRadiusAuthPluginSecret;
$username = strtolower($username);
//$handle=fopen("/tmp/radius","w");
//fwrite($handle,"$username;$password;\n");
foreach($wgRadiusAuthPluginServers as $server)
{
$radius = new Radius($server, $wgRadiusAuthPluginSecret);
//$radius->SetNasIpAddress('NAS_IP_ADDRESS'); // Needed for some devi$
//fwrite($handle,"Radius Objekt angelegt\n");
if ($radius->AccessRequest($username, $password))
{
return TRUE;
//fwrite($handle,"Auth successful\n");
}
//else{
// fwrite($handle,"Auth not successful\n");
// }
}
//fclose($handle);
return FALSE;
}
function modifyUITemplate(&$template, &$type)
{
global $wgRadiusAuthPluginExtrafields;
$template->set('usedomain', FALSE);
$template->set('useemail', FALSE);
$template->set('create', FALSE);
//$template->set('create', TRUE);
$template->set('canremember', FALSE);
$template->set('extrafields', $wgRadiusAuthPluginExtrafields);
}
function autoCreate()
{
global $wgRadiusAuthPluginAutoCreate;
if(isset($wgRadiusAuthPluginAutoCreate))
{
if(is_bool($wgRadiusAuthPluginAutoCreate))
{
return $wgRadiusAuthPluginAutoCreate;
}
}
return FALSE;
}
function validDomain($domain)
{
return TRUE;
}
function updateUser(&$user)
{
global $wgRadiusAuthPluginMaildomain;
$user->setEmail($user->getName()."@".$wgRadiusAuthPluginMaildomain);
$user->saveToCache();
return TRUE;
}
function allowPasswordChange()
{
//return false;
return TRUE; // since Ubuntu 14.04
}
function allowPropChange($prop = '')
{
return FALSE;
}
function allowSetLocalPassword()
{
return true;
}
function setPassword($user, $password)
{
return true;
}
function updateExternalDB($user)
{
return true;
}
function canCreateAccounts()
{
# return FALSE;
return TRUE;
}
function adduser($user, $password, $email = '', $realname = '')
{
return false;
# return true;
}
function strict()
{
global $wgRadiusAuthPluginStrict;
if(isset($wgRadiusAuthPluginStrict))
{
if(is_bool($wgRadiusAuthPluginStrict))
{
return $wgRadiusAuthPluginStrict;
}
}
return TRUE;
}
function strictUserAuth($user)
{
global $wgRadiusAuthPluginStrictUserAuth;
if(isset($wgRadiusAuthPluginStrictUserAuth))
{
if(is_bool($wgRadiusAuthPluginStrictUserAuth))
{
return $wgRadiusAuthPluginStrictUserAuth;
}
}
}
return TRUE;
}
function initUser(&$user, $autocreate = false)
{
global $wgRadiusAuthPluginMaildomain, $wgSitename, $wgRadiusAuthPluginM$
$user->setEmail($user->getName()."@".$wgRadiusAuthPluginMaildomain);
$user->setEmailAuthenticationTimestamp(wfTimestamp(TS_MW));
$user->sendMail("[".$wgSitename."] ".$wgRadiusAuthPluginMailSubject,$wg$
$user->removeGroup("User");
//$user->removeGroup("auto-registered User");
//$user->addGroup("USER");
}
}
$wgExtensionCredits['other'][] = array(
'name' => 'RadiusAuthPlugin',
'version' => '1.1.0',
'author' => 'James Young',
'author' => 'edited by Andreas Ihrig',
'description' => 'Automatic login with a RADIUS server; now with Setting-Op$
);
?>
我不知道该怎么办,非常感谢您的帮助。
到目前为止谢谢
User::saveToCache
已删除 two years ago。 (在此之前,它的文档说 "This method should not be called outside the User class"。那些警告是有原因的。)为什么有人会将更改保存到缓存而不是磁盘?坦率地说,那个插件的作者似乎不太了解他们在做什么。
您可以尝试将 saveToCache
替换为 saveSettings
。虽然理想情况下它应该首先检查电子邮件地址是否已经正确以避免无意义的数据库写入。并且可能也会调用 confirmEmail
,因为电子邮件地址来自权威来源。
我最近将 mediawiki 安装更新到 1.30,现在正在处理更新过程中出现的插件错误。
我最直接的错误是 Mediawiki 的 RadiusAuthPlugin。尝试登录时,页面上显示以下错误但登录成功:
[3d3906e176c5476982ff8037] /MEDIAWIKI/index.php?title=Spezial:Login&returnto=Mainpage Error from line 75 of /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/extensions/RadiusAuthPlugin/RadiusAuthPlugin.php: Call to undefined method User::saveToCache()
Backtrace:
#0 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthPluginPrimaryAuthenticationProvider.php(145): RadiusAuthPlugin->updateUser(User)
#1 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/Hooks.php(177): MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider->onUserLoggedIn(User)
#2 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/Hooks.php(205): Hooks::callHook(string, array, array, NULL)
#3 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthManager.php(2388): Hooks::run(string, array)
#4 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthManager.php(690): MediaWiki\Auth\AuthManager->setSessionDataForUser(User, boolean)
#5 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/auth/AuthManager.php(382): MediaWiki\Auth\AuthManager->continueAuthentication(array)
#6 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/AuthManagerSpecialPage.php(353): MediaWiki\Auth\AuthManager->beginAuthentication(array, string)
#7 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/AuthManagerSpecialPage.php(482): AuthManagerSpecialPage->performAuthenticationStep(string, array)
#8 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/htmlform/HTMLForm.php(669): AuthManagerSpecialPage->handleFormSubmit(array, VFormHTMLForm)
#9 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/AuthManagerSpecialPage.php(416): HTMLForm->trySubmit()
#10 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/LoginSignupSpecialPage.php(316): AuthManagerSpecialPage->trySubmit()
#11 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/SpecialPage.php(522): LoginSignupSpecialPage->execute(NULL)
#12 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/specialpage/SpecialPageFactory.php(578): SpecialPage->run(NULL)
#13 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/MediaWiki.php(287): SpecialPageFactory::executePath(Title, RequestContext)
#14 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/MediaWiki.php(851): MediaWiki->performRequest()
#15 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/includes/MediaWiki.php(523): MediaWiki->main()
#16 /usr/srv/www/vhosts/HOSTNAME/htdocs-ssl/MEDIAWIKI/index.php(43): MediaWiki->run()
#17 {main}
(出于安全原因,我删除了部分路径)
RadiusAuthPlugin.php:
<?php
require_once("$IP/includes/AuthPlugin.php");
require_once("radius.class.php");
require_once("$IP/includes/GlobalFunctions.php");
error_reporting(E_ALL);
class RadiusAuthPlugin extends AuthPlugin
{
function userExists($username)
{
return TRUE;
}
function authenticate($username, $password)
{
global $wgRadiusAuthPluginServers, $wgRadiusAuthPluginSecret;
$username = strtolower($username);
//$handle=fopen("/tmp/radius","w");
//fwrite($handle,"$username;$password;\n");
foreach($wgRadiusAuthPluginServers as $server)
{
$radius = new Radius($server, $wgRadiusAuthPluginSecret);
//$radius->SetNasIpAddress('NAS_IP_ADDRESS'); // Needed for some devi$
//fwrite($handle,"Radius Objekt angelegt\n");
if ($radius->AccessRequest($username, $password))
{
return TRUE;
//fwrite($handle,"Auth successful\n");
}
//else{
// fwrite($handle,"Auth not successful\n");
// }
}
//fclose($handle);
return FALSE;
}
function modifyUITemplate(&$template, &$type)
{
global $wgRadiusAuthPluginExtrafields;
$template->set('usedomain', FALSE);
$template->set('useemail', FALSE);
$template->set('create', FALSE);
//$template->set('create', TRUE);
$template->set('canremember', FALSE);
$template->set('extrafields', $wgRadiusAuthPluginExtrafields);
}
function autoCreate()
{
global $wgRadiusAuthPluginAutoCreate;
if(isset($wgRadiusAuthPluginAutoCreate))
{
if(is_bool($wgRadiusAuthPluginAutoCreate))
{
return $wgRadiusAuthPluginAutoCreate;
}
}
return FALSE;
}
function validDomain($domain)
{
return TRUE;
}
function updateUser(&$user)
{
global $wgRadiusAuthPluginMaildomain;
$user->setEmail($user->getName()."@".$wgRadiusAuthPluginMaildomain);
$user->saveToCache();
return TRUE;
}
function allowPasswordChange()
{
//return false;
return TRUE; // since Ubuntu 14.04
}
function allowPropChange($prop = '')
{
return FALSE;
}
function allowSetLocalPassword()
{
return true;
}
function setPassword($user, $password)
{
return true;
}
function updateExternalDB($user)
{
return true;
}
function canCreateAccounts()
{
# return FALSE;
return TRUE;
}
function adduser($user, $password, $email = '', $realname = '')
{
return false;
# return true;
}
function strict()
{
global $wgRadiusAuthPluginStrict;
if(isset($wgRadiusAuthPluginStrict))
{
if(is_bool($wgRadiusAuthPluginStrict))
{
return $wgRadiusAuthPluginStrict;
}
}
return TRUE;
}
function strictUserAuth($user)
{
global $wgRadiusAuthPluginStrictUserAuth;
if(isset($wgRadiusAuthPluginStrictUserAuth))
{
if(is_bool($wgRadiusAuthPluginStrictUserAuth))
{
return $wgRadiusAuthPluginStrictUserAuth;
}
}
}
return TRUE;
}
function initUser(&$user, $autocreate = false)
{
global $wgRadiusAuthPluginMaildomain, $wgSitename, $wgRadiusAuthPluginM$
$user->setEmail($user->getName()."@".$wgRadiusAuthPluginMaildomain);
$user->setEmailAuthenticationTimestamp(wfTimestamp(TS_MW));
$user->sendMail("[".$wgSitename."] ".$wgRadiusAuthPluginMailSubject,$wg$
$user->removeGroup("User");
//$user->removeGroup("auto-registered User");
//$user->addGroup("USER");
}
}
$wgExtensionCredits['other'][] = array(
'name' => 'RadiusAuthPlugin',
'version' => '1.1.0',
'author' => 'James Young',
'author' => 'edited by Andreas Ihrig',
'description' => 'Automatic login with a RADIUS server; now with Setting-Op$
);
?>
我不知道该怎么办,非常感谢您的帮助。
到目前为止谢谢
User::saveToCache
已删除 two years ago。 (在此之前,它的文档说 "This method should not be called outside the User class"。那些警告是有原因的。)为什么有人会将更改保存到缓存而不是磁盘?坦率地说,那个插件的作者似乎不太了解他们在做什么。
您可以尝试将 saveToCache
替换为 saveSettings
。虽然理想情况下它应该首先检查电子邮件地址是否已经正确以避免无意义的数据库写入。并且可能也会调用 confirmEmail
,因为电子邮件地址来自权威来源。