Jump to content

Topic on Project:Support desk

$wgMaxUploadSize has no effect

10
451plus (talkcontribs)

Hello,

I would like to upload some technical documentation to my wiki and some files are slightly bigger than the default maximum size of 2 MB. I first changed the settings in php.ini /etc/php5/apache2/php.ini

Maximum size of POST data that PHP will accept.
http://php.net/post-max-size

post_max_size = 160M

File Uploads ;
Whether to allow HTTP file uploads.
http://php.net/file-uploads

file_uploads = On

Temporary directory for HTTP uploaded files (will use system default if not
specified).
http://php.net/upload-tmp-dir
upload_tmp_dir =
Maximum allowed size for uploaded files.
http://php.net/upload-max-filesize

upload_max_filesize = 40M

Maximum number of files that can be uploaded via a single request

max_file_uploads = 20

I applied these changes also to /etc/php5/cli/php.ini

then I appended to the end of

/etc/mediawiki/LocalSettings.php (same as /var/lib/mediawiki/LocalSettings.php)

$wgUploadSizeWarning = 2147483648; $wgMaxUploadSize = 2147483648;

Restarting Apache or rebooting the computer has no effect. When I upload my 2.327 KB-file, mediawiki shows a warning in the preview, but the output looks fine. When I want to save the page, mediawiki refuses saving.

I use an Ubuntu 12.04 system with apache 2.2.22, mediawiki 1.15.5 and php 5.3.10.

How can I enable uploads >2MB?

Thanks, Martin

88.130.81.230 (talkcontribs)

Hi Martin,

have you checked, if the PHP settings you made are actually taking effect? Check what phpinfo() tells you about the values of these variables.

451plus (talkcontribs)

Thanks, but that seems ok:

php phpinfo.php|grep upload

file_uploads => On => On

max_file_uploads => 20 => 20

upload_max_filesize => 40M => 40M

upload_tmp_dir => no value => no value

file_uploads => On => On

max_file_uploads => 20 => 20

upload_max_filesize => 40M => 40M

upload_tmp_dir => no value => no value

Do you have other ideas?

88.130.81.230 (talkcontribs)

That is what you have in CLI mode. Did activating these settings also work properly for Apache in non CLI mode?

If that worked, I would search the MediaWiki source code for the exact error message, which you get. That way you should find the place in the source code, where this error happens. Then check, which conditions must have been true, before getting the error message. This should help you find the reason for the problem.

451plus (talkcontribs)

Thanks,

I never heard about Apache CLI/ non CLI mode and unfortunately, google does not help. I looked in /var/log/apache2/error.log, but there are no errors related to mediawiki listed. Is there a mediawiki error-log?

88.130.115.189 (talkcontribs)

When you posted this shell command some posts above I thought you knew about Apache and that stuff, that's why I didn't explain it in detail. ;-)

When you run a script on the shell like you do with

$php phpinfo.php|grep upload

then the CLI configuration of your machine is used.

But when you run a script with your webbrowser, the configuration, which you have provided for that mode will be used. Checking this configuration is rather easy: Upload a file to your webspace with this content:

<?php phpinfo(); ?>

and view it with your webbrowser. You will then see the PHP settings which apply, when your website (read: MediaWiki) is called with a webbrowser. There the upload sizes must be correct/big enough.

I don't know of a MediaWiki error log. MediaWiki can write a debug log, but I don't know, if failed uploads would be logged there. But where you could still have a look is the PHP error log, which you should find in the folder php/logs.

451plus (talkcontribs)

Thanks,

in non CLI-mode the settings are the same. I looked in the source-code and found the message called "longpageerror". This leads to a call in /usr/share/mediawiki/includes/EditPage.php:

if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
                        $wgOut->addHTML( "<div class='error' id='mw-edit-longpageerror'>\n" );
                        $wgOut->addWikiMsg( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) );

What can I do now? I have no idea of PHP. Can I change the condition to something like

$this->kblength > 10*$wgMaxArticleSize?

Do you know any work-arounds? Is it possible to post the page directly to the database without using the browser?

Thanks for your help, Martin

88.130.120.250 (talkcontribs)

Hi!

If this line cuases you trouble, you could change it to

 if ( $this->kblength > 10*$wgMaxArticleSize ) {

but you should not do this. ;-)

If the maximum article size is to small, it should be enough to raise $wgMaxArticleSize, e.g. by setting it to

 # Raise the maximum article size in kilobytes to 10 times its original value:
 $wgMaxArticleSize = 20480;

This might at the same time also prevent $this->tooBig from being set. So that way you kill two birds with one stone.

Reply to "$wgMaxUploadSize has no effect"