Page MenuHomePhabricator

math problem with web updater
Open, MediumPublic

Description

Hi there seems to be a problem with the math extension. when I try using the web updater it comes up with this error

<b>Warning</b>: in_array() expects parameter 2 to be array, null given in <b>/home/u699501870/public_html/extensions/Math/Math.hooks.php</b> on line <b>232</b><br />
<br />
<b>Warning</b>: in_array() expects parameter 2 to be array, null given in <b>/home/u699501870/public_html/extensions/Math/Math.hooks.php</b> on line <b>244</b><br /

I think the problem is to do with this https://gerrit.wikimedia.org/r/#/c/186255/1 patch

I am running mediawiki 1.25 wmf 16

Event Timeline

Paladox raised the priority of this task from to Unbreak Now!.
Paladox updated the task description. (Show Details)
Paladox added a project: Math.
Paladox subscribed.

Hi, thanks for your excellent report. What's your setting of

$wgMathValidModes

it's expected to be an array.
The default is

/**@var array defines the mode allowed on the server */
$wgMathValidModes = array( MW_MATH_PNG, MW_MATH_SOURCE, MW_MATH_MATHML, MW_MATH_MATHJAX );

Hi I haven't set $wgMathValidModes this in localsettings.php.

I have never had $wgMathValidModes this.

You, don't have to set that manually. It's the default value that comes from Math.php
I have no idea how the web updater works. Are you referring to this update process https://www.mediawiki.org/wiki/Manual:Upgrading#Web_browser
The error looks as if your $wgMathValidModes is not set resp was set to null explicitly.
Maybe this is connected with T87941
I feel sorry but I don't know how to help you.

Physikerwelt lowered the priority of this task from Unbreak Now! to Needs Triage.Feb 8 2015, 9:43 PM

Maybe if we roll back the patch https://gerrit.wikimedia.org/r/#/c/186255/ the problem would be fixed I can try to see if I I roll back the patch on my wiki and see if it fixes.

Can't you try the normal update via commandline. That's what I have tested.

Hi well no I carnt I doint have access to command line on my host. I can only do web updater.

The problem still hapends even if I revert the patch. so the problem has to be somewhere else in math. but it happened only recently. when I updated to math in wmf 16 so happened between wmf 15 and wmf 16.

@Paladox: https://gerrit.wikimedia.org/r/#/c/186255/ is not related to this problem. The lines the errors you report are performing checks with $wgMathValidModes. This behaviour has not been modified in this patch. The patches moves that line, but the operation was already there, just on a different line.

This is caused by an issue in your setup. To try it out, you can revert the commit in your local git clone (using git revert {hash of commit}) and observe the error is still there.

I suspect it may have to do with the way the extension file is loaded. Global variables not being global.

Is this still a problem?

@Paladox: Please try what's proposed in T88946#1039075 and be explicit about your steps and the result

Hi the steps I tooks was I went to my website with mediawiki installed. I then went to /mw-config/ I chose the language I then clicked next I then put in upgrade key and then clicked next I then clicked next on and then next on the upgrade page and then in the white box where it shows you what it did it shows this at the top of the box when you scroll up

<b>Warning</b>: in_array() expects parameter 2 to be array, null given in <b>/home/paladox/public_html/pt-br/extensions/Math/Math.hooks.php</b> on line <b>230</b><br />
<br />
<b>Warning</b>: in_array() expects parameter 2 to be array, null given in <b>/home/paladox/public_html/pt-br/extensions/Math/Math.hooks.php</b> on line <b>242</b><br />

This problem may be caused by mediawiki in core.

Hi it seems by doing this

if ( in_array( MW_MATH_LATEXML, array( $wgMathValidModes ) ) ) {

fixed the problem all I did was added array

Change 192074 had a related patch set uploaded (by Paladox):
Added array to fix web updater problems

https://gerrit.wikimedia.org/r/192074

Patch-For-Review

This indicates that $wgMathValidModes is misconfigured. For some reson $wgMathValidModes is not an array as it's set up in Math.php. If people are adding additional modes it's important to write $wgMathValidModes[] = ... rahter than $wgMathValidModes = ..

Oh ok this is then a temporarily fix.

Should I upload a patch that changes $wgMathValidModes = to $wgMathValidModes[] =

Change 193159 had a related patch set uploaded (by Paladox):
Fix webupdater in math

https://gerrit.wikimedia.org/r/193159

Change 192074 abandoned by Paladox:
Added array to fix web updater problems

Reason:
Please see https://gerrit.wikimedia.org/r/#/c/193159/

https://gerrit.wikimedia.org/r/192074

Thank you for submitting the second patch. But this would overwrite all configuration set by any user.
I think you need to debug your specific setting and track what happens to $wgMathValidModes.
There are two possible options
A) Math.php is not called prior to the call of onLoadExtensionSchemaUpdates
or
B) After Math.php $wgMathValidModes is overwritten with another place (e.g. in LocalSettings.php or some other config file)

If you are able to figure out if A or B is the case, the root cause of your problem can be identified and fixed.

But what abot doing something like $wgMathxxx = $wgMathValidModes so that it wont overwrite user setting and will be temporary till the problem can be identified.

