Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 13f67d7
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aa3539a
Choose a head ref
  • 4 commits
  • 249 files changed
  • 1 contributor

Commits on Feb 25, 2012

  1. Replace PHP UTF-8 library with PHP's mbstring extension

    For MantisBT 1.2.x, the PHP UTF-8 library at [1] was selected to provide
    proper Unicode support to MantisBT. This library wraps around PHP's
    mbstring extension and provides an alternative implemented-in-PHP
    approach where the mbstring extension is not available on a server
    running MantisBT. mbstring is a PHP extension that is not bundled with
    PHP by default. Linux distributions already package the extension and it
    is trivial to install. The extension is also bundled with the Windows
    .zip distribution of PHP for Windows users and is also trivial to
    install.
    
    The need to support platform configurations where mbstring isn't
    available and can't be installed stems from the days when shared hosting
    was popular. With the popularisation of virtualisation (virtual private
    servers) as a cheap replacement to shared hosting, administrators once
    again have control over their own platform, allowing them to install PHP
    extensions whenever they please. Popular Linux distributions have been
    packaging and making the mbstring PHP extension available for a long
    time. Installation on Windows platforms is also trivial (relative to the
    complexity of Windows platforms due to a lack of software package
    management functionality).
    
    Removal of the PHP UTF-8 wrapper simplifies MantisBT's code base and
    likely improves performance (no need to wrap function calls and compile
    and load an entire UTF-8 library into memory). More importantly,
    MantisBT no longer depends on a small library that hasn't seen updates
    since 2007. Reliance on mbstring is a less risky option because it is
    more widely used and ties in with PHP's official infrastructure and
    support/documentation system.
    
    MantisBT's documentation has been updated and expanded to reflect the
    new installation requirement. Links to external documentation on php.net
    have also been provided to guide new users in performing the simple
    action of adding the mbstring extension.
    
    [1] http://sourceforge.net/projects/phputf8/
    davidhicks committed Feb 25, 2012
    Copy the full SHA
    1b11094 View commit details
  2. Copy the full SHA
    5ea8ba4 View commit details
  3. Add new Locale i18n/l10n API to replace lang_api

    This is some initial work towards replacing lang_api with a new Locale
    API that makes use of PHP's gettext support for translation.
    
    gettext offers the following advantages:
    a) Greater performance
    b) Better supporting tools for translation work
    c) Import/export support at MediaWiki.net that doesn't require
    MantisBT-specific hacks
    d) Pluralisation (1 thing vs 1 things)
    e) en-US language is embedded in the source code and acts as a key --
    this makes the source code easier to read and sections of code easier to
    find upon searching for UI strings
    f) Easy plugin support via loading of new text domains
    g) Ability to perform more specific translations (en-US, en-GB,
    en-AU...) rather than "one English fits all"
    h) Support for context aware translations
    
    There is lot of negativity in the wild regarding gettext and PHP.
    Typical arguments include:
    
    1. Lack of thread safety - this is no longer an issue with php-fpm (or
    earlier Fast CGI methods) because each script will execute in a separate
    process. Threaded execution of PHP under mod_php (Apache) or an IIS
    equivalent is thoroughly deprecated and not recommended for numerous
    reasons.
    
    2. gettext is difficult to install with PHP - Linux distributions of PHP
    will most likely have gettext enabled by default. If not, packages are
    readily available in all the major distribution repositories. Windows
    users are given php_gettext.dll in the .zip distribution of PHP and
    simple instructions at [1] can be followed to get things up and running
    quickly.
    
    3. The gettext API is "inconsistent" or doesn't support xyz - it's
    trivial to create a new wrapper function around these APIs that allows
    us to implement enhanced functionality or make the API easier to use.
    
    Don't be tricked by the outdated negativity from the early 2000's.
    gettext is an "industry standard" and is not going away any time soon.
    
    [1] http://php.net/manual/en/install.windows.extensions.php
    davidhicks committed Feb 25, 2012
    Copy the full SHA
    9f7894b View commit details
  4. Remove ERROR_ constants and ERROR_STRINGS[...] translations

    The new Locale API (using gettext) and the new Exception approach to
    error handling in MantisBT means that ERROR_ constants are now
    unnecessary.
    
    All exceptions have been updated to use gettext for translating error
    strings. Because many of the error messages have been rewritten in the
    process, translations have been dropped. It is expected that we'll need
    to recommence translating MantisBT from scratch after the new Locale API
    is fully implemented. Why?
    
    1. We need to support pluralisation.
    2. We need to factor in the context of strings that need translating.
    3. Many old error messages/strings are confusing and desperately in need
    of updating.
    4. A move towards modern web standards compliant HTML will greatly
    increase the number of strings needing translation: alt and title
    attributes on images and hyperlinks being just one example.
    5. Huge chunks of MantisBT are likely going to be rewritten or
    redesigned, dramatically changing the strings/error messages that need
    to be translated.
    
    As part of this change error codes have also been removed from MantisBT
    exceptions. These codes do not add any value because exception class
    names already provide unique identification (that is superior than just
    a random number).
    
    Exception constructors are also heavily simplified -- now containing
    just a single argument for the error message.
    
    MantisBT\Error has also been cleaned up further in preparation for
    removal/replacement with a modern exception handler/displayer. We no
    longer have an error_handler: all errors are converted to exceptions of
    type ErrorException and handled by exception_handler. This removes a lot
    of duplication and complexity.
    davidhicks committed Feb 25, 2012
    Copy the full SHA
    aa3539a View commit details
