Fix: Added a bool parameter to Lang::line() to bypass error logging #1832

Closed
wants to merge 3 commits into
from

Projects

None yet

2 participants

ziyun commented Sep 27, 2012

Bug: Unit_test.php bloats the error_log when calling report(). Incorrect keys are sent to the Lang class causing many errors to be logged.

@ziyun ziyun Fix: Added a bool parameter to Lang::line() to bypass error logging
Bug: Unit_test.php bloats the error_log when calling report().
Incorrect keys are sent to the Lang class causing many errors to be
logged.
63a07c3
@narfbg narfbg commented on an outdated diff Sep 27, 2012
system/core/Lang.php
@@ -149,14 +149,15 @@ public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE
* Fetch a single line of text from the language array
*
* @param string $line the language line
+ * @param bool $log bypass error logging
narfbg
narfbg Sep 27, 2012 Contributor

Indentation looks weird here, use tabs instead of spaces.

Contributor
narfbg commented Sep 27, 2012

... now to the real question - should this really be included in the Language class if the errors are actually caused by Unit_test?

ziyun commented Sep 27, 2012

To be honest I'm not really sure, and you raise a very valid point.

It's messy because both the row header and value needs to be checked for language translations.

Maybe another solution would be to skip calls to Lang::line() for the key values:
test_name, file, line, notes

This way no modifications will have to be made to the Language class.

Contributor
narfbg commented Oct 5, 2012

From what I see in the current code - language strings for those keys do exist. Can you show those error logs?

Edit: Referencing #188

ziyun commented Oct 8, 2012

Yes, you are correct. There are language strings for the keys I listed above, but not for the values they correspond to in the report.

For example, there is a language string for the key "line" which in this case is "ut_line", but there is no key for "ut_18" (line 18). The error log below illustrates this:

DEBUG - 2012-09-26 04:05:07 --> Config Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Hooks Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Utf8 Class Initialized
DEBUG - 2012-09-26 04:05:07 --> UTF-8 Support Enabled
DEBUG - 2012-09-26 04:05:07 --> URI Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Router Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Output Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Security Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Input Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Global POST and COOKIE data sanitized
DEBUG - 2012-09-26 04:05:07 --> Language Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Loader Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Database Driver Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Session Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Helper loaded: string_helper
DEBUG - 2012-09-26 04:05:07 --> Encrypt Class Initialized
DEBUG - 2012-09-26 04:05:07 --> A session cookie was not found.
DEBUG - 2012-09-26 04:05:07 --> Session routines successfully run
DEBUG - 2012-09-26 04:05:07 --> Controller Class Initialized
DEBUG - 2012-09-26 04:05:07 --> Unit Testing Class Initialized
ERROR - 2012-09-26 04:05:07 --> Severity: Notice --> Undefined variable: expected_result /var/www/html/application/controllers/unit_testing.php 18
DEBUG - 2012-09-26 04:05:07 --> Language file loaded: language/english/unit_test_lang.php
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_message to json"
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_/var/www/html/application/controllers/unit_testing.php"
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_18"
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_"
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_message to json"
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_/var/www/html/application/controllers/unit_testing.php"
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_18"
ERROR - 2012-09-26 04:05:07 --> Could not find the language line "ut_"
DEBUG - 2012-09-26 04:05:07 --> Final output sent to browser
DEBUG - 2012-09-26 04:05:07 --> Total execution time: 0.0435

Contributor
narfbg commented Nov 1, 2012

You know what ... that might actually be useful. Could you pull in latest changes from the repository and add a changelog entry?

@narfbg narfbg added a commit that referenced this pull request Nov 22, 2012
@narfbg narfbg Fix issue #118 (manually implementing PR #1832) ce0c956
Contributor
narfbg commented Nov 22, 2012

@ziyun Manually applied your changes, thanks for submitting them. See the above commit.

@narfbg narfbg closed this Nov 22, 2012
@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this pull request Jun 29, 2013
@narfbg narfbg Fix issue #118 (manually implementing PR #1832) 497835b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment