Topic on Project:Support desk

Execute bash script, upload and create page

4
Marcusdesto (talkcontribs)

Dear community,

first of all, I would like to say, that you really did a great job on media wiki. I just started to use it and I am impressed. I will stick to testing mediawiki, accourding security, too.

Anyway, since I am new to php and media wiki, I hope you excuse, I am not an expert, so my question may appear little noobish.

Well, I would like to modify the upload and the multiupload function of media wiki, meaning I acctually would like to copy the functionalities of upload and multiupload and add some functionalities, so upload, multiupload and modified upload and modified multiupload are available at the same time.

The modification I would like to make is consisting of three parts:

  1. ) after the file f0 has been uploaded, in the background on the server a bash script starts to work (converting the file into different format). It is important, that this happens in the background. Maybe a message should be displayed to confirm the upload and inform user about the converting process. Therefore, I think the confirmation like upload does should be enough. After bash script starts working the number of free accepted upload slots (default is 20) should be reduced by custom value, say 5, as long as converting is in progress, because of performance. It also should be possible to se a limit for bash scripts running in the backgroud, preventing users do over load the server by too many uploads.
  2. ) after bash script converted the uploaded file f0 to new file f1, f1 should be also added to media wiki like it would be uploaded, meaning, after bash script action media wiki should upload f1 to itself. It should also be possible to handle converting a second file f2 (and maybe more) and process all of them to step 3.
  3. ) After step 1.) and 2.) are done, media wiki would create automatically a new page in a chosen category (page could be given by template). The created page would contain links to the files (both, the uploaded one and the converted file(s)) and some text as defined in template.

I think this could help a lot of people to work with content with several file types. In my case, it would save a lot of time.

I would really like to program it 100% by myself, but I have 0% knowledge about php and media wiki. Specially know where to start the approach in media wiki code would be important.

So, I ask you, please, to help me. Thanks.

Regards, Marcus

EDIT: Mediawiki 1.21.1, mysql 5.5, php 5.4

MarkAHershberger (talkcontribs)

This sort of work (async thumbnailing) is already done for the most part. Have a look at thumb.php.

Using this method, MediaWiki can convert to different formats (e.g. svg to png).

If you have another use case in mind, I would look at thumb.php to see how to extend it for what you want.

Bawolff (talkcontribs)

You would probably want to look at image handler classes (See things like Extension:PdfHandler.


If you want to convert something before its needed, you probably want to look at the job queue. Extension:TimedMediaHandler for example converts video files in the background to different formats.

Reply to "Execute bash script, upload and create page"