Index: branches/REL1_14/phase3/includes/api/ApiMove.php |
— | — | @@ -95,8 +95,9 @@ |
96 | 96 | // We're not gonna dieUsage() on failure, since we already changed something |
97 | 97 | else |
98 | 98 | { |
99 | | - $r['talkmove-error-code'] = ApiBase::$messageMap[reset($retval)]['code']; |
100 | | - $r['talkmove-error-info'] = ApiBase::$messageMap[reset($retval)]['info']; |
| 99 | + $parsed = $this->parseMsg(reset($retval)); |
| 100 | + $r['talkmove-error-code'] = $parsed['code']; |
| 101 | + $r['talkmove-error-info'] = $parsed['info']; |
101 | 102 | } |
102 | 103 | } |
103 | 104 | |
Index: branches/REL1_14/phase3/includes/api/ApiBase.php |
— | — | @@ -743,14 +743,28 @@ |
744 | 744 | |
745 | 745 | /** |
746 | 746 | * Output the error message related to a certain array |
747 | | - * @param array $error Element of a getUserPermissionsErrors() |
| 747 | + * @param array $error Element of a getUserPermissionsErrors()-style array |
748 | 748 | */ |
749 | 749 | public function dieUsageMsg($error) { |
| 750 | + $parsed = $this->parseMsg($error); |
| 751 | + $this->dieUsage($parsed['code'], $parsed['info']); |
| 752 | + } |
| 753 | + |
| 754 | + /** |
| 755 | + * Return the error message related to a certain array |
| 756 | + * @param array $error Element of a getUserPermissionsErrors()-style array |
| 757 | + * @return array('code' => code, 'info' => info) |
| 758 | + */ |
| 759 | + public function parseMsg($error) { |
750 | 760 | $key = array_shift($error); |
751 | 761 | if(isset(self::$messageMap[$key])) |
752 | | - $this->dieUsage(wfMsgReplaceArgs(self::$messageMap[$key]['info'], $error), wfMsgReplaceArgs(self::$messageMap[$key]['code'], $error)); |
| 762 | + return array( 'code' => |
| 763 | + wfMsgReplaceArgs(self::$messageMap[$key]['code'], $error), |
| 764 | + 'info' => |
| 765 | + wfMsgReplaceArgs(self::$messageMap[$key]['info'], $error) |
| 766 | + ); |
753 | 767 | // If the key isn't present, throw an "unknown error" |
754 | | - $this->dieUsageMsg(array('unknownerror', $key)); |
| 768 | + return $this->parseMsg(array('unknownerror', $key)); |
755 | 769 | } |
756 | 770 | |
757 | 771 | /** |