Page MenuHomePhabricator

Fatal error: Class MediaWiki\Session\PHPSessionHandler with Zend OPcache under MS Windows
Closed, ResolvedPublic

Assigned To
None
Authored By
Jongfeli
Dec 6 2016, 2:49 PM
Referenced Files
F5917177: Zend_OPCache.png
Feb 28 2017, 1:01 PM
F5194481: 1.png
Dec 30 2016, 7:17 PM
F5194550: error.log
Dec 30 2016, 7:17 PM
F5141544: php.ini
Dec 23 2016, 10:11 AM
F5141478: apache_error_x86_opcache_enabled.log
Dec 23 2016, 10:11 AM
F5141546: httpd.conf
Dec 23 2016, 10:11 AM
F5141473: trace_x86_opcache_enabled.png
Dec 23 2016, 10:11 AM
F5141541: LocalSettings.php
Dec 23 2016, 10:11 AM

Description

I am testing MW-1.27.1 & MW-1.28.0 on a Windows server. When starting the server all seems to be working just fine. After x time and some editing of pages (I can not exactly reproduce this) the below message pops up and the wiki can not be accessed anymore (blank screen).

Fatal error: Class MediaWiki\Session\PHPSessionHandler contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::close) in C:\Apache\htdocs\mediawiki-1.28.0\includes\session\PHPSessionHandler.php on line 34

Or

Fatal error: Class MediaWiki\Session\PHPSessionHandler contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::open, SessionHandlerInterface::gc) in C:\Apache\htdocs\mediawiki-1.28.0\includes\session\PHPSessionHandler.php on line 34

The other test wiki (MW-1.26) on the same server can be accessed normally when this happens. I tried using PHP 7.0.11 & 7.0.13 with the same result. I found that there where some changes in MW-1.27 regarding session handling.

Also found this in Configuration_changes_in_1.28: The load.php entry point now enforces the existing policy of not allowing access to session data, which includes the session user and the session user's language. If such access is attempted, an exception will be thrown

I must admit that I do not know what session handling actually does.

To get the wiki with 1.28.0 running again I need to stop and restart Apache.

I did set:

$wgSessionsInObjectCache = true;
$wgPHPSessionHandling = true;

I made the value for $wgPHPSessionHandling up because there is no documentation on this setting yet: Manual:$wgPHPSessionHandling.

My question is where to look first, is this a PHP configuration issue? Is this a bug in PHPSessionHandler.php or could it be that an extension is causing this?

  • MW-1.27.1 & MW-1.28.0
  • Apache 2.4.23
  • PHP 7.0.13 (apache2handler)
  • MySQL 5.6.25-log

Event Timeline

Ok, I have spend some time trying to debug this one and found out that I can reproduce the above error only when Zend OPcache is enabled. The fault pops up after x time.

When Zend OPcache is disabled the Wiki keeps working just fine.

I used a default installation of Apache, PHP (for windows) & Mediawiki-1.28.0. Only the necessary things are enabled. No extensions where enabled on MW-1.28.0. To stress the server I used Webserver Stress Tool 8.

The following configuration is used. I tested both the x86 & x64 versions of Apache & PHP:

  • Windows 7
  • MW-1.28.0
  • Apache 2.4.25
  • PHP 7.0.14 (apache2handler)
  • MariaDB 10.1.10-MariaDB

Enabled Xdebug in PHP and got the following trace and Apache access & error files:

trace_x86_opcache_enabled.png (273×1 px, 79 KB)

Unless I am doing something wrong here this basically breaks MW under windows when using OPcache.

I am happy to do some more testing but before I go any further I have some questions:

  • Am I doing something wrong here?
  • Is this problem related to MediaWiki or is there something wrong in PHP under windows?

If there are any other test that can be done to determine where this comes from please let me know.

Regards.

Aklapper renamed this task from Fatal error: Class MediaWiki\Session\PHPSessionHandler to Fatal error: Class MediaWiki\Session\PHPSessionHandler with Zend OPcache under MS Windows.Dec 30 2016, 6:00 PM

Your correct, according to http://php.net/manual/en/class.sessionhandlerinterface.php we need to add abstract to the function's

Change 329697 had a related patch set (by Paladox) published:
Make some functions in PHPSessionHandler.php abstracts

https://gerrit.wikimedia.org/r/329697

Change 329697 abandoned by Paladox:
Make some functions in PHPSessionHandler.php abstracts

https://gerrit.wikimedia.org/r/329697

Hello @Paladox, thanks for your fix. I understand that restarting Apache helps but only for a short while. After x time the same things happens again.

I tried your fix https://gerrit.wikimedia.org/r/329697 but that results in the following fatal error immediately when accessing the wiki:

1.png (899×1 px, 347 KB)

Ok, did some digging again. I tested this on:

  • A clean Windows 7 install
  • A clean Windows 10 install

The problem does not pop up during those tests, I can not get it to fail.

I am not sure but this probably means that we have something in our Windows 7 and Server 2008 image that causes this fault.

When tested I will report this here.

Other links:

-https://github.com/symfony/symfony/issues/21213

I just upgraded to PHP 7.0.15 on Linux and I'm seeing this same issue in MediaWiki 1.27.1:

Fatal error: Class MediaWiki\Session\PHPSessionHandler contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::open) in /home/data/sslvhost/mediawiki/includes/session/PHPSessionHandler.php on line 34

Restarting or reloading Apache temporarily solves the problem, bit it returns within a short amount of time.

According to my PHP configuration, the Zend OpCache is disabled.

@smkent could you be more specific on your configuration, which linux distro are you using and which version?

You say Zend OPCache is not running, if you see Zend OPCache when you use phpinfo(); like below it probably is running.

Zend_OPCache.png (832×934 px, 125 KB)

Hm, perhaps OPCache is active. I was just looking at php.ini before, but phpinfo() shows:

This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15, Copyright (c) 1999-2017, by Zend Technologies

I am running Gentoo Linux (Gentoo is rolling release and doesn't have any meaningful OS version number).

I mentioned before I am running MediaWiki 1.27.1 with PHP 7.0.15. I am also running Apache 2.4.25.

A short update for the people interested. After some testing we found out that when using mod_fcgid.so instead of php7apache2_4.dll to handle PHP it works just fine and more important it keeps working fine.

This means that this fault can be caused with the combination of apache2handler and Zend OPCache.