Topic on Extension talk:TinyMCE

Bug(s) with image uploads through TinyMCE?

14
WhitWye (talkcontribs)

The page mentions setting perms for this, but not which perms, where. On a wiki where MediaWiki's "Upload File" works fine for a png, TinyMCE's "Upload/edit file" button, after selecting a file from the local workstation, complains "I'm sorry, you have encountered an unknown error trying to upload this file. If this error persists please cntact your systems administrator". There's nothing in the Apache log -- no error at all. And of course I'm the administrator.


What does happen, instead of the image being uploaded, is this appearing on the page where it was to go, in double square brackets "undefined|right|middle|thumb". I haven't found a way yet to get more useful debugging data out of it.

DuncanCrane (talkcontribs)

Hi

Thank you for using this extension and also reporting this problem. There are in fact two problems, the second of which (the wiki code for a 'file' link being inserted into the editor rather than the image displaying) is a coding error and I will upload a fix for this the the master branch on gerrit over the next day or so. To solve the first problem with the upload, however, I will need some more information.

If the error was to do with permissions, files sizes, valid file types, duplicates etc, then the extension would report these explicitly. This error message is caused by the mediawiki API reporting a 'success' code for the file upload but returning an undefined result without either an error or warning response. The result should be an external URL to where your wiki has stored the file and also the link to the uploaded file to use from within a wiki page . As a result of the lack of information from the mediawiki API, the extension is unable to report further details of the error - which is frustrating I know!

However, perhaps with a bit more information, we should be able fix this. The following would help me to try and isolate the problem, which I haven't be able to reproduce, sorry.

  • the name of the file you were trying to upload (occasionally if there are non latin characters this can cause problems)
  • would you check the 'files' special page to see if the file was uploaded successfully (sometimes the upload happens anyway)
  • would you let me know the versions of software and extensions you are using from the 'versions' special page
  • would you let me know if there were any warnings and errors when you were using the upload dialog before you got the error message
  • if you are able, can you add the following to your 'localSetting.php' file after the '<php' tag as it will get mediawiki to report any errors it encounters during an upload to the web browser.
error_reporting( -1 );
ini_set( 'display_errors', 1 );

Many thanks, Duncan

WhitWye (talkcontribs)

Hi Duncan,


Appreciate the help. I tried with a number of .png and .jpg files, all with only Latin characters. Most were quite small. The files did not show up on the "Files" special page. There were no warnings or errors using the upload dialog before the message. I already tried those error reporting settings, and nothing more showed from that.

The Version page shows as installed software:

MediaWiki 1.35.0-alpha

PHP 7.2.24-0ubuntu0.18.04.2 (apache2handler)

MariaDB 10.1.43-MariaDB-0ubuntu0.18.04.1

ICU 60.2

Installed Extensions shows nothing, which is obviously wrong, since TinyMCE is running (via "wfLoadExtension( 'TinyMCE' );"). Should I back off from 1.35.0-alpha? I was starting with that to try to get Visual Editor running to test it, but that project is just a mess at present. TInyMCE has the great advantage of not requiring such a bloated stack.

A separate question: Can the vertical space taken by the TinyMCE window be set larger? With image uploading fixed, and that expanded, our users here (internal company wiki) should be happy with the upgrade from a much older MediaWiki with CKEditor -- which allows dragging the editing windows to arbitrary vertical sizes, but otherwise is not as polished.

DuncanCrane (talkcontribs)

Hi

I think the problem may be with the 1.35 alpha as that is a pre-production, pre-release version as I understand it (see Version lifecycle#Extension lifecycle management). I suspect it is not stable enough yet for anything like production work and it is quite likely there are changes to the API and underlying software versions of tools like PHP. I believe there are users of TinyMCE on versions of mediawiki up to 1.34, but personally I do most of my development and testing on 1.31 which is the current Long Term Stable (LTS) version, which should be supported until June 2021.

To change the displayed height of the editor window there is a setting in the MW_tinymce.js file in the extension root directory which can be used to reset the height:

autoresize_max_height: 400,

I'm currently working on a new version which I hope will replace the current beta version and I will consider if I can make the editor window user re-sizeable in that. As you'll appreciate, I want to focus new feature development on that version rather than the current version :-)

