Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Add support for loading shared modules
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkarminski committed Aug 18, 2014
1 parent cf05ed8 commit 50d3302
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions extensions/Scribunto/engines/LuaCommon/LuaCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,21 @@ function loadPackage( $name ) {
return array( $init );
}

$title = Title::newFromText( $name );
if ( !$title || $title->getNamespace() != NS_MODULE ) {
return array();
if ( preg_match( "/^Dev:/", $name ) ) {

This comment has been minimized.

Copy link
@Grunny

Grunny Aug 18, 2014

Member

The prefix should probably be in a constant, also you don't need regex, so just use strpos.

$sDevName = preg_replace( "/^Dev:/", "", $name );

This comment has been minimized.

Copy link
@Grunny

Grunny Aug 18, 2014

Member

Likewise here for both putting the prefix in a constant, and not needing regex (just use substr).

$title = GlobalTitle::newFromText( $sDevName, NS_MODULE, 7931 );

This comment has been minimized.

Copy link
@Grunny

Grunny Aug 18, 2014

Member

The shared module wikia ID shouldn't be a magic number, it should be either a constant or a config var.

if ( !$title ) {
return array();
}
$module = $this->fetchSharedModule( $title );
} else {

This comment has been minimized.

Copy link
@Grunny

Grunny Aug 18, 2014

Member

Weird whitespace ;).

$title = Title::newFromText( $name );
if ( !$title || $title->getNamespace() != NS_MODULE ) {
return array();
}
$module = $this->fetchModuleFromParser( $title );
}

$module = $this->fetchModuleFromParser( $title );
if ( $module ) {
return array( $module->getInitChunk() );
} else {
Expand Down

1 comment on commit 50d3302

@Grunny
Copy link
Member

@Grunny Grunny commented on 50d3302 Aug 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs "Wikia change" comments too.

Please sign in to comment.