Fixed: Lua and other errors on Kannada Wikipedia Time templates

Problem statement 1:

“Lua error in Module:TimeAgo at line 60: attempt to perform arithmetic on a string value”

The above error was prominent across many Infobox templates used on Kannada wikipedia where the different of date of birth and the current date was supposed to show when did the person was born, or when the organization was started etc.

For example: Here is how I wanted to see the start date of Wikipedia

ಟೆಂಪ್ಲೇಟು Infobox website   ವಿಕಿಪೀಡಿಯ

Sample testcases for {{Template:Time_ago}} found here never showed a single value in the above format.

Problem statement 2:

I remember working with M.G Harish an another Kannada wikipedian and admin on a similar issue last year where the expressions used in templates were unable to parse the Kannada numerals and used to result in an another error given below:

Expression error: Unrecognized punctuation character “�”

Since 2013 I have been working on articles falling under “Category:Pages with script errors” and working on resolving them step by step. Finding missing templates, modules etc used to be a work around for many such issues. With the expression parse issue reported here on Phabricator I was sure that we needed to understand the modules and templates or atleast mediawiki internals to fix some of these errors effectively. While we got a response from the developers on resolving the expression related issue, I could successfully use the same information fixing the problem statement 1 I have reported above.

To get a clue on similar template usage, I linked the template page to interwiki and found that many Indian and other language wikis use the similar template with some variations. Nepali wiki had the exact same copy of the template {{Template:Time ago}} but with minimal errors. I started skimming through various interlinked modules and template pages to find that the module {{Module:Time ago}} had a small variation in the line 54 and line 60.


Line: 54

– local noError, inputTime = pcall( lang.formatDate, lang, ‘U’, args[1], true ) (kn:wiki)

+ local noError, inputTime = pcall( lang.formatDate, lang, ‘xnU’, args[1], true ) (ne:wiki)

Line: 60

– local timeDiff = lang:formatDate( ‘U’, nil, true ) – inputTime (kn:wiki)

+ local timeDiff = lang:formatDate( ‘xnU’, nil, true ) – inputTime (ne:wiki)

The lua error on the first line of this article also clearly says that the error is due to a string that is being passed to perform an arithmetic operation. I applied the small change on the module, previewed the testcases to see the magic of errors disappearing from the screen.

It would be great to get some hands on walk through on the templates, modules, lua and other technologies to ensure language wiki’s look neat and the people working around these technical issues are empowered.

Thanks Ravi for forcing me to post this issue on Wikimedia India Technical Desk. Its a good initiative. It revealed that Punjabi wiki also needed a solution for this and I could apply my findings almost immediately to resolve the problem. Satdeep gill – lets keep exchanging issues and solutions to enhance Indic wiki’s.

Fix: MediaWiki Internal error

We were (myself and hpn) hit by a strange error (atleast for us ;) ) while we started putting up sampada media wiki onboard from backup. Wiki didn’t load for which we were using MySQL InnoDB tables. Dumping some other old database backup also didn’t help.

Here is what we were greeted with on the browser:

MediaWiki internal error.
Original exception: exception ‘DBQueryError’ with message ‘A database error has occurred Query: SELECT value,exptime FROM `wiki_objectcache` WHERE keyname=’techfizn_wiki1-wiki_:messages-hash’ Function: MediaWikiBagOStuff::_doquery Error: 1146 Table ‘techfizn_wiki1.wiki_objectcache’ doesn’t exist (localhost) ‘ in /home/techfizn/public_html/projects/wiki/includes/Database.php:824 Stack trace:
0 /home/techfizn/public_html/projects/wiki/includes/Database.php(779): Database->reportQueryError(‘Table ‘techfizn…’, 1146, ‘SELECT value,ex…’, ‘MediaWikiBagOSt…’, false)
1 /home/techfizn/public_html/projects/wiki/includes/BagOStuff.php(405): Database->query(‘SELECT value,ex…’, ‘MediaWikiBagOSt…’)
2 /home/techfizn/public_html/projects/wiki/includes/BagOStuff.php(300): MediaWikiBagOStuff->_doquery(‘SELECT value,ex…’)
3 /home/techfizn/public_html/projects/wiki/includes/BagOStuff.php(234): SqlBagOStuff->_query(‘SELECT value,ex…’, ‘techfizn_wiki1-…’)
4 /home/techfizn/public_html/projects/wiki/includes/MessageCache.php(205): SqlBagOStuff->get(‘techfizn_wiki1-…’)
5 /home/techfizn/public_html/projects/wiki/includes/MessageCache.php(441): MessageCache->load()
6 /home/techfizn/public_html/projects/wiki/includes/GlobalFunctions.php(467): MessageCache->get(‘mainpage’, true, true)
7 /home/techfizn/public_html/projects/wiki/includes/GlobalFunctions.php(421): wfMsgGetKey(‘mainpage’, true, true, true)
8 /home/techfizn/public_html/projects/wiki/includes/GlobalFunctions.php(368): wfMsgReal(‘mainpage’, Array, true, true)
9 /home/techfizn/public_html/projects/wiki/includes/Title.php(268): wfMsgForContent(‘mainpage’)
10 /home/techfizn/public_html/projects/wiki/includes/Wiki.php(92): Title::newMainPage()
11 /home/techfizn/public_html/projects/wiki/index.php(58): MediaWiki->checkInitialQueries(NULL, ‘view’, Object(StubObject), Object(WebRequest), Object(StubContLang))
12 {main}
Exception caught inside exception handler: exception ‘DBUnexpectedError’ with message ‘Error in fetchObject(): Table ‘techfizn_wiki1.wiki_page’ doesn’t exist (localhost)’ in /home/techfizn/public_html/projects/wiki/includes/Database.php:953 Stack trace:
0 /home/techfizn/public_html/projects/wiki/includes/MessageCache.php(314): Database->fetchObject(false)
1 /home/techfizn/public_html/projects/wiki/includes/MessageCache.php(251): MessageCache->loadFromDB()
2 /home/techfizn/public_html/projects/wiki/includes/MessageCache.php(441): MessageCache->load()
3 /home/techfizn/public_html/projects/wiki/includes/GlobalFunctions.php(467): MessageCache->get(‘databaseerror’, true, false)
4 /home/techfizn/public_html/projects/wiki/includes/GlobalFunctions.php(421): wfMsgGetKey(‘databaseerror’, true, false, true)
5 /home/techfizn/public_html/projects/wiki/includes/Exception.php(23): wfMsgReal(‘databaseerror’, Array)
6 /home/techfizn/public_html/projects/wiki/includes/Database.php(276): MWException->msg(‘databaseerror’, ‘Database error’)
7 /home/techfizn/public_html/projects/wiki/includes/Exception.php(125): DBQueryError->getPageTitle()
8 /home/techfizn/public_html/projects/wiki/includes/Exception.php(88): MWException->htmlHeader()
9 /home/techfizn/public_html/projects/wiki/includes/Exception.php(111): MWException->reportHTML()
10 /home/techfizn/public_html/projects/wiki/includes/Exception.php(191): MWException->report()
11 /home/techfizn/public_html/projects/wiki/includes/Exception.php(225): wfReportException(Object(DBQueryError))
12 [internal function]: wfExceptionHandler(Object(DBQueryError))
13 {main}

Fix: InnoDB engine works with 3 files in mysql data folder. ib_logfile0 and ib_logfile1 for logs and for data storage it uses ibdata1.

-rw-rw—- 1 mysql mysql 5242880 Oct 27 21:52 ib_logfile0
-rw-rw—- 1 mysql mysql 5242880 Oct 27 21:52 ib_logfile1
-rw-rw—- 1 mysql mysql 44040192 Oct 27 21:52 ibdata1

To resolve the above issue we removed the log files and restarted the MySQL to get going quickly with our mediawiki installation. Hope this saves few hours for others facing the same problem.