MediaWiki API errors in FileAnnotations

I am working on FileAnnotations’ error handling. When I started writing the patch I wasn’t aware of all the cases we’ll have to tackle, Mark was nice enough to guide. Below is a list of errors that could occur and how to handle them.

AbuseFilter
AbuseFilter does not reject the mw.Api promise, but returns an object that has a warning.

{
  "edit": {
    "code": "abusefilter-disallowed",
    "message": {
      "key": "abusefilter-disallowed",
      "params": [
        "Test filter",
        2
      ]
    },
    "abusefilter": {
      "id": 2,
      "description": "Test filter",
      "actions": [
        "disallow"
      ]
    },
    "info": "Hit AbuseFilter: Test filter",
    "warning": "This action has been automatically identified as harmful, and therefore disallowed.\nIf you believe your action was constructive, please inform an administrator of what you were trying to do.\nA brief description of the abuse rule which your action matched is: Test filter",
    "result": "Failure"
  }
}

Use the abusefilter-disallowed message here.

No edit permission
This one rejects the promise and the function has the error code as a string and an object literal that has details. It has the same object again as the third argument, I wonder what that is about.

{
  "error": {
    "code": "permissiondenied",
    "info": "The \"permissiondenied\" right is required to edit this page",
    "*": "See http://localhost:8080/w/api.php for API usage"
  }
}

Should probably not show the add annotation interface if the user does not have permissions in the first place. In case we do, use the permissionserror message from core.

Session expired
Tested a few cases for this. If the user is logged out in the middle of adding an annotation they’d get a permissiondenied error. But if one logs out and logs into a different account in another tab, the new edit is correctly attributed to the newly logged in account.

Unreachable server
I found the api-error-http error message but haven’t been able to figure out how or when it triggers. Have filed a separate task for now.

Block
This rejects the promise with error messages too. Could show api-error-blocked here, but it doesn’t show some of the useful information that is returned.

{
  "error": {
    "code": "blocked",
    "info": "You have been blocked from editing",
    "blockinfo": {
      "blockid": 1,
      "blockedby": "Admin",
      "blockedbyid": 1,
      "blockreason": "",
      "blockedtimestamp": "2016-09-27T20:25:49Z",
      "blockexpiry": "2016-09-27T22:25:49Z"
    },
    "*": "See http://localhost:8080/w/api.php for API usage"
  }
}

Protected page
Should protecting a File page automatically protect the Annotations page too? This is the same as some of the other errors, and core already has a protectedpage message.

{
  "error": {
    "code": "protectedpage",
    "info": "The \"editprotected\" right is required to edit this page",
    "*": "See http://localhost:8080/w/api.php for API usage"
  }
}

Looking at all the api-error-* messages in core, these might show up too.

  • autoblock
  • badtoken
  • http (timeout error?)
  • timeout
  • unclassified

Here is the updated patch.

Rhythm of prime numbers

I had been reading about music theory on Wikipedia and was fascinated with the amount of mathematics involved in it. After going into the rabbit hole of the circle of fifths, the duodecimal number system, and this crazy clock face, I finally decided to go to bed. Having read so much (and understood so little), I started to wonder where prime numbers fit in.

As I understand rhythm better than harmony and melody, I decided to map the first few prime numbers to a beat. Since most prime numbers below fifty are either one more, or one less than a multiple of six, I knew it’ll lead to interesting results.

Rock

The rock beat has a hi-hat on every eighth note, and I am counting every eighth note for mapping the prime numbers. There is a snare and the bass drum on 1 and 3, and 2 and 4 respectively to make a basic rock beat, a clap for every prime number, and a cow bell for multiples of six.

The accentuation is on the 6th eighth note of the first bar, the 4th eighth note of the second bar and so on, because of prime numbers lying adjacent to multiples of six. I feel this gives the beat some swing.

Jazz

Because of Jazz’s triplet beat structure, it lends itself better to multiples of six. I counted every triplet to map the prime numbers. Its the most basic jazz beat with the low tom playing for prime numbers.

Both beats sound alright and not as random as prime numbers are, mostly because we stuck to those below fifty. If you want to count along with the beat, here are slowed down versions of both:

The band Tool is known to have used the Fibonacci sequence in Lateralus, I wonder if they or someone else used prime numbers too.

To dwell

There are but two choices —
To follow the heart,
Clockwork you never understood.
Or to follow the world,
Why dream, even if you could?
No bread playing Soul out on the streets,
No soul spending days balancing sheets.
Earn the bread first, the heart can wait,
Play Soul today, the bread will come late.
Follow the heart and the world cries,
Follow the world and the heart dies.
The heart is dead,
The world moved ahead.
But the decision is simple —
Where do you often dwell?
The world or the heart.
Where do you go for solace?
Your wallet or your art?

Reboot the World

It’s much easier to load my thoughts into someone else’s little box and hit “Submit” (perhaps the most well-chosen interface word of all time). But submission comes at a price. My personal information, my finances, my family connections, my ideas—all are now in the hands of those to whom I have submitted.

From Reboot the World by Paul Ford

Make Firefox fast

Recently, I have been trying to untangle myself from closed software, and move to open source and free (as in speech) alternatives. The first switch I made was from Chrome to Firefox. I was always a Firefox fan, but after college, when the only computer I had was a borrowed 8 year old MacBook Pro, I had no choice but to switch to Chrome for it’s speed.

Even though I have a fast computer now, I was a bit skeptical about Firefox’s performance. I use it often for testing and the speed did not compare favorably with Chrome. Upon a friend’s suggestion I installed the Developer Edition and was pleasantly surprised to see the improvement that Electrolysis brought! After a few days of using it, I decided to do some more research and stumbled upon a config that lets each tab run it’s own process. I set the process count limit to 128 and since then it has been smooth sailing.

These features exist in the normal versions of Firefox too, but are hidden behind config flags. To set them, go to about:config and set the following:


browser.tabs.remote.autostart true
dom.ipc.processCount 128

Restart, and see multiple browser processes (Activity Manager on Mac OS). Enjoy your new 128 Foxpower browser, yes foxes are better than horses.

Update: Based on when you’re reading this, you might need the Developer Edition or the Beta version of Firefox for this to work.

A man may be so much of everything that he is nothing of anything.

Samuel Johnson

Contentless RSS feeds

I’ve been using Feedly regularly now and am loving it. Being able to stay up to date with the websites I like without having to follow them on Twitter or Facebook has made me more of a follower than I was.

There are however certain feeds that make it hard for anyone to like them. The Dilbert Daily Strip for example, apart from its weekend comic, the feed only has the following content:

Dilbert readers – Please visit Dilbert.com to read this feature. Due to changes with our feeds, we are now making this RSS feed a link to Dilbert.com.

This is what shows up in my reader everyday. Thankfully, Feedly has an option to open the linked web page directly, which is what I have now done for this feed.

Why do publishers do this? To get more ad impressions? Are ads not allowed on feeds? I’d really love to know the reasons behind this strategy.