r81394 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81393‎ | r81394 | r81395 >
Date:15:33, 2 February 2011
Author:catrope
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/REL1_17/extensions/AntiSpoof/batchAntiSpoof.php (modified) (history)
  • /branches/REL1_17/extensions/Asksql/Asksql_body.php (modified) (history)
  • /branches/REL1_17/extensions/DSMW/includes/IntegrationFunctions.php (modified) (history)
  • /branches/REL1_17/extensions/DeleteBatch/DeleteBatch.body.php (modified) (history)
  • /branches/REL1_17/extensions/FCKeditor/FCKeditorSkin.body.php (modified) (history)
  • /branches/REL1_17/extensions/IndexFunction/SpecialIndex.php (modified) (history)
  • /branches/REL1_17/extensions/InterwikiList/InterwikiList_body.php (modified) (history)
  • /branches/REL1_17/extensions/MassBlank/MassBlank_body.php (modified) (history)
  • /branches/REL1_17/extensions/MetavidWiki/includes/articlepages/MV_CategoryPage.php (modified) (history)
  • /branches/REL1_17/extensions/NewUserNotif/NewUserNotif.class.php (modified) (history)
  • /branches/REL1_17/extensions/NewUserNotif/NewUserNotif.php (modified) (history)
  • /branches/REL1_17/extensions/NewUserNotif/README (modified) (history)
  • /branches/REL1_17/extensions/News/NewsRenderer.php (modified) (history)
  • /branches/REL1_17/extensions/Nuke/Nuke_body.php (modified) (history)
  • /branches/REL1_17/extensions/OpenID/OpenID.hooks.php (modified) (history)
  • /branches/REL1_17/extensions/OpenSearchXml/ApiOpenSearchXml.php (modified) (history)
  • /branches/REL1_17/extensions/OpenSearchXml/OpenSearchXml.php (modified) (history)
  • /branches/REL1_17/extensions/Player/PlayerClass.php (modified) (history)
  • /branches/REL1_17/extensions/ProofreadPage/proofread.js (modified) (history)
  • /branches/REL1_17/extensions/RandomImage/RandomImage.class.php (modified) (history)
  • /branches/REL1_17/extensions/Renameuser/Renameuser_body.php (modified) (history)
  • /branches/REL1_17/extensions/ReplaceText/SpecialReplaceText.php (modified) (history)
  • /branches/REL1_17/extensions/SecurePoll/includes/entities/Election.php (modified) (history)
  • /branches/REL1_17/extensions/SecurePoll/includes/entities/Entity.php (modified) (history)
  • /branches/REL1_17/extensions/SecurePoll/includes/main/Context.php (modified) (history)
  • /branches/REL1_17/extensions/SecurePoll/includes/main/Store.php (modified) (history)
  • /branches/REL1_17/extensions/SmoothGallery/SmoothGalleryParser.php (modified) (history)
  • /branches/REL1_17/extensions/TitleKey/TitleKey_body.php (modified) (history)
  • /branches/REL1_17/extensions/Transliterator/Transliterator_body.php (modified) (history)
  • /branches/REL1_17/extensions/WatchSubpages/WatchSubpages_body.php (modified) (history)
  • /branches/REL1_17/extensions/WebDAV/WebDavServer.php (modified) (history)
  • /branches/REL1_17/extensions/WikiTrust/sql/create_db.php (modified) (history)
  • /branches/REL1_17/extensions/Wikilog/WikilogComment.php (modified) (history)
  • /branches/REL1_17/extensions/Wikilog/WikilogQuery.php (modified) (history)
  • /branches/REL1_17/extensions/WikimediaIncubator/TestWikiRC.php (modified) (history)
  • /branches/REL1_17/extensions/auth/GlobalAuth.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/extensions/InterwikiList/InterwikiList_body.php
@@ -42,7 +42,7 @@
4343
4444 $conds = array();
4545 if ( !is_null( $prefix ) ) {
46 - $conds[] = "iw_prefix LIKE " . $dbr->addQuotes( $dbr->escapeLike( $prefix ) . "%" );
 46+ $conds[] = "iw_prefix " . $dbr->buildLike( $prefix, $dbr->anyString() );
4747 }
4848
4949 $results = $dbr->select( 'interwiki', array( 'iw_prefix', 'iw_url' ), $conds );
Index: branches/REL1_17/extensions/DeleteBatch/DeleteBatch.body.php
@@ -315,7 +315,7 @@
316316 $art = new ImagePage( $page );
317317 /*this is absolutely required - creating a new ImagePage object does not automatically
318318 provide it with image */
319 - $art->img = new Image( $art->mTitle );
 319+ $art->img = wfFindFile( $art->mTitle );
320320 } else {
321321 $art = new Article( $page );
322322 }
Index: branches/REL1_17/extensions/SmoothGallery/SmoothGalleryParser.php
@@ -205,7 +205,8 @@
206206
207207 // Create a thumbnail the same size as our gallery so that
208208 // full images fit correctly
209 - $full_thumb_obj = $img_obj->getThumbnail( $this->argumentArray["width"], $this->argumentArray["height"] );
 209+
 210+ $full_thumb_obj = $img_obj->transform( array( 'width' => $this->argumentArray["width"], 'height' => $this->argumentArray["height"] ), 0 );
