Page MenuHomePhabricator

LDAPProvider in MediaWiki 1.33.1 fails with "Fatal error: Exception thrown without a stack frame in Unknown on line 0"
Open, Needs TriagePublic

Description

When I install MediaWiki
and I install extensions for LDAP authentication:

then I receive "Fatal error: Exception thrown without a stack frame in Unknown on line 0".

Details
LDAPProvider: 1.0.1
PluggableAuth: 5.7
LDAPAuthentication2: 1.0.0

MediaWiki: 1.33.1
PHP: 7.0.33-0+deb9u6 (apache2handler)
MariaDB: 10.1.41-MariaDB-0+deb9u1
ICU: 57.1

Event Timeline

Pavche created this task.Dec 12 2019, 1:30 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 12 2019, 1:30 PM
Aklapper renamed this task from Using extension LDAPProvider in MediaWiki 1.33.1 fails with fatal error to LDAPProvider in MediaWiki 1.33.1 fails with "Fatal error: Exception thrown without a stack frame in Unknown on line 0".Dec 12 2019, 1:56 PM

When debugging is enabled in WikiMedia:

`Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /mnt/data/www/mediawiki-1.33.1/w/extensions/LDAPProvider/src/Config.php on line 9

Fatal error: Exception thrown without a stack frame in Unknown on line 0`

