linkeddata: Fix broken check in PageDataRequestHandler
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 27 Mar 2019 15:22:39 +0000 (16:22 +0100)
committerDaniel Kinzler <dkinzler@wikimedia.org>
Mon, 1 Apr 2019 11:26:48 +0000 (11:26 +0000)
commit3821a2b5b77109e187a666d04d7dd6787aea44dd
treebff0aaf0722e5e8e616e65f426813e356e7a2307
parent2e7b7eed40bad1b79ce2f7cfe77df2e2139a20ba
linkeddata: Fix broken check in PageDataRequestHandler

First I noticed a weird check that assumes that explode() would return
an integer. But it returns an array of strings. There is obviously a
count() missing.

Then I started simplifying the code:
* The count can only be 2 or 1, never anything else.
* If it is one, the first element in the array contains the original string.
* The empty string is already checked above and can never end down there.
* Finally I made the remaining `if ( … ) return true else return false` a
  straight `return …`.

Change-Id: I289144e64f449ee0875009aaa22e10a5c0eb2734
includes/linkeddata/PageDataRequestHandler.php
tests/phpunit/includes/linkeddata/PageDataRequestHandlerTest.php