Last modified: 2013-03-12 00:57:24 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 T48006, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46006 - $wgExtensionAssetsPath is empty (but should not) when it is used in an extension. Wrong place in includes/setup.php ?
$wgExtensionAssetsPath is empty (but should not) when it is used in an extens...
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.21.x
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-11 21:59 UTC by T. Gries
Modified: 2013-03-12 00:57 UTC (History)
4 users (show)

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


Attachments

Description T. Gries 2013-03-11 21:59:55 UTC
See https://gerrit.wikimedia.org/r/#/c/53009/

Some developers proposed to me https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/OpenID.git;a=commitdiff;h=61d5807ea49252683c04408c34913952049a26c8

--- a/OpenID.php
+++ b/OpenID.php
@@ -46,7 +46,7 @@ $wgOpenIDHideOpenIDLoginLink = false;
  * Location of the OpenID login logo. You can copy this to your server if you
  * want.
  */
-$wgOpenIDLoginLogoUrl = $wgScriptPath . '/extensions/OpenID/skin/icons/openid-inputicon.png';
+$wgOpenIDLoginLogoUrl = $wgExtensionAssetsPath . '/OpenID/skin/icons/openid-inputicon.png';
 

This is empty in all my installations, also on the instances on wmflabs which are standards.

It's not clear, what is happening, and I think, the setup of this variable in core in includes/setup.php is substantially >> wrong << at this place in core.

https://gerrit.wikimedia.org/r/#/c/53009/ comment to patch set 2


I ask you, as an expert, can you try -- in your code just BEFORE you include the extension add three lines and tell me if your browser shows the correct path - or nothing - when navigating to your wiki:

### $wgExtensionAssetsPath = "$wgScriptPath/extensions";
echo $wgExtensionAssetsPath; // We need this because wfDebug() is not working at this stage !!
die();

require_once( "$IP/extensions/OpenID/OpenID.php" );
Comment 1 Brion Vibber 2013-03-11 22:10:12 UTC
You should only use things like $wgExtensionAssetsPath *after* basic initialziation, or it probably won't be set yet. Use it at general runtime -- when using something -- or from an initialization function.

(Same really goes for $wgScriptPath as it can be customized, though usually the autodetected value will already be set correctly.)
Comment 2 T. Gries 2013-03-11 22:11:48 UTC
So basically I need a variable for the web-access to the image = the fully specified path of an image in the extension.

It is strange, that the value is empty, in my installations.

Is its setup in includes/setup.php perhaps wrong, when it is to be used in LocalSettings or DefaultSettings ?
Comment 3 T. Gries 2013-03-11 22:13:56 UTC
(In reply to comment #1)
> You should only use things like $wgExtensionAssetsPath *after* basic
> initialziation, or it probably won't be set yet. Use it at general runtime --
> when using something -- or from an initialization function.
> 
> (Same really goes for $wgScriptPath as it can be customized, though usually
> the
> autodetected value will already be set correctly.)

mid-air...

what would you suggest ?

One working method is to parse the _url_ of the running file (here: OpenID.php ) directly from the $_SERVER[], strip-off the basename to get the Web-path --- but this is ugly, isn't it ?Ireally wish to have a method for that.
Comment 4 T. Gries 2013-03-11 22:15:29 UTC
(copied from one of my sniplet archives)


$server = $_SERVER['SERVER_NAME'];
$remoteAddress = $_SERVER['REMOTE_ADDR'];

$pathParts = pathinfo( __FILE__ );
$scriptName = $pathParts['basename'];

function scriptUrl() {
	$pageUrl = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == "on" ) ? 'https://' : 'http://';
	$pageUrl .= $_SERVER['SERVER_PORT'] != '80' ? $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . $_SERVER['SCRIPT_NAME'] : $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
	return $pageUrl;
}
$imageBase = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR;
$imageBaseUrl = str_replace( $scriptName, "", scriptUrl() ) . "img/";
Comment 5 Brion Vibber 2013-03-11 22:15:34 UTC
It is normal that it is empty when your extension's configuration file is being loaded, because it may be *set by* LocalSettings.php.

If not set explicitly, it will be derived by other settings that may be set or overridden in LocalSettings.php.

As mentioned above, either use it at runtime -- NOT at config time -- or make an initialization function ($wgSetupFunctions or whatever it's called) which get run after these auto-detected settings are filled out.
Comment 7 T. Gries 2013-03-11 22:19:26 UTC
I read this. thanks

"As mentioned above, either use it at runtime -- NOT at config time -- or make
an initialization function ($wgSetupFunctions or whatever it's called) which
get run after these auto-detected settings are filled out."
Comment 8 T. Gries 2013-03-12 00:57:24 UTC
just for my (E:OpenId) records: fixed in https://gerrit.wikimedia.org/r/#/c/53292/

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


Navigation
Links