Showing with 594 additions and 8,765 deletions.
  1. +1 −0 application/MantisBT/Database/DriverAbstract.php
  2. +9 −142 application/MantisBT/Error.php
  3. +2 −4 application/MantisBT/Exception/Access/AccessDenied.php
  4. +2 −4 application/MantisBT/Exception/Access/IssueHandlerAccessDenied.php
  5. +2 −5 application/MantisBT/Exception/Access/RelationshipDestinationIssueAccessDenied.php
  6. +2 −4 application/MantisBT/Exception/Access/SponsorshipAssignerAccessDenied.php
  7. +2 −4 application/MantisBT/Exception/Access/SponsorshipHandlerAccessDenied.php
  8. +2 −4 application/MantisBT/Exception/Attachment/AttachmentDuplicate.php
  9. +2 −4 application/MantisBT/Exception/Attachment/AttachmentFileTypeDisallowed.php
  10. +2 −4 application/MantisBT/Exception/Attachment/AttachmentMoveFailed.php
  11. +2 −4 application/MantisBT/Exception/Attachment/AttachmentNotReadable.php
  12. +2 −4 application/MantisBT/Exception/Attachment/AttachmentOversized.php
  13. +2 −4 application/MantisBT/Exception/Attachment/AttachmentsPathInvalid.php
  14. +2 −4 application/MantisBT/Exception/Attachment/EmptyAttachment.php
  15. +2 −4 application/MantisBT/Exception/Attachment/FTPConnectionFailed.php
  16. +2 −4 application/MantisBT/Exception/Authentication/LostPasswordBlankEmail.php
  17. +2 −4 application/MantisBT/Exception/Authentication/LostPasswordConfirmationHashInvalid.php
  18. +2 −4 application/MantisBT/Exception/Authentication/LostPasswordDisabled.php
  19. +2 −4 application/MantisBT/Exception/Authentication/LostPasswordInvalidAccount.php
  20. +2 −4 application/MantisBT/Exception/Authentication/LostPasswordMaximumAttemptsExceeded.php
  21. +2 −4 application/MantisBT/Exception/Authentication/SignupConfirmationHashInvalid.php
  22. +2 −5 application/MantisBT/Exception/Column/ColumnDuplicate.php
  23. +2 −5 application/MantisBT/Exception/Column/ColumnInvalid.php
  24. +2 −5 application/MantisBT/Exception/Configuration/ConfigurationOptionCannotBeSpecifiedInDatabase.php
  25. +2 −5 application/MantisBT/Exception/Configuration/ConfigurationOptionInvalidValue.php
  26. +2 −5 application/MantisBT/Exception/Configuration/ConfigurationOptionNotFound.php
  27. +2 −4 application/MantisBT/Exception/CustomField/CustomFieldInvalidDefinition.php
  28. +2 −5 application/MantisBT/Exception/CustomField/CustomFieldInvalidValue.php
  29. +2 −5 application/MantisBT/Exception/CustomField/CustomFieldNameNotUnique.php
  30. +2 −5 application/MantisBT/Exception/CustomField/CustomFieldNotFound.php
  31. +2 −5 application/MantisBT/Exception/CustomField/CustomFieldNotLinkedToProject.php
  32. +2 −5 application/MantisBT/Exception/Database/ColumnNotFound.php
  33. +2 −5 application/MantisBT/Exception/Database/ConnectionFailed.php
  34. +2 −7 application/MantisBT/Exception/Database/DatabaseTypeNotSupported.php
  35. +4 −7 application/MantisBT/Exception/Database/ParameterCountMismatch.php
  36. +2 −5 application/MantisBT/Exception/Database/QueryFailed.php
  37. +2 −4 application/MantisBT/Exception/Email/DisposableEmailAddressDisallowed.php
  38. +2 −5 application/MantisBT/Exception/Email/EmailAddressInvalid.php
  39. +3 −15 application/MantisBT/Exception/ExceptionAbstract.php
  40. +2 −5 application/MantisBT/Exception/Field/EmptyField.php
  41. +2 −4 application/MantisBT/Exception/Field/InvalidDateFormat.php
  42. +2 −5 application/MantisBT/Exception/Filter/FilterNotFound.php
  43. +2 −4 application/MantisBT/Exception/Filter/FilterTooOldToUpgrade.php
  44. +2 −5 application/MantisBT/Exception/GPC/ArrayExpected.php
  45. +2 −5 application/MantisBT/Exception/GPC/ArrayUnexpected.php
  46. +2 −5 application/MantisBT/Exception/GPC/NumberExpected.php
  47. +2 −4 application/MantisBT/Exception/HTTP/PageRedirectionFailed.php
  48. +2 −4 application/MantisBT/Exception/Issue/Category/CategoryDuplicate.php
  49. +2 −4 application/MantisBT/Exception/Issue/Category/CategoryNotFound.php
  50. +2 −5 application/MantisBT/Exception/Issue/Category/CategoryNotFoundForProject.php
  51. +2 −5 application/MantisBT/Exception/Issue/Comment/CommentNotFound.php
  52. +2 −5 application/MantisBT/Exception/Issue/DependantIssuesNotResolved.php
  53. +2 −4 application/MantisBT/Exception/Issue/IssueDuplicateSelf.php
  54. +2 −5 application/MantisBT/Exception/Issue/IssueNotFound.php
  55. +2 −5 application/MantisBT/Exception/Issue/IssueReadOnly.php
  56. +2 −4 application/MantisBT/Exception/Issue/NewHandlerDisallowed.php
  57. +2 −4 application/MantisBT/Exception/Issue/Relationship/RelationshipDuplicate.php
  58. +2 −4 application/MantisBT/Exception/Issue/Relationship/RelationshipLoopbackDisallowed.php
  59. +2 −4 application/MantisBT/Exception/Issue/Relationship/RelationshipNotFound.php
  60. +2 −5 application/MantisBT/Exception/Issue/Revision/RevisionNotFound.php
  61. +2 −4 application/MantisBT/Exception/Issue/Tag/TagAlreadyAttached.php
  62. +2 −4 application/MantisBT/Exception/Issue/Tag/TagNotAttached.php
  63. +2 −4 application/MantisBT/Exception/Issue/Version/VersionDuplicate.php
  64. +2 −5 application/MantisBT/Exception/Issue/Version/VersionNotFound.php
  65. +2 −4 application/MantisBT/Exception/LDAP/AuthenticationFailed.php
  66. +2 −4 application/MantisBT/Exception/LDAP/ExtensionNotLoaded.php
  67. +2 −4 application/MantisBT/Exception/LDAP/ServerConnectFailed.php
  68. +2 −5 application/MantisBT/Exception/Language/LanguageStringNotFound.php
  69. +12 −0 application/MantisBT/Exception/Locale/LocaleNotProvidedByUserAgent.php
  70. +13 −0 application/MantisBT/Exception/Locale/LocalesNotSupported.php
  71. +2 −5 application/MantisBT/Exception/News/NewsItemNotFound.php
  72. +2 −5 application/MantisBT/Exception/Plugin/EventUndeclared.php
  73. +2 −5 application/MantisBT/Exception/Plugin/InstallationFailed.php
  74. +2 −5 application/MantisBT/Exception/Plugin/PluginAlreadyInstalled.php
  75. +2 −5 application/MantisBT/Exception/Plugin/PluginNotRegistered.php
  76. +2 −5 application/MantisBT/Exception/Plugin/PluginPageNotFound.php
  77. +2 −5 application/MantisBT/Exception/Plugin/UpgradeFailed.php
  78. +2 −5 application/MantisBT/Exception/Project/ProjectNameInvalid.php
  79. +2 −5 application/MantisBT/Exception/Project/ProjectNameNotUnique.php
  80. +2 −5 application/MantisBT/Exception/Project/ProjectNotFound.php
  81. +3 −5 application/MantisBT/Exception/Project/RecursiveHierarchyDisallowed.php
  82. +2 −4 application/MantisBT/Exception/Security/CSPRNGNotAvailable.php
  83. +2 −4 application/MantisBT/Exception/Security/CSRFTokenInvalid.php
  84. +2 −4 application/MantisBT/Exception/Security/MasterSaltInvalid.php
  85. +2 −4 application/MantisBT/Exception/Session/SessionHandlerInvalid.php
  86. +2 −4 application/MantisBT/Exception/Session/SessionInvalid.php
  87. +2 −5 application/MantisBT/Exception/Session/SessionVariableNotFound.php
  88. +2 −5 application/MantisBT/Exception/Sponsorship/SponsorshipAmountTooLow.php
  89. +2 −4 application/MantisBT/Exception/Sponsorship/SponsorshipDisabled.php
  90. +2 −5 application/MantisBT/Exception/Sponsorship/SponsorshipNotFound.php
  91. +2 −5 application/MantisBT/Exception/Tag/TagNameInvalid.php
  92. +2 −5 application/MantisBT/Exception/Tag/TagNameNotUnique.php
  93. +2 −5 application/MantisBT/Exception/Tag/TagNotFound.php
  94. +2 −4 application/MantisBT/Exception/TimeZone/TimeZoneUpdateFailed.php
  95. +2 −5 application/MantisBT/Exception/Token/TokenNotFound.php
  96. +2 −4 application/MantisBT/Exception/Twitter/cURLMissing.php
  97. +2 −4 application/MantisBT/Exception/UnspecifiedException.php
  98. +2 −4 application/MantisBT/Exception/User/CannotModifyProtectedAccount.php
  99. +2 −4 application/MantisBT/Exception/User/LastAdministratorProtected.php
  100. +2 −5 application/MantisBT/Exception/User/UserByIDNotFound.php
  101. +2 −5 application/MantisBT/Exception/User/UserByNameNotFound.php
  102. +2 −5 application/MantisBT/Exception/User/UserNameInvalid.php
  103. +2 −5 application/MantisBT/Exception/User/UserNameNotUnique.php
  104. +2 −4 application/MantisBT/Exception/User/UserPasswordMismatch.php
  105. +2 −4 application/MantisBT/Exception/User/UserPreferencesNotFound.php
  106. +2 −4 application/MantisBT/Exception/User/UserProfileNotFound.php
  107. +6 −5 application/MantisBT/Exception/User/UserRealNameMatchesExistingUserName.php
  108. +115 −0 application/MantisBT/Locale/LocaleManager.php
  109. +51 −0 application/MantisBT/Locale/locale_support_functions.php
  110. +1 −3 application/configs/config_defaults_inc.php
  111. +3 −4 application/core/authentication_api.php
  112. +1 −1 application/core/bug_api.php
  113. +1 −1 application/core/bugnote_api.php
  114. +4 −4 application/core/cfdefs/cfdef_standard.php
  115. +8 −8 application/core/columns_api.php
  116. +1 −1 application/core/config_api.php
  117. +0 −158 application/core/constant_inc.php
  118. +3 −3 application/core/custom_field_api.php
  119. +2 −2 application/core/custom_function_api.php
  120. +7 −7 application/core/database_api.php
  121. +2 −2 application/core/date_api.php
  122. +4 −4 application/core/email_api.php
  123. +2 −2 application/core/file_api.php
  124. +9 −9 application/core/filter_api.php
  125. +2 −2 application/core/form_api.php
  126. +1 −1 application/core/gpc_api.php
  127. +1 −1 application/core/html_api.php
  128. +2 −2 application/core/http_api.php
  129. +1 −1 application/core/install_helper_functions_api.php
  130. +1 −1 application/core/lang_api.php
  131. +1 −1 application/core/php_api.php
  132. +2 −2 application/core/plugin_api.php
  133. +4 −4 application/core/print_api.php
  134. +1 −1 application/core/project_api.php
  135. +5 −5 application/core/relationship_api.php
  136. +1 −1 application/core/session_api.php
  137. +6 −6 application/core/string_api.php
  138. +2 −2 application/core/tag_api.php
  139. +5 −5 application/core/user_api.php
  140. +1 −1 application/core/version_api.php
  141. +1 −1 application/core/xmlhttprequest_api.php
  142. +2 −4 application/services/soap/mc_api.php
  143. +1 −3 docbook/Admin_Guide/en-US/Configuration.xml
  144. +25 −17 docbook/Admin_Guide/en-US/Installation.xml
  145. +0 −38 languages/strings_afrikaans.txt
  146. +0 −4 languages/strings_amharic.txt
  147. +0 −95 languages/strings_arabic.txt
  148. +0 −95 languages/strings_arabicegyptianspoken.txt
  149. +0 −95 languages/strings_breton.txt
  150. +0 −73 languages/strings_bulgarian.txt
  151. +0 −95 languages/strings_catalan.txt
  152. +0 −71 languages/strings_chinese_simplified.txt
  153. +0 −70 languages/strings_chinese_traditional.txt
  154. +0 −3 languages/strings_croatian.txt
  155. +0 −95 languages/strings_czech.txt
  156. +0 −62 languages/strings_danish.txt
  157. +0 −97 languages/strings_dutch.txt
  158. +0 −103 languages/strings_english.txt
  159. +0 −95 languages/strings_estonian.txt
  160. +0 −95 languages/strings_finnish.txt
  161. +0 −97 languages/strings_french.txt
  162. +0 −97 languages/strings_galician.txt
  163. +0 −97 languages/strings_german.txt
  164. +0 −16 languages/strings_greek.txt
  165. +0 −92 languages/strings_hebrew.txt
  166. +0 −95 languages/strings_hungarian.txt
  167. +0 −61 languages/strings_icelandic.txt
  168. +0 −86 languages/strings_italian.txt
  169. +0 −95 languages/strings_japanese.txt
  170. +0 −66 languages/strings_korean.txt
  171. +0 −10 languages/strings_latvian.txt
  172. +0 −84 languages/strings_lithuanian.txt
  173. +0 −97 languages/strings_macedonian.txt
  174. +0 −97 languages/strings_norwegian_bokmal.txt
  175. +0 −2 languages/strings_norwegian_nynorsk.txt
  176. +0 −95 languages/strings_occitan.txt
  177. +0 −95 languages/strings_polish.txt
  178. +0 −95 languages/strings_portuguese_brazil.txt
  179. +0 −71 languages/strings_portuguese_standard.txt
  180. +0 −58 languages/strings_ripoarisch.txt
  181. +0 −73 languages/strings_romanian.txt
  182. +0 −97 languages/strings_russian.txt
  183. +0 −54 languages/strings_serbian.txt
  184. +0 −95 languages/strings_slovak.txt
  185. +0 −52 languages/strings_slovene.txt
  186. +0 −95 languages/strings_spanish.txt
  187. +0 −95 languages/strings_swedish.txt
  188. +0 −97 languages/strings_swissgerman.txt
  189. +0 −93 languages/strings_tagalog.txt
  190. +0 −3 languages/strings_turkish.txt
  191. +0 −61 languages/strings_ukrainian.txt
  192. +0 −69 languages/strings_urdu.txt
  193. +0 −44 languages/strings_volapuk.txt
  194. +0 −837 library/utf8/ChangeLog
  195. +0 −504 library/utf8/LICENSE
  196. +0 −82 library/utf8/README
  197. +0 −14 library/utf8/TODO.tsk
  198. +0 −37 library/utf8/exp/regexunicode.php
  199. 0 library/utf8/index.html
  200. +0 −140 library/utf8/mbstring/core.php
  201. +0 −438 library/utf8/native/core.php
  202. +0 −92 library/utf8/ord.php
  203. +0 −15 library/utf8/readme_mantis.txt
  204. +0 −80 library/utf8/str_ireplace.php
  205. +0 −57 library/utf8/str_pad.php
  206. +0 −35 library/utf8/str_split.php
  207. +0 −26 library/utf8/strcasecmp.php
  208. +0 −41 library/utf8/strcspn.php
  209. +0 −36 library/utf8/stristr.php
  210. +0 −22 library/utf8/strrev.php
  211. +0 −36 library/utf8/strspn.php
  212. +0 −24 library/utf8/substr_replace.php
  213. +0 −68 library/utf8/trim.php
  214. +0 −34 library/utf8/ucfirst.php
  215. +0 −44 library/utf8/ucwords.php
  216. +0 −74 library/utf8/utf8.php
  217. +0 −220 library/utf8/utils/ascii.php
  218. +0 −421 library/utf8/utils/bad.php
  219. +0 −69 library/utf8/utils/patterns.php
  220. +0 −173 library/utf8/utils/position.php
  221. +0 −131 library/utf8/utils/specials.php
  222. +0 −269 library/utf8/utils/unicode.php
  223. +0 −185 library/utf8/utils/validation.php
  224. +2 −4 public/admin/check/check_api.php
  225. +2 −2 public/browser_search_plugin.php
  226. +1 −1 public/bug_actiongroup_ext_page.php
  227. +1 −1 public/bug_actiongroup_page.php
  228. +1 −1 public/bugnote_view_inc.php
  229. +1 −1 public/changelog_page.php
  230. +33 −7 public/core.php
  231. +1 −1 public/csv_export.php
  232. +1 −1 public/file_download.php
  233. +1 −1 public/issues_rss.php
  234. +1 −1 public/make_captcha_img.php
  235. +1 −1 public/manage_proj_cat_update.php
  236. +3 −3 public/manage_proj_edit_page.php
  237. +1 −1 public/manage_tags_page.php
  238. +1 −1 public/manage_user_page.php
  239. +1 −1 public/news_rss.php
  240. +1 −1 public/plugins/MantisGraph/pages/bug_graph_bystatus.php
  241. +1 −4 public/print_all_bug_options_reset.php
  242. +2 −5 public/print_all_bug_options_update.php
  243. +1 −1 public/print_all_bug_page_word.php
  244. +1 −1 public/print_bugnote_inc.php
  245. +3 −3 public/return_dynamic_filters.php
  246. +1 −1 public/roadmap_page.php
  247. +1 −1 public/search.php
  248. +1 −1 public/signup.php
  249. +2 −4 public/view_user_page.php