The TinyMCE extension is very much intended as a simple to implement and familiar to use WYSIWYG editor interface, yet with a rich feature set, which will I hope will be even more evident in the next version so I'm glad you are trying it out. Do let me know if you need any further help. I will try to get a patch for the other problem you had uploaded to the Git master over the weekend.

Many thanks

Duncan

WhitWye (talkcontribs)

Hi Duncan,

Same behavior on 1.34. I'll fall back to 1.31.6 now -- was hoping for 1.34 since 1.31.6 will require bringing in the old DB again.

Whit

WhitWye (talkcontribs)

Hi again,

Exactly the same behavior from 1.31.6. It did, on one file, give proper notice that it already existed. But for a new upload, it just goes right to the generic error message. Nothing logged anywhere.

Whit


WhitWye (talkcontribs)

Ah, learned something: It's not enough to change the version, but for some reason Apache must be restarted to avoid partial inheritance -- or is it the browser caching script, or session management on the server? So now with 1.31.6 I get to a new error:

I'm sorry, you have encountered the following warnings trying to upload this file:

You have received the warning thumb

Please correct the errors and try again

At least it's the thumb and not the finger. But what can that mean?

Best,

Whit

WhitWye (talkcontribs)

On another try I get to the point where, within double square brackets, is the code that should be there if this were the wiki code version of the page:

File:Bluesteal.png|right|middle|thumb -- which then does pull the file in once saved, and displays the image during a subsequent edit, which it did not do on first insertion. Definitely progress. Is this overall the expected behavior?

Thanks again,

Whit

WhitWye (talkcontribs)

Once a file is on the page, going in again to edit its properties by double clicking on it results in adding a duplicate of the file to the page. Is this to be expected?

Whit

WhitWye (talkcontribs)

Firefox duplicated the image when trying to move/resize it on the page. Chrome leaves it single, but it picks up extra code when saved, which is also a problem in Firefox (both Linux here). First there's a font spec in angle brackets, then also in angle brackets:

img src="" srcset="/wiki/images/5/56/Bluesteal.png 1.5x" alt="Bluesteal.png" width="697" height="653" data-mce-src="images/thumb/5/56/Bluesteal.png/300px-Bluesteal.png"

The "src =" part actually has the image displayed between the quotes. The angle brackets are actually the HTML codes to display those, rather than really being angle brackets at the code level.

Should I take it that TinyMCE 4 just isn't good with images? Is 5 improved in this?

Whit

DuncanCrane (talkcontribs)

Hi Whit

Sorry for delay - for some reason I wasn't getting notified of your further questions :-{.

As for inserting the wiki code when first uploading - did you manage to download the patch that I mentioned earlier? You can find it here.

It's been a while since I used the image upload extensively so some other changes may have upset it but it should work better than you are experiencing. It can be a little convoluted, in part because of the checks and warning mediawiki makes, but it shouldn't be crashing or dumping html code into the page. Your additional information ios very helpful so I'll investigate a little more.

B.T.W. did you retry mediawiki 1.34 after you resolved the caching problem? I know there are other users using 1.34 on a regular basis so you should be able to use it O.K. Caching can cause issues when the code changes, as you found, both at the client and server end so if you change any code (js or css) it's often advisable to purge the caches. To do this at the client end I often find it best to go into the browser's 'inspect/debug' mode and then follow the recommended procedure to purge the cache and reload the page.

Many thanks

Duncan


WhitWye (talkcontribs)

Duncan,


Much appreciate your help and efforts here. Meanwhile I've finally got Visual Editor working, so I'm on to trying to work out why CirrusSearch and friends fail to work by date order in 1.34. Hope to see your work with TinyMCE keep it in contention, as Visual Editor is overly much in many contexts, and underdocumented.


Whit

DuncanCrane (talkcontribs)

Thanks Whit, I should be able to get this working as it was before. If you check back I will post my progress here.

DuncanCrane (talkcontribs)

Hi Whit As I suspected an earlier edit I had made had caused this problem :-( I've submitted some changes that should fix the problem so, should you wish to try TinyMCE at some time again, it should now work as you might expect. The changes are waiting review before they are merged to the master branch but if you (or anyone else for that matter) need to see what the changes are you can get a patch at https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/TinyMCE/+/569318/ Many thanks Duncan