Ruby gem mediawiki_api uses wrong path to index.php if wiki is in root
Open, LowPublic

Description

  • Install mediawiki in root directory
  • Try to use it via mediawiki_api ruby gem:
require 'mediawiki_api'
client = MediawikiApi::Client.new 'http://privatewiki/api.php'
client.log_in("Usr", "passwrd")
client.get_wikitext("Pagetitlee")

I don't know where this gem invents this subdirectory from. In program code line 2 I specify /api.php, so it should use /index.php and not /w/index.php

Full log/output:

C:\>irb
irb(main):001:0> require 'mediawiki_api'
=> true
irb(main):002:0> client = MediawikiApi::Client.new 'http://privatewiki/api.php'
=> #<MediawikiApi::Client:0x00000003108b20 @cookies=#<HTTP::CookieJar:0x00000003
108aa8 @store=#<HTTP::CookieJar::HashStore:0x000000030ec6c8 @mon_owner=nil, @mon
_count=0, @mon_mutex=#<Mutex:0x000000030d5ae0>, @logger=nil, @gc_threshold=150,
@jar={}, @gc_index=0>>, @conn=#<Faraday::Connection:0x000000030d5928 @parallel_m
anager=nil, @headers={"User-Agent"=>"Faraday v0.9.2"}, @params={}, @options=#<Fa
raday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_pa
rallel_manager=nil, @builder=#<Faraday::RackBuilder:0x000000030d5658 @handlers=[
Faraday::Request::Multipart, Faraday::Request::UrlEncoded, Faraday::CookieJar, F
araday::Adapter::NetHttp]>, @url_prefix=#<URI::HTTP:0x000000030ce970 URL:http://
privatewiki/api.php>, @proxy=nil>, @logged_in=false, @tokens={}>
irb(main):003:0> client.log_in("Usr", "passwrd")
=> {"result"=>"Success", "lguserid"=>42, "lgusername"=>"Usr", "lgtoken"=>"6a8ee9
99999999999999999999999999", "cookieprefix"=>"mypref", "sessionid"=>"52a04022e49
999999999999999999999"}	
irb(main):004:0> client.get_wikitext("Pagetitlee")
=> #<Faraday::Response:0x0000000313aeb8 @on_complete_callbacks=[], @env=#<Farada
y::Env @method=:get @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<!DOCTY
PE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n  \"http://www.w3.org/TR/
xhtml1/DTD/xhtml1-strict.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\"
lang=\"en\" xml:lang=\"en\">\r\n<head>\r\n<title>Object not found!</title>\r\n<l
ink rev=\"made\" href=\"mailto:postmaster@localhost\" />\r\n<style type=\"text/c
ss\"><!--/*--><![CDATA[/*><!--*/ \r\n    body { color: #000000; background-color
: #FFFFFF; }\r\n    a:link { color: #0000CC; }\r\n    p, address {margin-left: 3
em;}\r\n    span {font-size: smaller;}\r\n/*]]>*/--></style>\r\n</head>\r\n\r\n<
body>\r\n<h1>Object not found!</h1>\r\n<p>\r\n\r\n\r\n    The requested URL was
not found on this server.\r\n\r\n  \r\n\r\n    If you entered the URL manually p
lease check your\r\n    spelling and try again.\r\n\r\n  \r\n\r\n</p>\r\n<p>\r\n
If you think this is a server error, please contact\r\nthe <a href=\"mailto:post
master@localhost\">webmaster</a>.\r\n\r\n</p>\r\n\r\n<h2>Error 404</h2>\r\n<addr
ess>\r\n  <a href=\"/\">privatewiki</a><br />\r\n  <span>Apache/2.4.2 (Win32) Ope
nSSL/1.0.1c PHP/5.4.4</span>\r\n</address>\r\n</body>\r\n</html>\r\n\r\n" @url=#
<URI::HTTP:0x00000003162a08 URL:http://privatewiki/w/index.php?action=raw&title=P
agetitlee> @request=#<Faraday::RequestOptions (empty)> @request_headers={"User-A
gent"=>"Faraday v0.9.2"} @ssl=#<Faraday::SSLOptions (empty)> @response=#<Faraday
::Response:0x0000000313aeb8 ...> @response_headers={"date"=>"Thu, 19 May 2016 14
:59:13 GMT", "server"=>"Apache/2.4.2 (Win32) OpenSSL/1.0.1c PHP/5.4.4", "vary"=>
"accept-language,accept-charset", "accept-ranges"=>"bytes", "connection"=>"close
", "transfer-encoding"=>"chunked", "content-type"=>"text/html; charset=utf-8", "
content-language"=>"en"} @status=404>>

Versions:

C:\>ruby -v
ruby 2.0.0p645 (2015-04-13) [x64-mingw32]

C:\>gem list |grep mediawiki
mediawiki_api (0.5.0)
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 31 2016, 10:49 AM

Just realized that there is mediawiki_api 0.6.0. Installed that but behaviour is the same.

Aklapper triaged this task as Low priority.Jun 16 2016, 9:48 AM