Last modified: 2013-07-04 08:43:00 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T48615, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46615 - updateCollation.php should sanity check the collation before proceeding
updateCollation.php should sanity check the collation before proceeding
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Categories (Other open bugs)
1.22.0
All All
: Low minor (vote)
: ---
Assigned To: Bartosz Dziewoński
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-27 20:15 UTC by Bartosz Dziewoński
Modified: 2013-07-04 08:43 UTC (History)
8 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Bartosz Dziewoński 2013-03-27 20:15:24 UTC
updateCollation.php should sanity check the collation before proceeding.

This could prevent some silly mistakes like the one seen on bug 46005 comment 4.
Comment 1 Bartosz Dziewoński 2013-03-27 20:17:43 UTC
I5be1b1ec.
Comment 2 Bartosz Dziewoński 2013-03-27 20:22:14 UTC
Basically, updateCollation didn't actually check if chosen collation is supported by both the underlying ICU library and MediaWiki's list of first-letters for this language, and so processed all the pages without complaining; the error was only revealed when actually browsing the wiki.
Comment 3 Bawolff (Brian Wolff) 2013-04-04 01:24:34 UTC
I merged the change.
Comment 4 Platonides 2013-04-04 12:01:07 UTC
That change then breaks at update.php:

Updating category collations...PHP Fatal error:  Call to undefined method UppercaseCollation::getFirstLetterData() in mediawiki/core/maintenance/updateCollation.php on line 87

UppercaseCollation extends Collation, but getFirstLetterData() is provided by IcuCollation, so UppercaseCollation doesn't have such method.

It may be better to break at update instead of when browsing the category page but it shouldn't fail at all.
Comment 5 Bawolff (Brian Wolff) 2013-04-04 12:30:08 UTC
Whoops that method isnt in the base class and i had only tested on uca collations. I submitted a revert for now (can I +2 a revert if its reverting code I +2'd in the first place)
Comment 6 Bawolff (Brian Wolff) 2013-04-04 12:36:18 UTC
That's gerrit change Ib7b9597ff842a76185ba5c153922834ffb741237 for reference
Comment 7 Platonides 2013-04-04 12:54:16 UTC
Maybe we should wrap it in an if instanceof IcuCollation instead of reverting?
Comment 8 Bawolff (Brian Wolff) 2013-04-04 16:31:35 UTC
The revert was meant as a temporary measure.

In this case maybe the constructor should be changed to throw an exception. MatmaRex had previously tried to do that, at the time I didnt think it was a good idea, but now I thimk it makes more sense.
Comment 9 Bartosz Dziewoński 2013-04-04 17:24:39 UTC
Ughhhh. Sorry for the fail.

Throwing in the constructor will require us to either:
* keep a hard-coded list of allowed collations (bad, see bug 44667
  and bug 46058)
* duplicate the loading logic to check if all will be OK without
  loading (bad for obvious reasons)
* or just actually load the data in it, which seems sane, but I assume
  we're not doing for a reason.

Tim wrote the code - can you explain? I suppose loading all the data
would be slow, but it's not like we're instantiating Collations left
and right.
Comment 10 Platonides 2013-04-04 17:56:48 UTC
What about changing $collation->getFirstLetterData(); to $collation->getFirstLetter(); ?
On a IcuCollation, it will call getFirstLetterCount() which will load getFirstLetterData(), but it's a member of Collation class, to it should work everywhere.

The other IcuCollation members should probably be changed to protected, to prevent future issues like this.
Comment 11 Gerrit Notification Bot 2013-05-15 22:40:39 UTC
https://gerrit.wikimedia.org/r/57500 (Gerrit Change Ib7b9597ff842a76185ba5c153922834ffb741237) | change APPROVED and MERGED [by Tim Starling]
Comment 12 Tim Starling 2013-05-15 22:55:38 UTC
(In reply to comment #5)
>(can I +2 a revert if its reverting code I +2'd in the first place)

Yes. I would have preferred it if you had done that instead of leaving the maintenance script horribly broken for 6 weeks.

(In reply to comment #9)
> Tim wrote the code - can you explain? I suppose loading all the data
> would be slow, but it's not like we're instantiating Collations left
> and right.

In the code I wrote, only uca-default was allowed, and I imagined that there would be one class per additional locale, so the developer would be required to check if the relevant locale actually worked before adding a class. You were the one who added the ability to use any ICU locale, in I838484b9.

Why not call getFirstLetter() from updateCollation.php and see if that throws an exception?
Comment 13 Bartosz Dziewoński 2013-05-18 19:51:32 UTC
> (In reply to comment #9)
> > Tim wrote the code - can you explain? I suppose loading all the data
> > would be slow, but it's not like we're instantiating Collations left
> > and right.
> 
> In the code I wrote, only uca-default was allowed, and I imagined that there
> would be one class per additional locale, so the developer would be required
> to
> check if the relevant locale actually worked before adding a class. You were
> the one who added the ability to use any ICU locale, in I838484b9.

This doesn't answer my question about why we are not loading the first-letter data in IcuCollation's consturctor, but only lazy-loading it using getFirstLetterData().


> Why not call getFirstLetter() from updateCollation.php and see if that throws
> an exception?

I77de040f.
Comment 14 Gerrit Notification Bot 2013-05-18 19:51:59 UTC
Related URL: https://gerrit.wikimedia.org/r/64503 (Gerrit Change I77de040f97080653fe0d1734d38490eaa2d322db)
Comment 15 Gerrit Notification Bot 2013-07-04 05:26:20 UTC
Change 64503 merged by jenkins-bot:
updateCollation.php: sanity check the collation before proceeding

https://gerrit.wikimedia.org/r/64503

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links