It appears that LDAPProvider requires PHP 7.1+, where support for class constant visibility was added (https://www.php.net/manual/en/migration71.new-features.php#migration71.new-features.class-constant-visibility). @Osnard, can you confirm?

@Pavche, are you able to upgrade to PHP 7.1 or later?

Following steps from manuals:
https://tecadmin.net/install-php-debian-9-stretch/
https://www.rosehosting.com/blog/how-to-install-php-7-2-on-debian-9/

Upgrading PHP from 7.0 to 7.3

$ php -v
PHP 7.3.12-1+0~20191128.49+debian9~1.gbp24559b (cli) (built: Nov 28 2019 07:38:18) ( NTS )

$ php --ini | grep "Loaded Configuration File"
Loaded Configuration File:         /etc/php/7.3/cli/php.ini

$ sudo a2dismod php7.0
Module php7.0 disabled.

$ sudo a2enmod php7.3
Considering dependency mpm_prefork for php7.3:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php7.3:
Enabling module php7.3.

$ sudo systemctl restart apache2

Then MediaWiki works.
When I open the page "Special:Version"
then I see

Installed software

ProductVersion
MediaWiki1.33.1 (a2297e6) 10:10, 13 December 2019
PHP7.3.12-1+0~20191128.49+debian9~1.gbp24559b (apache2handler)
MariaDB10.1.41-MariaDB-0+deb9u1

Installed extensions

ExtensionVersionLicenseDescriptionAuthors
LDAPAuthentication21.0.0 (8b04318) 07:36, 21 October 2019GPL-2.0Allows authentication against a LDAP resourceCindy Cicalese, Mark A. Hershberger and Robert Vogel
LDAPProvider1.0.1 (a5cf2cb) 09:47, 5 December 2019GPL-2.0+Provides a common infratructure to connect to a LDAP resource and run queries against itCindy Cicalese, Mark A. Hershberger and Robert Vogel
PluggableAuth5.7 (a69f626) 04:03, 7 February 2019MITProvides framework for pluggable authentication and authorizationCindy Cicalese

The extensions works.

Please, do not close this ticket unless I test it with our LDAP server.
Thanks for the help.

Good job!

When I try to log via LDAP credentials then I get :

Internal error

[6bf5d36542ce35464c10ce36] /wiki-test/Special:PluggableAuthLogin Error from line 244 of /mnt/data/www/mediawiki-1.33.1/w/extensions/LDAPProvider/src/PlatformFunctionWrapper.php: Call to undefined function ldap_connect()

Backtrace:

#0 /mnt/data/www/mediawiki-1.33.1/w/extensions/LDAPProvider/src/PlatformFunctionWrapper.php(261): MediaWiki\Extension\LDAPProvider\PlatformFunctionWrapper->connect(string, integer)
#1 /mnt/data/www/mediawiki-1.33.1/w/extensions/LDAPProvider/src/Client.php(88): MediaWiki\Extension\LDAPProvider\PlatformFunctionWrapper::getConnection(string)
#2 /mnt/data/www/mediawiki-1.33.1/w/extensions/LDAPProvider/src/Client.php(76): MediaWiki\Extension\LDAPProvider\Client->makeNewConnection()
#3 /mnt/data/www/mediawiki-1.33.1/w/extensions/LDAPProvider/src/Client.php(313): MediaWiki\Extension\LDAPProvider\Client->init()
#4 /mnt/data/www/mediawiki-1.33.1/w/extensions/LDAPAuthentication2/src/PluggableAuth.php(78): MediaWiki\Extension\LDAPProvider\Client->canBindAs(string, string)
#5 /mnt/data/www/mediawiki-1.33.1/w/extensions/PluggableAuth/includes/PluggableAuthLogin.php(30): MediaWiki\Extension\LDAPAuthentication2\PluggableAuth->authenticate(NULL, string, NULL, NULL, NULL)
#6 /mnt/data/www/mediawiki-1.33.1/w/includes/specialpage/SpecialPage.php(569): PluggableAuthLogin->execute(NULL)
#7 /mnt/data/www/mediawiki-1.33.1/w/includes/specialpage/SpecialPageFactory.php(558): SpecialPage->run(NULL)
#8 /mnt/data/www/mediawiki-1.33.1/w/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#9 /mnt/data/www/mediawiki-1.33.1/w/includes/MediaWiki.php(865): MediaWiki->performRequest()
#10 /mnt/data/www/mediawiki-1.33.1/w/includes/MediaWiki.php(515): MediaWiki->main()
#11 /mnt/data/www/mediawiki-1.33.1/w/index.php(46): MediaWiki->run()
#12 {main}

You need to install the php-ldap package and restart apache.

It appears that LDAPProvider requires PHP 7.1+, where support for class constant visibility was added (https://www.php.net/manual/en/migration71.new-features.php#migration71.new-features.class-constant-visibility). @Osnard, can you confirm?

Looks like PHP 7.1 requirement was added by https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/LDAPProvider/+/544281/ into the master branch. I wasn't aware of that. REL1_31 branch should still be compatible with PHP 7.1

So yes, I can confirm. Still, I recommend using REL1_31 branch.

When I removed the old php-ldap and installed the new one
then I got a mixture of php7.0, php7.3, php7.4.

# apt remove php-ldap

# apt install php-ldap
...
The following additional packages will be installed:
  libapache2-mod-php7.3 php7.3-cli php7.3-common php7.3-curl php7.3-json
  php7.3-ldap php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-readline
  php7.3-xml
The following NEW packages will be installed:
  php-ldap php7.3-ldap
The following packages will be upgraded:
  libapache2-mod-php7.3 php7.3-cli php7.3-common php7.3-curl php7.3-json
...

# apt list php-ldap -a
Listing... Done
php-ldap/unknown,now 2:7.4+71+0~20191219.19+debian9~1.gbpefc769 all [installed]
php-ldap/oldstable 1:7.0+49 all

# a2dismod php7.3
# a2enmod php7.4
# systemctl restart apache2

When I open the home page of MediaWiki
then I receive "Notice: Trying to access array offset on value of type null in /mnt/data/www/mediawiki-1.33.1/w/includes/profiler/SectionProfiler.php on line 101".

On the top of the login dialog I see:

Could not authenticate credentials against domain "LDAP"

At the bottom I see debug information:

IP: <my IP address>
Start request GET /w/index.php?title=Special:UserLogin&returnto=Main+Page
HTTP HEADERS:
HOST: kiwi-test.egi.eu
USER-AGENT: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
ACCEPT-LANGUAGE: en-US,en;q=0.5
ACCEPT-ENCODING: gzip, deflate, br
REFERER: https://kiwi-test.egi.eu/w/index.php?title=Special:UserLogin&returnto=Main+Page
CONNECTION: keep-alive
COOKIE: _ga=GA1.2.189891916.1576752599; _gid=GA1.2.2030414493.1576752599; wikidb_session=gdmbc1sp98kt621q1prpncdghatjnrid; _gat=1
UPGRADE-INSECURE-REQUESTS: 1
[caches] cluster: APCBagOStuff, WAN: mediawiki-main-default, stash: db-replicated, message: APCBagOStuff, session: APCBagOStuff
[caches] LocalisationCache: using store LCStoreCDB
[session] Session "gdmbc1sp98kt621q1prpncdghatjnrid" requested without UserID cookie
[session] SessionBackend "gdmbc1sp98kt621q1prpncdghatjnrid" data dirty due to dirty(): AuthManagerSpecialPage->handleReturnBeforeExecute/MediaWiki\Auth\AuthManager->removeAuthenticationSessionData/MediaWiki\Session\Session->setSecret/MediaWiki\Session\Session->set/MediaWiki\Session\SessionBackend->dirty
[session] SessionBackend "gdmbc1sp98kt621q1prpncdghatjnrid" save: dataDirty=1 metaDirty=0 forcePersist=0
[MessageCache] MessageCache::load: Loading en... local cache is empty, got from global cache
Unstubbing $wgParser on call of $wgParser::firstCallInit from MessageCache->transform
Parser: using preprocessor: Preprocessor_DOM
Unstubbing $wgLang on call of $wgLang::_unstub from ParserOptions->__construct
[session] SessionBackend "gdmbc1sp98kt621q1prpncdghatjnrid" data dirty due to dirty(): PluggableAuthPrimaryAuthenticationProvider->continuePrimaryAuthentication/MediaWiki\Auth\AuthManager->removeAuthenticationSessionData/MediaWiki\Session\Session->setSecret/MediaWiki\Session\Session->set/MediaWiki\Session\SessionBackend->dirty
[authentication] Login failed in primary authentication by PluggableAuthPrimaryAuthenticationProvider
[session] SessionBackend "gdmbc1sp98kt621q1prpncdghatjnrid" data dirty due to dirty(): AuthManagerSpecialPage->handleFormSubmit/AuthManagerSpecialPage->performAuthenticationStep/MediaWiki\Auth\AuthManager->continueAuthentication/MediaWiki\Session\Session->remove/MediaWiki\Session\SessionBackend->dirty
[session] SessionBackend "gdmbc1sp98kt621q1prpncdghatjnrid" save: dataDirty=1 metaDirty=0 forcePersist=0
[authevents] Login attempt
MediaWiki::preOutputCommit: primary transaction round committed
MediaWiki::preOutputCommit: pre-send deferred updates completed
[DBReplication] Cannot use ChronologyProtector with EmptyBagOStuff.
[DBReplication] Wikimedia\Rdbms\LBFactory::getChronologyProtector: using request info {
"IPAddress": "<my IP address>",
"UserAgent": "Mozilla\/5.0 (X11; Linux x86_64; rv:68.0) Gecko\/20100101 Firefox\/68.0",
"ChronologyProtection": false,
"ChronologyPositionIndex": 0,
"ChronologyClientId": null
}
MediaWiki::preOutputCommit: LBFactory shutdown completed
[DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: calling initLB() before first connection.
[DBConnection] Wikimedia\Rdbms\LoadBalancer::openLocalConnection: connected to database 0 at 'localhost'.
Osnard added a comment.Jan 9 2020, 7:09 AM

Is this still an issue? Your mail from 2020-01-08 implies that it's working now. Did you find a solution? If so, could you please share it?