Last modified: 2013-11-15 11:09:55 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 T48635, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46635 - Scribunto_LuaLibraryBase registerInterface() produces internal error on Windows platform
Scribunto_LuaLibraryBase registerInterface() produces internal error on Windo...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All Windows XP
: Unprioritized normal (vote)
: ---
Assigned To: Brad Jorsch
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-28 13:42 UTC by MWJames
Modified: 2013-11-15 11:09 UTC (History)
5 users (show)

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


Attachments

Description MWJames 2013-03-28 13:42:05 UTC
Following up on [1]

[1] http://www.mediawiki.org/wiki/Extension_talk:Scribunto#Register_external_library_using_registerInterface.28.29_25635

## Report 

Using the following registration method
$this->getEngine()->registerInterface( dirname( __FILE__ ) . '/' . 'smw.library.lua', $lib, array() );
will cause an internal error
Lua file does not exist: C:\xampp\htdocs\mw\extensions\Scribunto\engines\LuaCommon/lualib/C:\xampp\htdocs\mw\extensions\SemanticMediaWiki\includes\lua/smw.library.lua
Verification

## Environment

MediaWiki 1.21alpha (37875db), Scribunto (a852755)

## Anomie responded

The problem is the Windows directory paths with drive letter; since c98cc645 Scribunto has supported absolute Unix-style paths in registerInterface(), and 8fd45026 tried to extend this to Windows but failed to consider drive letters.
Comment 1 MWJames 2013-03-28 15:51:05 UTC
Could we also make sure that test cases don't have to same problem. For example:

return parent::getTestModules() + array(
	'PropertyLibraryTests' => __DIR__ . '/PropertyLibraryTests.lua',
);

Right now when trying to load a PropertyLibraryTests.lua from a non-Scribunto directory it returns with a 

Invalid argument supplied for foreach() in C:\xampp\htdocs\mw\extensions\Scribunto\tests\engines\LuaCommon\LuaEngineTestBase.php on line 183
Unexpected non-MediaWiki exception encountered, of type "Exception"
exception 'Exception' with message 'Failed to load module PropertyLibraryTests'

But PropertyLibraryTests.lua do exists in folder C:\xampp\htdocs\mw\extensions\SemanticMediaWiki\tests\phpunit\includes\lua which is the same directory that holds PropertyLibraryTest.php

Because as long as tests do not work, [1] is blocked.

