Skip to content

Commit

Permalink
Merge pull request #36 from HydraWiki/201
Browse files Browse the repository at this point in the history
2.0.1
  • Loading branch information
Alexia committed Apr 4, 2016
2 parents 92381e7 + a21a6ee commit 323bb14
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 49 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
This changelog only shows recent version history, because of the lack of documentation from the former maintainers. The very first changelog (1.0.2) is likely incomplete.

## Version 2
### 2.0.1
* New offset parameter in oredictsearch for continuation (#34).
* oredictsearch no longer sorts by entry ID as the key; it is now an array of hashes.
* oredictentry and oredictsearch now return the entry ID with the rest of the data.
* Fix oredictsearch registration in the entry point (not the extension.json)
* Improve oredictsearch API query.
* Fix oredictsearch limit issues (#35).
* Fix oredictsearch
* Clean up database things and improve security.

### 2.0.0
* Fix OreDict entry shuffling and page loading issues related to that.
* Database sanitization issues that could later turn into security holes.
Expand Down
1 change: 1 addition & 0 deletions OreDict.body.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ static public function getArrayFromRow($row) {
'item_name' => $row->item_name,
'grid_params' => $row->grid_params,
'flags' => $row->flags,
'id' => $row->entry_id
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions OreDict.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @file
* @ingroup Extensions
* @version 2.0.0
* @version 2.0.1
* @author Jinbobo <[email protected]>
* @license
*/
Expand All @@ -18,7 +18,7 @@
'path' => __FILE__,
'name' => 'OreDict',
'descriptionmsg' => 'oredict-desc',
'version' => '2.0.0',
'version' => '2.0.1',
'author' => '[http://ftb.gamepedia.com/User:Jinbobo Jinbobo], Telshin, [http://ftb.gamepedia.com/User:Retep998 Retep998], [http://ftb.gamepedia.com/User:TheSatanicSanta SatanicSanta], noahm',
'url' => 'http://help.gamepedia.com/Extension:OreDict'
);
Expand All @@ -40,7 +40,7 @@
$wgAutoloadClasses['OreDictQueryEntryApi'] = __DIR__ . '/api/OreDictQueryEntryApi.php';
$wgAPIPropModules['oredictentry'] = 'OreDictQueryEntryApi';
$wgAutoloadClasses['OreDictQuerySearchApi'] = __DIR__ . '/api/OreDictQuerySearchApi.php';
$wgApiListClasses['oredictsearch'] = 'OreDictQuerySearchApi';
$wgAPIListModules['oredictsearch'] = 'OreDictQuerySearchApi';

$wgAutoloadClasses['OreDict'] = dirname(__FILE__)."/OreDict.body.php";
$wgAutoloadClasses['OreDictItem'] = dirname(__FILE__)."/OreDict.body.php";
Expand Down
85 changes: 40 additions & 45 deletions api/OreDictQuerySearchApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public function getAllowedParams() {
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_DFLT => '',
),
'offset' => array(
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_DFLT => 0,
ApiBase::PARAM_MIN => 0,
)
);
}

Expand All @@ -40,6 +45,7 @@ public function getParamDescription() {
'mod' => 'Restricts results to this mod',
'tag' => 'Restricts results to this tag name',
'name' => 'Restricts results to this item name',
'offset' => 'The query offset, like a continue param.'
);
}

Expand All @@ -60,63 +66,52 @@ public function execute() {
$mod = $this->getParameter('mod');
$name = $this->getParameter('name');
$limit = $this->getParameter('limit');
$offset = $this->getParameter('offset');
$dbr = wfGetDB(DB_SLAVE);

$resultPrefix = $dbr->select(
'ext_oredict_items',
'*',
array('item_name BETWEEN '.$dbr->addQuotes($prefix)." AND 'zzzzzzzz'"),
__METHOD__,
array('LIMIT' => $limit)
);
$resultTag = $dbr->select(
'ext_oredict_items',
'*',
array('tag_name' => $tag),
__METHOD__,
array('LIMIT' => $limit)
);
$resultMod = $dbr->select(
'ext_oredict_items',
'*',
array('mod_name' => $mod),
__METHOD__,
array('Limit' => $limit)
);
$resultName = $dbr->select(
$conditions = array();
if ($prefix != '') {
$conditions[] = 'item_name BETWEEN ' . $dbr->addQuotes($prefix) . " AND 'zzzzzzzzz'";
}
if ($tag != '') {
$conditions['tag_name'] = $tag;
}
if ($mod != '') {
$conditions['mod_name'] = $mod;
}
if ($name != '') {
$conditions['item_name'] = $name;
}

$results = $dbr->select(
'ext_oredict_items',
'*',
array('item_name' => $name),
__METHOD__,
array('LIMIT' => $limit)
$conditions,
__METHOD__
);

$ret = array();

if ($resultTag->numRows() > 0) {
foreach ($resultTag as $row) {
$ret[$row->entry_id] = OreDict::getArrayFromRow($row);
}
}

if ($resultMod->numRows() > 0) {
foreach ($resultMod as $row) {
$ret[$row->entry_id] = OreDict::getArrayFromRow($row);
$i = 0;
$more = $results->numRows() - $offset > $limit;
if ($results->numRows() > 0) {
foreach ($results as $row) {
if ($i < $offset) {
$i++;
continue;
}
if (count($ret) < $limit) {
$i++;
$ret[] = OreDict::getArrayFromRow($row);
}
}
}

if ($resultName->numRows() > 0) {
foreach ($resultName as $row) {
$ret[$row->entry_id] = OreDict::getArrayFromRow($row);
}
}

if ($resultPrefix->numRows() > 0) {
foreach ($resultPrefix as $row) {
$ret[$row->entry_id] = OreDict::getArrayFromRow($row);
}
if ($more) {
$this->getResult()->addValue('continue', 'offset', $i);
}

$this->getResult()->addValue('query', 'totalhits', $results->numRows());
$this->getResult()->addValue('query', 'oredictentries', $ret);
}
}
}
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "OreDict",
"version": "2.0.0",
"version": "2.0.1",
"author": "[http://ftb.gamepedia.com/User:Jinbobo Jinbobo], Telshin, [http://ftb.gamepedia.com/User:Retep998 Retep998], [http://ftb.gamepedia.com/User:TheSatanicSanta Eli Foster], noahm, applehat",
"url": "http://help.gamepedia.com/Extension:OreDict",
"descriptionmsg": "oredict-desc",
Expand Down

0 comments on commit 323bb14

Please sign in to comment.