Revert r34541 for the moment pending further review & discussion...
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 9 May 2008 23:52:04 +0000 (23:52 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 9 May 2008 23:52:04 +0000 (23:52 +0000)
There's some kind of crazy magic_quotes stuff in here which screams RED ALERT, something's weird going on! :)

includes/GlobalFunctions.php
includes/Title.php
skins/common/wikibits.js

index 0cd02fa..e84e82c 100644 (file)
@@ -983,40 +983,25 @@ function wfSetBit( &$dest, $bit, $state = true ) {
 }
 
 /**
- * This function takes one or two arrays, objects, or strings as input, and returns a CGI-style string, e.g.
+ * This function takes two arrays as input, and returns a CGI-style string, e.g.
  * "days=7&limit=100". Options in the first array override options in the second.
  * Options set to "" will not be output.
- * @depreciated
- */
-function wfArrayToCGI( $query1, $query2 = null ) {
-       if( is_null($query2) ) wfBuildQuery( $query1 );
-       else wfBuildQuery( $query2, $query1 );
-}
-/**
- * wfBuildQuery is a improved wrapper for http_build_query.
- * We support a defaults array which the query may be merged with. As well we also support
- * arrays, objects, and strings as input.
- */
-function wfBuildQuery( $query, $defaults = null ) {
-       if( !is_null($defaults) ) {
-               ## If either array is a string, then parse it and make sure to fix magic quotes.
-               foreach( array( 'query', 'defaults' ) as $var ) {
-                       if( is_string($$var) ) {
-                               $arr = array();
-                               parse_str($$var, &$arr);
-                               if( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
-                                       global $wgRequest;
-                                       $wgRequest->fix_magic_quotes( $arr );
-                               }
-                               $$var = $arr;
+ */
+function wfArrayToCGI( $array1, $array2 = NULL )
+{
+       if ( !is_null( $array2 ) ) {
+               $array1 = $array1 + $array2;
+       }
+
+       $cgi = '';
+       foreach ( $array1 as $key => $value ) {
+               if ( '' !== $value ) {
+                       if ( '' != $cgi ) {
+                               $cgi .= '&';
                        }
+                       $cgi .= urlencode( $key ) . '=' . urlencode( $value );
                }
-               # Merge, make sure they are arrays, not objects.
-               $query = ((array)$defaults) + ((array)$query);
        }
-       
-       # Note that we must specify & because the default is sometimes &amp;
-       $cgi = is_string($query) ? $query : http_build_query( $query, null, '&' );
        return $cgi;
 }
 
@@ -2352,8 +2337,13 @@ function wfFormatStackFrame($frame) {
  * Get a cache key
  */
 function wfMemcKey( /*... */ ) {
+       global $wgDBprefix, $wgDBname;
        $args = func_get_args();
-       $key = wfWikiID() . ':' . implode( ':', $args );
+       if ( $wgDBprefix ) {
+               $key = "$wgDBname-$wgDBprefix:" . implode( ':', $args );
+       } else {
+               $key = $wgDBname . ':' . implode( ':', $args );
+       }
        return $key;
 }
 
@@ -2362,7 +2352,11 @@ function wfMemcKey( /*... */ ) {
  */
 function wfForeignMemcKey( $db, $prefix /*, ... */ ) {
        $args = array_slice( func_get_args(), 2 );
-       wfForeignWikiID($db,$prefix) . ':' . implode( ':', $args );
+       if ( $prefix ) {
+               $key = "$db-$prefix:" . implode( ':', $args );
+       } else {
+               $key = $db . ':' . implode( ':', $args );
+       }
        return $key;
 }
 
@@ -2371,7 +2365,7 @@ function wfForeignMemcKey( $db, $prefix /*, ... */ ) {
  * This is used as a prefix in memcached keys
  */
 function wfWikiID() {
-       global $wgDBname, wgDBprefix;
+       global $wgDBprefix, $wgDBname;
        if ( $wgDBprefix ) {
                return "$wgDBname-$wgDBprefix";
        } else {
@@ -2379,22 +2373,6 @@ function wfWikiID() {
        }
 }
 
-/**
- * Get an ASCII string identifying a foreign wiki or shared db
- * This is used as a prefix in foreign memcached keys
- */
-function wfForeignWikiID( $db = null, $prefix = null ) {
-       global $wgSharedDB, $wgSharedPrefix, $wgDBname, $wgDBprefix;
-       if( !isset($db) ) $db = (isset($wgSharedDB) ? $wgSharedDB, $wgDBname);
-       if( !isset($prefix) ) $prefix = ($wgSharedPrefix ? $wgSharedPrefix, $wgDBprefix);
-       
-       if ( $prefix ) {
-               return "$db-$prefix";
-       } else {
-               return $db;
-       }
-}
-
 /**
  * Split a wiki ID into DB name and table prefix
  */
index b4978c9..9dc3b4e 100644 (file)
@@ -761,12 +761,10 @@ class Title {
         */
        public function getFullURL( $query = '', $variant = false ) {
                global $wgContLang, $wgServer, $wgRequest;
-               
-               $query = wfBuildQuery( $query ); # Support query input other than strings.
-               
+
                if ( '' == $this->mInterwiki ) {
                        $url = $this->getLocalUrl( $query, $variant );
-                       
+
                        // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc)
                        // Correct fix would be to move the prepending elsewhere.
                        if ($wgRequest->getVal('action') != 'render') {
@@ -774,7 +772,7 @@ class Title {
                        }
                } else {
                        $baseUrl = $this->getInterwikiLink( $this->mInterwiki );
-                       
+
                        $namespace = wfUrlencode( $this->getNsText() );
                        if ( '' != $namespace ) {
                                # Can this actually happen? Interwikis shouldn't be parsed.
@@ -803,16 +801,14 @@ class Title {
        public function getLocalURL( $query = '', $variant = false ) {
                global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
                global $wgVariantArticlePath, $wgContLang, $wgUser;
-               
-               $query = wfBuildQuery( $query ); # Support query input other than strings.
-               
+
                // internal links should point to same variant as current page (only anonymous users)
                if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){
                        $pref = $wgContLang->getPreferredVariant(false);
                        if($pref != $wgContLang->getCode())
                                $variant = $pref;
                }
-               
+
                if ( $this->isExternal() ) {
                        $url = $this->getFullURL();
                        if ( $query ) {
@@ -848,7 +844,7 @@ class Title {
                                                $query = $matches[1];
                                                if( isset( $matches[4] ) ) $query .= $matches[4];
                                                $url = str_replace( '$1', $dbkey, $wgActionPaths[$action] );
-                                               $url = wfAppendQuery( $url, $query );
+                                               if( $query != '' ) $url .= '?' . $query;
                                        }
                                }
                                if ( $url === false ) {
@@ -858,7 +854,7 @@ class Title {
                                        $url = "{$wgScript}?title={$dbkey}&{$query}";
                                }
                        }
-                       
+
                        // FIXME: this causes breakage in various places when we
                        // actually expected a local URL and end up with dupe prefixes.
                        if ($wgRequest->getVal('action') == 'render') {
index 839e624..812710b 100644 (file)
@@ -461,53 +461,6 @@ function akeytt( doId ) {
        }
 }
 
-function setupRightClickEdit() {
-       if (document.getElementsByTagName) {
-               var spans = document.getElementsByTagName('span');
-               for (var i = 0; i < spans.length; i++) {
-                       var el = spans[i];
-                       if(el.className == 'editsection') {
-                               addRightClickEditHandler(el);
-                       }
-               }
-       }
-}
-
-function addRightClickEditHandler(el) {
-       for (var i = 0; i < el.childNodes.length; i++) {
-               var link = el.childNodes[i];
-               if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') {
-                       var editHref = link.getAttribute('href');
-                       // find the enclosing (parent) header
-                       var prev = el.parentNode;
-                       if (prev && prev.nodeType == 1 &&
-                       prev.nodeName.match(/^[Hh][1-6]$/)) {
-                               prev.oncontextmenu = function(e) {
-                                       if (!e) { e = window.event; }
-                                       // e is now the event in all browsers
-                                       var targ;
-                                       if (e.target) { targ = e.target; }
-                                       else if (e.srcElement) { targ = e.srcElement; }
-                                       if (targ.nodeType == 3) { // defeat Safari bug
-                                               targ = targ.parentNode;
-                                       }
-                                       // targ is now the target element
-
-                                       // We don't want to deprive the noble reader of a context menu
-                                       // for the section edit link, do we?  (Might want to extend this
-                                       // to all <a>'s?)
-                                       if (targ.nodeName.toLowerCase() != 'a'
-                                       || targ.parentNode.className != 'editsection') {
-                                               document.location = editHref;
-                                               return false;
-                                       }
-                                       return true;
-                               };
-                       }
-               }
-       }
-}
-
 var checkboxes;
 var lastCheckbox;