From: Brion Vibber Date: Sun, 9 Jan 2005 21:18:07 +0000 (+0000) Subject: * (bug 1201) Double-escaping in brokenlinks, imagelinks, categorylinks, searchindex X-Git-Tag: 1.5.0alpha1~974 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=ce980f78225daf2a9a7c4e90bd62c328043bfb54;p=lhc%2Fweb%2Fwiklou.git * (bug 1201) Double-escaping in brokenlinks, imagelinks, categorylinks, searchindex [forward port from REL1_4] --- diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 7384177a90..08fad8b473 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -70,13 +70,13 @@ class LinksUpdate { if ( 0 != count( $add ) ) { $arr=array(); foreach($add as $lt=>$lid) - array_push($arr,array( - 'l_from'=>$this->mId, - 'l_to'=>$lid)); + array_push( $arr, array( + 'l_from' => $this->mId, + 'l_to' => $lid ) ); # The link cache was constructed without FOR UPDATE, so there may be collisions # Ignoring for now, I'm not sure if that causes problems or not, but I'm fairly # sure it's better than without IGNORE - $dbw->insert('links', $arr, $fname, array('IGNORE')); + $dbw->insert( 'links', $arr, $fname, array( 'IGNORE' ) ); } #------------------------------------------------------------------------------ @@ -109,14 +109,13 @@ class LinksUpdate { # Do additions $sql = ''; if ( 0 != count ( $add ) ) { - $arr=array(); + $arr = array(); foreach( $add as $blt ) { - $blt = $dbw->strencode( $blt ); - array_push($arr,array( - 'bl_from'=>$this->mId, - 'bl_to'=>$blt)); + array_push( $arr, array( + 'bl_from' => $this->mId, + 'bl_to' => $blt ) ); } - $dbw->insert( 'brokenlinks',$arr,$fname,array('IGNORE')); + $dbw->insert( 'brokenlinks', $arr, $fname, array( 'IGNORE' ) ); } #------------------------------------------------------------------------------ @@ -136,10 +135,9 @@ class LinksUpdate { $nt = Title::makeTitle( $image, $iname ); if( !$nt ) continue; $nt->invalidateCache(); - $iname = $dbw->strencode( $iname ); - array_push($arr,array( - 'il_from'=>$this->mId, - 'il_to'=>$iname)); + array_push( $arr, array( + 'il_from' => $this->mId, + 'il_to' => $iname ) ); } $dbw->insert('imagelinks', $arr, $fname, array('IGNORE')); } @@ -156,17 +154,17 @@ class LinksUpdate { # Do the insertion $sql = ''; if ( 0 != count ( $add ) ) { - $arr=array(); + $arr = array(); foreach( $add as $cname => $sortkey ) { $nt = Title::makeTitle( NS_CATEGORY, $cname ); - if( !$nt ) continue; - $nt->invalidateCache(); - array_push($arr,array( - 'cl_from'=>$this->mId, - 'cl_to'=>$dbw->strencode( $cname ), - 'cl_sortkey'=>$dbw->strencode( $sortkey ))); + if( !$nt ) continue; + $nt->invalidateCache(); + array_push( $arr, array( + 'cl_from' => $this->mId, + 'cl_to' => $cname, + 'cl_sortkey' => $sortkey ) ); } - $dbw->insert('categorylinks',$arr,$fname,array('IGNORE')); + $dbw->insert( 'categorylinks', $arr, $fname, array( 'IGNORE' ) ); } } @@ -198,13 +196,13 @@ class LinksUpdate { $a = $wgLinkCache->getGoodLinks(); if ( 0 != count( $a ) ) { - $arr=array(); + $arr = array(); foreach( $a as $lt => $lid ) { - array_push($arr,array( - 'l_from'=>$this->mId, - 'l_to'=>$lid)); + array_push( $arr, array( + 'l_from' => $this->mId, + 'l_to' => $lid ) ); } - $dbw->insert('links',$arr,$fname,array('IGNORE')); + $dbw->insert( 'links', $arr, $fname, array( 'IGNORE' ) ); } $sql = "DELETE FROM $brokenlinks WHERE bl_from={$this->mId}"; @@ -212,14 +210,13 @@ class LinksUpdate { $a = $wgLinkCache->getBadLinks(); if ( 0 != count ( $a ) ) { - $arr=array(); + $arr = array(); foreach( $a as $blt ) { - $blt = $dbw->strencode( $blt ); array_push($arr,array( - 'bl_from'=>$this->mId, - 'bl_to'=>$blt)); + 'bl_from' => $this->mId, + 'bl_to' => $blt)); } - $dbw->insert('brokenlinks',$arr,$fname,array('IGNORE')); + $dbw->insert( 'brokenlinks', $arr, $fname, array( 'IGNORE' ) ); } $sql = "DELETE FROM $imagelinks WHERE il_from={$this->mId}"; @@ -228,12 +225,12 @@ class LinksUpdate { $a = $wgLinkCache->getImageLinks(); $sql = ''; if ( 0 != count ( $a ) ) { - $arr=array(); + $arr = array(); foreach( $a as $iname => $val ) - array_push($arr,array( - 'il_from'=>$this->mId, - 'il_to'=>$dbw->strencode( $iname ))); - $dbw->insert('imagelinks',$arr,$fname,array('IGNORE')); + array_push( $arr, array( + 'il_from' => $this->mId, + 'il_to' => $iname ) ); + $dbw->insert( 'imagelinks', $arr, $fname, array( 'IGNORE' ) ); } if( $wgUseCategoryMagic ) { @@ -246,18 +243,18 @@ class LinksUpdate { # Do the insertion $sql = ''; if ( 0 != count ( $add ) ) { - $arr=array(); + $arr = array(); foreach( $add as $cname => $sortkey ) { # FIXME: Change all this to avoid unnecessary duplication $nt = Title::makeTitle( NS_CATEGORY, $cname ); if( !$nt ) continue; $nt->invalidateCache(); - array_push($arr,array( - 'cl_from'=>$this->mId, - 'cl_to'=>$dbw->strencode( $cname ), - 'cl_sortkey'=>$dbw->strencode( $sortkey ))); + array_push( $arr, array( + 'cl_from' => $this->mId, + 'cl_to' => $cname, + 'cl_sortkey' => $sortkey ) ); } - $dbw->insert('categorylinks',$arr,$fname,array('IGNORE')); + $dbw->insert( 'categorylinks', $arr, $fname, array( 'IGNORE' ) ); } } $this->fixBrokenLinks(); @@ -286,14 +283,16 @@ class LinksUpdate { while ( $row = $dbw->fetchObject( $res ) ) { if ( ! $first ) { $sql2 .= ","; } $first = false; - array_push($arr,array('l_from'=>$row->bl_from,'l_to'=>$this->mId)); + array_push( $arr, array( + 'l_from' => $row->bl_from, + 'l_to' => $this->mId ) ); $sql2 .= $row->bl_from; } $sql2 .= ')'; # Ignore errors. If a link existed in both the brokenlinks table and the links # table, that's an error which can be fixed at this stage by simply ignoring collisions - $dbw->insert('links',$arr,$fname,array('IGNORE')); + $dbw->insert( 'links', $arr, $fname, array( 'IGNORE' ) ); $dbw->query( $sql2, $fname ); $dbw->delete( 'brokenlinks', array( 'bl_to' => $this->mTitle ), $fname ); } diff --git a/includes/SearchMySQL3.php b/includes/SearchMySQL3.php index 48770d1812..07b9810e98 100644 --- a/includes/SearchMySQL3.php +++ b/includes/SearchMySQL3.php @@ -88,8 +88,8 @@ class SearchMySQL3 extends SearchEngine { $dbw->replace( 'searchindex', array(array('si_page')), array( 'si_page' => $id, - 'si_title' => $dbw->strencode($title), - 'si_text' => $dbw->strencode( $text ) + 'si_title' => $title, + 'si_text' => $text ), 'SearchMySQL3::update' ); } diff --git a/includes/SearchMySQL4.php b/includes/SearchMySQL4.php index 761d6f58ef..c0462c46c8 100644 --- a/includes/SearchMySQL4.php +++ b/includes/SearchMySQL4.php @@ -85,8 +85,8 @@ class SearchMySQL4 extends SearchEngine { $dbw->replace( 'searchindex', array(array('si_page')), array( 'si_page' => $id, - 'si_title' => $dbw->strencode($title), - 'si_text' => $dbw->strencode( $text ) + 'si_title' => $title, + 'si_text' => $text ), 'SearchMySQL4::update' ); }