r88819 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88818‎ | r88819 | r88820 >
Date:19:30, 25 May 2011
Author:reedy
Status:deferred
Tags:
Comment:
Fix spaces to tabs

Set svn:eol-style native
Modified paths:
  • /trunk/extensions/ShortUrl/README (modified) (history)
  • /trunk/extensions/ShortUrl/ShortUrl.functions.php (modified) (history)
  • /trunk/extensions/ShortUrl/SpecialShortUrl.php (modified) (history)
  • /trunk/extensions/ShortUrl/install.settings (modified) (history)

Diff [purge]

Index: trunk/extensions/ShortUrl/ShortUrl.functions.php
@@ -15,68 +15,66 @@
1616
1717 /* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */
1818 function urlsafe_b64encode( $string ) {
19 - $data = base64_encode( $string );
20 - $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), $data );
21 - return $data;
 19+ $data = base64_encode( $string );
 20+ $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), $data );
 21+ return $data;
2222 }
2323
2424 /* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */
2525 function urlsafe_b64decode( $string ) {
26 - $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string );
27 - $mod4 = strlen( $data ) % 4;
28 - if ( $mod4 ) {
29 - $data .= substr( '====', $mod4 );
30 - }
31 - return base64_decode( $data );
 26+ $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string );
 27+ $mod4 = strlen( $data ) % 4;
 28+ if ( $mod4 ) {
 29+ $data .= substr( '====', $mod4 );
 30+ }
 31+ return base64_decode( $data );
3232 }
3333
3434 function shorturlEncode ( $title ) {
35 - global $wgMemc;
 35+ global $wgMemc;
3636
37 - $id = null;
38 - $id = $wgMemc->get( wfMemcKey( 'shorturls', 'title', $title->getFullText() ) );
39 - if ( !$id ) {
40 - $dbr = wfGetDB( DB_SLAVE );
41 - $query = $dbr->select(
42 - 'shorturls',
43 - array( 'su_id' ),
44 - array( 'su_namespace' => $title->getNamespace(), 'su_title' => $title->getText() ),
45 - __METHOD__ );
46 - if ( $dbr->numRows( $query ) > 0 ) {
47 - $entry = $dbr->fetchRow( $query );
48 - $id = $entry['su_id'];
49 - } else {
50 - $dbw = wfGetDB( DB_MASTER );
51 - $row_data = array(
52 - 'su_id' => $dbw->nextSequenceValue( 'shorturls_id_seq' ),
53 - 'su_namespace' => $title->getNamespace(),
54 - 'su_title' => $title->getText()
55 - );
56 - $dbw->insert( 'shorturls', $row_data );
57 - $id = $dbw->insertId();
58 - }
59 - $wgMemc->set( wfMemcKey( 'shorturls', 'title', $title->getFullText() ), $id, 0 );
60 - }
 37+ $id = $wgMemc->get( wfMemcKey( 'shorturls', 'title', $title->getFullText() ) );
 38+ if ( !$id ) {
 39+ $dbr = wfGetDB( DB_SLAVE );
 40+ $query = $dbr->select(
 41+ 'shorturls',
 42+ array( 'su_id' ),
 43+ array( 'su_namespace' => $title->getNamespace(), 'su_title' => $title->getText() ),
 44+ __METHOD__ );
 45+ if ( $dbr->numRows( $query ) > 0 ) {
 46+ $entry = $dbr->fetchRow( $query );
 47+ $id = $entry['su_id'];
 48+ } else {
 49+ $dbw = wfGetDB( DB_MASTER );
 50+ $row_data = array(
 51+ 'su_id' => $dbw->nextSequenceValue( 'shorturls_id_seq' ),
 52+ 'su_namespace' => $title->getNamespace(),
 53+ 'su_title' => $title->getText()
 54+ );
 55+ $dbw->insert( 'shorturls', $row_data );
 56+ $id = $dbw->insertId();
 57+ }
 58+ $wgMemc->set( wfMemcKey( 'shorturls', 'title', $title->getFullText() ), $id, 0 );
 59+ }
6160 return urlsafe_b64encode( $id );
6261 }
6362
6463 function shorturlDecode ( $data ) {
65 - global $wgMemc;
 64+ global $wgMemc;
6665
67 - $id = intval( urlsafe_b64decode ( $data ) );
68 - $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) );
69 - if ( !$entry ) {
70 - $dbr = wfGetDB( DB_SLAVE );
71 - $query = $dbr->select(
72 - 'shorturls',
73 - array( 'su_namespace', 'su_title' ),
74 - array( 'su_id' => $id ),
75 - __METHOD__
76 - );
 66+ $id = intval( urlsafe_b64decode ( $data ) );
 67+ $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) );
 68+ if ( !$entry ) {
 69+ $dbr = wfGetDB( DB_SLAVE );
 70+ $query = $dbr->select(
 71+ 'shorturls',
 72+ array( 'su_namespace', 'su_title' ),
 73+ array( 'su_id' => $id ),
 74+ __METHOD__
 75+ );
7776
78 - $entry = $dbr->fetchRow( $query );
79 - $wgMemc->set( wfMemcKey( 'shorturls', 'id', $id ), $entry, 0 );
80 - }
81 - return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] );
82 -
 77+ $entry = $dbr->fetchRow( $query );
 78+ $wgMemc->set( wfMemcKey( 'shorturls', 'id', $id ), $entry, 0 );
 79+ }
 80+ return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] );
8381 }
Property changes on: trunk/extensions/ShortUrl/install.settings
___________________________________________________________________
Added: svn:eol-style
8482 + native
Index: trunk/extensions/ShortUrl/SpecialShortUrl.php
@@ -36,7 +36,7 @@
3737 * @param $par Mixed: Parameters passed to the page
3838 */
3939 public function execute( $par ) {
40 - global $wgOut, $wgRequest;
 40+ global $wgOut;
4141
4242 $title = shorturlDecode( $par );
4343 if ( $title ) {
Property changes on: trunk/extensions/ShortUrl/README
___________________________________________________________________
Added: svn:eol-style
4444 + native

Status & tagging log