What's your ultimate goal?
I see that it's extremely hard to debug without shell access.

What about changing in_array to array seems to fix the problem.

A possible solution would be to create all tables independent of the user settings.
In the worst case people would have additional, but empty tables.
Since the updater is not run on WMF wikis this would not affect production at all.
@Krinkle: What do you think?

What about doing

if ( is_array( $wgMathValidModes ) && in_array( MW_MATH_LATEXML, $wgMathValidModes ) ) {

and

if ( is_array( $wgMathValidModes ) && in_array( MW_MATH_MATHML, $wgMathValidModes ) ) {

seems to also fix issue.

I got answer from http://stackoverflow.com/questions/16347490/in-array-expects-parameter-2-to-be-array-null-given-error

@Paladox I love your motivation, but remember the real problem is with $wgMathValidModes, not with the code using that variable. Focus on figuring out why, for your install, the variable is not becoming an array. Suppressing the problem by removing the variable or adding additional tolerance does not fix the problem.

Krinkle closed this task as Declined.EditedFeb 27 2015, 10:12 PM
Krinkle claimed this task.

Closing this issue as all signs point there is an issue with the user's setup. Not a bug in the software. Feel free to discuss further here to figure that out, however. Re-open the task if the cause turns out to be Math or MediaWiki core.

Krinkle unsubscribed.

Change 193159 abandoned by Physikerwelt:
Fix webupdater in math

Reason:
The Math extension is deployed on a lot of wikis. A temporary fix would cause other problems. I think we should not merge temporary changes.

https://gerrit.wikimedia.org/r/193159

Paladox added a subscriber: Physikerwelt.

I think I found a way to fix problem by replacing in_array with array since in_array allows an array to be in an array where as an array dosent I think.

Change 206804 had a related patch set uploaded (by Paladox):
Replaced in_array with array

https://gerrit.wikimedia.org/r/206804

And because it expects parameter 2 to be an array and its not because it is not needed in array.

Krinkle claimed this task.

@Paladox I'm re-closing this. @Physikerwelt and I have both tried to help you before. Please understand that the problem is not in the Math extension. There is a misconfiguration in your server that is causing this variable to be missing. I recommend focusing your efforts on investigating why that variable is missing. From the extension perspective, it is an impossible scenario that the variable is undefined. It does not make sense to add conditional guards around impossible scenarios.

Paladox changed the task status from Declined to Resolved.May 16 2015, 2:29 PM

Change 206804 abandoned by Physikerwelt:
Added GLOBAL['']

Reason:
It's not an option to use globals. We will change to the new json update mechnism...which will solve the problems

https://gerrit.wikimedia.org/r/206804

Paladox reopened this task as Open.EditedOct 29 2015, 8:05 PM

Re opening, It is now causing the web updater to not work if I have the math extension installed.

Causes this error now

<br />
<b>Warning</b>: array_map() [<a href='function.array-map'>function.array-map</a>]: Argument #2 should be an array in <b>/home/paladox1/public_html/extensions/Math/MathRenderer.php</b> on line <b>652</b><br />
<!DOCTYPE html>
<html><head><title>Internal error - MediaWiki</title><style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style></head><body>
<p>[739075ea] /mw-config/?page=Upgrade MWException from line 220 of /home/paladox1/public_html/includes/Hooks.php: Detected bug in an extension! Hook MathHooks::onLoadExtensionSchemaUpdates has invalid call signature; in_array() expects parameter 2 to be array, null given</p><p>Backtrace:</p><p>#0 /home/paladox1/public_html/includes/installer/DatabaseUpdater.php(118): Hooks::run(string, array)<br />
#1 /home/paladox1/public_html/includes/installer/DatabaseUpdater.php(183): DatabaseUpdater-&gt;__construct(DatabaseMysqli, boolean, NULL)<br />
#2 /home/paladox1/public_html/includes/installer/DatabaseInstaller.php(305): DatabaseUpdater::newForDB(DatabaseMysqli)<br />
#3 /home/paladox1/public_html/includes/installer/WebInstallerPage.php(647): DatabaseInstaller-&gt;doUpgrade()<br />
#4 /home/paladox1/public_html/includes/installer/WebInstaller.php(279): WebInstallerUpgrade-&gt;execute()<br />
#5 /home/paladox1/public_html/mw-config/index.php(77): WebInstaller-&gt;execute(array)<br />
#6 /home/paladox1/public_html/mw-config/index.php(36): wfInstallerMain()<br />
#7 {main}</p>
</body></html>

Change 249816 had a related patch set uploaded (by Paladox):
Change array_map to array

https://gerrit.wikimedia.org/r/249816

Change 249816 abandoned by Paladox:
Change array_map to array

Reason:
Wrong fix.

https://gerrit.wikimedia.org/r/249816

Change 249870 had a related patch set uploaded (by Paladox):
Fix in_array error

https://gerrit.wikimedia.org/r/249870

Krinkle removed a project: Patch-For-Review.

Change 249870 abandoned by Paladox:
Fix in_array error

https://gerrit.wikimedia.org/r/249870