Last modified: 2014-02-12 23:32:45 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T46132, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 44132 - webstart tries to get realpath to set $IP instead of using dirname(__DIR__)
webstart tries to get realpath to set $IP instead of using dirname(__DIR__)
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Installer (Other open bugs)
1.20.x
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on: 44157
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-19 00:22 UTC by Mark A. Hershberger
Modified: 2014-02-12 23:32 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Mark A. Hershberger 2013-01-19 00:22:17 UTC
This caused the installer the installer to fail on a webhost that was using windows.  Changing it to dirname(__DIR__) or dirname(dirname(__FILE__)) worked.
Comment 1 Pavel Selitskas [wizardist] 2013-01-19 00:53:31 UTC
I'm not sure if it's relevant, but on Windows I sometimes get an error from load.php (it fails randomly I guess):

Warning: require_once(Z:\usr\local\apache\bin/includes/Init.php) [function.require-once]: failed to open stream: No such file or directory in E:\Wikimedia\mediawiki\core\includes\WebStart.php on line 94
Fatal error:  require_once() [function.require]: Failed opening required 'Z:\usr\local\apache\bin/includes/Init.php' (include_path='.;C:\php\pear') in E:\Wikimedia\mediawiki\core\includes\WebStart.php on line 94

With your patch Id7cd604d applied, I get something way more weird:

Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error:  Unknown: Failed opening required 'Z:/home/wikimedia/mw/load.php' (include_path='.;C:\php\pear') in Unknown> on line 0
Comment 2 Mark A. Hershberger 2013-01-19 16:55:19 UTC
It may be related.  I've updated my commit message to say exactly why WebStart was failing: realpath returned false.

What version of PHP are you using?
Comment 3 Pavel Selitskas [wizardist] 2013-01-19 17:17:21 UTC
(In reply to comment #2)
> What version of PHP are you using?

PHP Version 5.3.13 (Build MSVC9 (Visual C++ 2008)); Apache/2.2.22
Comment 4 Mark A. Hershberger 2013-01-19 20:23:30 UTC
The patch on 44157 has a better fix for this -- could you try it out?
Comment 5 Mark A. Hershberger 2013-01-19 20:25:13 UTC
bug 44157, that is, points to https://gerrit.wikimedia.org/r/44832
Comment 6 Pavel Selitskas [wizardist] 2013-01-19 20:32:56 UTC
(In reply to comment #5)
> bug 44157, that is, points to https://gerrit.wikimedia.org/r/44832

No, it still throws an error sometimes, trying to require_once(Z:\usr\local\apache\bin/includes/Init.php).

For the record: document root for my MediaWiki instance is Z:/home/wikimedia/mw/, and it's actually an NTFS symlink to another path. May this fail be a consequence of such scheme?

(I actually don't strive for better Windows support, as it's just so mess with all work-arounds, but if it can be fixed without any collateral damage, then I hope my reports will be in some way useful.)
Comment 7 Mark A. Hershberger 2013-01-19 20:53:25 UTC
I have a windows system that I can test on, but I'm NTFS ignorant.  How can I create one of these NTFS symlinks?  That does sound like a probable suspect.

Hrm... Another possibility, the realpath(".").  It sounds like this is being executed when the webserver's path is z:\usr\local\apache\bin and it decides that is the value for $IP, not MW's root.

Is the path for require_once correct? Is Init.php at Z:\usr\local\apache\bin/includes/Init.php ??
Comment 8 Pavel Selitskas [wizardist] 2013-01-19 21:00:01 UTC
(In reply to comment #7)
> I have a windows system that I can test on, but I'm NTFS ignorant.  How can I
> create one of these NTFS symlinks?  That does sound like a probable suspect.
> 
> Hrm... Another possibility, the realpath(".").  It sounds like this is being
> executed when the webserver's path is z:\usr\local\apache\bin and it decides
> that is the value for $IP, not MW's root.
> 
> Is the path for require_once correct? Is Init.php at
> Z:\usr\local\apache\bin/includes/Init.php ??

According to Wikipedia, a symlink is made with the following command:
  mklink /D linkName target

No, it seems like in some situations $IP is set to "Z:/usr/local/apache/bin", not the actual MediaWiki path. Init.php is at Z:/home/wikimedia/mw/includes/Init.php. Z:/usr/local/apache/bin is the path where httpd.exe lives.

If you have a Windows installation, please test these. On my side, I'll try to debug that piece of code to learn what environment does the code execute in, when it fails.
Comment 9 Mark A. Hershberger 2013-01-19 22:55:38 UTC
(In reply to comment #8)
> No, it seems like in some situations $IP is set to "Z:/usr/local/apache/bin",
> not the actual MediaWiki path. Init.php is at
> Z:/home/wikimedia/mw/includes/Init.php. Z:/usr/local/apache/bin is the path
> where httpd.exe lives.

Right.  This makes complete sense.

Now, the question is why does apache/php sometimes execute the the php files from the apache directory instead of the script's directory?  Is it just not setting the CWD?
Comment 10 Pavel Selitskas [wizardist] 2013-01-19 23:00:41 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > No, it seems like in some situations $IP is set to "Z:/usr/local/apache/bin",
> > not the actual MediaWiki path. Init.php is at
> > Z:/home/wikimedia/mw/includes/Init.php. Z:/usr/local/apache/bin is the path
> > where httpd.exe lives.
> 
> Right.  This makes complete sense.
> 
> Now, the question is why does apache/php sometimes execute the the php files
> from the apache directory instead of the script's directory?  Is it just not
> setting the CWD?

I dunno. I wish I did. Here is some info for further consideration.

When load.php doesn't fail, we have the following data ($IP is the current $IP, realpath - realpath( '.' ) called once again for debugging, dirname - dirname( __DIR__ ), dir - __DIR__ itself):
$IP: E:\Wikimedia\mediawiki\core
realpath: E:\Wikimedia\mediawiki\core
dirname: E:\Wikimedia\mediawiki\core
dir: E:\Wikimedia\mediawiki\core\includes

As you see, all symlinks were resolved into proper paths (not Z:\home\...). When load.php fails, we have the following picture:
$IP: Z:\usr\local\apache\bin
realpath: Z:\usr\local\apache\bin
dirname: E:\Wikimedia\mediawiki\core
dir: E:\Wikimedia\mediawiki\core\includes

According to the logics of present code, realpath should have failed and return false, thus giving MediaWiki a way to fall back to dirname, but it didn't, and moreover it provides a wrong path...
Comment 11 Mark A. Hershberger 2013-01-20 02:16:40 UTC
do you control the configuration of apache and php on this host?  Would you mind emailing them directly to me?
Comment 12 Mark A. Hershberger 2013-01-31 21:05:07 UTC
This bug is fixed since gerrit change Id178ee2f

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links