210211 if ( !is_null( $full_thumb_obj ) ) {
211212 $full_thumb = $full_thumb_obj->getUrl();
212213 } else {
@@ -225,7 +226,7 @@
226227 // We are going to show a carousel to the user; we need
227228 // to make icon thumbnails
228229 // $thumb_obj = $img_obj->getThumbnail( 120, 120 ); //would be nice to reuse images already loaded...
229 - $thumb_obj = $img_obj->getThumbnail( $wgSmoothGalleryThumbWidth, $wgSmoothGalleryThumbHeight );
 230+ $thumb_obj = $img_obj->transform( array( 'width' => $wgSmoothGalleryThumbWidth, 'height' => $wgSmoothGalleryThumbHeight ), 0 );
230231 if ( $thumb_obj ) {
231232 $icon_thumb = $thumb_obj->getUrl();
232233 }
Index: branches/REL1_17/extensions/Renameuser/Renameuser_body.php
@@ -296,8 +296,7 @@
297297 array( 'page_namespace', 'page_title' ),
298298 array(
299299 'page_namespace IN (' . NS_USER . ',' . NS_USER_TALK . ')',
300 - '(page_title LIKE ' .
301 - $dbr->addQuotes( $dbr->escapeLike( $oldusername->getDBkey() ) . '/%' ) .
 300+ '(page_title ' . $dbr->buildLike( $oldusername->getDBkey() . '/', $dbr->anyString() ) .
302301 ' OR page_title = ' . $dbr->addQuotes( $oldusername->getDBkey() ) . ')'
303302 ),
304303 __METHOD__
Index: branches/REL1_17/extensions/AntiSpoof/batchAntiSpoof.php
@@ -12,7 +12,7 @@
1313
1414 $result = $dbw->select( 'user', 'user_name', null, 'batchAntiSpoof.php' );
1515 $n = 0;
16 -foreach( $res as $row ) {
 16+foreach( $result as $row ) {
1717 if ( $n++ % $batchSize == 0 ) {
1818 echo "$wgDBname $n\n";
1919 }
Index: branches/REL1_17/extensions/WebDAV/WebDavServer.php
@@ -605,7 +605,7 @@
606606 $entryCondition = null;
607607 foreach ( $entryConditions as $path => $revisionCondition ) {
608608 if ( !empty( $path ) ) {
609 - $pathCondition = '(page_title = ' . $dbr->addQuotes( $path ) . ' OR page_title LIKE \'' . $dbr->escapeLike( $path ) . '/%\')';
 609+ $pathCondition = '(page_title = ' . $dbr->addQuotes( $path ) . ' OR page_title ' . $dbr->buildLike( $path . '/', $dbr->anyString() ) . ')';
610610
611611 if ( !empty( $revisionCondition ) ) {
612612 $revisionCondition = ' AND ' . $revisionCondition;
Index: branches/REL1_17/extensions/ProofreadPage/proofread.js
@@ -117,25 +117,20 @@
118118 pageFooter = pageFooter.substr( 0, pageFooter.length - 6 );
119119 }
120120
121 - // escape & character
122 - pageBody = pageBody.split( '&' ).join( '&' );
123 - pageHeader = pageHeader.split( '&' ).join( '&' );
124 - pageFooter = pageFooter.split( '&' ).join( '&' );
125 -
126121 container.innerHTML = '' +
127122 '<div id="prp_header" style="">' +
128123 '<span style="color:gray;font-size:80%;line-height:100%;">' +
129124 escapeQuotesHTML( mediaWiki.msg( 'proofreadpage_header' ) ) + '</span>' +
130 - '<textarea name="wpHeaderTextbox" rows="2" cols="80" tabindex=1>' + pageHeader + '</textarea><br />' +
 125+ '<textarea name="wpHeaderTextbox" rows="2" cols="80" tabindex=1>' + escapeQuotesHTML( pageHeader ) + '</textarea><br />' +
131126 '<span style="color:gray;font-size:80%;line-height:100%;">' +
132127 escapeQuotesHTML( mediaWiki.msg( 'proofreadpage_body' ) ) + '</span></div>' +
133128 '<textarea name="wpTextbox1" id="wpTextbox1" tabindex=1 style="height:' + ( self.DisplayHeight - 6 ) + 'px;">' +
134 - pageBody + '</textarea>' +
 129+ escapeQuotesHTML( pageBody ) + '</textarea>' +
135130 '<div id="prp_footer" style="">' +
136131 '<span style="color:gray;font-size:80%;line-height:100%;">' +
137132 escapeQuotesHTML( mediaWiki.msg( 'proofreadpage_footer' ) ) + '</span><br />' +
138133 '<textarea name="wpFooterTextbox" rows="2" cols="80" tabindex=1>' +
139 - pageFooter + '</textarea></div>';
 134+ escapeQuotesHTML( pageFooter ) + '</textarea></div>';
140135 }
141136
142137 function pr_reset_size() {
@@ -951,13 +946,13 @@
952947
953948 if( !proofreadPageAddButtons ) {
954949 f.innerHTML =
955 - ' <input type="hidden" name="wpProofreader" value="' + self.proofreadpage_username + '">' +
956 - '<input type="hidden" name="quality" value=' + self.proofreadpage_quality + ' >';
 950+ ' <input type="hidden" name="wpProofreader" value="' + escapeQuotesHTML( self.proofreadpage_username ) + '">' +
 951+ '<input type="hidden" name="quality" value="' + escapeQuotesHTML( self.proofreadpage_quality ) + '" >';
957952 return;
958953 }
959954
960955 f.innerHTML =
961 -' <input type="hidden" name="wpProofreader" value="' + self.proofreadpage_username + '">'
 956+' <input type="hidden" name="wpProofreader" value="' + escapeQuotesHTML( self.proofreadpage_username ) + '">'
962957 +'<span class="quality0"> <input type="radio" name="quality" value=0 onclick="pr_add_quality(this.form,0)" tabindex=4> </span>'
963958 +'<span class="quality2"> <input type="radio" name="quality" value=2 onclick="pr_add_quality(this.form,2)" tabindex=4> </span>'
964959 +'<span class="quality1"> <input type="radio" name="quality" value=1 onclick="pr_add_quality(this.form,1)" tabindex=4> </span>'
Index: branches/REL1_17/extensions/WikiTrust/sql/create_db.php
@@ -73,7 +73,7 @@
7474 // Load all of the MW files.
7575 include($mw_root."/maintenance/commandLine.inc");
7676
77 -global $wgDBserver, $wgDBname, $wgDBuser, $wgDBprefix, $wgCreateRevisionIndex;
 77+global $wgDBserver, $wgDBname, $wgDBtype, $wgDBuser, $wgDBprefix, $wgCreateRevisionIndex;
7878
7979 // Source the update scripts
8080 require($mw_root."/extensions/WikiTrust/includes/TrustUpdateScripts.inc");
@@ -103,7 +103,14 @@
104104 }
105105
106106 // We need root priveledges to do this.
107 -$db_root = Database::newFromParams($wgDBserver, $dba, $dba_pass, $wgDBname);
 107+$db_root = DatabaseBase::newFromType( $wgDBtype,
 108+ array(
 109+ 'host' => $wgDBserver,
 110+ 'user' => $dba,
 111+ 'password' => $dba_pass,
 112+ 'dbname' => $wgDBname
 113+ )
 114+);
108115
109116 if (!$do_remove){
110117 // Now do the actual creating of tables.
Index: branches/REL1_17/extensions/MassBlank/MassBlank_body.php
@@ -94,7 +94,7 @@
9595 foreach( $pages as $info ) {
9696 list( $title, $edits ) = $info;
9797 $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
98 - $thumb = $image && $image->exists() ? $image->getThumbnail( 120, 120 ) : false;
 98+ $thumb = $image && $image->exists() ? $image->transform( array( 'width' => 120, 'height' => 120 ), 0 ) : false;
9999
100100 $changes = wfMsgExt( 'nchanges', 'parsemag', $wgLang->formatNum( $edits ) );
101101
Index: branches/REL1_17/extensions/News/NewsRenderer.php
@@ -640,7 +640,7 @@
641641 $image = false;
642642 }
643643
644 - $thumb = $image ? $image->getThumbnail(80, 16) : null;
 644+ $thumb = $image ? $image->transform( array( 'width' => 80, 'height' => 16 ), 0 ) : null;
645645 if ($image && !$thumb) $thumb = $image;
646646 $iconurl = $thumb ? $thumb->getUrl() : null;
647647
Index: branches/REL1_17/extensions/OpenSearchXml/ApiOpenSearchXml.php
@@ -31,6 +31,8 @@
3232 */
3333 class ApiOpenSearchXml extends ApiOpenSearch {
3434
 35+ private $mSeen;
 36+
3537 public function getCustomPrinter() {
3638 $format = $this->validateFormat();
3739 $printer = $this->getMain()->createPrinterByName( $format );
@@ -103,7 +105,7 @@
104106 $item['Description']['*'] = $extract;
105107 $item['Url']['*'] = $title->getFullUrl();
106108 if( $image ) {
107 - $thumb = $image->getThumbnail( 50, 50, false );
 109+ $thumb = $image->transform( array( 'width' => 50, 'height' => 50 ), 0 );
108110 $item['Image'] = array(
109111 'source' => wfExpandUrl( $thumb->getUrl() ),
110112 //alt
@@ -125,7 +127,11 @@
126128 return $title;
127129 }
128130 }
129 -
 131+
 132+ /**
 133+ * @param $title Title
 134+ * @return bool
 135+ */
130136 protected function _seen( $title ) {
131137 $name = $title->getPrefixedText();
132138 if( isset( $this->mSeen[$name] ) ) {
@@ -317,7 +323,12 @@
318324 }
319325 return '';
320326 }
321 -
 327+
 328+ /**
 329+ * @param $title Title
 330+ * @param $fromText
 331+ * @return File
 332+ */
322333 protected function getBadge( $title, $fromText ) {
323334 if( $title->getNamespace() == NS_IMAGE ) {
324335 $image = wfFindFile( $title );
Index: branches/REL1_17/extensions/OpenSearchXml/OpenSearchXml.php
@@ -28,11 +28,12 @@
2929 'url' => 'http://www.mediawiki.org/wiki/Extension:OpenSearchXml'
3030 );
3131
32 -$wgExtensionMessagesFiles['OpenSearchXml'] = dirname(__FILE__) . '/OpenSearchXml.i18n.php';
 32+$dir = dirname(__FILE__);
3333
 34+$wgExtensionMessagesFiles['OpenSearchXml'] = $dir . '/OpenSearchXml.i18n.php';
 35+
3436 $wgAPIModules['opensearch'] = 'ApiOpenSearchXml';
35 -$wgAutoloadClasses['ApiOpenSearchXml'] =
36 - dirname(__FILE__) . '/ApiOpenSearchXml.php';
 37+$wgAutoloadClasses['ApiOpenSearchXml'] = $dir . '/ApiOpenSearchXml.php';
3738
3839 $wgHooks['OpenSearchUrls'][] = 'efOpenSearchXmlUrls';
3940
Index: branches/REL1_17/extensions/DSMW/includes/IntegrationFunctions.php
@@ -207,7 +207,6 @@
208208 $indexNS = 0;
209209 wfDebugLog( 'p2p', ' - function logootIntegrate : ' . $article );
210210 $dbr = wfGetDB( DB_SLAVE );
211 - $dbr->immediateBegin();
212211 if ( is_string( $article ) ) {
213212 // if there is a space in the title, repalce by '_'
214213 $article = str_replace( " ", "_", $article );
@@ -296,7 +295,6 @@
297296 */
298297 function logootIntegrateAtt( $article, $edit ) {
299298 $dbr = wfGetDB( DB_SLAVE );
300 - $dbr->immediateBegin();
301299 $title = Title::newFromText( $article );
302300 $lastRevision = Revision::loadFromTitle( $dbr, $title );
303301
Index: branches/REL1_17/extensions/TitleKey/TitleKey_body.php
@@ -208,7 +208,7 @@
209209 array(
210210 'tk_page=page_id',
211211 'tk_namespace' => $ns,
212 - 'tk_key LIKE \'' . $dbr->escapeLike( $key ) . '%\'',
 212+ 'tk_key ' . $dbr->buildLike( $key, $dbr->anyString() ),
213213 ),
214214 __METHOD__,
215215 array(
Index: branches/REL1_17/extensions/RandomImage/RandomImage.class.php
@@ -82,9 +82,7 @@
8383 * @return bool
8484 */
8585 protected function imageExists( $title ) {
86 - $file = function_exists( 'wfFindFile' )
87 - ? wfFindFile( $title )
88 - : new Image( $title );
 86+ $file = wfFindFile( $title );
8987 return is_object( $file ) && $file->exists();
9088 }
9189
Index: branches/REL1_17/extensions/Nuke/Nuke_body.php
@@ -134,7 +134,7 @@
135135 foreach( $pages as $info ) {
136136 list( $title, $edits ) = $info;
137137 $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
138 - $thumb = $image && $image->exists() ? $image->getThumbnail( 120, 120 ) : false;
 138+ $thumb = $image && $image->exists() ? $image->transform( array( 'width' => 120, 'height' => 120 ), 0 ) : false;
139139
140140 $changes = wfMsgExt( 'nchanges', 'parsemag', $wgLang->formatNum( $edits ) );
141141
Index: branches/REL1_17/extensions/Wikilog/WikilogQuery.php
@@ -674,8 +674,7 @@
675675 if ( $this->mItem !== null ) {
676676 $q_conds['wlc_post'] = $this->mItem->getID();
677677 if ( $this->mThread ) {
678 - $thread = $db->escapeLike( $this->mThread );
679 - $q_conds[] = "wlc_thread LIKE '{$thread}/%'";
 678+ $q_conds[] = "wlc_thread " . $db->buildLike( $this->mThread . '/', $db->anyString() );
680679 }
681680 } elseif ( $this->mWikilog !== null ) {
682681 $join_wlp = true;
Index: branches/REL1_17/extensions/Wikilog/WikilogComment.php
@@ -478,9 +478,8 @@
479479 if ( is_array( $thread ) ) {
480480 $thread = implode( '/', $thread );
481481 }
482 - $thread = $dbr->escapeLike( $thread );
483482 return self::fetchFromConds( $dbr,
484 - array( 'wlc_post' => $itemid, "wlc_thread LIKE '{$thread}/%'" ),
 483+ array( 'wlc_post' => $itemid, "wlc_thread " . $dbr->buildLike( $thread . '/', $dbr->anyString() ) ),
485484 array( 'ORDER BY' => 'wlc_thread, wlc_id' )
486485 );
487486 }
Index: branches/REL1_17/extensions/MetavidWiki/includes/articlepages/MV_CategoryPage.php
@@ -96,7 +96,7 @@
9797 }
9898 function addMVThumb( Title $title, $sortkey, $pageLength, $isRedirect = false ) {
9999 if ( $this->showGallery ) {
100 - $image = new MV_Image( $title );
 100+ $image = wfFindFile( $title );
101101 if ( $this->flip ) {
102102 $this->gallery->insert( $image );
103103 } else {
Index: branches/REL1_17/extensions/IndexFunction/SpecialIndex.php
@@ -112,12 +112,13 @@
113113 $indexconds[] = 'in_title' . $operator . $this->mDb->addQuotes( $offset );
114114 }
115115 $ns = $this->mSearchTitle->getNamespace();
116 - $like = $this->mDb->escapeLike( $this->mSearchTitle->getDBkey() ) . '%';
 116+
 117+ $like = $this->mDb->buildLike( $this->mSearchTitle->getDBkey(), $this->mDb->anyString() );
117118
118119 $pageconds[] = "page_namespace = $ns";
119 - $pageconds[] = "page_title LIKE '$like'";
 120+ $pageconds[] = "page_title " . $like;
120121 $indexconds[] = "in_namespace = $ns";
121 - $indexconds[] = "in_title LIKE '$like'";
 122+ $indexconds[] = "in_title " . $like;
122123
123124
124125 $pagequery = $this->mDb->selectSQLText( 'page',
Index: branches/REL1_17/extensions/NewUserNotif/NewUserNotif.class.php
@@ -37,13 +37,13 @@
3838 * Send email to external addresses
3939 */
4040 private function sendExternalMails() {
41 - global $wgNewUserNotifEmailTargets, $wgNewUserNotifSenderParam, $wgNewUserNotifSenderSubjParam;
 41+ global $wgNewUserNotifEmailTargets, $wgSitename;
4242 foreach( $wgNewUserNotifEmailTargets as $target ) {
4343 UserMailer::send(
4444 new MailAddress( $target ),
4545 new MailAddress( $this->sender ),
46 - $this->makeMessage( $target, $this->user, 'newusernotifsubj', $wgNewUserNotifSenderSubjParam),
47 - $this->makeMessage( $target, $this->user, 'newusernotifbody', $wgNewUserNotifSenderParam)
 46+ wfMsgForContent( 'newusernotifsubj', $wgSitename ),
 47+ $this->makeMessage( $target, $this->user )
4848 );
4949 }
5050 }
@@ -52,13 +52,13 @@
5353 * Send email to users
5454 */
5555 private function sendInternalMails() {
56 - global $wgNewUserNotifTargets, $wgNewUserNotifSenderParam, $wgNewUserNotifSenderSubjParam;
 56+ global $wgNewUserNotifTargets, $wgSitename;
5757 foreach( $wgNewUserNotifTargets as $userSpec ) {
5858 $user = $this->makeUser( $userSpec );
5959 if( $user instanceof User && $user->isEmailConfirmed() ) {
6060 $user->sendMail(
61 - $this->makeMessage( $user->getName(), $this->user, 'newusernotifsubj', $wgNewUserNotifSenderSubjParam ),
62 - $this->makeMessage( $user->getName(), $this->user, 'newusernotifbody', $wgNewUserNotifSenderParam ),
 61+ wfMsgForContent( 'newusernotifsubj', $wgSitename ),
 62+ $this->makeMessage( $user->getName(), $this->user ),
6363 $this->sender
6464 );
6565 }
@@ -80,18 +80,22 @@
8181 }
8282
8383 /**
84 - * Build a notification email message (body and subject)
 84+ * Build a notification email
8585 *
86 - * @param string $recipient Name of the new user notification email recipient
87 - * @param User $user User (object) created for new user
88 - * @param string $msgId Localised Message Identifier
89 - * @param string $parmArr Array of Strings eval'd to pass parameters to message
90 - * @return string
 86+ * @param string $recipient Name of the recipient
 87+ * @param User $user User that was created
9188 */
92 - private function makeMessage( $recipient, $user, $msgId, $parmArr) {
93 - global $wgSitename,$wgContLang;
94 - eval( "\$retval = wfMsgForContent('".$msgId."',".implode(",",$parmArr).");" );
95 - return ($retval);
 89+ private function makeMessage( $recipient, $user ) {
 90+ global $wgSitename, $wgContLang;
 91+ return wfMsgForContent(
 92+ 'newusernotifbody',
 93+ $recipient,
 94+ $user->getName(),
 95+ $wgSitename,
 96+ $wgContLang->timeAndDate( wfTimestampNow() ),
 97+ $wgContLang->date( wfTimestampNow() ),
 98+ $wgContLang->time( wfTimestampNow() )
 99+ );
96100 }
97101
98102 /**
Index: branches/REL1_17/extensions/NewUserNotif/README
@@ -1,5 +1,4 @@
22 NEW USER EMAIL NOTIFICATION EXTENSION
3 -(http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification)
43
54 Version 1.5
65 © 2006-2007 Rob Church
@@ -14,9 +13,8 @@
1514 2. Installation requirements
1615 3. Installing the extension
1716 4. Editing the notification email
18 - 5. Configuration
19 - 6. Advanced Configuration
20 - 7. Feedback
 17+ 5. Further configuration
 18+ 6. Feedback
2119
2220 == 1. Introduction ==
2321
@@ -53,12 +51,9 @@
5452 $2 is replaced with the username of the new user account;
5553 $3 is replaced with the wiki site name from $wgSitename;
5654 $4 is replaced with the time and date of the account's creation.
57 - $5 is replaced with the date of the account's creation.
58 - $6 is replaced with the time of the account's creation.
5955
 56+== 5. Further configuration ==
6057
61 -== 5. Configuration ==
62 -
6358 The behaviour of the extension can be tweaked using three configuration
6459 variables. To override the defaults for these, set them in LocalSettings.php
6560 underneath the call to the extension file.
@@ -78,76 +73,7 @@
7974 $wgNewUserNotifEmailTargets
8075 Array containing email addresses to which a notification should also be sent
8176 Defaults to no additional addresses
82 -
83 -== 6. Advanced Configuration ==
8477
85 -As of version 1.5.2 of this extension, you can customize and add parameters passed to both the subject and body messages in your localsettings.php without modifying the extension code.
 78+== 6. Feedback ==
8679
87 -You can do this by adding (or changing) parameter values and/or functions that return the desired parameter values to the parameter definition arrays underneath the call to the extension file. In both cases you can use references to $this, $user (created user object), $recipient (target), or from globals $wfContLang, $wgSitename. (For advanced techniques and using other globals, see below).
88 -
89 -$wgNewUserNotifSenderSubjParam
90 - The list of evaluated parameters passed to the message subject(MediaWiki:Newusernotifsubj). Default is:
91 - '$wgSitename', // $1 Site Name
92 -
93 -$wgNewUserNotifSenderParam
94 - The list of evaluated parameters passed to the message body(MediaWiki:Newusernotifbody). Defaults are:
95 - '$recipient', // $1 Recipient (of notification message)
96 - '$user->getname()', // $2 User Name
97 - '$wgSitename', // $3 Site Name
98 - '$wgContLang->timeAndDate( wfTimestampNow() )', // $4 Time and date stamp
99 - '$wgContLang->date( wfTimestampNow() )', // $5 Date Stamp
100 - '$wgContLang->time( wfTimestampNow() )', // $6 Time Stamp
101 -
102 -You can then either edit MediaWiki:Newusernotifbody to make use of the new parameters (e.g. add "\n\nThe request came from $7.").
103 -
104 -=== 6.1 Upgrading from 1.5.1 ===
105 -
106 -If you did not customize the passed parameters, this extension works exactly as before and no action need to be taken.
107 -
108 -If you added to or changed the default passed parameters, you will need to correspondingly add to or change the corresponding arrays. You should be able to take the exact same code and add to or replace it in the arrays.
109 -
110 -For example, if you added a 7th parameter (in his case, the email address of the new user), you would just add it (in localsettings.php, below the extension reference) like this:
111 -
112 -<source lang="php">
113 -$wgNewUserNotifSenderParam[] = '$user->getEmail()'; // $7 new user email address
114 -</source>
115 -
116 -The code for the parameter to be passed should be exactly the same (except enclosed in quotes) as it is in your modified wfMsgForContent function call found in private function makeMessage.
117 -
118 -=== 6.2 Examples For Adding Additional Parameters ===
119 -
120 -Here are some commonly used additional parameter you could add to further customize your notification message subject and body:
121 -<source lang="php">
122 -$wgNewUserNotifSenderParam[] = '$user->getEmail()'; // $7 email
123 -$wgNewUserNotifSenderParam[] = 'rawurlencode($wgSitename)'; // $8 Escaped for email message
124 -$wgNewUserNotifSenderParam[] = 'wfGetIP()'; // $9 Submitter's IP Address
125 -</source>
126 -
127 -Of course if you wanted to pass these parameter(s) to the subject message, you would add them to the $wgNewUserNotifSenderSubjParam array instead of the $wgNewUserNotifSenderParam array.
128 -
129 -=== 6.4 Some Technique/Tricks for Adding Additional Parameters ===
130 -
131 -Let's say you wanted to use a global variable or reference other than $this, $user (created user object), $recipient (target), $wfContLang, or $wgSitename.
132 -
133 -You could do so by directly referencing a previously assigned global. Example:
134 -
135 -<source lang="php">
136 -$wgNewUserNotifSenderParam[] = '$GLOBALS["wgUser"]->getEmail()'; // $10 email
137 -</source>
138 -
139 -Note: This isn't the best example, because it would be easier to use the $user object ('$user->getEmail()'), but it gives you an idea how you could reference the global variable (in this case objec) $wgUser directly.
140 -
141 -=== 6.5 Advanced Customization Prior to 1.5.2 ===
142 -
143 -If you want to change the parameters passed in a version prior to 1.5.2, you would need to modify the extension code directly in wfMsgForContent function call found in private function makeMessage of NewUserNotif.class.php.
144 -
145 -== 7. Feedback ==
146 -
147 -Bugs and enhancement requests should be submitted through bugzilla for the MediaWiki Extensions at:
148 -
149 -https://bugzilla.wikimedia.org/enter_bug.cgi?product=MediaWiki%20extensions
150 -
151 -For comments and discussion, see:
152 -
153 -http://www.mediawiki.org/wiki/Extension_talk:New_User_Email_Notification
154 -
 80+All feedback, bug reports, etc. welcome via <robchur@gmail.com>.
\ No newline at end of file
Index: branches/REL1_17/extensions/NewUserNotif/NewUserNotif.php
@@ -1,6 +1,6 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
4 - die();
 4+ die();
55
66 /**
77 * Extension to provide customisable email notification of new user creation
@@ -13,9 +13,9 @@
1414 */
1515
1616 $wgExtensionCredits['other'][] = array(
17 - 'path' => __FILE__,
 17+ 'path' => __FILE__,
1818 'name' => 'New User Email Notification',
19 - 'version' => '1.5.2',
 19+ 'version' => '1.5.1',
2020 'author' => 'Rob Church',
2121 'url' => 'http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification',
2222 'descriptionmsg' => 'newusernotif-desc',
@@ -40,26 +40,6 @@
4141 * Additional email addresses to send mails to
4242 */
4343 $wgNewUserNotifEmailTargets = array();
44 -/**
45 - * These are the parameters that will be passed into MediaWiki:newusernotifbody
46 - * Can use anthing available as part of $this, $user (created user object), $recipient (target),
47 - * or from globals $wgContLang, $wgSitename
48 - */
49 -$wgNewUserNotifSenderParam = array(
50 - '$recipient', // $1 Recipient (of notification message)
51 - '$user->getname()', // $2 User Name
52 - '$wgSitename', // $3 Site Name
53 - '$wgContLang->timeAndDate( wfTimestampNow() )', // $4 Time and date stamp
54 - '$wgContLang->date( wfTimestampNow() )', // $5 Date Stamp
55 - '$wgContLang->time( wfTimestampNow() )', // $6 Time Stamp
56 -);
57 -/**
58 - * These are the parameters that will be passed into MediaWiki:Newusernotifsubj (for use in the "subject:" line)
59 - * parameters defs have same options as $wgNewUserNotifSenderParam
60 - */
61 -$wgNewUserNotifSenderSubjParam = array(
62 - '$wgSitename', // $1 Site Name
63 -);
6444
6545 /**
6646 * Extension setup
Index: branches/REL1_17/extensions/Asksql/Asksql_body.php
@@ -85,15 +85,24 @@
8686 function doSubmit() {
8787 global $wgOut, $wgUser, $wgServer, $wgScript, $wgLang, $wgContLang;
8888 global $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname, $wgSqlTimeout;
 89+ global $wgDBtype;
8990
9091 # Use a limit, folks!
9192 $this->query = trim( $this->query );
9293 if ( preg_match( '/^SELECT/i', $this->query )
93 - and !preg_match( '/LIMIT/i', $this->query ) ) {
 94+ && !preg_match( '/LIMIT/i', $this->query ) ) {
9495 $this->query .= ' LIMIT 100';
9596 }
96 - $conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname );
9797
 98+ $conn = DatabaseBase::newFromType( $wgDBtype,
 99+ array(
 100+ 'host' => $wgDBserver,
 101+ 'user' => $wgDBsqluser,
 102+ 'password' => $wgDBsqlpassword,
 103+ 'dbname' => $wgDBname
 104+ )
 105+ );
 106+
98107 $this->logQuery( $this->query );
99108
100109 # Start timer, will kill the DB thread in $wgSqlTimeout seconds
@@ -118,7 +127,7 @@
119128 }
120129
121130 $a = array();
122 - while ( $s = $conn->fetchObject( $res ) ) {
 131+ foreach ( $res as $s ) {
123132 array_push( $a, $s );
124133 }
125134 $conn->freeResult( $res );
Index: branches/REL1_17/extensions/FCKeditor/FCKeditorSkin.body.php
@@ -20,7 +20,7 @@
2121 function makeImageLinkObj( $nt, $label, $alt, $align = '', $params = array(), $framed = false,
2222 $thumb = false, $manual_thumb = '', $valign = '' ) {
2323 $orginal = $nt->getText();
24 - $img = new Image( $nt );
 24+ $img = wfFindFile( $nt );
2525 $imgName = $img->getName();
2626 $found = $img->getURL();
2727
@@ -119,7 +119,7 @@
120120 */
121121 function makeImageLink2( Title $nt, $file, $frameParams = array(), $handlerParams = array() ) {
122122 $orginal = $nt->getText();
123 - $img = new Image( $nt );
 123+ $img = wfFindFile( $nt );
124124 $imgName = $img->getName();
125125 $found = $img->getURL();
126126
Index: branches/REL1_17/extensions/Player/PlayerClass.php
@@ -383,7 +383,8 @@
384384 if ($thumbname) $thumbimg = wfFindFile( $thumbname );
385385
386386 if ($thumbimg && $thumbimg->exists()) {
387 - $tni = $thumbimg->getThumbnail( $this->width, $this->height );
 387+
 388+ $tni = $thumbimg->transform( array( 'width' => $this->width, 'height' => $this->height ), 0 );
388389 if ($tni) $thumbstyle = 'background-image:url('.$tni->getUrl().'); background-position:center; background-repeat:no-repeat; text-decoration:none;';
389390 }
390391
Index: branches/REL1_17/extensions/SecurePoll/includes/entities/Entity.php
@@ -62,7 +62,7 @@
6363
6464 /**
6565 * Get the parent election
66 - * @return Int
 66+ * @return SecurePoll_Election
6767 */
6868 public function getElection() {
6969 return $this->electionId !== null
Index: branches/REL1_17/extensions/SecurePoll/includes/entities/Election.php
@@ -93,7 +93,7 @@
9494 * Get the election's parent election... hmm...
9595 */
9696 function getElection() {
97 - return $this->id;
 97+ return $this;
9898 }
9999
100100 /**
Index: branches/REL1_17/extensions/SecurePoll/includes/main/Store.php
@@ -229,7 +229,7 @@
230230 return $questions;
231231 }
232232
233 - function callbackValidVotes( $electionId, $callback, $voterId=null ) {
 233+ function callbackValidVotes( $electionId, $callback, $voterId = null ) {
234234 $dbr = $this->getDB();
235235 $where = array(
236236 'vote_election' => $electionId,
@@ -356,7 +356,7 @@
357357 }
358358
359359 function getEntityType( $id ){
360 - return array_key_exists( $this->entityInfo[$id] )
 360+ return isset( $this->entityInfo[$id] )
361361 ? $this->entityInfo[$id]['type']
362362 : false;
363363 }
Index: branches/REL1_17/extensions/SecurePoll/includes/main/Context.php
@@ -96,7 +96,7 @@
9797 }
9898
9999 /** Get the type of a particular entity **/
100 - function getEntityType( $id ){
 100+ function getEntityType( $id ) {
101101 return $this->getStore()->getEntityType( $id );
102102 }
103103
@@ -105,7 +105,7 @@
106106 * false if it does not exist.
107107 */
108108 function getElection( $id ) {
109 - if( !isset( $this->electionCache[$id] ) ){
 109+ if( !isset( $this->electionCache[$id] ) ) {
110110 $info = $this->getStore()->getElectionInfo( array( $id ) );
111111 if ( $info ) {
112112 $this->electionCache[$id] = $this->newElection( reset( $info ) );
Index: branches/REL1_17/extensions/WatchSubpages/WatchSubpages_body.php
@@ -254,7 +254,7 @@
255255 array( 'page_namespace', 'page_title', 'page_id', 'page_is_redirect' ),
256256 array(
257257 'page_namespace' => $prefixNS,
258 - 'page_title LIKE \'' . $dbr->escapeLike( $prefixKey ) .'%\'',
 258+ 'page_title ' . $dbr->buildLike( $prefixKey, $dbr->anyString() ),
259259 ),
260260 __METHOD__,
261261 array(
Index: branches/REL1_17/extensions/auth/GlobalAuth.php
@@ -93,7 +93,7 @@
9494 $fname );
9595 while ( $row = $dbr->fetchObject( $res ) ) {
9696 if ( $row->user_wiki == $this->thiswiki || $row->user_wiki == '*' ) {
97 - if ( $row->user_password == wfEncryptPassword( $row->user_id, $password ) ) {
 97+ if ( $row->user_password == User::oldCrypt( $password, $row->user_id ) ) {
9898 $this->data =& $row;
9999 return true;
100100 }
@@ -153,7 +153,7 @@
154154 function setPassword( $password ) {
155155 $dbw = wfGetDB( DB_MASTER );
156156 $success = $dbw->update( $this->tablename,
157 - array( 'user_password' => wfEncryptPassword( $this->data->user_id, $password ) ),
 157+ array( 'user_password' => User::oldCrypt( $password, $this->data->user_id ) ),
158158 array( 'user_id' => $this->data->user_id,
159159 'user_wiki' => $this->data->user_wiki ),
160160 'GlobalAuth::setPassword' );
@@ -226,7 +226,7 @@
227227 return false;
228228 # The password matches one of the already existing accounts.
229229 # Allow creation of an account.
230 - if ( $row->user_password == wfEncryptPassword( $row->user_id, $password ) ) {
 230+ if ( $row->user_password == User::oldCrypt( $password, $row->user_id ) ) {
231231 $create = true;
232232 }
233233 }
Index: branches/REL1_17/extensions/WikimediaIncubator/TestWikiRC.php
@@ -25,7 +25,7 @@
2626 $dbr = wfGetDB( DB_SLAVE );
2727 $namespaces = array( NS_MAIN, NS_TALK, NS_TEMPLATE, NS_TEMPLATE_TALK, NS_CATEGORY, NS_CATEGORY_TALK );
2828 $conds[] = 'rc_namespace IN (' . $dbr->makeList( $namespaces ) . ')';
29 - $conds[] = 'rc_title like ' . $dbr->addQuotes( $dbr->escapeLike( $fullprefix ) . '/%' ) .
 29+ $conds[] = 'rc_title ' . $dbr->buildLike( $fullprefix . '/', $dbr->anyString() ) .
3030 ' OR rc_title = ' . $dbr->addQuotes( $fullprefix );
3131 return true;
3232 }
Index: branches/REL1_17/extensions/Transliterator/Transliterator_body.php
@@ -141,7 +141,7 @@
142142 array( 'page_title', 'page_id' ),
143143 array(
144144 'page_namespace' => NS_MEDIAWIKI,
145 - 'page_title LIKE \'' . $dbr->escapeLike( self::getMapPagePrefix() ) . '%\''
 145+ 'page_title ' . $dbr->buildLike( self::getMapPagePrefix(), $dbr->anyString() )
146146 ),
147147 __METHOD__
148148 );
Index: branches/REL1_17/extensions/ReplaceText/SpecialReplaceText.php
@@ -515,10 +515,10 @@
516516 'rev_text_id = old_id'
517517 );
518518 } else {
519 - $search = $dbr->escapeLike( $search );
 519+ $any = $dbr->anyString();
520520 $include_ns = $dbr->makeList( $namespaces );
521521 $conds = array(
522 - "old_text LIKE '%$search%'",
 522+ "old_text " . $dbr->buildLike( $any, $search, $any ),
523523 "page_namespace IN ($include_ns)",
524524 'rev_id = page_latest',
525525 'rev_text_id = old_id'
Index: branches/REL1_17/extensions/OpenID/OpenID.hooks.php
@@ -295,7 +295,9 @@
296296 $dbPatch = "$base/" . ( $updater->getDB()->getType() == 'postgres' ?
297297 'openid_table.pg.sql' : 'openid_table.sql' );
298298 $updater->addExtensionUpdate( array( 'addTable', 'user_openid', $dbPatch, true ) );
299 - $updater->addExtensionUpdate( array( array( __CLASS__, 'makeUoiUserNotUnique' ) ) );
 299+ if ( $updater->getDB()->getType() == 'mysql' ) {
 300+ $updater->addExtensionUpdate( array( array( __CLASS__, 'makeUoiUserNotUnique' ) ) );
 301+ }
300302 }
301303
302304 return true;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81026Per MarkAHershberger's comment on r60241: isMultipleKey() only exists in MySQLialex15:14, 26 January 2011
r81116Partial revert of r68257: bizarre eval() stuff added to NewUserNotif contrary...brion00:31, 28 January 2011
r81155ProofreadPage: Fix stored XSS in edit form. Report and patch by Bawolffcatrope19:50, 28 January 2011
r81201followup r75647 typo in var namemah03:24, 30 January 2011
r81204Fixup usage of $file->getThumbnail as it's deprecated...reedy08:06, 30 January 2011
r81205Like r81204, fixup other usages of getThumbnail in extensions (One extension,...reedy08:11, 30 January 2011
r81220Part of bug 27041, removing all calls to escapeLike in extensionsreedy22:34, 30 January 2011
r81235SecurePoll: fixes for r64483:...tstarling06:13, 31 January 2011
r81240Remove calls to wfEncryptPassword (bug 27401)reedy12:17, 31 January 2011
r81241bug 27041, fixup usages of userMailer()reedy12:21, 31 January 2011
r81242Per bug 27041, remove calls to $dbr->immediateBegin();...reedy12:24, 31 January 2011
r81244bug 27041, swap Database::newFromParams to DatabaseBase::newFromType()reedy12:34, 31 January 2011
r81245bug 27041, kill Image::__constructreedy12:45, 31 January 2011

Status & tagging log