/**
* Fetch a value from the given array or return $default if it's not set.
*
- * @param array &$arr
+ * @param array $arr
* @param string $name
* @param mixed $default
* @return mixed
* @private
*/
- function getGPCVal( &$arr, $name, $default ) {
+ function getGPCVal( $arr, $name, $default ) {
if( isset( $arr[$name] ) ) {
- global $wgServer, $wgContLang;
+ global $wgContLang;
$data = $arr[$name];
if( isset( $_GET[$name] ) && !is_array( $data ) ) {
# Check for alternate/legacy character encoding.
* @return int
*/
function getInt( $name, $default = 0 ) {
- return IntVal( $this->getVal( $name, $default ) );
+ return intval( $this->getVal( $name, $default ) );
}
/**
function getIntOrNull( $name ) {
$val = $this->getVal( $name );
return is_numeric( $val )
- ? IntVal( $val )
+ ? intval( $val )
: null;
}
* @return string
*/
function getRequestURL() {
- return $_SERVER['REQUEST_URI'];
+ $base = $_SERVER['REQUEST_URI'];
+ if( $base{0} == '/' ) {
+ return $base;
+ } else {
+ // We may get paths with a host prepended; strip it.
+ return preg_replace( '!^[^:]+://[^/]+/!', '/', $base );
+ }
}
/**
return $_FILES[$key]['size'];
}
+ /**
+ * Return the upload error or 0
+ * @param string $key
+ * @return integer
+ */
+ function getUploadError( $key ) {
+ if( !isset( $_FILES[$key] ) || !isset( $_FILES[$key]['error'] ) ) {
+ return 0/*UPLOAD_ERR_OK*/;
+ }
+ return $_FILES[$key]['error'];
+ }
+
/**
* Return the original filename of the uploaded file, as reported by
* the submitting user agent. HTML-style character entities are