r97666 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97665‎ | r97666 | r97667 >
Date:21:32, 20 September 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Add /secure skins symlink
* Refactored out code duplication with createSymlink()
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki
@@ -83,67 +83,40 @@
8484
8585 # Create symlink to wmf-config/AdminSettings.php...
8686 $path = "$destIP/AdminSettings.php";
87 - if ( !file_exists( $path ) ) {
88 - if ( symlink( "../wmf-config/AdminSettings.php", $path ) ) {
89 - print "Created AdminSettings.php symlink.\n";
90 - }
91 - } else {
92 - print "Symlink file already exists: $path\n";
93 - }
 87+ $link = "../wmf-config/AdminSettings.php";
 88+ createSymlink( $path, $link, "Created AdminSettings.php symlink." );
9489
9590 # Create symlink to wmf-config/StartProfiler.php...
9691 $path = "$destIP/StartProfiler.php";
97 - if ( !file_exists( $path ) ) {
98 - if ( symlink( "../wmf-config/StartProfiler.php", $path ) ) {
99 - print "Created StartProfiler.php symlink.\n";
100 - }
101 - } else {
102 - print "Symlink file already exists: $path\n";
103 - }
 92+ $link = "../wmf-config/StartProfiler.php";
 93+ createSymlink( $path, $link, "Created StartProfiler.php symlink." );
10494
10595 # Create bits.wikimedia.org symlinks...
10696 $path = "$commonHomeDir/docroot/bits/skins-$dstVersionNum";
107 - if ( !file_exists( $path ) ) {
108 - if ( symlink( "$commonLocalDir/php-$dstVersionNum/skins/", $path ) ) {
109 - print "Created skins-$dstVersionNum symlink.\n";
110 - }
111 - } else {
112 - print "Symlink file already exists: $path\n";
113 - }
 97+ $link = "$commonLocalDir/php-$dstVersionNum/skins/";
 98+ createSymlink( $path, $link, "Created skins-$dstVersionNum symlink." );
 99+
114100 $path = "$commonHomeDir/docroot/bits/w/extensions-$dstVersionNum";
115 - if ( !file_exists( $path ) ) {
116 - if ( symlink( "$commonLocalDir/php-$dstVersionNum/extensions", $path ) ) {
117 - print "Created w/extensions-$dstVersionNum symlink.\n";
118 - }
119 - } else {
120 - print "Symlink file already exists: $path\n";
121 - }
 101+ $link = "$commonLocalDir/php-$dstVersionNum/extensions";
 102+ createSymlink( $path, $link, "Created w/extensions-$dstVersionNum symlink." );
122103
 104+ # Create secure.wikimedia.org symlinks...
 105+ $path = "$commonHomeDir/docroot/secure/skins-$dstVersionNum";
 106+ $link = "$commonLocalDir/php-$dstVersionNum/skins";
 107+ createSymlink( $path, $link, "Created secure/skins-$dstVersionNum symlink." );
 108+
123109 # Create skins/resources symlinks...
124110 $path = "$commonHomeDir/live-1.5/extensions-$dstVersionNum";
125 - if ( !file_exists( $path ) ) {
126 - if ( symlink( "$commonLocalDir/php-$dstVersionNum/extensions", $path ) ) {
127 - print "Created live-1.5/extensions-$dstVersionNum symlink.\n";
128 - }
129 - } else {
130 - print "Symlink file already exists: $path\n";
131 - }
 111+ $link = "$commonLocalDir/php-$dstVersionNum/extensions";
 112+ createSymlink( $path, $link, "Created live-1.5/extensions-$dstVersionNum symlink." );
 113+
132114 $path = "$commonHomeDir/live-1.5/skins-$dstVersionNum";
133 - if ( !file_exists( $path ) ) {
134 - if ( symlink( "$commonLocalDir/php-$dstVersionNum/skins", $path ) ) {
135 - print "Created live-1.5/skins-$dstVersionNum symlink.\n";
136 - }
137 - } else {
138 - print "Symlink file already exists: $path\n";
139 - }
 115+ $link = "$commonLocalDir/php-$dstVersionNum/skins";
 116+ createSymlink( $path, $link, "Created live-1.5/skins-$dstVersionNum symlink." );
 117+
140118 $path = "$commonHomeDir/live-1.5/resources-$dstVersionNum";
141 - if ( !file_exists( $path ) ) {
142 - if ( symlink( "$commonLocalDir/php-$dstVersionNum/resources", $path ) ) {
143 - print "Created live-1.5/resources-$dstVersionNum symlink.\n";
144 - }
145 - } else {
146 - print "Symlink file already exists: $path\n";
147 - }
 119+ $link = "$commonLocalDir/php-$dstVersionNum/resources";
 120+ createSymlink( $path, $link, "Created live-1.5/resources-$dstVersionNum symlink." );
148121
149122 # Create libs symlinks...
150123 $libDir = "$commonHomeDir/php-$dstVersionNum/lib";
@@ -172,4 +145,14 @@
173146 print "\nMediaWiki $dstVersionNum, from $svnVersion, successfully checked out.\n";
174147 }
175148
 149+function createSymlink( $path, $link, $createdMsg ) {
 150+ if ( !file_exists( $path ) ) {
 151+ if ( symlink( $link, $path ) ) {
 152+ print "$createdMsg\n";
 153+ }
 154+ } else {
 155+ print "Symlink file already exists: $path\n";
 156+ }
 157+}
 158+
176159 checkoutMediaWiki();

Comments

#Comment by Platonides (talk | contribs)   21:38, 20 September 2011

Shouldn't createSymlink() do something if symlink() fails?

#Comment by Catrope (talk | contribs)   20:26, 4 October 2011

Yeah, it should print an error message. Tagging todo.

#Comment by Aaron Schulz (talk | contribs)   20:27, 4 October 2011

Shouldn't the PHP warnings show up already?

#Comment by Catrope (talk | contribs)   20:27, 4 October 2011

Fair enough.

Status & tagging log