1 change: 1 addition & 0 deletions application/MantisBT/Database/DriverAbstract.php
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
namespace MantisBT\Database;

use MantisBT\Database\PDO\MySQL\MySQLDriver;
use MantisBT\Exception\Database\DatabaseTypeNotSupported;
use MantisBT\Exception\Database\ParameterCountMismatch;
use MantisBT\Exception\Database\QueryFailed;
use MantisBT\Exception\UnspecifiedException;
151 changes: 9 additions & 142 deletions application/MantisBT/Error.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php
namespace MantisBT;
use \stdClass;

require_api('lang_api.php');
use \ErrorException;

class Error {
/**
@@ -12,7 +11,6 @@ class Error {

/**
* Indicates if an error/exception has been handled
* Note: this also indicates additional shutdown functions have been setup.
*/
private static $handled = false;

@@ -51,7 +49,7 @@ public static function exception_handler($exception) {
$errorInfo->type = 'EXCEPTION';
$errorInfo->name = 'InvalidException';
$errorInfo->code = 0;
$errorInfo->message = 'An invalid exception type was caught by the exception handler. Unfortuantly no further information can be obtained.';
$errorInfo->message = _('An invalid exception type was caught by the exception handler. Unfortuantly no further information can be obtained.');

if (is_object($exception)) {
$reflectionClass = new \ReflectionClass($exception);
@@ -62,78 +60,15 @@ public static function exception_handler($exception) {
$errorInfo->file = $exception->getFile();
$errorInfo->line = $exception->getLine();
$errorInfo->trace = $exception->getTrace();
$errorInfo->context = $exception->getContext();
}
}

self::init();
self::$allErrors[] = $errorInfo;
}

public static function error_handler( $type, $error, $file, $line, $context ) {
$errorInfo = new stdClass();
$errorInfo->time = time();
$errorInfo->type = 'ERROR';
$errorInfo->name = isset( self::$errorConstants[$type] ) ? self::$errorConstants[$type] : 'UNKNOWN';
$errorInfo->code = $type;
$errorInfo->message = is_numeric( $error ) ? self::error_string( $error ) : $error;
$errorInfo->file = $file;
$errorInfo->line = $line;
$errorInfo->context = $context;
$errorInfo->trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);

self::$allErrors[] = $errorInfo;

if( 0 == error_reporting() ) {
return false;
}

// historically we inline warnings
if( $type != E_WARNING && $type != E_USER_WARNING ) {
self::init();
}

if( $type == E_WARNING || $type == E_USER_WARNING ) {

switch( $type ) {
case E_WARNING:
$errorType = 'SYSTEM WARNING';
$errorDescription = $error;
break;
case E_USER_WARNING:
$errorType = "APPLICATION WARNING #$error";
$errorDescription = self::error_string( $error );
break;
}
$errorDescription = nl2br( $errorDescription );
echo '<p style="color:red">', $errorType, ': ', $errorDescription, '</p>';

return true; // @todo true|false??
}

exit();
}

