Page MenuHomePhabricator

Media selector doesn't find local media in private wiki
Closed, ResolvedPublic

Description

The media selector (both in WikiEditor and Visual Editor) does not find local images in a private wiki. When the same wiki is set to public, it works.

I've tried this with 3 different installations (1.22 and 1.23wmf20) on two different servers, both with Visual Editor and WikiEditor.

The relevant setting is

$wgGroupPermissions['*']['read'] = false;

When this is set to false, when a user (logged in and registered) edits a page and starts typing the name of an existing file in the media selector, the input box remains empty and does not suggest existing file names.

When the read permission is set to true, then it works as expected (giving a list of suggestions in the input box) - but of course then the wiki is no longer private.

On the other hand, the link selector finds the files when I type "File:Filename..". Also, the image is actually shown in the article when I insert it with Wiki markup, or when I type in the correct filename in the selector and click on "insert".

So somehow the media selector (but not the link selector) does not understand the permission correctly for a logged-in user.


Version: unspecified
Severity: normal

Details

Reference
bz63282

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:58 AM
bzimport added a project: WikiEditor.
bzimport set Reference to bz63282.
bzimport added a subscriber: Unknown Object (MLST).

Maybe private only wikis cause api to be disabled.

(In reply to Bawolff (Brian Wolff) from comment #1)

Maybe private only wikis cause api to be disabled.

API is not disabled completely. All other API calls seem to work, only image search is affected.

The following workaround in LocalSettings.php also works:

if ( strpos($_SERVER['REQUEST_URI'], "prop=imageinfo") > 0 ) {

$wgGroupPermissions['*']['read'] = true;

}

This disables read protection selectively for the image search.

(In reply to Stephan Matthiesen from comment #2)

(In reply to Bawolff (Brian Wolff) from comment #1)

Maybe private only wikis cause api to be disabled.

API is not disabled completely. All other API calls seem to work, only image
search is affected.

The following workaround in LocalSettings.php also works:

if ( strpos($_SERVER['REQUEST_URI'], "prop=imageinfo") > 0 ) {

$wgGroupPermissions['*']['read'] = true;

}

This disables read protection selectively for the image search.

Actually that can be exploited to get around read protection everywhere (including normal web requests). Any url can have that string in it.

(In reply to Bawolff (Brian Wolff) from comment #3)

Actually that can be exploited to get around read protection everywhere
(including normal web requests). Any url can have that string in it.

Of course, and I don't recommend it. It was just meant as an indication that it's a bug in this specific api call for image searches and that other api calls are ok, so it's not a disabled api.

gabriel_stelmach wrote:

Hello there,

I just face this issue in my installation. There are any news about solution for this?

In time. Thank you Stephan for the workaround.

[]s

In 1.25wmf8, it works now correctly without the (unsecure) workaround. I guess some other things with permissions were fixed which solved this one as a side effect too.

I still have the same problem in version 1.25wmf17 (rMWd70b7512acb9)
e.g. typing "l" shows only two images, adding an "e" shows only one, other(!) image.
In order to find a file, I have to enter the complete name, including the extension :-(
Even worse, some files cannot be found at all. They can only be inserted using the text-editor.
I cannot find the file "At_venice.jpg". The file appears as "At_venice.jpg" in the images-directory, but as "At venice" on the wiki-page describing the image.
Anyway, I can't find the file Koala.jpg either, no spaces or underscores there :-( (but a capital letter...)

Still the same issues as described earlier: I can find the file "test_lego.jpg" by typing "test", but not by typing "lego".

It's getting better: I upload a file as "jorun.jpg" but cannot find it, unless by typing the complete name. I upload the same file as "jorun test.jpg". I can find this photo by typing 'jorun'.

Still looks like a bug to me!

I've got the same problem (on a private wiki).

I've tryed the permission fix. Still no effect on the first glance.

However, If i type "*" or the complete name (including the namespace), it finds my image, if I type the only the name (or a part of the name) nothing appears.

This seems to be an issue with the MediaWiki API. It's search algorithm is so strict, that you already need to know the exact name in order to get a result.

Appending / prepending an astericks helps, though. Maybe VE should do that by default?

VisualEditor-REL1_25
MediaWiki 1.25.1
PHP 5.5.9-1ubuntu4.9 (apache2handler)

This comment was removed by Fannon.

Presumably some permission is missing. Can you post the exact API requests and responses?

Yes, this is the API request that fails to find the image:

api.php?callback=jQuery1113038504008506424725_1437475882811&action=query&format=json&iiurlheight=200&generator=search&gsrnamespace=6&continue=&iiprop=dimensions%7Curl%7Cmediatype%7Cextmetadata%7Ctimestamp&prop=imageinfo&gsrsearch=Server&iiurlwidth=300&gsroffset=0&gsrlimit=30

It results in:

/**/jQuery1113038504008506424725_1437475882811({"batchcomplete":""})

If I add an astericks at the end of the search-term, it works:

api.php?callback=jQuery1113038504008506424725_1437475882811&action=query&format=json&iiurlheight=200&generator=search&gsrnamespace=6&continue=&iiprop=dimensions%7Curl%7Cmediatype%7Cextmetadata%7Ctimestamp&prop=imageinfo&gsrsearch=Server*&iiurlwidth=300&gsroffset=0&gsrlimit=30

Results in:

/**/
jQuery1113038504008506424725_1437475882811({
    "continue": {
        "iistart": "2015-06-23T05:30:36Z",
        "continue": "||"
    },
    "query": {
        "pages": {
            "6672": {
                "pageid": 6672,
                "ns": 6,
                "title": "Datei:Server\u00dcbersicht.png",
                "index": 1,
                "imagerepository": "local",
                "imageinfo": [{
                    "timestamp": "2015-06-23T05:31:57Z",
                    "size": 188839,
                    "width": 3000,
                    "height": 1606,
                   ....
                    "mediatype": "BITMAP"
                }]
            }
        }
    }
})

When using the astericks, the VE request works, but is repeated endlessly:

2015-07-21 12 58 20.png (229×1 px, 61 KB)

I could not reproduce the error on officewiki (a private wiki which is about a week behind master). Both your examples return a readapidenied error (which is a bug on its own right, reported as T106425). The VE media selector works fine, with or without an asterisk.

You could try to reproduce the bug in a controlled environment by using MediaWiki-Vagrant with the private and visualeditor roles.