r82208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82207‎ | r82208 | r82209 >
Date:02:40, 16 February 2011
Author:tstarling
Status:ok
Tags:
Comment:
* Suppress warning from php_format_date() per CR r82112.
* Log server hostname
* Added php_standard.h and removed some redundant headers.
* Updated changelog and extension version ready for packaging
Modified paths:
  • /trunk/php/wmerrors/debian/changelog (modified) (history)
  • /trunk/php/wmerrors/wmerrors.c (modified) (history)

Diff [purge]

Index: trunk/php/wmerrors/wmerrors.c
@@ -5,15 +5,11 @@
66
77 #include "php.h"
88 #include "php_ini.h"
9 -#include "ext/standard/info.h"
109 #include "php_wmerrors.h"
11 -#include "php_streams.h" /* for __php_stream_call_depth */
 10+#include "ext/standard/php_standard.h"
1211 #include "SAPI.h" /* for sapi_module */
13 -#include "ext/standard/file.h" /* for file_globals aka. FG() */
1412 #include "ext/date/php_date.h" /* for php_format_date */
1513 #include "ext/standard/php_smart_str.h" /* for smart_str */
16 -#include "ext/standard/php_string.h" /* for php_basename() */
17 -#include "ext/standard/html.h" /* for php_escape_html_entities */
1814 #include "Zend/zend_builtin_functions.h" /* for zend_fetch_debug_backtrace */
1915
2016 static void wmerrors_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
@@ -41,7 +37,7 @@
4238 PHP_RSHUTDOWN(wmerrors),
4339 PHP_MINFO(wmerrors),
4440 #if ZEND_MODULE_API_NO >= 20010901
45 - "1.1.1",
 41+ "1.1.2",
4642 #endif
4743 STANDARD_MODULE_PROPERTIES
4844 };
@@ -250,6 +246,7 @@
251247 char *error_time_str;
252248 va_list my_args;
253249 php_stream *logfile_stream;
 250+ int old_error_reporting;
254251
255252 if ( !WMERRORS_G(enabled) ) {
256253 /* Redundant with the caller */
@@ -275,8 +272,13 @@
276273 tmp1_len = vspprintf(&tmp1, 0, format, my_args);
277274 va_end(my_args);
278275
 276+ /* Get a date string (without warning messages) */
 277+ old_error_reporting = EG(error_reporting);
 278+ EG(error_reporting) = 0;
 279+ error_time_str = php_format_date("d-M-Y H:i:s", 11, time(NULL), 1 TSRMLS_CC);
 280+ EG(error_reporting) = old_error_reporting;
 281+
279282 /* Log the error */
280 - error_time_str = php_format_date("d-M-Y H:i:s", 11, time(NULL), 1 TSRMLS_CC);
281283 php_stream_printf(logfile_stream TSRMLS_CC, "[%s] %s: %.*s at %s on line %u%s",
282284 error_time_str, wmerrors_error_type_to_string(type), tmp1_len, tmp1, error_filename,
283285 error_lineno, PHP_EOL);
@@ -343,9 +345,16 @@
344346 HashTable * server_ht;
345347 zval **info;
346348 smart_str s = {NULL};
 349+ char *hostname;
347350
348351 server_ht = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
349352
 353+ /* Server */
 354+ hostname = php_get_uname('n');
 355+ smart_str_appends(&s, "Server: ");
 356+ smart_str_appends(&s, hostname);
 357+ smart_str_appends(&s, PHP_EOL);
 358+
350359 /* Method */
351360 if (SG(request_info).request_method) {
352361 smart_str_appends(&s, "Method: ");
Index: trunk/php/wmerrors/debian/changelog
@@ -1,3 +1,11 @@
 2+php5-wmerrors (1.1.2-1) lucid; urgency=low
 3+
 4+ * Fixed incorrect usage of ALLOC_ZVAL()
 5+ * Fixed timezone warning
 6+ * Added logging of server hostname
 7+
 8+ -- Tim Starling <tstarling@wikimedia.org> Wed, 16 Feb 2011 10:57:19 +1100
 9+
210 php5-wmerrors (1.1.1-1) lucid; urgency=low
311
412 * Fixed missing line break at end of backtrace

Follow-up revisions

RevisionCommit summaryAuthorDate
r82227Follow up r82208. Fix leak.platonides08:50, 16 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82112* Use debug_print_backtrace() to make the backtrace, instead of print_r(). Th...tstarling12:21, 14 February 2011

Status & tagging log