public static function shutdown_error_handler() {
$error = error_get_last();
if( $error === null ) {
return;
}

self::init();

$errorInfo = new stdClass();
$errorInfo->time = time();
$errorInfo->type = 'ERROR_LAST';
$errorInfo->name = isset( self::$errorConstants[$error['type']] ) ? self::$errorConstants[$error['type']] : 'UNKNOWN';
$errorInfo->code = $error['type'];
$errorInfo->message = $error['message'];
$errorInfo->file = $error['file'];
$errorInfo->line = $error['line'];
$errorInfo->trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
$errorInfo->context = null;

self::$allErrors[] = $errorInfo;
public static function exception_error_handler( $errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

public static function display_errors( $noHeader = false ) {
@@ -164,7 +99,7 @@ public static function display_errors( $noHeader = false ) {
echo '<hr />';

echo '<div align="center">';
echo lang_get( 'error_no_proceed' );
echo _('Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.');
echo '<br />';

foreach ( self::$allErrors as $key => $errorInfo ) {
@@ -194,7 +129,7 @@ public static function display_error( $error) {
echo '<tr><td class="form-title">' . $error->name . '</td></tr>';
echo '<tr><td><p class="center" style="color:red">' . nl2br( $error->message ) . '</p></td></tr>';
echo '<tr><td>';
self::error_print_details( basename( $error->file ), $error->line, $error->context );
self::error_print_details( basename( $error->file ), $error->line );
echo '</td></tr>';
if ( !config_get( 'show_friendly_errors' ) ) {
echo '<tr><td>';
@@ -205,13 +140,12 @@ public static function display_error( $error) {
}

/**
* Print out the error details including context
* Print out the error details
* @param string $file
* @param int $line
* @param string $context
* @return null
*/
public static function error_print_details( $file, $line, $context ) {
public static function error_print_details( $file, $line ) {
if ( !config_get( 'show_friendly_errors' ) ) {
?>
<table class="width75">
@@ -221,11 +155,6 @@ public static function error_print_details( $file, $line, $context ) {
<tr>
<td>Line: <?php echo $line?></td>
</tr>
<tr>
<td>
<?php self::error_print_context( $context )?>
</td>
</tr>
</table>
<?php
} else {
@@ -243,47 +172,7 @@ public static function error_print_details( $file, $line, $context ) {
}
}

/**
* Print out the variable context given
* @param string $context
* @return null
*/
public static function error_print_context( $context ) {
if( !is_array( $context ) && !is_object( $context )) {
return;
}

echo '<table class="width100"><tr><th>Variable</th><th>Value</th><th>Type</th></tr>';

# print normal variables
foreach( $context as $var => $val ) {
if( !is_array( $val ) && !is_object( $val ) ) {
$type = gettype( $val );
$val = htmlentities( (string) $val, ENT_COMPAT, 'UTF-8' );

# Mask Passwords
if( strpos( $var, 'pass' ) !== false ) {
$val = '**********';
}

echo '<tr><td>', $var, '</td><td>', $val, '</td><td>', $type, '</td></tr>', "\n";
}
}

# print arrays
foreach( $context as $var => $val ) {
if( is_array( $val ) && ( $var != 'GLOBALS' ) ) {
echo '<tr><td colspan="3"><br /><strong>', $var, '</strong></td></tr>';
echo '<tr><td colspan="3">';
self::error_print_context( $val );
echo '</td></tr>';
}
}

echo '</table>';
}

public static function error_print_stack_trace( $stack ) {
public static function error_print_stack_trace( $stack ) {
echo '<table class="width75">';
echo '<tr><th>Filename</th><th>Line</th><th></th><th></th><th>Function</th><th>Args</th></tr>';

@@ -345,28 +234,6 @@ public static function error_build_parameter_string( $param, $showType = true, $
}
}

/**
* Return an error string (in the current language) for the given error.
* @param int $error
* @return string
* @access public
*/
public static function error_string( $error ) {
# We pad the parameter array to make sure that we don't get errors if
# the caller didn't give enough parameters for the error string
$padding = array_pad( array(), 10, '' );

$error = lang_get( $error, null, false );

if( $error == '' ) {
return lang_get( 'missing_error_string' ) . $error;
}

# ripped from string_api
$string = call_user_func_array( 'sprintf', array_merge( array( $error ), self::$parameters, $padding ) );
return preg_replace( "/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", @htmlspecialchars( $string, ENT_COMPAT, 'UTF-8' ) );
}

public static function error_handled() {
return self::$handled;
}
6 changes: 2 additions & 4 deletions application/MantisBT/Exception/Access/AccessDenied.php
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Access;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class AccessDenied extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_ACCESS_DENIED, null, false);
parent::__construct( ERROR_ACCESS_DENIED, $errorMessage, null );
$errorMessage = _('Access Denied.');
parent::__construct($errorMessage);
$this->responseCode = 403;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Access;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class IssueHandlerAccessDenied extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_HANDLER_ACCESS_TOO_LOW, null, false);
parent::__construct(ERROR_HANDLER_ACCESS_TOO_LOW, $errorMessage, null);
$errorMessage = _('Issue handler does not have sufficient access rights to handle issue at this status.');
parent::__construct($errorMessage);
$this->responseCode = 400;
}
}
Original file line number Diff line number Diff line change
@@ -2,13 +2,10 @@
namespace MantisBT\Exception\Access;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class RelationshipDestinationIssueAccessDenied extends ExceptionAbstract {
public function __construct($destinationIssueID) {
$errorMessage = lang_get(ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, null, false);
$errorMessage = sprintf($errorMessage, $destinationIssueID);
parent::__construct(ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, $errorMessage, null);
$errorMessage = sprintf(_('Access denied: You do not have permission to modify relationships for destination issue %1$d.'), $destinationIssueID);
parent::__construct($errorMessage);
$this->responseCode = 403;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Access;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class SponsorshipAssignerAccessDenied extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, null, false);
parent::__construct(ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, $errorMessage, null);
$errorMessage = _('Access Denied: Assigning sponsored issues requires a higher access level.');
parent::__construct($errorMessage);
$this->responseCode = 403;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Access;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class SponsorshipHandlerAccessDenied extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, null, false);
parent::__construct(ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, $errorMessage, null);
$errorMessage = _('Handler does not have the required access level to handle sponsored issues.');
parent::__construct($errorMessage);
$this->responseCode = 400;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Attachment;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class AttachmentDuplicate extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_FILE_DUPLICATE, null, false);
parent::__construct(ERROR_FILE_DUPLICATE, $errorMessage, null);
$errorMessage = _('This is a duplicate file. Please delete the existing file first.');
parent::__construct($errorMessage);
$this->responseCode = 400;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Attachment;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class AttachmentFileTypeDisallowed extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_FILE_NOT_ALLOWED, null, false);
parent::__construct(ERROR_FILE_NOT_ALLOWED, $errorMessage, null);
$errorMessage = _('File type not allowed for uploads.');
parent::__construct($errorMessage);
$this->responseCode = 400;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Attachment;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class AttachmentMoveFailed extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_FILE_MOVE_FAILED, null, false);
parent::__construct(ERROR_FILE_MOVE_FAILED, $errorMessage, null);
$errorMessage = _('Uploaded file could not be moved to the file storage directory. Directory either does not exist or not writable to webserver.');
parent::__construct($errorMessage);
$this->responseCode = 500;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Attachment;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class AttachmentNotReadable extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_UPLOAD_FAILURE, null, false);
parent::__construct(ERROR_UPLOAD_FAILURE, $errorMessage, null);
$errorMessage = _('File upload failed. File is not readable by MantisBT. Please check the project settings.');
parent::__construct($errorMessage);
$this->responseCode = 500;
}
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,10 @@
namespace MantisBT\Exception\Attachment;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class AttachmentOversized extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_FILE_TOO_BIG, null, false);
parent::__construct( ERROR_FILE_TOO_BIG, $errorMessage, null );
$errorMessage = _('File upload failed. This is likely because the filesize was larger than is currently allowed by this PHP installation.');
parent::__construct($errorMessage);
$this->responseCode = 400;
}
}
Loading