Mediawiki extensions, will not read my i18n file - php

As far as i'm aware, the only steps required in order to create a internationalized extension is to create a i18n file like the following:
//SemanticHighcharts.i18n.php
$messages = array();
$messages['en'] = array(
'semantichighcharts-desc' => 'A SMW result format displaying data with the help of highcharts
);
and then reference this file with the global variable wgExtensionMessageFiles
//SemanticHighcharts.php
global $wgExtensionMessagesFiles, $wgExtensionCredits;
$wgExtensionCredits['semantic'][] = array(
'path' => __FILE__,
'name' => 'SemanticHighcharts',
'version' => '0.0.1',
'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticHighcharts',
'descriptionmsg' => 'semantichighcharts-desc'
);
//i18n
$wgExtensionMessagesFiles['SemanticHighcharts'] = dirname(__FILE__) . '/SemanticHighcharts.i18n.php';
This should cause the descriptionmsg in wgExtensionCredits to be internationalized when displayed on Special:Version.
However this is not the case... In fact, no message key from the i18n file is being read!
How can i debug this issue? I've tried to debug callstack when doing a wfMessage() call without any great success.
Any help is appreciated. I'm running the latest version of mediawiki from git. And all extensions have been installed with composer.
//composer.json
{
"require": {
"php": ">=5.3.2",
"mediawiki/side-bar-menu": "dev-master",
"mediawiki/semantic-highcharts": "dev-master",
"mediawiki/semantic-result-formats": "dev-master"
},
"suggest": {
"ext-fileinfo": "*",
"ext-mbstring": "*",
"ext-wikidiff2": "*",
"ext-apc": "*"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/netbrain/SemanticHighcharts"
}
]
}

Typical, after struggling with this issue for quite some time. Right after posting this question I tried to remove all other extensions from composer.json, and did a composer update. Which magically fixed my issue.
I'm suspecting that there might be a conflicting extension or maybe it was just something wrong with the composer autoloading mechanism.
Ill try to look into it further.
It seems that composer was the culprit, after re-adding the extensions previously removed, it still worked. So i can only guess that there is some quirk in composers dependency management.

Related

Geolocation package with laravel: Midnite81\Geolocation\GeoLocationServiceProvider' not found

I want to use the following package for geolocation with laravel.
https://github.com/midnite81/geolocation
I have done everything they wrote in their documentation but find an error
Midnite81\Geolocation\GeoLocationServiceProvider' not found
i am unable to solve this problem. Can't understand what's wrong. What i did, at first, write "midnite81/geolocation": "1.*" in the composer.json file.
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"midnite81/geolocation": "1.*"
},
After that run composer update. Then run composer dump-autoload -o. Then in the config/app.php file, put the following part in providers and aliases array.
'providers' => [
Midnite81\Geolocation\GeoLocationServiceProvider::class
];
'aliases' => [
'GeoLocation' => Midnite81\GeoLocation\Facades\GeoLocation::class,
];
then run the following command.
php artisan vendor:publish --provider="Midnite81\GeoLocation\GeoLocationServiceProvider"
Then got the error, Midnite81\Geolocation\GeoLocationServiceProvider' not found
Can't figure out what's wrong in it.
I verified and confirm the problem.
The problem is:
Midnite81\Geolocation\GeoLocationServiceProvider::class
You should change this into
Midnite81\GeoLocation\GeoLocationServiceProvider::class
Notice the difference Geolocation vs GeoLocation. It seems there is error in readme for this package on Github
I've already sent Pull request https://github.com/midnite81/geolocation/pull/2 to fix readme for this package

Composer: How to override a requirement globally for composer.json?

TL;DR:
My Project requires library A, A requires B1.
B1 is broken but there is a fork B2.
I want to achieve that composer will install B2 instead of B1 even if A requires B1 and not B2.
How to do that?
More in detail:
In a symfony project we require the following library:
"require": {
"emanueleminotto/twig-cache-bundle": "1.0.2",
}
This library requires itself another library that is currently broken:
"require": {
"asm89/twig-cache-extension": "^1.3"
},
For the broken library exists already a pull request for over 4 month but the maintainer refuses to merge it.
My question is, if it would be possible to overwrite the dependencies also for sub-dependencies, that always the patched fork would be used instead of the original one?
For the asm89/twig-cache-extension exists the following fork with fixes: https://github.com/blackandred/twig-cache-extension
I tried to add this fork to my composer.json and registered the fork explicitly under "repositories":
"repositories": [
{
"type": "git",
"url": "https://github.com/blackandred/twig-cache-extension"
}
],
and added the dependency also in my composer-json with a changed version to "dev-master":
"require": {
"asm89/twig-cache-extension": "dev-master",
"emanueleminotto/twig-cache-bundle": "1.0.2",
}
But since the emanueleminotto/twig-cache-bundle still requires the original library, composer ignores the fork and installs the original.
Anything i can do here?
I believe the docs have a good example for this scenario.
Basically you need to define an alias in your composer.json as following:
"require": {
"asm89/twig-cache-extension": "dev-master as 1.3",
"emanueleminotto/twig-cache-bundle": "1.0.2",
}
Added by the questioner:
One step was still missing: "composer update asm89/twig-cache-extension"
Add the replace section into composer.json of your fork:
{
"replace": {
"asm89/twig-cache-extension": "self.version"
}
}

Composer hook to fix package version

I need to hook in composer installation process to fix versions of second level dependencies of root package. I.e. my package depends on some packages (with correct versions) but these packages depends on other packages and its versions are "wrong". I try to use pre-package-install hook to patch such versions but it is not working for me, code inside Installer::prePackageInstall is not executed.
Root package composer.json looks like this:
{
"name": "***/root-package",
"repositories": [ { "type": "composer", "url": "http://***/packages.json" } ],
"require": {
"***/first-level-dep-1": "dev-release-XX",
"***/first-level-dep-2": "dev-release-XX"
},
"scripts": {
"pre-package-install": [
"root-package\\Installer::prePackageInstall"
]
}
}
First level dependency composer.json looks like this:
{
"name": "***/first-level-dep-1",
"repositories": [ { "type": "composer", "url": "http://***/packages.json" } ],
"require": {
"***/second-level-dep-1": "*", // !!! here is my problem
"***/second-level-dep-2": "*"
}
}
I need to replace * to appropriate version during installation process.
You don't have to "fix" that version. You should simply add that second-level-dep as your own dependency in the correct version, and the case is solved.
If the first-level-dependency requires ANY version of that package, then YOU depending on the correct version will restrict the installable versions to the one you allow.

Zend2 install ZendOauth module with composer

I'm totally new to zend2 and would like to install the zendframework/zendoauth module.
I added the module to composer.json and installed it properly with "composer install"
Contents of my composer.json
{
"name": "my_project_name",
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": ">2.2.0rc1",
"doctrine/doctrine-module": "*",
"doctrine/doctrine-orm-module": "*",
"zendframework/zendoauth": "2.0.*",
}
}
This downloaded the module into vendor/zendframework/zendoauth.
I edited config/application.config and added 'ZendOauth'.
Contents of my config/application.config.php
<?php
return array(
// This should be an array of module namespaces used in the application.
'modules' => array(
'Application',
'ZendOAuth'
),
...
Now when i try to access my website i get an error:
Fatal error:
Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException'
with message 'Module (ZendOAuth) could not be initialized.'
My question is: Is there anything i missed?!
Thanks in advance!
ZendOAuth isn't a module, it's a library, which is why you're getting an error message when you add it to the list of modules. You just use the classes it supplies in your own application.
Unfortunately, there doesn't appear to be any documentation for it at the moment, but to get an idea of usage, maybe take a look at the unit tests https://github.com/zendframework/ZendOAuth/tree/master/tests/ZendOAuth

ZendService\WindowsAzure with zf2

I'm trying to install zendservice-windowsazure using composer. My composer.json looks like this:
{
"repositories": [{
"type": "pear",
"url": "http://pear.php.net"
},
{
"type": "composer",
"url": "https://packages.zendframework.com/"
}],
"require": {
"microsoft/windowsazure": "*",
"zendframework/zendservice-windowsazure": "2.*"
},
"minimum-stability": "dev"
}
According to the docs here:
http://framework.zend.com/manual/2.1/en/modules/zendservice.windows-azure.html
I can then create a new storage client like so:
$storageClient = new ZendService\WindowsAzure\Storage\Blob();
However, the source that composer installs is structured differently and appears to be a completely different version to the classes referenced in the documentation. For example, the above call, according to the source code that composer has installed, is actually:
$storageClient = new ZendService\WindowsAzure\Storage\Blob\Blob();
But then when listing blobs, the installed zendservice-windowsazure library calls:
Zend\Http\Client->request()
which is no longer a valid method in the Client class.
So it looks like either:
a) The wrong version of zendservice-windowsazure is being installed
b) The Zend documentation is incorrect
I'm inclined to think it's the first option, due to the invalid reference to
Zend\Http\Client->request()
If that's the case, how can I get the latest version of the module? Even the github repo for the module is the same version as that installed by composer, and therefore doesn't work as specified in the documentation.
https://github.com/zendframework/ZendService_WindowsAzure
You can use old Windows Azure SDK for PHP 4.1.0 http://phpazure.codeplex.com/releases/view/78020. It works fine.

Categories