[1] https://gerrit.wikimedia.org/r/#/c/56393/
Comment 2 Brad Jorsch 2013-03-28 16:50:51 UTC
(In reply to comment #1)
> Could we also make sure that test cases don't have to same problem.

It doesn't appear that they do, as the code in question only accepts absolute paths and does not try to prepend anything.

> Invalid argument supplied for foreach() in
> C:
> \xampp\htdocs\mw\extensions\Scribunto\tests\engines\LuaCommon\LuaEngineTestBa
> se.php
> on line 183

That warning seems to indicate that your getTestModules() is not in fact returning an array.

> Because as long as tests do not work, [1] is blocked.
> 
> [1] https://gerrit.wikimedia.org/r/#/c/56393/

I see no unit tests being added in that changeset.
Comment 3 MWJames 2013-03-28 17:17:50 UTC
> > Because as long as tests do not work, [1] is blocked.
> > 
> > [1] https://gerrit.wikimedia.org/r/#/c/56393/
> 
> I see no unit tests being added in that changeset.

Well, I updated the change but as you can see their are two issues first PropertyLibraryTests.lua returns locally with

Notice: unserialize(): Error at offset 114 of 118 bytes in C:\xampp\htdocs\mw\extensions\Scribunto\engines\LuaStandalone\LuaStandaloneEngine.php on line 384 Lua error: Internal error: Unable to decode message. Backtrace: #0

but the more severe issue is '''Jenkins''' since Scribunto is not a dependency "$wgAutoloadClasses['Scribunto_LuaEngineTestBase']" or class_exists() won't work because Jenkins checks the directory (-- extensions/SemanticMediaWiki) and not the "UnitTestsList hook" so doing 

" ... extends Scribunto_LuaEngineTestBase" will fail in Jenkins for extensions. It is not really a nice design for a test case rather I would expect to invoke the Scribunto_LuaEngineTestBase class and set properties via setter/getter but I can't do this because the $moduleName is protected (of course I could try going through the ReflectionClass but this shouldn't be necessary).
Comment 4 Brad Jorsch 2013-03-28 18:48:45 UTC
(In reply to comment #3)
> > > Because as long as tests do not work, [1] is blocked.
> > > 
> > > [1] https://gerrit.wikimedia.org/r/#/c/56393/
> > 
> > I see no unit tests being added in that changeset.
> 
> Well, I updated the change but as you can see their are two issues first
> PropertyLibraryTests.lua returns locally with
> 
> Notice: unserialize(): Error at offset 114 of 118 bytes in
> C:
> \xampp\htdocs\mw\extensions\Scribunto\engines\LuaStandalone\LuaStandaloneEngi
> ne.php
> on line 384 Lua error: Internal error: Unable to decode message. Backtrace:
> #0

I wonder if that's bug 46294.

> but the more severe issue is '''Jenkins''' since Scribunto is not a
> dependency
> "$wgAutoloadClasses['Scribunto_LuaEngineTestBase']" or class_exists() won't
> work because Jenkins checks the directory (-- extensions/SemanticMediaWiki)
> and
> not the "UnitTestsList hook" so doing 
> 
> " ... extends Scribunto_LuaEngineTestBase" will fail in Jenkins for
> extensions.

I tried to ask hashar about this a while ago. Now that we have an actual example of the problem, perhaps he can tell us what to do about this situation.

> It is not really a nice design for a test case

You're welcome to try to redesign it. Note that all the tests must be run against both engines, the tests should actually run as separate tests and not one test with hundreds of assertions, it should not require every test class to be updated should another engine be added, and it's best not to require a ton of boilerplate to do so. Good luck.
Comment 5 MWJames 2013-03-28 19:09:05 UTC
> I wonder if that's bug 46294.
Just tested [1] and PHPUnit didn't crash with unserialize(), tests return with OK, but incomplete or skipped tests! Tests: 3, Assertions: 2, Skipped: 1. of course only after I copied the smw.property.lua file into the LuaCommon\lualib folder.

[1] https://gerrit.wikimedia.org/r/#/c/56425/
Comment 6 MWJames 2013-03-29 04:12:49 UTC
Back the original problem of registerInterface() which generates a concatenated string of C:\xampp\htdocs\mw\extensions\Scribunto\engines\LuaCommon/lualib/C:\xampp\htdocs\mw\extensions\SemanticMediaWiki\includes\lua/smw.property.lua

The problem lies with the Scribunto_LuaEngine class where the check $fileName[0] !== DIRECTORY_SEPARATOR will not provide sufficient clarity and end up putting $this->getLuaLibDir() {C:\xampp\htdocs\mw\extensions\Scribunto\engines\LuaCommon/lualib/} and $fileName {C:\xampp\htdocs\mw\extensions\SemanticMediaWiki\includes\lua/smw.property.lua} together.

protected function normalizeModuleFileName( $fileName ) {
	return $fileName[0] !== DIRECTORY_SEPARATOR ? "{$this->getLuaLibDir()}/{$fileName}" : $fileName;
}
Comment 7 Antoine "hashar" Musso (WMF) 2013-03-29 11:16:50 UTC
Please fill a new bug for the Jenkins issue reported in Comment #3:

---
but the more severe issue is '''Jenkins''' since Scribunto is not a dependency
"$wgAutoloadClasses['Scribunto_LuaEngineTestBase']" or class_exists() won't
work because Jenkins checks the directory (-- extensions/SemanticMediaWiki) and
not the "UnitTestsList hook" so doing 
---

I suspect the request is to add Scribunto has an extension dependency to the SemanticMediaWiki extension.
Comment 8 Brad Jorsch 2013-03-29 12:11:00 UTC
(In reply to comment #6)
> Back the original problem of registerInterface() which generates a
> concatenated
> string of
> C:\xampp\htdocs\mw\extensions\Scribunto\engines\LuaCommon/lualib/C:
> \xampp\htdocs\mw\extensions\SemanticMediaWiki\includes\lua/smw.property.lua
> 
> The problem lies with the Scribunto_LuaEngine class where the check
> $fileName[0] !== DIRECTORY_SEPARATOR will not provide sufficient clarity and

As I said, it's not recognizing that the path beginning with the drive letter is absolute, so it's treating it as relative.

Gerrit change #56596 should theoretically fix it.
Comment 9 MWJames 2013-03-29 12:43:52 UTC
(In reply to comment #7)
> Please fill a new bug for the Jenkins issue reported in Comment #3:
>
> I suspect the request is to add Scribunto has an extension dependency to the
> SemanticMediaWiki extension.

I'm just to lazy for creating yet another bug, I went ahead and added the dependency [1].

[1] https://gerrit.wikimedia.org/r/#/c/56570/
Comment 10 MWJames 2013-03-29 12:45:18 UTC
(In reply to comment #8)
> (In reply to comment #6)
> 
> Gerrit change #56596 should theoretically fix it.

Gerrit change #56596 returns with Warning: preg_match(): No ending matching delimiter '>' found in C:\xampp\htdocs\mw\extensions\Scribunto\engines\LuaCommon\LuaCommon.php on line 142
Comment 11 Brad Jorsch 2013-03-30 00:54:42 UTC
Changeset merged to fix the original issue here. Unit test file loading seems fine as well, and the Jenkins dependency has been merged too.
Comment 12 Gerrit Notification Bot 2013-11-14 15:19:20 UTC
Change 95396 had a related patch set uploaded by MarkAHershberger:
(bug 46635) Recognize Windows path+drive letter

https://gerrit.wikimedia.org/r/95396
Comment 13 Gerrit Notification Bot 2013-11-14 15:29:01 UTC
Change 95396 merged by MarkAHershberger:
(bug 46635) Recognize Windows path+drive letter

https://gerrit.wikimedia.org/r/95396
Comment 14 Andre Klapper 2013-11-15 11:09:55 UTC
No open patches to review here (backport patch to REL_1_21 got merged), hence resetting status to RESOLVED FIXED. Backport_to_Stable flag might be set to "+" by hexmode.

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


Navigation
Links