Re: [Toolserver-l] [Wikitech-l] 403: User account expired toolserver.org/~soxred93

2012-03-12 Thread Soxred93
If you are pushing for an MMP, it would be best not to use my code. It's 
shoddy, poorly written, broken, and inefficient. Frankly, I'm amazed it lasted 
as long as it did. 

-X!

On Mar 12, 2012, at 12:05 PM, Paul Selitskas p.selits...@gmail.com wrote:

 On Mon, Mar 12, 2012 at 6:59 PM, Merlijn van Deen valhall...@arctus.nl 
 wrote:
 On 12 March 2012 15:49, Hydriz Wikipedia ad...@alphacorp.tk wrote:
 
 Tparis has the full source code of those tools, and looks like he has
 already brought them up on his own account. See
 https://toolserver.org/~tparis.
 
 
 Could we (in general) *please* not do this? If someones tools are important
 enough to be taken over by someone else, they are most certainly important
 enough for a multi-maintainer project. In {one month, one year, five years},
 Tparis' account will also expire and we will have the same problem all over
 again.
 
 Best,
 Merlijn
 
 
 ___
 Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org)
 https://lists.wikimedia.org/mailman/listinfo/toolserver-l
 Posting guidelines for this list:
 https://wiki.toolserver.org/view/Mailing_list_etiquette
 
 That's a good point not to do this ever more. But then we are about to
 return to the stable toolserver approach, aren't we? :) By the way
 there is a sort of bugs in Soxred's tools concerning language code -
 project subdomain conversion which I would like to fix or at least
 report them (I can remind that I've already done it once in Soxred's
 googlecode issue tracker).
 
 -- 
 З павагай,
 Павел Селіцкас/Paul Selitskas
 Wizardist @ Wikimedia projects
 p.selits...@gmail.com, +375257408304
 Skype: p.selitskas
 
 ___
 Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org)
 https://lists.wikimedia.org/mailman/listinfo/toolserver-l
 Posting guidelines for this list: 
 https://wiki.toolserver.org/view/Mailing_list_etiquette

___
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org)
https://lists.wikimedia.org/mailman/listinfo/toolserver-l
Posting guidelines for this list: 
https://wiki.toolserver.org/view/Mailing_list_etiquette

Re: [Wikitech-l] testing of localization

2011-03-22 Thread Soxred93

On Mar 22, 2011, at 1:32 PM, Amir E. Aharoni wrote:

 1. Are there currently any tests in the MediaWiki test suite that
 focus on localization?

The MediaWiki PHPUnit test suites are still very much incomplete, and have yet 
to test a fraction of the MediaWiki code. That said, there are tests that test 
the wfMessage() function and the Message class, including the various 
translations. So if I am understanding your question correctly, the answer is 
somewhat yes.

-X!


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[MediaWiki-CVS] SVN: [82315] trunk/phase3/skins/vector/screen.css

2011-02-16 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/82315

Revision: 82315
Author:   soxred93
Date: 2011-02-17 00:30:19 + (Thu, 17 Feb 2011)
Log Message:
---
Reverting r76017 per discussion on Bugzilla. Lack of community consensus for 
change, and the whole purpose of the new messages box is *NOT* to fit into 
the skin, so people will see it immediately.

Modified Paths:
--
trunk/phase3/skins/vector/screen.css

Modified: trunk/phase3/skins/vector/screen.css
===
--- trunk/phase3/skins/vector/screen.css2011-02-17 00:24:24 UTC (rev 
82314)
+++ trunk/phase3/skins/vector/screen.css2011-02-17 00:30:19 UTC (rev 
82315)
@@ -969,8 +969,8 @@
 }
 /* User Message */
 .usermessage {
-   background-color: #e0e8ff;
-   border: 1px solid #99b3ff;
+   background-color: #ffce7b;
+   border: 1px solid #ffa500;
color: black;
font-weight: bold;
margin: 2em 0 1em;


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


Re: [Wikitech-l] Fwd: Gender preference

2011-02-10 Thread Soxred93
prefstats maybe?

On Feb 10, 2011, at 8:17 AM, Roan Kattouw wrote:

 2011/2/10 Andrew Garrett agarr...@wikimedia.org:
 That's not accurate. Aggregate preference data is available to
 toolserver users — the view omits the user ID field.
 
 The view of which table? Running SHOW TABLES; on enwiki_p, I don't
 see user_properties or anything else that looks like it might contain
 preferences data.
 
 Roan Kattouw (Catrope)
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Mediawiki-api] Image uploading: no response in last step

2011-02-09 Thread Soxred93
Snoopy is horribly out of date and no longer maintainted, as far as I know. I 
would reccommend using a framework that works with API. There's a list at 
http://enwp.org/WP:MAKEBOT.

-X!

On Feb 9, 2011, at 11:48 AM, Juan Rodríguez wrote:

 Hi, I'm experimenting with the api, I'm interested in create a bot to upload 
 images. This is my code (I'm using the Snoopy.php class):
 
 # get token
 $getToken = array(
 'action' = 'query', 
 'prop' = 'info', 
 'intoken' = 'edit',
 'titles' = 'Wiki1',
 'format' = 'php');
 
 echo br/;
 if(!$snoopy-submit($api_url, $getToken))
 echo TOKEN DENIED;
 else
 echo GOT TOKEN;
 echo br/;
 
 $array_ = unserialize($snoopy-results);
 
 $myFile = fopen(/var/www/dib.jpg,r);
 $returned = fread($myFile, 500);
 while($devuelto != false) {
 $fileContent .= $returned;
 $returned = fread($myFile, 500);
 }
 
 #upload
 $uploadVars['format'] = 'php';
 $uploadVars['action'] = 'upload';
 $uploadVars['filename'] = 'wikip.png';
 $uploadVars['url'] = 'http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png';
 $uploadVars['file'] = $fileContent;
 $uploadVars['token'] = 
 $array_[query][pages][key($array_[query][pages])][edittoken];
 
 $snoopy-set_submit_multipart();
 echo br/;
 if(!$snoopy-submit($api_url, $uploadVars))
 echo UPLOAD DENIED;
 else
 echo UPLOAD OK;
 echo br/;
 
 $array_ = unserialize($snoopy-results);
 echo br/---br/;
 print_r($array_);
 echo br/.br/;
 echo $snoopy-results;
 echo br/---;
 
 The execution of this code produce the output bellow:
 GOT TOKEN
 
 UPLOAD OK
 
 ---
 .
 ---
 
 It's supposed I should receive something like this in the last step:
 api
   upload result=Success filename=Test.txt
 
 imageinfo timestamp=2000-01-01T00:00:00Z user=127.0.0.1 anon= 
 size=1000 width=0 height=0 url=http://localhost/images/3/35/Test.txt; 
 descriptionurl=http://localhost/index.php/File:Test.txt; comment= 
 sha1=b8f32ebbf9512d8641d7e72c86614c2cee3e8108 metadata= mime=text/plain 
 bitdepth=0 /
 
   /upload
 /api
 
 
 In fact, nothing really happen, no file is uploaded (the file exists).
 
 Some useful information:
 PHP 5.3.3
 Ubuntu10.10
 mediawiki1.16.0
 
 ___
 Mediawiki-api mailing list
 Mediawiki-api@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

___
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api


[MediaWiki-CVS] SVN: [81323] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-02-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/81323

Revision: 81323
Author:   soxred93
Date: 2011-02-01 21:38:30 + (Tue, 01 Feb 2011)
Log Message:
---
Update to most recent messages

Modified Paths:
--

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Modified: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-02-01 21:22:24 UTC (rev 81322)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-02-01 21:38:30 UTC (rev 81323)
@@ -28,10 +28,18 @@
'toolbase-navigation-homepage' = 'Homepage',
'toolbase-navigation-api' = 'API',
'toolbase-navigation-user_id' = 'Find user ID',
+   'toolbase-navigation-autoedits' = 'Automated edit counter',

'toolbase-userid-submit' = 'Get user ID',
'toolbase-userid-title' = 'Find a user ID',
'toolbase-userid-result' = 'The user ID for b$1/b on a 
href=$3b$3/b/a is b$2/b.',
+   
+   'toolbase-autoedits-title' = 'Automated edit calculator',
+   'toolbase-autoedits-submit' = 'Calculate',
+   'toolbase-autoedits-approximate' = 'bApproximate/b number of edits 
using',
+   'toolbase-autoedits-totalauto' = 'Total number of automated edits',
+   'toolbase-autoedits-totalall' = 'Total edit count',
+   'toolbase-autoedits-pct' = 'Percentage of automated edits',
 
'toolbase-main-title' = 'Welcome!',
'toolbase-main-content' = 'Welcome to X!\'s tools! The tool suite is 
still in the process of being converted to the a href=$1Symfony/a 
framework. This process will take a while, but it should be working now. 
@@ -49,6 +57,7 @@

'toolbase-error-nouser' = '$1 is not a valid user',
'toolbase-error-nowiki' = '$1.$2.org is not a valid wiki',
+   'toolbase-error-toomanyedits' = '$1 has $2 edits. This tool has a 
maximum of $3 edits.',
 );
 
 /** Message documentation (Message documentation)
@@ -145,7 +154,7 @@
'toolbase-form-wiki' = 'ويكي',
 );
 
-/** Belarusian (Taraškievica orthography) (‪Беларуская (тарашкевіца)‬)
+/** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца))
  * @author EugeneZelenko
  * @author Jim-by
  */
@@ -710,7 +719,7 @@
'toolbase-error-nowiki' = '“$1.$2.org” không phải là wiki hợp lệ',
 );
 
-/** Simplified Chinese (‪中文(简体)‬)
+/** Simplified Chinese (中文(简体))
  * @author Hydra
  */
 $messages['zh-hans'] = array(
@@ -724,7 +733,7 @@
'toolbase-form-wiki' = '维基',
 );
 
-/** Traditional Chinese (‪中文(繁體)‬)
+/** Traditional Chinese (中文(繁體))
  * @author Mark85296341
  */
 $messages['zh-hant'] = array(


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [80741] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-01-21 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80741

Revision: 80741
Author:   soxred93
Date: 2011-01-22 03:03:30 + (Sat, 22 Jan 2011)
Log Message:
---
Updating to most recent i18n for Soxred93s Tools

Modified Paths:
--

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Modified: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-22 01:57:25 UTC (rev 80740)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-22 03:03:30 UTC (rev 80741)
@@ -46,7 +46,9 @@
 If you followed a link from somewhere, please a href=$1report a bug/a.
 /ul',
'toolbase-form-wiki' = 'Wiki',
+   
'toolbase-error-nouser' = '$1 is not a valid user',
+   'toolbase-error-nowiki' = '$1.$2.org is not a valid wiki',
 );
 
 /** Message documentation (Message documentation)


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [80501] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-01-18 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80501

Revision: 80501
Author:   soxred93
Date: 2011-01-18 17:34:11 + (Tue, 18 Jan 2011)
Log Message:
---
Add new message file.

Added Paths:
---

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Added: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
(rev 0)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-18 17:34:11 UTC (rev 80501)
@@ -0,0 +1,50 @@
+?php
+
+$messages = array (
+  'en' = 
+  array (
+'soxredtoolbase-1' = 'Find a User ID',
+'soxredtoolbase-2' = 'Wiki',
+'soxredtoolbase-3' = 'Get user ID',
+'soxredtoolbase-4' = 'X!\'s Tools',
+'soxredtoolbase-5' = 'Bugs',
+'soxredtoolbase-6' = 'Twitter',
+'soxredtoolbase-7' = 'Executed in %count% seconds',
+'soxredtoolbase-8' = 'Navigation',
+'soxredtoolbase-9' = 'Homepage',
+'soxredtoolbase-10' = 'View Source',
+'soxredtoolbase-11' = 'Change language',
+'soxredtoolbase-12' = 'The user ID for b$1/b is b$2/b.',
+'soxredtoolbase-13' = 'Global Toolserver Sitenotice:',
+'soxredtoolbase-14' = 'Server lagged by ',
+'soxredtoolbase-15' = 'years',
+'soxredtoolbase-16' = 'months',
+'soxredtoolbase-17' = 'weeks',
+'soxredtoolbase-18' = 'days',
+'soxredtoolbase-19' = 'hours',
+'soxredtoolbase-20' = 'minutes',
+'soxredtoolbase-21' = 'seconds',
+'soxredtoolbase-22' = '%name% is not a valid user',
+'soxredtoolbase-23' = 'The user ID for b%name%/b is b%id%/b.',
+'soxredtoolbase-24' = 'Welcome!',
+'soxredtoolbase-25' = 'Welcome to X!\'s tools! The tool suite is still in 
the process of being converted to the a href=\\$1Symfony/a framework. 
This process will take a while, but it should be working now. 
+
+For a list of tools that are currently running right now on this framework, 
see the sidebar to the right.
+
+Bugs can be reported at a href=\\$2Google Code/a.
+
+
+',
+'soxredtoolbase-26' = 'File not found',
+'soxredtoolbase-27' = '
+Oops! No page was found!
+
+Make sure that you typed the URL correctly.
+If you followed a link from somewhere, please a href=\\$1report a bug/a.
+/ul
+
+',
+'soxredtoolbase-28' = 'API',
+'soxredtoolbase-29' = '$1 is not a valid user',
+  ),
+);
\ No newline at end of file


Property changes on: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [80505] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-01-18 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80505

Revision: 80505
Author:   soxred93
Date: 2011-01-18 18:27:35 + (Tue, 18 Jan 2011)
Log Message:
---
Clean up i18n code for Soxred93's tools

Modified Paths:
--

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Modified: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-18 18:25:42 UTC (rev 80504)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-18 18:27:35 UTC (rev 80505)
@@ -3,29 +3,29 @@
 $messages = array (
   'en' = 
   array (
-'soxredtoolbase-1' = 'Find a User ID',
-'soxredtoolbase-2' = 'Wiki',
-'soxredtoolbase-3' = 'Get user ID',
-'soxredtoolbase-4' = 'X!\'s Tools',
-'soxredtoolbase-5' = 'Bugs',
-'soxredtoolbase-6' = 'Twitter',
-'soxredtoolbase-7' = 'Executed in %count% seconds',
-'soxredtoolbase-8' = 'Navigation',
-'soxredtoolbase-9' = 'Homepage',
-'soxredtoolbase-10' = 'View Source',
-'soxredtoolbase-11' = 'Change language',
-'soxredtoolbase-12' = 'The user ID for b$1/b is b$2/b.',
-'soxredtoolbase-13' = 'Global Toolserver Sitenotice:',
-'soxredtoolbase-14' = 'Server lagged by ',
-'soxredtoolbase-15' = 'years',
-'soxredtoolbase-16' = 'months',
-'soxredtoolbase-17' = 'weeks',
-'soxredtoolbase-18' = 'days',
-'soxredtoolbase-19' = 'hours',
-'soxredtoolbase-20' = 'minutes',
-'soxredtoolbase-21' = 'seconds',
-'soxredtoolbase-22' = '%name% is not a valid user',
-'soxredtoolbase-23' = 'The user ID for b%name%/b is b%id%/b.',
+'soxredtoolbase-1' = 'X!\'s Tools',
+'soxredtoolbase-2' = 'Bugs',
+'soxredtoolbase-3' = 'Twitter',
+'soxredtoolbase-4' = 'Global Toolserver Sitenotice:',
+'soxredtoolbase-5' = 'Server lagged by ',
+'soxredtoolbase-6' = 'years',
+'soxredtoolbase-7' = 'months',
+'soxredtoolbase-8' = 'weeks',
+'soxredtoolbase-9' = 'days',
+'soxredtoolbase-10' = 'hours',
+'soxredtoolbase-11' = 'minutes',
+'soxredtoolbase-12' = 'seconds',
+'soxredtoolbase-13' = 'Executed in $1 seconds',
+'soxredtoolbase-14' = 'Navigation',
+'soxredtoolbase-15' = 'Homepage',
+'soxredtoolbase-16' = 'Get user ID',
+'soxredtoolbase-17' = 'API',
+'soxredtoolbase-18' = 'View Source',
+'soxredtoolbase-19' = 'Wiki',
+'soxredtoolbase-20' = '$1 is not a valid user',
+'soxredtoolbase-21' = 'Find a User ID',
+'soxredtoolbase-22' = 'The user ID for b$1/b is b$2/b.',
+'soxredtoolbase-23' = 'Change language',
 'soxredtoolbase-24' = 'Welcome!',
 'soxredtoolbase-25' = 'Welcome to X!\'s tools! The tool suite is still in 
the process of being converted to the a href=\\$1Symfony/a framework. 
This process will take a while, but it should be working now. 
 
@@ -44,7 +44,5 @@
 /ul
 
 ',
-'soxredtoolbase-28' = 'API',
-'soxredtoolbase-29' = '$1 is not a valid user',
   ),
 );
\ No newline at end of file


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [80510] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-01-18 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80510

Revision: 80510
Author:   soxred93
Date: 2011-01-18 19:34:27 + (Tue, 18 Jan 2011)
Log Message:
---
Updating to most recent i18n for Soxred93s Tools

Modified Paths:
--

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Modified: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-18 19:19:40 UTC (rev 80509)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-18 19:34:27 UTC (rev 80510)
@@ -3,46 +3,58 @@
 $messages = array (
   'en' = 
   array (
-'soxredtoolbase-1' = 'X!\'s Tools',
-'soxredtoolbase-2' = 'Bugs',
-'soxredtoolbase-3' = 'Twitter',
-'soxredtoolbase-4' = 'Global Toolserver Sitenotice:',
-'soxredtoolbase-5' = 'Server lagged by ',
-'soxredtoolbase-6' = 'years',
-'soxredtoolbase-7' = 'months',
-'soxredtoolbase-8' = 'weeks',
-'soxredtoolbase-9' = 'days',
-'soxredtoolbase-10' = 'hours',
-'soxredtoolbase-11' = 'minutes',
-'soxredtoolbase-12' = 'seconds',
-'soxredtoolbase-13' = 'Executed in $1 seconds',
-'soxredtoolbase-14' = 'Navigation',
-'soxredtoolbase-15' = 'Homepage',
-'soxredtoolbase-16' = 'Get user ID',
-'soxredtoolbase-17' = 'API',
-'soxredtoolbase-18' = 'View Source',
-'soxredtoolbase-19' = 'Wiki',
-'soxredtoolbase-20' = '$1 is not a valid user',
-'soxredtoolbase-21' = 'Find a User ID',
-'soxredtoolbase-22' = 'The user ID for b$1/b is b$2/b.',
-'soxredtoolbase-23' = 'Change language',
-'soxredtoolbase-24' = 'Welcome!',
-'soxredtoolbase-25' = 'Welcome to X!\'s tools! The tool suite is still in 
the process of being converted to the a href=\\$1Symfony/a framework. 
This process will take a while, but it should be working now. 
+'toolbase-header-title' = 'X!\'s Tools',
+'toolbase-header-bugs' = 'Bugs',
+'toolbase-header-twitter' = 'Twitter',
+'toolbase-header-sitenotice' = 'Global Toolserver Sitenotice: $1',
+
+'toolbase-replag' = 'Server lagged by $1',
+'toolbase-replag-years' = 'years',
+'toolbase-replag-months' = 'months',
+'toolbase-replag-weeks' = 'weeks',
+'toolbase-replag-days' = 'days',
+'toolbase-replag-hours' = 'hours',
+'toolbase-replag-minutes' = 'minutes',
+'toolbase-replag-seconds' = 'seconds',
+
+'toolbase-footer-exectime' = 'Executed in $1 seconds',
+'toolbase-footer-source' = 'View Source',
+'toolbase-footer-language' = 'Change language',
+
+'toolbase-navigation' = 'Navigation',
+'toolbase-navigation-homepage' = 'Homepage',
+'toolbase-navigation-api' = 'API',
+
+'toolbase-userid-submit' = 'Get user ID',
+'toolbase-userid-title' = 'Find a User ID',
+'toolbase-userid-result' = 'The user ID for b$1/b is b$2/b.',
+
+
+'toolbase-main-title' = 'Welcome!',
+'toolbase-main-content' = 'Welcome to X!\'s tools! The tool suite is 
still in the process of being converted to the a href=$1Symfony/a 
framework. This process will take a while, but it should be working now. 
 
 For a list of tools that are currently running right now on this framework, 
see the sidebar to the right.
 
-Bugs can be reported at a href=\\$2Google Code/a.
+Bugs can be reported at a href=$2Google Code/a.
 
 
 ',
-'soxredtoolbase-26' = 'File not found',
-'soxredtoolbase-27' = '
+'toolbase-main-404' = 'File not found',
+'toolbase-main-404-content' = '
 Oops! No page was found!
 
 Make sure that you typed the URL correctly.
-If you followed a link from somewhere, please a href=\\$1report a bug/a.
+If you followed a link from somewhere, please a href=$1report a bug/a.
 /ul
 
 ',
+
+
+'toolbase-form-wiki' = 'Wiki',
+
+
+'toolbase-error-nouser' = '$1 is not a valid user',
+
+
   ),
 );
\ No newline at end of file


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [80522] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-01-18 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80522

Revision: 80522
Author:   soxred93
Date: 2011-01-18 21:53:31 + (Tue, 18 Jan 2011)
Log Message:
---
Updating to most recent i18n for Soxred93s Tools

Modified Paths:
--

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Modified: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-18 21:38:26 UTC (rev 80521)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-18 21:53:31 UTC (rev 80522)
@@ -22,10 +22,12 @@
'toolbase-footer-exectime' = 'Executed in $1 seconds',
'toolbase-footer-source' = 'View source',
'toolbase-footer-language' = 'Change language',
+   'toolbase-footer-translate' = 'Translate',

'toolbase-navigation' = 'Navigation',
'toolbase-navigation-homepage' = 'Homepage',
'toolbase-navigation-api' = 'API',
+   'toolbase-navigation-user_id' = 'Find user ID',

'toolbase-userid-submit' = 'Get user ID',
'toolbase-userid-title' = 'Find a user ID',


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [80539] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-01-18 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80539

Revision: 80539
Author:   soxred93
Date: 2011-01-19 00:06:30 + (Wed, 19 Jan 2011)
Log Message:
---
Updating to most recent i18n for Soxred93s Tools

Modified Paths:
--

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Modified: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-19 00:02:15 UTC (rev 80538)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-19 00:06:30 UTC (rev 80539)
@@ -5,7 +5,7 @@
  * @author soxred93
  */
 $messages['en'] = array (
-   'toolbase-header-title' = X!'s Tools,
+   'toolbase-header-title' = X!'s Tools (BETA),
'toolbase-header-bugs' = 'Bugs',
'toolbase-header-twitter' = 'Twitter',
'toolbase-header-sitenotice' = 'Global Toolserver Sitenotice: $1',


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [80556] trunk/extensions/ToolserverTools/Soxred93EditCounter/ ToolbaseMessages.i18n.php

2011-01-18 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80556

Revision: 80556
Author:   soxred93
Date: 2011-01-19 04:40:22 + (Wed, 19 Jan 2011)
Log Message:
---
Updating to most recent i18n for Soxred93s Tools

Modified Paths:
--

trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php

Modified: 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php
===
--- 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-19 04:02:50 UTC (rev 80555)
+++ 
trunk/extensions/ToolserverTools/Soxred93EditCounter/ToolbaseMessages.i18n.php  
2011-01-19 04:40:22 UTC (rev 80556)
@@ -31,7 +31,7 @@

'toolbase-userid-submit' = 'Get user ID',
'toolbase-userid-title' = 'Find a user ID',
-   'toolbase-userid-result' = 'The user ID for b$1/b is b$2/b.',
+   'toolbase-userid-result' = 'The user ID for b$1/b on a 
href=$3b$3/b/a is b$2/b.',
 
'toolbase-main-title' = 'Welcome!',
'toolbase-main-content' = 'Welcome to X!\'s tools! The tool suite is 
still in the process of being converted to the a href=$1Symfony/a 
framework. This process will take a while, but it should be working now. 


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[Toolserver-l] Sitenotice?

2011-01-18 Thread Soxred93
Whatever happened to that global sitenotice file that was mentioned here: [0]? 
Running  a ls -l on the file indicates it's been almost 7 months without an 
update. Is it still being used, or is it essentially deprecated? I still like 
the idea, but if it's not used anymore, I'd like to know if I can remove it.

-X!

[0] - http://www.mail-archive.com/toolserver-l@lists.wikimedia.org/msg01641.html___
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org)
https://lists.wikimedia.org/mailman/listinfo/toolserver-l
Posting guidelines for this list: 
https://wiki.toolserver.org/view/Mailing_list_etiquette

Re: [Wikitech-l] Minimum PHP now 5.2 in trunk (was: [Mediawiki-l] about requiring PHP 5.2)

2011-01-18 Thread Soxred93

On Jan 18, 2011, at 2:00 PM, Chad wrote:

 +1 here. a::b syntax is less keystrokes having to use an array. Also
 lets us remove the stupid hack from r68760[0] (probably similar things
 elsewhere in the code)

Can't forget the hack that is MWFunction::callArray, which is also a hack that 
is intended to fix PHP 5.1's incompatibillity. 

-X!


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[MediaWiki-CVS] SVN: [80445] trunk/phase3/tests/phpunit/includes/HooksTest.php

2011-01-17 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80445

Revision: 80445
Author:   soxred93
Date: 2011-01-17 16:43:12 + (Mon, 17 Jan 2011)
Log Message:
---
Followup to r80435: Forgot the svn add

Added Paths:
---
trunk/phase3/tests/phpunit/includes/HooksTest.php

Added: trunk/phase3/tests/phpunit/includes/HooksTest.php
===
--- trunk/phase3/tests/phpunit/includes/HooksTest.php   
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/HooksTest.php   2011-01-17 16:43:12 UTC 
(rev 80445)
@@ -0,0 +1,130 @@
+?php
+
+
+class HooksTest extends MediaWikiTestCase {
+   
+   
+   public function testOldStyleHooks() {
+   
+   $foo = 'Foo';
+   $bar = 'Bar';
+   
+   $i = new NothingClass();
+   
+   global $wgHooks;
+   
+   $wgHooks['MediaWikiHooksTest001'][] = array( $i, 
'someNonStatic' );
+   
+   wfRunHooks( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'fOO', $foo, 'Standard method' );
+   $foo = 'Foo';
+   
+   
+   $wgHooks['MediaWikiHooksTest001'][] = $i;
+   
+   wfRunHooks( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'foo', $foo, 'onEventName style' );
+   $foo = 'Foo';
+   
+   
+   $wgHooks['MediaWikiHooksTest001'][] = array( $i, 
'someNonStaticWithData', 'baz' );
+   
+   wfRunHooks( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'baz', $foo, 'Data included' );
+   $foo = 'Foo';
+   
+   
+   $wgHooks['MediaWikiHooksTest001'][] = array( $i, 'someStatic' );
+   
+   wfRunHooks( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'bah', $foo, 'Standard static method' );
+   $foo = 'Foo';
+   
+   
+   unset( $wgHooks['MediaWikiHooksTest001'] );
+   
+   }
+   
+   public function testNewStyleHooks() {
+   
+   $foo = 'Foo';
+   $bar = 'Bar';
+   
+   $i = new NothingClass();
+   
+   
+   Hooks::register( 'MediaWikiHooksTest001', array( $i, 
'someNonStatic' ) );
+   
+   Hooks::run( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'fOO', $foo, 'Standard method' );
+   $foo = 'Foo';
+   
+   
+   Hooks::register( 'MediaWikiHooksTest001', $i );
+   
+   Hooks::run( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'foo', $foo, 'onEventName style' );
+   $foo = 'Foo';
+   
+   
+   Hooks::register( 'MediaWikiHooksTest001', array( $i, 
'someNonStaticWithData', 'baz' ) );
+   
+   Hooks::run( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'baz', $foo, 'Data included' );
+   $foo = 'Foo';
+   
+   
+   Hooks::register( 'MediaWikiHooksTest001', array( $i, 
'someStatic' ) );
+   
+   Hooks::run( 'MediaWikiHooksTest001', array( $foo, $bar ) );
+   
+   $this-assertEquals( 'bah', $foo, 'Standard static method' );
+   $foo = 'Foo';
+   
+   }
+   
+}
+
+class NothingClass {
+   
+   static public function someStatic( $foo, $bar ) {
+   
+   $foo = 'bah';
+   
+   return true;
+   
+   }
+   
+   public function someNonStatic( $foo, $bar ) {
+   
+   $foo = 'fOO';
+   $bar = 'bAR';
+   
+   return true;
+   
+   }
+   
+   public function onMediaWikiHooksTest001( $foo, $bar ) {
+   
+   $foo = 'foo';
+   
+   return true;
+   
+   }
+   
+   public function someNonStaticWithData( $foo, $bar ) {
+   
+   $bar = $foo;
+   
+   return true;
+   
+   }
+   
+}


Property changes on: trunk/phase3/tests/phpunit/includes/HooksTest.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS

[MediaWiki-CVS] SVN: [80435] trunk/phase3

2011-01-16 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/80435

Revision: 80435
Author:   soxred93
Date: 2011-01-17 03:35:42 + (Mon, 17 Jan 2011)
Log Message:
---
Add new Hooks class, because $wgHooks globals are evil. 
$wgHooks['EventName'][] = $callback; -- Hooks::register( 'EventName', 
$callback );
wfRunHooks( 'EventName', array() ); -- Hooks::run( 'EventName', array() );
Tests added to complement change. Backwards compatibility added.

Modified Paths:
--
trunk/phase3/RELEASE-NOTES
trunk/phase3/includes/AutoLoader.php
trunk/phase3/includes/Hooks.php

Modified: trunk/phase3/RELEASE-NOTES
===
--- trunk/phase3/RELEASE-NOTES  2011-01-17 03:34:08 UTC (rev 80434)
+++ trunk/phase3/RELEASE-NOTES  2011-01-17 03:35:42 UTC (rev 80435)
@@ -49,6 +49,7 @@
 * New hook ArticlePrepareTextForEdit added, called when preparing text to be 
saved.
 * New parser option PreSaveTransform added, allows the pre-save transformation
   to be selectively disabled.
+* Alternative to $wgHooks implemented, using the new Hooks class. 
 
 === Bug fixes in 1.18 ===
 * (bug 23119) WikiError class and subclasses are now marked as deprecated

Modified: trunk/phase3/includes/AutoLoader.php
===
--- trunk/phase3/includes/AutoLoader.php2011-01-17 03:34:08 UTC (rev 
80434)
+++ trunk/phase3/includes/AutoLoader.php2011-01-17 03:35:42 UTC (rev 
80435)
@@ -105,6 +105,7 @@
'HistoryBlobStub' = 'includes/HistoryBlob.php',
'HistoryPage' = 'includes/HistoryPage.php',
'HistoryPager' = 'includes/HistoryPage.php',
+   'Hooks' = 'includes/Hooks.php',
'Html' = 'includes/Html.php',
'HTMLCacheUpdate' = 'includes/HTMLCacheUpdate.php',
'HTMLCacheUpdateJob' = 'includes/HTMLCacheUpdate.php',

Modified: trunk/phase3/includes/Hooks.php
===
--- trunk/phase3/includes/Hooks.php 2011-01-17 03:34:08 UTC (rev 80434)
+++ trunk/phase3/includes/Hooks.php 2011-01-17 03:35:42 UTC (rev 80435)
@@ -35,172 +35,268 @@
  * @param $args Array: parameters passed to hook functions
  * @return Boolean
  */
-function wfRunHooks($event, $args = array()) {
+function wfRunHooks( $event, $args = array() ) {
+   return Hooks::run( $event, $args );
+}
 
-   global $wgHooks;
+function hookErrorHandler( $errno, $errstr ) {
+   return Hooks::hookErrorHandler( $errno, $errstr );
+}
 
-   // Return quickly in the most common case
-   if ( !isset( $wgHooks[$event] ) ) {
-   return true;
-   }
+class MWHookException extends MWException {}
 
-   if (!is_array($wgHooks)) {
-   throw new MWException(Global hooks array is not an array!\n);
-   }
 
-   if (!is_array($wgHooks[$event])) {
-   throw new MWException(Hooks array for event '$event' is not an 
array!\n);
+/**
+ * Hooks class.
+ * 
+ * Used to supersede $wgHooks, because globals are EVIL.
+ *
+ */
+class Hooks {
+   
+   protected static $handlers = array();
+   
+   /**
+* Attach an event handler to a given hook
+* 
+* @access public
+* @param mixed $name Name of hook
+* @param mixed $callback Callback function to attach
+* @return void
+*/
+   public static function register( $name, $callback ) {
+   
+   if( !isset( self::$handlers[$name] ) ) {
+   self::$handlers[$name] = array();
+   }
+   
+   self::$handlers[$name][] = $callback;
+   
}
-
-   foreach ($wgHooks[$event] as $index = $hook) {
-
-   $object = null;
-   $method = null;
-   $func = null;
-   $data = null;
-   $have_data = false;
-   $closure = false;
-   $badhookmsg = false;
-
-   /* $hook can be: a function, an object, an array of $function 
and $data,
-* an array of just a function, an array of object and method, 
or an
-* array of object, method, and data.
-*/
-
-   if ( is_array( $hook ) ) {
-   if ( count( $hook )  1 ) {
-   throw new MWException(Empty array in hooks for 
 . $event . \n);
-   } else if ( is_object( $hook[0] ) ) {
-   $object = $wgHooks[$event][$index][0];
-   if ( $object instanceof Closure ) {
-   $closure = true;
-   if ( count( $hook )  1 ) {
+   
+   /**
+* Returns true if a hook has a function registered to it.
+* 
+* @access public
+* @param mixed $name Name of hook
+* @return bool
+*/
+   public static function isRegistered

Re: [Wikitech-l] Need some input

2011-01-05 Thread Soxred93
Ninjas  9000.


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[MediaWiki-CVS] SVN: [79519] trunk/phase3/includes/MWFunction.php

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79519

Revision: 79519
Author:   soxred93
Date: 2011-01-03 19:55:44 + (Mon, 03 Jan 2011)
Log Message:
---
Run is_callable, just to make sure the autoloader gets called.

Modified Paths:
--
trunk/phase3/includes/MWFunction.php

Modified: trunk/phase3/includes/MWFunction.php
===
--- trunk/phase3/includes/MWFunction.php2011-01-03 19:50:01 UTC (rev 
79518)
+++ trunk/phase3/includes/MWFunction.php2011-01-03 19:55:44 UTC (rev 
79519)
@@ -30,6 +30,9 @@
}
}

+   // Run autoloader (workaround for call_user_func_array bug: 
http://bugs.php.net/bug.php?id=51329)
+   is_callable( $callback );
+   
return $callback;
}



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79523] trunk/phase3/includes/MWFunction.php

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79523

Revision: 79523
Author:   soxred93
Date: 2011-01-03 20:19:51 + (Mon, 03 Jan 2011)
Log Message:
---
Throw an exception if calling parent or self on MWFunction.

Modified Paths:
--
trunk/phase3/includes/MWFunction.php

Modified: trunk/phase3/includes/MWFunction.php
===
--- trunk/phase3/includes/MWFunction.php2011-01-03 20:18:52 UTC (rev 
79522)
+++ trunk/phase3/includes/MWFunction.php2011-01-03 20:19:51 UTC (rev 
79523)
@@ -30,6 +30,14 @@
}
}

+   $callback = (array) $callback;
+   
+   if( count( $callback ) == 2  $callback[0] == 'self' || 
$callback[0] == 'parent' ) {
+   
+   throw new MWException( 'MWFunction cannot call 
self::method() or parent::method()' );
+   
+   }
+   
// Run autoloader (workaround for call_user_func_array bug: 
http://bugs.php.net/bug.php?id=51329)
is_callable( $callback );



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79529] trunk/phase3/tests/phpunit/includes/MWFunctionTest.php

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79529

Revision: 79529
Author:   soxred93
Date: 2011-01-03 21:14:22 + (Mon, 03 Jan 2011)
Log Message:
---
Followup r79523: Test that calling self:: and parent:: throws exception

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/MWFunctionTest.php

Modified: trunk/phase3/tests/phpunit/includes/MWFunctionTest.php
===
--- trunk/phase3/tests/phpunit/includes/MWFunctionTest.php  2011-01-03 
21:04:05 UTC (rev 79528)
+++ trunk/phase3/tests/phpunit/includes/MWFunctionTest.php  2011-01-03 
21:14:22 UTC (rev 79529)
@@ -50,6 +50,22 @@

}

+   /**
+* @expectedException MWException
+*/
+   function testCallingParentFails() {
+   
+   MWFunction::call( 'parent::foo' );
+   }
+   
+   /**
+* @expectedException MWException
+*/
+   function testCallingSelfFails() {
+   
+   MWFunction::call( 'self::foo' );
+   }
+   
public static function someMethod() {
return func_get_args();
}


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79530] trunk/phase3/tests/phpunit/includes/JsonTest.php

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79530

Revision: 79530
Author:   soxred93
Date: 2011-01-03 21:14:51 + (Mon, 03 Jan 2011)
Log Message:
---
Add JSON test case

Added Paths:
---
trunk/phase3/tests/phpunit/includes/JsonTest.php

Added: trunk/phase3/tests/phpunit/includes/JsonTest.php
===
--- trunk/phase3/tests/phpunit/includes/JsonTest.php
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/JsonTest.php2011-01-03 21:14:51 UTC 
(rev 79530)
@@ -0,0 +1,33 @@
+?php
+
+class JsonTest extends MediaWikiTestCase {
+   
+   function testPHPBug46944Test() {
+   
+   $this-assertNotEquals( 
+   '\ud840\udc00', 
+   strtolower( FormatJson::encode( \xf0\xa0\x80\x80 ) ),
+   'Test encoding an broken json_encode character 
(U+2)'
+   );
+   
+   
+   }
+   
+   function testDecodeVarTypes() {
+   
+   $this-assertInternalType( 
+   'object',   
+   FormatJson::decode( '{Name: Cheeso, Rank: 7}' ),
+   'Default to object'
+   );
+   
+   $this-assertInternalType( 
+   'array',
+   FormatJson::decode( '{Name: Cheeso, Rank: 7}', 
true ),
+   'Optional array'
+   );
+   
+   }
+   
+}
+


Property changes on: trunk/phase3/tests/phpunit/includes/JsonTest.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79532] trunk/phase3/tests/phpunit/includes/api

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79532

Revision: 79532
Author:   soxred93
Date: 2011-01-03 21:36:49 + (Mon, 03 Jan 2011)
Log Message:
---
Add API format testing

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/api/ApiSetup.php

Added Paths:
---
trunk/phase3/tests/phpunit/includes/api/format/
trunk/phase3/tests/phpunit/includes/api/format/ApiFormatPhpTest.php
trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php

Modified: trunk/phase3/tests/phpunit/includes/api/ApiSetup.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiSetup.php2011-01-03 
21:33:10 UTC (rev 79531)
+++ trunk/phase3/tests/phpunit/includes/api/ApiSetup.php2011-01-03 
21:36:49 UTC (rev 79532)
@@ -17,7 +17,7 @@
$this-setupUser();
}
 
-   protected function doApiRequest( $params, $data = null ) {
+   protected function doApiRequest( $params, $data = null, $appendModule = 
false ) {
$_SESSION = isset( $data[2] ) ? $data[2] : array();
 
$req = new FauxRequest( $params, true, $_SESSION );
@@ -27,6 +27,8 @@
$data[0] = $module-getResultData();
$data[1] = $req;
$data[2] = $_SESSION;
+   
+   if( $appendModule ) $data[3] = $module;
 
return $data;
}

Added: trunk/phase3/tests/phpunit/includes/api/format/ApiFormatPhpTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/format/ApiFormatPhpTest.php 
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/api/format/ApiFormatPhpTest.php 
2011-01-03 21:36:49 UTC (rev 79532)
@@ -0,0 +1,26 @@
+?php
+
+require_once dirname( __FILE__ ) . '/ApiFormatTestBase.php';
+
+/**
+ * @group API
+ */
+class ApiFormatPhpTest extends ApiFormatTestBase {
+
+   /*function setUp() {
+   parent::setUp();
+   $this-doLogin();
+   }*/
+
+   
+   function testValidPHPSyntax() {
+   
+   $data = $this-apiRequest( 'php', array( 'action' = 'query', 
'meta' = 'siteinfo' ) );
+   
+   $this-assertInternalType( 'array', unserialize( $data ) );
+   $this-assertGreaterThan( 0, count( (array) $data ) );
+   
+   
+   }
+
+}


Property changes on: 
trunk/phase3/tests/phpunit/includes/api/format/ApiFormatPhpTest.php
___
Added: svn:eol-style
   + native

Added: trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php
===
--- trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php
2011-01-03 21:36:49 UTC (rev 79532)
@@ -0,0 +1,28 @@
+?php
+
+require_once dirname( dirname( __FILE__ ) ) . '/ApiSetup.php';
+
+abstract class ApiFormatTestBase extends ApiTestSetup {
+
+   protected function apiRequest( $format, $params, $data = null ) {
+   
+   $data = parent::doApiRequest( $params, $data, true );
+   
+   $module = $data[3];
+   
+   $printer = $module-createPrinterByName( $format );
+   $printer-setUnescapeAmps(false);
+
+   $printer-initPrinter(false, true);
+
+   ob_start();
+   $printer-execute();
+   $out = ob_get_clean();
+   
+   $printer-closePrinter();
+
+   return $out;
+   }
+
+}
+


Property changes on: 
trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79543] trunk/phase3/tests/RunSeleniumTests.php

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79543

Revision: 79543
Author:   soxred93
Date: 2011-01-04 01:33:57 + (Tue, 04 Jan 2011)
Log Message:
---
Update to use the PHPUnit autoloader, define $IP

Modified Paths:
--
trunk/phase3/tests/RunSeleniumTests.php

Modified: trunk/phase3/tests/RunSeleniumTests.php
===
--- trunk/phase3/tests/RunSeleniumTests.php 2011-01-04 00:42:48 UTC (rev 
79542)
+++ trunk/phase3/tests/RunSeleniumTests.php 2011-01-04 01:33:57 UTC (rev 
79543)
@@ -24,13 +24,25 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+$IP = dirname( dirname( __FILE__ ) );
+
 define( 'SELENIUMTEST', true );
 
 //require_once( dirname( __FILE__ ) . '/../maintenance/commandLine.inc' );
 require( dirname( __FILE__ ) . '/../maintenance/Maintenance.php' );
-require_once( 'PHPUnit/Framework.php' );
+
+require_once( 'PHPUnit/Runner/Version.php' );
+if( version_compare( PHPUnit_Runner_Version::id(), '3.5.0', '=' ) ) {
+   # PHPUnit 3.5.0 introduced a nice autoloader based on class name
+   require_once( 'PHPUnit/Autoload.php' );
+} else {
+   # Keep the old pre PHPUnit 3.5.0 behaviour for compatibility
+   require_once( 'PHPUnit/TextUI/Command.php' );
+}
+
 require_once( 'PHPUnit/Extensions/SeleniumTestCase.php' );
 include_once( 'PHPUnit/Util/Log/JUnit.php' );
+
 require_once( dirname( __FILE__ ) . /selenium/SeleniumServerManager.php );
 
 class SeleniumTester extends Maintenance {


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79544] trunk/phase3

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79544

Revision: 79544
Author:   soxred93
Date: 2011-01-04 01:35:01 + (Tue, 04 Jan 2011)
Log Message:
---
Followup to r79532: Did I really need to implement a parameter? No, I did not.

Modified Paths:
--
trunk/phase3/includes/api/ApiFormatBase.php
trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php

Modified: trunk/phase3/includes/api/ApiFormatBase.php
===
--- trunk/phase3/includes/api/ApiFormatBase.php 2011-01-04 01:33:57 UTC (rev 
79543)
+++ trunk/phase3/includes/api/ApiFormatBase.php 2011-01-04 01:35:01 UTC (rev 
79544)
@@ -145,9 +145,11 @@
if ( is_null( $mime ) ) {
return; // skip any initialization
}
+   
+   if( !$this-getMain()-isInternalMode() ) {
+   header( Content-Type: $mime; charset=utf-8 );
+   }
 
-   header( Content-Type: $mime; charset=utf-8 );
-
if ( $isHtml ) {
 ?
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

Modified: trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php
===
--- trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php
2011-01-04 01:33:57 UTC (rev 79543)
+++ trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php
2011-01-04 01:35:01 UTC (rev 79544)
@@ -13,7 +13,7 @@
$printer = $module-createPrinterByName( $format );
$printer-setUnescapeAmps(false);
 
-   $printer-initPrinter(false, true);
+   $printer-initPrinter(false);
 
ob_start();
$printer-execute();


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79546] trunk/phase3

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79546

Revision: 79546
Author:   soxred93
Date: 2011-01-04 01:44:11 + (Tue, 04 Jan 2011)
Log Message:
---
Fix r79494: Don't prefix functions now that they're in their own class

Modified Paths:
--
trunk/phase3/includes/Fallback.php
trunk/phase3/includes/GlobalFunctions.php
trunk/phase3/tests/phpunit/includes/GlobalTest.php

Modified: trunk/phase3/includes/Fallback.php
===
--- trunk/phase3/includes/Fallback.php  2011-01-04 01:39:02 UTC (rev 79545)
+++ trunk/phase3/includes/Fallback.php  2011-01-04 01:44:11 UTC (rev 79546)
@@ -23,7 +23,7 @@
  */
 class Fallback {

-   public static function fallback_iconv( $from, $to, $string ) {
+   public static function iconv( $from, $to, $string ) {
if ( substr( $to, -8 ) == '//IGNORE' ) {
$to = substr( $to, 0, strlen( $to ) - 8 );
}
@@ -49,21 +49,21 @@
 * can be up to 100x slower than native if the text is heavily
 * multibyte and we have to slog through a few hundred kb.
 */
-   public static function fallback_mb_substr( $str, $start, $count='end' ) 
{
+   public static function mb_substr( $str, $start, $count='end' ) {
if( $start != 0 ) {
-   $split = self::fallback_mb_substr_split_unicode( $str, 
intval( $start ) );
+   $split = self::mb_substr_split_unicode( $str, intval( 
$start ) );
$str = substr( $str, $split );
}

if( $count !== 'end' ) {
-   $split = self::fallback_mb_substr_split_unicode( $str, 
intval( $count ) );
+   $split = self::mb_substr_split_unicode( $str, intval( 
$count ) );
$str = substr( $str, 0, $split );
}

return $str;
}

-   public static function fallback_mb_substr_split_unicode( $str, 
$splitPos ) {
+   public static function mb_substr_split_unicode( $str, $splitPos ) {
if( $splitPos == 0 ) {
return 0;
}
@@ -114,7 +114,7 @@
 * @param string $enc optional encoding; ignored
 * @return int
 */
-   public static function fallback_mb_strlen( $str, $enc = '' ) {
+   public static function mb_strlen( $str, $enc = '' ) {
$counts = count_chars( $str );
$total = 0;

@@ -139,7 +139,7 @@
 * @param $encoding String: optional encoding; ignored
 * @return int
 */
-   public static function fallback_mb_strpos( $haystack, $needle, $offset 
= 0, $encoding = '' ) {
+   public static function mb_strpos( $haystack, $needle, $offset = 0, 
$encoding = '' ) {
$needle = preg_quote( $needle, '/' );

$ar = array();
@@ -160,7 +160,7 @@
 * @param $encoding String: optional encoding; ignored
 * @return int
 */
-   public static function fallback_mb_strrpos( $haystack, $needle, $offset 
= 0, $encoding = '' ) {
+   public static function mb_strrpos( $haystack, $needle, $offset = 0, 
$encoding = '' ) {
$needle = preg_quote( $needle, '/' );

$ar = array();

Modified: trunk/phase3/includes/GlobalFunctions.php
===
--- trunk/phase3/includes/GlobalFunctions.php   2011-01-04 01:39:02 UTC (rev 
79545)
+++ trunk/phase3/includes/GlobalFunctions.php   2011-01-04 01:44:11 UTC (rev 
79546)
@@ -23,37 +23,37 @@
 
 if( !function_exists( 'iconv' ) ) {
function iconv( $from, $to, $string ) {
-   return Fallback::fallback_iconv( $from, $to, $string );
+   return Fallback::iconv( $from, $to, $string );
}
 }
 
 if ( !function_exists( 'mb_substr' ) ) {
function mb_substr( $str, $start, $count='end' ) {
-   return Fallback::fallback_mb_substr( $str, $start, $count );
+   return Fallback::mb_substr( $str, $start, $count );
}
 
function mb_substr_split_unicode( $str, $splitPos ) {
-   return Fallback::fallback_mb_substr_split_unicode( $str, 
$splitPos );
+   return Fallback::mb_substr_split_unicode( $str, $splitPos );
}
 }
 
 if ( !function_exists( 'mb_strlen' ) ) {
function mb_strlen( $str, $enc = '' ) {
-   return Fallback::fallback_mb_strlen( $str, $enc );
+   return Fallback::mb_strlen( $str, $enc );
}
 }
 
 if( !function_exists( 'mb_strpos' ) ) {

function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
-   return Fallback::fallback_mb_strpos( $haystack, $needle, 
$offset, $encoding );
+   return Fallback::mb_strpos( $haystack, $needle, $offset

[MediaWiki-CVS] SVN: [79547] trunk/phase3

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79547

Revision: 79547
Author:   soxred93
Date: 2011-01-04 01:51:48 + (Tue, 04 Jan 2011)
Log Message:
---
Forcing array breaks MWFunction with 2 parameters

Modified Paths:
--
trunk/phase3/includes/MWFunction.php
trunk/phase3/tests/phpunit/includes/GlobalTest.php

Modified: trunk/phase3/includes/MWFunction.php
===
--- trunk/phase3/includes/MWFunction.php2011-01-04 01:44:11 UTC (rev 
79546)
+++ trunk/phase3/includes/MWFunction.php2011-01-04 01:51:48 UTC (rev 
79547)
@@ -30,8 +30,6 @@
}
}

-   $callback = (array) $callback;
-   
if( count( $callback ) == 2  $callback[0] == 'self' || 
$callback[0] == 'parent' ) {

throw new MWException( 'MWFunction cannot call 
self::method() or parent::method()' );

Modified: trunk/phase3/tests/phpunit/includes/GlobalTest.php
===
--- trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-04 01:44:11 UTC 
(rev 79546)
+++ trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-04 01:51:48 UTC 
(rev 79547)
@@ -421,8 +421,8 @@
array_unshift( $param_set, $sampleUTF );

$this-assertEquals(
-   call_user_func_array( 'mb_substr', $param_set ),
-   call_user_func_array( array( 'Fallback', 
'mb_substr' ), $param_set ),
+   MWFunction::callArray( 'mb_substr', $param_set 
),
+   MWFunction::callArray( 'Fallback::mb_substr', 
$param_set ),
'Fallback mb_substr with params ' . implode( ', 
', $old_param_set )
);  
}
@@ -451,14 +451,14 @@
array_unshift( $param_set, $sampleUTF );

$this-assertEquals(
-   call_user_func_array( 'mb_strpos', $param_set ),
-   call_user_func_array( array( 'Fallback', 
'mb_strpos' ), $param_set ),
+   MWFunction::callArray( 'mb_strpos', $param_set 
),
+   MWFunction::callArray( 'Fallback::mb_strpos', 
$param_set ),
'Fallback mb_strpos with params ' . implode( ', 
', $old_param_set )
);  

$this-assertEquals(
-   call_user_func_array( 'mb_strrpos', $param_set 
),
-   call_user_func_array( array( 'Fallback', 
'mb_strrpos' ), $param_set ),
+   MWFunction::callArray( 'mb_strrpos', $param_set 
),
+   MWFunction::callArray( 'Fallback::mb_strrpos', 
$param_set ),
'Fallback mb_strrpos with params ' . implode( 
', ', $old_param_set )
);  
}


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79555] trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php

2011-01-03 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79555

Revision: 79555
Author:   soxred93
Date: 2011-01-04 03:22:40 + (Tue, 04 Jan 2011)
Log Message:
---
Add API query test

Added Paths:
---
trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php

Added: trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php2011-01-04 
03:22:40 UTC (rev 79555)
@@ -0,0 +1,73 @@
+?php
+
+require_once dirname( __FILE__ ) . '/ApiSetup.php';
+
+/**
+ * @group Database
+ */
+class ApiQueryTest extends ApiTestSetup {
+
+   function setUp() {
+   parent::setUp();
+   $this-doLogin();
+   }
+   
+   function testTitlesGetNormalized() {
+   
+   global $wgSitename;
+   
+   $data = $this-doApiRequest( array(
+   'action' = 'query',
+   'titles' = 'Project:articleA|article_B' ) );
+   
+   
+   $this-assertArrayHasKey( 'query', $data[0] );
+   $this-assertArrayHasKey( 'normalized', $data[0]['query'] );
+   
+   $this-assertEquals( 
+   array( 
+   'from' = 'Project:articleA',
+   'to' = $wgSitename . ':ArticleA'
+   ),
+   $data[0]['query']['normalized'][0]
+   );
+   
+   $this-assertEquals( 
+   array( 
+   'from' = 'article_B',
+   'to' = 'Article B'
+   ),
+   $data[0]['query']['normalized'][1]
+   );
+   
+   }
+   
+   function testTitlesAreRejectedIfInvalid() {
+   
+   global $wgSitename;
+   
+   
+   $title = false;
+   while( !$title || Title::newFromText( $title )-exists() ) {
+   $title = md5( mt_rand( 0, 1 ) + rand( 0, 999000 ) );
+   }
+   
+   $data = $this-doApiRequest( array(
+   'action' = 'query',
+   'titles' = $title . '|Talk:' ) );
+   
+   
+   $this-assertArrayHasKey( 'query', $data[0] );
+   $this-assertArrayHasKey( 'pages', $data[0]['query'] );
+   $this-assertEquals( 2, count( $data[0]['query']['pages'] ) );
+   
+   $this-assertArrayHasKey( -2, $data[0]['query']['pages'] );
+   $this-assertArrayHasKey( -1, $data[0]['query']['pages'] );
+   
+   $this-assertArrayHasKey( 'missing', 
$data[0]['query']['pages'][-2] );
+   $this-assertArrayHasKey( 'invalid', 
$data[0]['query']['pages'][-1] );
+   
+   
+   }
+
+}


Property changes on: trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79494] trunk/phase3

2011-01-02 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79494

Revision: 79494
Author:   soxred93
Date: 2011-01-02 15:54:18 + (Sun, 02 Jan 2011)
Log Message:
---
Followup to r79463: Move fallback functions to new Fallback class

Modified Paths:
--
trunk/phase3/includes/AutoLoader.php
trunk/phase3/includes/GlobalFunctions.php
trunk/phase3/tests/phpunit/includes/GlobalTest.php

Added Paths:
---
trunk/phase3/includes/Fallback.php

Modified: trunk/phase3/includes/AutoLoader.php
===
--- trunk/phase3/includes/AutoLoader.php2011-01-02 15:16:13 UTC (rev 
79493)
+++ trunk/phase3/includes/AutoLoader.php2011-01-02 15:54:18 UTC (rev 
79494)
@@ -86,6 +86,7 @@
'FatalError' = 'includes/Exception.php',
'FakeTitle' = 'includes/FakeTitle.php',
'FakeMemCachedClient' = 'includes/ObjectCache.php',
+   'Fallback' = 'includes/Fallback.php',
'FauxRequest' = 'includes/WebRequest.php',
'FauxResponse' = 'includes/WebResponse.php',
'FeedItem' = 'includes/Feed.php',

Added: trunk/phase3/includes/Fallback.php
===
--- trunk/phase3/includes/Fallback.php  (rev 0)
+++ trunk/phase3/includes/Fallback.php  2011-01-02 15:54:18 UTC (rev 79494)
@@ -0,0 +1,177 @@
+?php
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+/**
+ * Fallback functions for PHP installed without mbstring support
+ */
+class Fallback {
+   
+   public static function fallback_iconv( $from, $to, $string ) {
+   if ( substr( $to, -8 ) == '//IGNORE' ) {
+   $to = substr( $to, 0, strlen( $to ) - 8 );
+   }
+   if( strcasecmp( $from, $to ) == 0 ) {
+   return $string;
+   }
+   if( strcasecmp( $from, 'utf-8' ) == 0 ) {
+   return utf8_decode( $string );
+   }
+   if( strcasecmp( $to, 'utf-8' ) == 0 ) {
+   return utf8_encode( $string );
+   }
+   return $string;
+   }   
+   
+   /**
+* Fallback implementation for mb_substr, hardcoded to UTF-8.
+* Attempts to be at least _moderately_ efficient; best optimized
+* for relatively small offset and count values -- about 5x slower
+* than native mb_string in my testing.
+*
+* Larger offsets are still fairly efficient for Latin text, but
+* can be up to 100x slower than native if the text is heavily
+* multibyte and we have to slog through a few hundred kb.
+*/
+   public static function fallback_mb_substr( $str, $start, $count='end' ) 
{
+   if( $start != 0 ) {
+   $split = self::fallback_mb_substr_split_unicode( $str, 
intval( $start ) );
+   $str = substr( $str, $split );
+   }
+   
+   if( $count !== 'end' ) {
+   $split = self::fallback_mb_substr_split_unicode( $str, 
intval( $count ) );
+   $str = substr( $str, 0, $split );
+   }
+   
+   return $str;
+   }
+   
+   public static function fallback_mb_substr_split_unicode( $str, 
$splitPos ) {
+   if( $splitPos == 0 ) {
+   return 0;
+   }
+   
+   $byteLen = strlen( $str );
+   
+   if( $splitPos  0 ) {
+   if( $splitPos  256 ) {
+   // Optimize large string offsets by skipping 
ahead N bytes.
+   // This will cut out most of our slow time on 
Latin-based text,
+   // and 1/2 to 1/3 on East European and Asian 
scripts.
+   $bytePos = $splitPos;
+   while ( $bytePos  $byteLen  $str{$bytePos} 
= \x80  $str{$bytePos}  \xc0 ) {
+   ++$bytePos;
+   }
+   $charPos = mb_strlen( substr( $str, 0, $bytePos

[MediaWiki-CVS] SVN: [79499] trunk/phase3

2011-01-02 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79499

Revision: 79499
Author:   soxred93
Date: 2011-01-02 19:58:27 + (Sun, 02 Jan 2011)
Log Message:
---
-Add watchuser option to ApiBlock
-Write tests for ApiBlock

Modified Paths:
--
trunk/phase3/includes/api/ApiBlock.php

Added Paths:
---
trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php

Modified: trunk/phase3/includes/api/ApiBlock.php
===
--- trunk/phase3/includes/api/ApiBlock.php  2011-01-02 19:45:05 UTC (rev 
79498)
+++ trunk/phase3/includes/api/ApiBlock.php  2011-01-02 19:58:27 UTC (rev 
79499)
@@ -90,6 +90,7 @@
$form-BlockHideName = $params['hidename'];
$form-BlockAllowUsertalk = $params['allowusertalk']  
$wgBlockAllowsUTEdit;
$form-BlockReblock = $params['reblock'];
+   $form-BlockWatchUser = $params['watchuser'];
 
$userID = $expiry = null;
$retval = $form-doBlock( $userID, $expiry );
@@ -120,6 +121,9 @@
if ( $params['allowusertalk'] ) {
$res['allowusertalk'] = '';
}
+   if ( $params['watchuser'] ) {
+   $res['watchuser'] = '';
+   }
 
$this-getResult()-addValue( null, $this-getModuleName(), 
$res );
}
@@ -149,6 +153,7 @@
'hidename' = false,
'allowusertalk' = false,
'reblock' = false,
+   'watchuser' = false,
);
}
 
@@ -166,6 +171,7 @@
'hidename' = 'Hide the username from the block log. 
(Requires the hideuser right.)',
'allowusertalk' = 'Allow the user to edit their own 
talk page (depends on $wgBlockAllowsUTEdit)',
'reblock' = 'If the user is already blocked, overwrite 
the existing block',
+   'watchuser' = 'Watch the user/IP\'s user and talk 
pages',
);
}
 

Added: trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php2011-01-02 
19:58:27 UTC (rev 79499)
@@ -0,0 +1,67 @@
+?php
+
+require_once dirname( __FILE__ ) . '/ApiSetup.php';
+
+/**
+ * @group Database
+ * @group Destructive
+ */
+class ApiBlockTest extends ApiTestSetup {
+
+   function setUp() {
+   parent::setUp();
+   $this-doLogin();
+   }
+   
+   function getTokens() {
+   return $this-getTokenList( $this-sysopUser );
+   }
+
+   function addDBData() {
+   $user = User::newFromName( 'UTBlockee' );
+   
+   if ( $user-getId() == 0 ) {
+   $user-addToDatabase();
+   $user-setPassword( 'UTBlockeePassword' );
+
+   $user-saveSettings();
+   }
+   }
+   
+
+   
+   function testMakeNormalBlock() {
+   
+   $data = $this-getTokens();
+   
+   $user = User::newFromName( 'UTBlockee' );
+   
+   if ( !$user-getId() ) {
+   $this-markTestIncomplete( The user UTBlockee does not 
exist );
+   }
+   
+   if( !isset( $data[0]['query']['pages'] ) ) {
+   $this-markTestIncomplete( No block token found );
+   }
+   
+   $keys = array_keys( $data[0]['query']['pages'] );
+   $key = array_pop( $keys );
+   $pageinfo = $data[0]['query']['pages'][$key];
+   
+   $data = $this-doApiRequest( array(
+   'action' = 'block',
+   'user' = 'UTBlockee',
+   'reason' = 'Some reason',
+   'token' = $pageinfo['blocktoken'] ), $data );
+   
+   $block = Block::newFromDB('UTBlockee');
+   
+   $this-assertTrue( !is_null( $block ), 'Block is valid' );
+
+   $this-assertEquals( 'UTBlockee', $block-mAddress );
+   $this-assertEquals( 'Some reason', $block-mReason );
+   $this-assertEquals( 'infinity', $block-mExpiry );
+   
+   }
+
+}


Property changes on: trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79504] trunk/phase3

2011-01-02 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79504

Revision: 79504
Author:   soxred93
Date: 2011-01-03 02:10:05 + (Mon, 03 Jan 2011)
Log Message:
---
Move wfCreateObject to MWFunction::newObj. This uses the ReflectionClass to
instantiate a variable-length constructor in php 5.1.3 and up, and falls
back to the old, ugly, manual method that was in the old wfCreateObject
function. The instances in the core have been replaced.

Modified Paths:
--
trunk/phase3/includes/GlobalFunctions.php
trunk/phase3/includes/MWFunction.php
trunk/phase3/includes/SpecialPage.php
trunk/phase3/includes/StubObject.php
trunk/phase3/tests/phpunit/includes/MWFunctionTest.php

Modified: trunk/phase3/includes/GlobalFunctions.php
===
--- trunk/phase3/includes/GlobalFunctions.php   2011-01-03 02:05:10 UTC (rev 
79503)
+++ trunk/phase3/includes/GlobalFunctions.php   2011-01-03 02:10:05 UTC (rev 
79504)
@@ -2842,27 +2842,10 @@
  * Create an object with a given name and an array of construct parameters
  * @param $name String
  * @param $p Array: parameters
+ * @deprecated
  */
 function wfCreateObject( $name, $p ) {
-   $p = array_values( $p );
-   switch ( count( $p ) ) {
-   case 0:
-   return new $name;
-   case 1:
-   return new $name( $p[0] );
-   case 2:
-   return new $name( $p[0], $p[1] );
-   case 3:
-   return new $name( $p[0], $p[1], $p[2] );
-   case 4:
-   return new $name( $p[0], $p[1], $p[2], $p[3] );
-   case 5:
-   return new $name( $p[0], $p[1], $p[2], $p[3], $p[4] );
-   case 6:
-   return new $name( $p[0], $p[1], $p[2], $p[3], $p[4], 
$p[5] );
-   default:
-   throw new MWException( 'Too many arguments to 
construtor in wfCreateObject' );
-   }
+   return MWFunction::newObj( $name, $p );
 }
 
 function wfHttpOnlySafe() {

Modified: trunk/phase3/includes/MWFunction.php
===
--- trunk/phase3/includes/MWFunction.php2011-01-03 02:05:10 UTC (rev 
79503)
+++ trunk/phase3/includes/MWFunction.php2011-01-03 02:10:05 UTC (rev 
79504)
@@ -42,11 +42,92 @@

}

-   public static function callArray( $callback, $params ) {
+   public static function callArray( $callback, $argsarams ) {

$callback = self::cleanCallback( $callback );
-   return call_user_func_array( $callback, $params );
+   return call_user_func_array( $callback, $argsarams );

}

+   public static function newObj( $class, $args = array(), $force_fallback 
= false ) {
+   if( !count( $args ) ) {
+   return new $class;
+   }
+   
+   if ( version_compare( PHP_VERSION, '5.1.3', '' ) || 
$force_fallback ) {
+   
+   //If only MW needed 5.1.3 and up... sigh
+   
+   $args = array_values( $args );
+   switch ( count( $args ) ) {
+   case 0:
+   return new $class;
+   case 1:
+   return new $class( $args[0] );
+   case 2:
+   return new $class( $args[0], $args[1] );
+   case 3:
+   return new $class( $args[0], $args[1], 
$args[2] );
+   case 4:
+   return new $class( $args[0], $args[1], 
$args[2], $args[3] );
+   case 5:
+   return new $class( $args[0], $args[1], 
$args[2], $args[3], $args[4] );
+   case 6:
+   return new $class( $args[0], $args[1], 
$args[2], $args[3], $args[4], $args[5] );
+   case 7:
+   return new $class( $args[0], $args[1], 
$args[2], $args[3], $args[4], $args[5], $args[6] );
+   case 8:
+   return new $class( 
+   $args[0], $args[1], $args[2], 
$args[3], $args[4], $args[5], $args[6], 
+   $args[7] 
+   );
+   case 9:
+   return new $class( 
+   $args[0], $args[1], $args[2], 
$args[3], $args[4], $args[5], $args[6

[MediaWiki-CVS] SVN: [79505] trunk/phase3/tests/phpunit/includes/parser

2011-01-02 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79505

Revision: 79505
Author:   soxred93
Date: 2011-01-03 02:49:52 + (Mon, 03 Jan 2011)
Log Message:
---
Mark broken parser tests as broken

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

Modified: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2011-01-03 02:10:05 UTC (rev 79504)
+++ trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2011-01-03 02:49:52 UTC (rev 79505)
@@ -7,6 +7,8 @@
  * @group Parser
  * @group Destructive
  * @group Database
+ * @group Broken
+ * It's not really broken, but superseded
  */
 class MediaWikiParserTest extends MediaWikiTestCase {
public $count;  // Number of tests in the suite.

Modified: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-03 02:10:05 UTC (rev 79504)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-03 02:49:52 UTC (rev 79505)
@@ -468,6 +468,8 @@
 */
function testFuzzTests() {

+   $this-markTestIncomplete( 'Breaks tesla due to memory 
restrictions' );
+   
global $wgParserTestFiles;

$files = $wgParserTestFiles;


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79431] trunk/phase3/tests/phpunit/includes/parser

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79431

Revision: 79431
Author:   soxred93
Date: 2011-01-01 17:05:08 + (Sat, 01 Jan 2011)
Log Message:
---
Don't use the --verbose option anymore

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php

Modified: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 16:58:00 UTC (rev 79430)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 17:05:08 UTC (rev 79431)
@@ -302,9 +302,12 @@

foreach ( $iter as $t ) {

-   $result = $this-doRunTest( $t['test'], 
$t['input'], $t['result'], $t['options'], $t['config'] );
-   
-   //$this-recorder-record( $t['test'], $result 
);
+   try {
+   $result = $this-doRunTest( $t['test'], 
$t['input'], $t['result'], $t['options'], $t['config'] );
+   } catch( Exception $e ) {
+   $this-assertTrue( false, $t['test'] . 
' (failed: ' . $e-getMessage() . ')' );
+   }
+   
}

}

Modified: trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php
===
--- trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php
2011-01-01 16:58:00 UTC (rev 79430)
+++ trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php
2011-01-01 17:05:08 UTC (rev 79431)
@@ -2,19 +2,16 @@
 
 class PHPUnitParserTest extends ParserTest {
function showTesting( $desc ) {
-   if( MediaWikiPHPUnitCommand::$additionalArgs['verbose'] ) 
parent::showTesting( $desc );
/* Do nothing since we don't want to show info during PHPUnit 
testing. */
}
 
public function showSuccess( $desc ) {
PHPUnit_Framework_Assert::assertTrue( true, $desc );
-   if( MediaWikiPHPUnitCommand::$additionalArgs['verbose'] ) 
parent::showSuccess( $desc );
return true;
}
 
public function showFailure( $desc, $expected, $got ) {
PHPUnit_Framework_Assert::assertEquals( $expected, $got, $desc 
);
-   if( MediaWikiPHPUnitCommand::$additionalArgs['verbose'] ) 
parent::showFailure( $desc, $expected, $got );
return false;
}



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79435] trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79435

Revision: 79435
Author:   soxred93
Date: 2011-01-01 18:10:28 + (Sat, 01 Jan 2011)
Log Message:
---
Add fuzz tests to new parser tests (someone else should make sure this works as 
expected)

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

Modified: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 17:51:10 UTC (rev 79434)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 18:10:28 UTC (rev 79435)
@@ -16,6 +16,11 @@
public $hooks = array();
public $functionHooks = array();

+   //Fuzz test
+   public $maxFuzzTestLength = 300;
+   public $fuzzSeed = 0;
+   public $memoryLimit = 50;
+   
function setUp() {
global $wgContLang;
$wgContLang = Language::factory( 'en' );
@@ -311,12 +316,145 @@
}

}
+   
+   }
+   
+   /**
+* Run a fuzz test series
+* Draw input from a set of test files
+*/
+   function testFuzzTests() {

+   global $wgParserTestFiles;
+   
+   $files = $wgParserTestFiles;
+   
+   if( $this-getCliArg( 'file=' ) ) {
+   $files = array( $this-getCliArg( 'file=' ) );
+   }
+   
+   $dict = $this-getFuzzInput( $files );
+   $dictSize = strlen( $dict );
+   $logMaxLength = log( $this-maxFuzzTestLength );
+   
+   ini_set( 'memory_limit', $this-memoryLimit * 1048576 );
+
+   $user = new User;
+   $opts = ParserOptions::newFromUser( $user );
+   $title = Title::makeTitle( NS_MAIN, 'Parser_test' );
+
+   $id = 1;
+   
+   while ( true ) {

+   // Generate test input
+   mt_srand( ++$this-fuzzSeed );
+   $totalLength = mt_rand( 1, $this-maxFuzzTestLength );
+   $input = '';
+
+   while ( strlen( $input )  $totalLength ) {
+   $logHairLength = mt_rand( 0, 100 ) / 
100 * $logMaxLength;
+   $hairLength = min( intval( exp( $logHairLength 
) ), $dictSize );
+   $offset = mt_rand( 0, $dictSize - $hairLength );
+   $input .= substr( $dict, $offset, $hairLength );
+   }
+
+   $this-setupGlobals();
+   $parser = $this-getParser();
+
+   // Run the test
+   try {
+   $parser-parse( $input, $title, $opts );
+   $this-assertTrue( true, Test $id, fuzz seed 
{$this-fuzzSeed} );
+   } catch ( Exception $exception ) {
+   
+   ob_start();
+   var_dump( $input );
+   $input_dump = ob_get_contents();
+   ob_end_clean();
+   
+   $this-assertTrue( false, Test $id, fuzz seed 
{$this-fuzzSeed}. \n\nInput: $input_dump\n\nError: 
{$exception-getMessage()}\n\nBacktrace: {$exception-getTraceAsString()} );
+   }
+
+   $this-teardownGlobals();
+   $parser-__destruct();
+
+   if ( $id % 100 == 0 ) {
+   $usage = intval( memory_get_usage( true ) / 
$this-memoryLimit / 1048576 * 100 );
+   //echo {$this-fuzzSeed}: 
$numSuccess/$numTotal (mem: $usage%)\n;
+   if ( $usage  90 ) {
+   $ret = Out of memory:\n;
+   $memStats = $this-getMemoryBreakdown();
+
+   foreach ( $memStats as $name = $usage 
) {
+   $ret .= $name: $usage\n;
+   }
+   
+   throw new MWException( $ret );
+   return;
+   }
+   }
+   
+   $id++;
+   
+   }
}

+   /**
+* Get an input dictionary from a set of parser test files
+*/
+   function getFuzzInput( $filenames ) {
+   $dict

[MediaWiki-CVS] SVN: [79438] trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79438

Revision: 79438
Author:   soxred93
Date: 2011-01-01 20:57:13 + (Sat, 01 Jan 2011)
Log Message:
---
Reorder functions around, add some form of order to the test suite. 
It'd be nice to break some of these functions out to another class, but then 
again, 
I'd also like to see Windows actually become stable, MediaWiki to become fully 
class based, 
and Google to stop taking over the world. We can't all have what we want.

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

Modified: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 20:56:39 UTC (rev 79437)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 20:57:13 UTC (rev 79438)
@@ -21,6 +21,10 @@
public $fuzzSeed = 0;
public $memoryLimit = 50;

+   
+   
+   //PHPUnit + MediaWikiTestCase functions
+   
function setUp() {
global $wgContLang;
$wgContLang = Language::factory( 'en' );
@@ -88,6 +92,94 @@

}

+   public function tearDown() {
+   }
+   
+   function addDBData() {
+   # Hack: insert a few Wikipedia in-project interwiki prefixes,
+   # for testing inter-language links
+   $this-db-insert( 'interwiki', array(
+   array( 'iw_prefix' = 'wikipedia',
+  'iw_url'= 
'http://en.wikipedia.org/wiki/$1',
+  'iw_api'= '',
+  'iw_wikiid' = '',
+  'iw_local'  = 0 ),
+   array( 'iw_prefix' = 'meatball',
+  'iw_url'= 
'http://www.usemod.com/cgi-bin/mb.pl?$1',
+  'iw_api'= '',
+  'iw_wikiid' = '',
+  'iw_local'  = 0 ),
+   array( 'iw_prefix' = 'zh',
+  'iw_url'= 
'http://zh.wikipedia.org/wiki/$1',
+  'iw_api'= '',
+  'iw_wikiid' = '',
+  'iw_local'  = 1 ),
+   array( 'iw_prefix' = 'es',
+  'iw_url'= 
'http://es.wikipedia.org/wiki/$1',
+  'iw_api'= '',
+  'iw_wikiid' = '',
+  'iw_local'  = 1 ),
+   array( 'iw_prefix' = 'fr',
+  'iw_url'= 
'http://fr.wikipedia.org/wiki/$1',
+  'iw_api'= '',
+  'iw_wikiid' = '',
+  'iw_local'  = 1 ),
+   array( 'iw_prefix' = 'ru',
+  'iw_url'= 
'http://ru.wikipedia.org/wiki/$1',
+  'iw_api'= '',
+  'iw_wikiid' = '',
+  'iw_local'  = 1 ),
+   ) );
+
+
+   # Update certain things in site_stats
+   $this-db-insert( 'site_stats', array( 'ss_row_id' = 1, 
'ss_images' = 2, 'ss_good_articles' = 1 ) );
+
+   # Reinitialise the LocalisationCache to match the database state
+   Language::getLocalisationCache()-unloadAll();
+
+   # Make a new message cache
+   global $wgMessageCache, $wgMemc;
+   $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
+
+   $this-uploadDir = $this-setupUploadDir();
+   
+   $user = User::newFromId( 0 );
+   
+   $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) 
);
+   $image-recordUpload2( '', 'Upload of some lame file', 'Some 
lame file', array(
+   'size'= 12345,
+   'width'   = 1941,
+   'height'  = 220,
+   'bits'= 24,
+   'media_type'  = MEDIATYPE_BITMAP,
+   'mime'= 'image/jpeg',
+   'metadata'= serialize( array() ),
+   'sha1'= wfBaseConvert( '', 16, 36, 31 ),
+   'fileExists'  = true
+   ), $this-db-timestamp( '20010115123500' ), $user );
+
+   # This image will be blacklisted in [[MediaWiki:Bad image list]]
+   $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
+   $image-recordUpload2( '', 'zomgnotcensored', 'Borderline 
image', array

[MediaWiki-CVS] SVN: [79447] trunk/phase3/tests

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79447

Revision: 79447
Author:   soxred93
Date: 2011-01-01 22:16:54 + (Sat, 01 Jan 2011)
Log Message:
---
Followup r79443: Add some form of organization to the test autoloader

Modified Paths:
--
trunk/phase3/tests/TestsAutoLoader.php
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

Modified: trunk/phase3/tests/TestsAutoLoader.php
===
--- trunk/phase3/tests/TestsAutoLoader.php  2011-01-01 22:15:42 UTC (rev 
79446)
+++ trunk/phase3/tests/TestsAutoLoader.php  2011-01-01 22:16:54 UTC (rev 
79447)
@@ -4,10 +4,20 @@
 $testFolder = dirname( __FILE__ );
 
 $wgAutoloadClasses += array(
+
+   //PHPUnit
'MediaWikiTestCase' = $testFolder/phpunit/MediaWikiTestCase.php,
'MediaWikiPHPUnitCommand' = 
$testFolder/phpunit/MediaWikiPHPUnitCommand.php,
-   'ApiTestSetup' = $testFolder/phpunit/includes/api/ApiSetup.php,
-   'RandomImageGenerator' = 
$testFolder/phpunit/includes/api/RandomImageGenerator.php,
+   
+   //API
+   'ApiTestSetup' = 
$testFolder/phpunit/includes/api/ApiSetup.php,
+   'RandomImageGenerator' = 
$testFolder/phpunit/includes/api/RandomImageGenerator.php,
+   
+   //Parser
+   'ParserTestFileIterator' = 
$testFolder/phpunit/includes/parser/NewParserHelpers.php,
+   
+   
+   //Selenium
'SeleniumTestConstants' = 
$testFolder/selenium/SeleniumTestConstants.php,
 );
 

Modified: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 22:15:42 UTC (rev 79446)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 22:16:54 UTC (rev 79447)
@@ -1,7 +1,5 @@
 ?php
 
-require_once( dirname( __FILE__ ) . '/NewParserHelpers.php' );
-
 /**
  * @group Database
  */
@@ -12,6 +10,8 @@
public $runDisabled = false;
public $regex = '';
public $showProgress = true;
+   public $savedInitialGlobals = array();
+   public $savedWeirdGlobals = array();
public $savedGlobals = array();
public $hooks = array();
public $functionHooks = array();
@@ -26,7 +26,7 @@
//PHPUnit + MediaWikiTestCase functions

function setUp() {
-   global $wgContLang;
+   global $wgContLang, $wgUseDatabaseMessages, $wgMsgCacheExpiry, 
$wgNamespaceProtection, $wgNamespaceAliases;
$wgContLang = Language::factory( 'en' );


@@ -41,22 +41,15 @@

$this-keepUploads = $this-getCliArg( 'keep-uploads' );

-   
-   
-   global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, 
$wgDeferredUpdateList,
-   $wgUser, $wgLang, $wgOut, $wgRequest, 
$wgStyleDirectory, $wgEnableParserCache,
-   $wgMessageCache, $wgUseDatabaseMessages, 
$wgMsgCacheExpiry, $parserMemc,
-   $wgNamespaceAliases, $wgNamespaceProtection, 
$wgLocalFileRepo,
-   $wgThumbnailScriptPath, $wgScriptPath,
-   $wgArticlePath, $wgStyleSheetPath, $wgScript, 
$wgStylePath;
-
-   $wgScript = '/index.php';
-   $wgScriptPath = '/';
-   $wgArticlePath = '/wiki/$1';
-   $wgStyleSheetPath = '/skins';
-   $wgStylePath = '/skins';
-   $wgThumbnailScriptPath = false;
-   $wgLocalFileRepo = array(
+   $tmpGlobals = array();
+   
+   $tmpGlobals['wgScript'] = '/index.php';
+   $tmpGlobals['wgScriptPath'] = '/';
+   $tmpGlobals['wgArticlePath'] = '/wiki/$1';
+   $tmpGlobals['wgStyleSheetPath'] = '/skins';
+   $tmpGlobals['wgStylePath'] = '/skins';
+   $tmpGlobals['wgThumbnailScriptPath'] = false;
+   $tmpGlobals['wgLocalFileRepo'] = array(
'class' = 'LocalRepo',
'name' = 'local',
'directory' = wfTempDir() . '/test-repo',
@@ -65,34 +58,59 @@
'hashLevels' = 2,
'transformVia404' = false,
);
-   $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
-   $wgNamespaceAliases['Image'] = NS_FILE;
-   $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
+   
+   var_dump(2);
 
-
-   $wgEnableParserCache = false;
-   $wgDeferredUpdateList = array();
-   $wgMemc = wfGetMainCache();
+   $tmpGlobals['wgEnableParserCache'] = false

[MediaWiki-CVS] SVN: [79449] trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79449

Revision: 79449
Author:   soxred93
Date: 2011-01-01 22:19:22 + (Sat, 01 Jan 2011)
Log Message:
---
Fix r79447: Remove debugging code

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

Modified: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 22:16:58 UTC (rev 79448)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 22:19:22 UTC (rev 79449)
@@ -59,8 +59,6 @@
'transformVia404' = false,
);

-   var_dump(2);
-
$tmpGlobals['wgEnableParserCache'] = false;
$tmpGlobals['wgDeferredUpdateList'] = array();
$tmpGlobals['wgMemc'] = wfGetMainCache();


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79463] trunk/phase3/includes/GlobalFunctions.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79463

Revision: 79463
Author:   soxred93
Date: 2011-01-02 01:29:00 + (Sun, 02 Jan 2011)
Log Message:
---
Move fallback function creation out of function_exists() conditionals.
This allows for unit testing of the fallback functions to ensure that
they work like the real functions do

Modified Paths:
--
trunk/phase3/includes/GlobalFunctions.php

Modified: trunk/phase3/includes/GlobalFunctions.php
===
--- trunk/phase3/includes/GlobalFunctions.php   2011-01-02 00:10:42 UTC (rev 
79462)
+++ trunk/phase3/includes/GlobalFunctions.php   2011-01-02 01:29:00 UTC (rev 
79463)
@@ -20,170 +20,206 @@
  * Re-implementations of newer functions or functions in non-standard
  * PHP extensions may be included here.
  */
+
+# iconv support is not in the default configuration and so may not be present.
+# Assume will only ever use utf-8 and iso-8859-1.
+# This will *not* work in all circumstances.
+function fallback_iconv( $from, $to, $string ) {
+   if ( substr( $to, -8 ) == '//IGNORE' ) {
+   $to = substr( $to, 0, strlen( $to ) - 8 );
+   }
+   if( strcasecmp( $from, $to ) == 0 ) {
+   return $string;
+   }
+   if( strcasecmp( $from, 'utf-8' ) == 0 ) {
+   return utf8_decode( $string );
+   }
+   if( strcasecmp( $to, 'utf-8' ) == 0 ) {
+   return utf8_encode( $string );
+   }
+   return $string;
+}
+
 if( !function_exists( 'iconv' ) ) {
-   # iconv support is not in the default configuration and so may not be 
present.
-   # Assume will only ever use utf-8 and iso-8859-1.
-   # This will *not* work in all circumstances.
function iconv( $from, $to, $string ) {
-   if ( substr( $to, -8 ) == '//IGNORE' ) {
-   $to = substr( $to, 0, strlen( $to ) - 8 );
-   }
-   if( strcasecmp( $from, $to ) == 0 ) {
-   return $string;
-   }
-   if( strcasecmp( $from, 'utf-8' ) == 0 ) {
-   return utf8_decode( $string );
-   }
-   if( strcasecmp( $to, 'utf-8' ) == 0 ) {
-   return utf8_encode( $string );
-   }
-   return $string;
+   return fallback_iconv( $from, $to, $string )
}
 }
 
-if ( !function_exists( 'mb_substr' ) ) {
-   /**
-* Fallback implementation for mb_substr, hardcoded to UTF-8.
-* Attempts to be at least _moderately_ efficient; best optimized
-* for relatively small offset and count values -- about 5x slower
-* than native mb_string in my testing.
-*
-* Larger offsets are still fairly efficient for Latin text, but
-* can be up to 100x slower than native if the text is heavily
-* multibyte and we have to slog through a few hundred kb.
-*/
-   function mb_substr( $str, $start, $count='end' ) {
-   if( $start != 0 ) {
-   $split = mb_substr_split_unicode( $str, intval( $start 
) );
-   $str = substr( $str, $split );
-   }
 
-   if( $count !== 'end' ) {
-   $split = mb_substr_split_unicode( $str, intval( $count 
) );
-   $str = substr( $str, 0, $split );
-   }
 
-   return $str;
+
+/**
+ * Fallback implementation for mb_substr, hardcoded to UTF-8.
+ * Attempts to be at least _moderately_ efficient; best optimized
+ * for relatively small offset and count values -- about 5x slower
+ * than native mb_string in my testing.
+ *
+ * Larger offsets are still fairly efficient for Latin text, but
+ * can be up to 100x slower than native if the text is heavily
+ * multibyte and we have to slog through a few hundred kb.
+ */
+function fallback_mb_substr( $str, $start, $count='end' ) {
+   if( $start != 0 ) {
+   $split = fallback_mb_substr_split_unicode( $str, intval( $start 
) );
+   $str = substr( $str, $split );
}
 
-   function mb_substr_split_unicode( $str, $splitPos ) {
-   if( $splitPos == 0 ) {
-   return 0;
-   }
+   if( $count !== 'end' ) {
+   $split = fallback_mb_substr_split_unicode( $str, intval( $count 
) );
+   $str = substr( $str, 0, $split );
+   }
 
-   $byteLen = strlen( $str );
+   return $str;
+}
 
-   if( $splitPos  0 ) {
-   if( $splitPos  256 ) {
-   // Optimize large string offsets by skipping 
ahead N bytes.
-   // This will cut out most of our slow time on 
Latin-based text,
-   // and 1/2 to 1/3 on East European and Asian 
scripts.
-   $bytePos = $splitPos

[MediaWiki-CVS] SVN: [79465] trunk/phase3/includes/GlobalFunctions.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79465

Revision: 79465
Author:   soxred93
Date: 2011-01-02 01:35:24 + (Sun, 02 Jan 2011)
Log Message:
---
Fix r79463 and r79464: Syntax error

Modified Paths:
--
trunk/phase3/includes/GlobalFunctions.php

Modified: trunk/phase3/includes/GlobalFunctions.php
===
--- trunk/phase3/includes/GlobalFunctions.php   2011-01-02 01:34:26 UTC (rev 
79464)
+++ trunk/phase3/includes/GlobalFunctions.php   2011-01-02 01:35:24 UTC (rev 
79465)
@@ -120,7 +120,7 @@
 
 if ( !function_exists( 'mb_substr' ) ) {
function mb_substr( $str, $start, $count='end' ) {
-   return fallback_mb_substr( $str, $start, $count )
+   return fallback_mb_substr( $str, $start, $count );
}
 
function mb_substr_split_unicode( $str, $splitPos ) {


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79467] trunk/phase3/tests/phpunit/includes/GlobalTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79467

Revision: 79467
Author:   soxred93
Date: 2011-01-02 01:59:52 + (Sun, 02 Jan 2011)
Log Message:
---
Add some wfDebug() unit tests

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/GlobalTest.php

Modified: trunk/phase3/tests/phpunit/includes/GlobalTest.php
===
--- trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 01:51:44 UTC 
(rev 79466)
+++ trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 01:59:52 UTC 
(rev 79467)
@@ -464,6 +464,32 @@
}

}
+   
+   
+   function testDebugFunctionTest() {
+   global $wgDebugLogFile;
+   
+   $old_log_file = $wgDebugLogFile;
+   
+   $wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
+   
+   
+   wfDebug( This is a normal string );
+   $this-assertEquals( This is a normal string, 
file_get_contents( $wgDebugLogFile ) );
+   unlink( $wgDebugLogFile );
+   
+   wfDebug( This is nöt an ASCII string );
+   $this-assertEquals( This is nöt an ASCII string, 
file_get_contents( $wgDebugLogFile ) );
+   unlink( $wgDebugLogFile );
+   
+   wfDebug( \00305This has böth UTF and control chars\003 );
+   $this-assertEquals(  05This has böth UTF and control chars , 
file_get_contents( $wgDebugLogFile ) );
+   unlink( $wgDebugLogFile );
+   
+   
+   $wgDebugLogFile = $old_log_file;
+   
+   }
 
/* TODO: many more! */
 }


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79468] trunk/phase3/tests/phpunit/includes/GlobalTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79468

Revision: 79468
Author:   soxred93
Date: 2011-01-02 02:16:32 + (Sun, 02 Jan 2011)
Log Message:
---
Followup r79467: Add more wfDebug() tests, complete with MockOutputPage

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/GlobalTest.php

Modified: trunk/phase3/tests/phpunit/includes/GlobalTest.php
===
--- trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 01:59:52 UTC 
(rev 79467)
+++ trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 02:16:32 UTC 
(rev 79468)
@@ -467,26 +467,58 @@


function testDebugFunctionTest() {
-   global $wgDebugLogFile;
+   
+   global $wgDebugLogFile, $wgOut, $wgShowDebug;

$old_log_file = $wgDebugLogFile;
-   
$wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );


+   
wfDebug( This is a normal string );
$this-assertEquals( This is a normal string, 
file_get_contents( $wgDebugLogFile ) );
unlink( $wgDebugLogFile );

+   
wfDebug( This is nöt an ASCII string );
$this-assertEquals( This is nöt an ASCII string, 
file_get_contents( $wgDebugLogFile ) );
unlink( $wgDebugLogFile );

+   
wfDebug( \00305This has böth UTF and control chars\003 );
$this-assertEquals(  05This has böth UTF and control chars , 
file_get_contents( $wgDebugLogFile ) );
unlink( $wgDebugLogFile );


+   
+   $old_wgOut = $wgOut;
+   $old_wgShowDebug = $wgShowDebug;
+   
+   $wgOut = new StubObject( 'wgOut', 'MockOutputPage' );
+   $wgOut-doNothing(); //just to unstub it
+   
+   $wgShowDebug = true;
+   
+   $message = \00305This has böth UTF and control chars\003;
+   
+   wfDebug( $message );
+   
+   if( $wgOut-message == JAJA is a stupid error message. Anyway, 
here's your message: $message ) {
+   $this-assertTrue( true, 'MockOutputPage called, set 
the proper message.' );
+   }
+   else {
+   $this-assertTrue( false, 'MockOutputPage was not 
called.' );
+   }
+   
+   unlink( $wgDebugLogFile );
+   
+   
+   $wgOut = $old_wgOut;
+   $wgShowDebug = $old_wgShowDebug;
+
+   
+   
+   
$wgDebugLogFile = $old_log_file;

}
@@ -495,3 +527,14 @@
 }
 
 
+class MockOutputPage {
+   
+   public $message;
+   
+   function debug( $message ) {
+   $this-message = JAJA is a stupid error message. Anyway, 
here's your message: $message;
+   }
+   
+   function doNothing() {}
+}
+


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79469] trunk/phase3/tests/phpunit/includes/GlobalTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79469

Revision: 79469
Author:   soxred93
Date: 2011-01-02 02:33:07 + (Sun, 02 Jan 2011)
Log Message:
---
Add more wfDebug tests

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/GlobalTest.php

Modified: trunk/phase3/tests/phpunit/includes/GlobalTest.php
===
--- trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 02:16:32 UTC 
(rev 79468)
+++ trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 02:33:07 UTC 
(rev 79469)
@@ -510,15 +510,22 @@
$this-assertTrue( false, 'MockOutputPage was not 
called.' );
}

+   $wgOut = $old_wgOut;
+   $wgShowDebug = $old_wgShowDebug;
unlink( $wgDebugLogFile );


-   $wgOut = $old_wgOut;
-   $wgShowDebug = $old_wgShowDebug;
-

+   wfDebugMem();
+   $this-assertGreaterThan( 5000, preg_replace( '/\D/', '', 
file_get_contents( $wgDebugLogFile ) ) );
+   unlink( $wgDebugLogFile );

+   wfDebugMem(true);
+   $this-assertGreaterThan( 500, preg_replace( '/\D/', '', 
file_get_contents( $wgDebugLogFile ) ) );
+   unlink( $wgDebugLogFile );

+   
+   
$wgDebugLogFile = $old_log_file;

}


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79473] trunk/phase3

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79473

Revision: 79473
Author:   soxred93
Date: 2011-01-02 04:38:04 + (Sun, 02 Jan 2011)
Log Message:
---
GlobalFunction additions: 
-in_string has a case-insensitive option
-wfClientAcceptsGzip has a force option to force resetting the static value, 
useful for unit tests

Unit tests for more global functions added

Modified Paths:
--
trunk/phase3/includes/GlobalFunctions.php
trunk/phase3/tests/phpunit/includes/GlobalTest.php

Modified: trunk/phase3/includes/GlobalFunctions.php
===
--- trunk/phase3/includes/GlobalFunctions.php   2011-01-02 04:37:06 UTC (rev 
79472)
+++ trunk/phase3/includes/GlobalFunctions.php   2011-01-02 04:38:04 UTC (rev 
79473)
@@ -1273,9 +1273,9 @@
  *
  * @return bool Whereas client accept gzip compression
  */
-function wfClientAcceptsGzip() {
+function wfClientAcceptsGzip( $force = false ) {
static $result = null;
-   if ( $result === null ) {
+   if ( $result === null || $force ) {
$result = false;
if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
# FIXME: we may want to blacklist some broken browsers
@@ -2426,10 +2426,14 @@
  *
  * @param $needle String
  * @param $str String
+ * @param $insensitive Boolean
  * @return Boolean
  */
-function in_string( $needle, $str ) {
-   return strpos( $str, $needle ) !== false;
+function in_string( $needle, $str, $insensitive = false ) {
+   $func = 'strpos';
+   if( $insensitive ) $func = 'stripos';
+   
+   return $func( $str, $needle ) !== false;
 }
 
 function wfSpecialList( $page, $details ) {

Modified: trunk/phase3/tests/phpunit/includes/GlobalTest.php
===
--- trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 04:37:06 UTC 
(rev 79472)
+++ trunk/phase3/tests/phpunit/includes/GlobalTest.php  2011-01-02 04:38:04 UTC 
(rev 79473)
@@ -529,7 +529,85 @@
$wgDebugLogFile = $old_log_file;

}
+   
+   function testClientAcceptsGzipTest() {
+   
+   $settings = array(
+   'gzip' = true,
+   'bzip' = false,
+   '*' = false,
+   'compress, gzip' = true,
+   'gzip;q=1.0' = true,
+   'foozip' = false,
+   'foo*zip' = false,
+   'gzip;q=abcde' = true, //is this REALLY valid?
+   'gzip;q=12345678.9' = true,
+   ' gzip' = true,
+   );
+   
+   if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) 
$old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
+   
+   foreach ( $settings as $encoding = $expect ) {
+   $_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding;
+   
+   $this-assertEquals( $expect, wfClientAcceptsGzip( true 
),
+   '$encoding' =  . wfBoolToStr( $expect ) );
+   }
+   
+   if( isset( $old_server_setting ) ) 
$_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
 
+   }
+   
+   
+   
+   function testSwapVarsTest() {
+   
+
+   $var1 = 1;
+   $var2 = 2;
+
+   $this-assertEquals( $var1, 1, 'var1 is set originally' );
+   $this-assertEquals( $var2, 2, 'var1 is set originally' );
+
+   swap( $var1, $var2 );
+
+   $this-assertEquals( $var1, 2, 'var1 is swapped' );
+   $this-assertEquals( $var2, 1, 'var2 is swapped' );
+
+   }
+
+
+   function testWfPercentTest() {
+
+   $pcts = array(
+   array( 6/7, '0.86%', 2, false ),
+   array( 3/3, '1%' ),
+   array( 22/7, '3.14286%', 5 ),
+   array( 3/6, '0.5%' ),
+   array( 1/3, '0%', 0 ),
+   array( 10/3, '0%', -1 ),
+   array( 3/4/5, '0.1%', 1 ),
+   array( 6/7*8, '6.8571428571%', 10 ),
+   );
+   
+   foreach( $pcts as $pct ) {
+   if( !isset( $pct[2] ) ) $pct[2] = 2;
+   if( !isset( $pct[3] ) ) $pct[3] = true;
+   
+   $this-assertEquals( wfPercent( $pct[0], $pct[2], 
$pct[3] ), $pct[1], $pct[1] );
+   }
+
+   }
+
+
+   function testInStringTest() {
+   
+   $this-assertTrue( in_string( 'foo', 'foobar' ), 'foo is in 
foobar' );
+   $this-assertFalse( in_string( 'Bar', 'foobar' ), 
'Case-sensitive by default' );
+   $this-assertTrue( in_string( 'Foo', 'foobar', true ), 
'Case-insensitive

[MediaWiki-CVS] SVN: [79476] trunk/phase3/tests/phpunit/includes/api

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79476

Revision: 79476
Author:   soxred93
Date: 2011-01-02 05:52:00 + (Sun, 02 Jan 2011)
Log Message:
---
Refactor much of the API testing code. 
Old: ApiWatchTest not only tested the watch module, but also tested the login 
module,
 and the login module test was also used to log in to the API for the other 
tests.
New: ApiWatchTest only contains watch-specific methods. The login testing has 
been moved
 to ApiTest. The code used to log in and get tokens have been moved to 
ApiSetup. Nice,
 organized, and much nicer than before. ApiUploadTest is still pretty 
fugly, though.

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/api/ApiSetup.php
trunk/phase3/tests/phpunit/includes/api/ApiTest.php
trunk/phase3/tests/phpunit/includes/api/ApiUploadTest.php
trunk/phase3/tests/phpunit/includes/api/ApiWatchTest.php

Modified: trunk/phase3/tests/phpunit/includes/api/ApiSetup.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiSetup.php2011-01-02 
04:46:44 UTC (rev 79475)
+++ trunk/phase3/tests/phpunit/includes/api/ApiSetup.php2011-01-02 
05:52:00 UTC (rev 79476)
@@ -39,6 +39,34 @@
 
$GLOBALS['wgUser'] = $this-sysopUser-user;
}
+   
+   function doLogin() {
+   $data = $this-doApiRequest( array(
+   'action' = 'login',
+   'lgname' = $this-sysopUser-userName,
+   'lgpassword' = $this-sysopUser-password ) );
+
+   $token = $data[0]['login']['token'];
+
+   $data = $this-doApiRequest( array(
+   'action' = 'login',
+   lgtoken = $token,
+   lgname = $this-sysopUser-userName,
+   lgpassword = $this-sysopUser-password ), $data );
+   
+   return $data;
+   }
+   
+   function getTokenList( $user ) {
+   $GLOBALS['wgUser'] = $user-user;
+   $data = $this-doApiRequest( array(
+   'action' = 'query',
+   'titles' = 'Main Page',
+   'intoken' = 'edit|delete|protect|move|block|unblock',
+   'prop' = 'info' ) );
+   return $data;
+   }
+   
 }
 
 class UserWrapper {

Modified: trunk/phase3/tests/phpunit/includes/api/ApiTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiTest.php 2011-01-02 04:46:44 UTC 
(rev 79475)
+++ trunk/phase3/tests/phpunit/includes/api/ApiTest.php 2011-01-02 05:52:00 UTC 
(rev 79476)
@@ -58,6 +58,7 @@
 * @expectedException UsageException
 */
function testApi() {
+   
$api = new ApiMain(
new FauxRequest( array( 'action' = 'help', 'format' = 
'xml' ) )
);
@@ -222,4 +223,66 @@
$this-assertThat( $sxe, $this-isInstanceOf( 
SimpleXMLElement ) );
$a = $sxe-query[0]-pages[0]-page[0]-attributes();
}
+   
+   function testRunLogin() {
+   $data = $this-doApiRequest( array(
+   'action' = 'login',
+   'lgname' = $this-sysopUser-userName,
+   'lgpassword' = $this-sysopUser-password ) );
+
+   $this-assertArrayHasKey( login, $data[0] );
+   $this-assertArrayHasKey( result, $data[0]['login'] );
+   $this-assertEquals( NeedToken, $data[0]['login']['result'] );
+   $token = $data[0]['login']['token'];
+
+   $data = $this-doApiRequest( array(
+   'action' = 'login',
+   lgtoken = $token,
+   lgname = $this-sysopUser-userName,
+   lgpassword = $this-sysopUser-password ), $data );
+
+   $this-assertArrayHasKey( login, $data[0] );
+   $this-assertArrayHasKey( result, $data[0]['login'] );
+   $this-assertEquals( Success, $data[0]['login']['result'] );
+   $this-assertArrayHasKey( 'lgtoken', $data[0]['login'] );
+   
+   return $data;
+   }
+   
+   function testGettingToken() {
+   foreach ( array( $this-user, $this-sysopUser ) as $user ) {
+   $this-runTokenTest( $user );
+   }
+   }
+
+   function runTokenTest( $user ) {
+   
+   $data = $this-getTokenList( $user );
+
+   $this-assertArrayHasKey( 'query', $data[0] );
+   $this-assertArrayHasKey( 'pages', $data[0]['query'] );
+   $keys = array_keys( $data[0]['query']['pages'] );
+   $key = array_pop( $keys );
+
+   $rights = $user-user-getRights();
+
+   $this-assertArrayHasKey( $key

[MediaWiki-CVS] SVN: [79477] trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79477

Revision: 79477
Author:   soxred93
Date: 2011-01-02 06:09:58 + (Sun, 02 Jan 2011)
Log Message:
---
Add API purge test (mainly as proof of concept for how API tests should be 
written)

Added Paths:
---
trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php

Added: trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php2011-01-02 
06:09:58 UTC (rev 79477)
@@ -0,0 +1,38 @@
+?php
+
+require_once dirname( __FILE__ ) . '/ApiSetup.php';
+
+/**
+ * @group Database
+ */
+class ApiPurgeTest extends ApiTestSetup {
+
+   function setUp() {
+   parent::setUp();
+   $this-doLogin();
+   }
+   
+   function testPurgeMainPage() {
+   
+   if ( !Title::newFromText( 'UTPage' )-exists() ) {
+   $this-markTestIncomplete( The article [[UTPage]] does 
not exist );
+   }
+   
+   $somePage = mt_rand();
+
+   $data = $this-doApiRequest( array(
+   'action' = 'purge',
+   'titles' = 'UTPage|' . $somePage ) );
+   
+   $this-assertArrayHasKey( 'purge', $data[0] );
+   $this-assertArrayHasKey( 0, $data[0]['purge'] );
+   $this-assertArrayHasKey( 'purged', $data[0]['purge'][0] );
+   $this-assertEquals( 'UTPage', $data[0]['purge'][0]['title'] );
+   
+   $this-assertArrayHasKey( 1, $data[0]['purge'] );
+   $this-assertArrayHasKey( 'missing', $data[0]['purge'][1] );
+   $this-assertEquals(  $somePage, $data[0]['purge'][1]['title'] 
);
+   
+   }
+
+}


Property changes on: trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79478] trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79478

Revision: 79478
Author:   soxred93
Date: 2011-01-02 06:15:32 + (Sun, 02 Jan 2011)
Log Message:
---
Followup to r79477: Add invalid purge title

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php

Modified: trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php2011-01-02 
06:09:58 UTC (rev 79477)
+++ trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php2011-01-02 
06:15:32 UTC (rev 79478)
@@ -22,17 +22,22 @@
 
$data = $this-doApiRequest( array(
'action' = 'purge',
-   'titles' = 'UTPage|' . $somePage ) );
+   'titles' = 'UTPage|' . $somePage . '|%5D' ) );

$this-assertArrayHasKey( 'purge', $data[0] );
+   
$this-assertArrayHasKey( 0, $data[0]['purge'] );
$this-assertArrayHasKey( 'purged', $data[0]['purge'][0] );
$this-assertEquals( 'UTPage', $data[0]['purge'][0]['title'] );

$this-assertArrayHasKey( 1, $data[0]['purge'] );
$this-assertArrayHasKey( 'missing', $data[0]['purge'][1] );
-   $this-assertEquals(  $somePage, $data[0]['purge'][1]['title'] 
);
+   $this-assertEquals( $somePage, $data[0]['purge'][1]['title'] );

+   $this-assertArrayHasKey( 2, $data[0]['purge'] );
+   $this-assertArrayHasKey( 'invalid', $data[0]['purge'][2] );
+   $this-assertEquals( '%5D', $data[0]['purge'][2]['title'] );
+   
}
 
 }


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79479] trunk/phase3

2011-01-01 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79479

Revision: 79479
Author:   soxred93
Date: 2011-01-02 06:48:07 + (Sun, 02 Jan 2011)
Log Message:
---
Per my comment on r68760: Make MWfunction class, complete with call_user_func 
helper functions that automatically
make the callback PHP 5.1 compatible with the Class::Method syntax. Add Unit 
tests to supplement it.

Modified Paths:
--
trunk/phase3/includes/AutoLoader.php
trunk/phase3/includes/WebStart.php
trunk/phase3/maintenance/doMaintenance.php

Added Paths:
---
trunk/phase3/includes/MWFunction.php
trunk/phase3/tests/phpunit/includes/MWFunctionTest.php

Modified: trunk/phase3/includes/AutoLoader.php
===
--- trunk/phase3/includes/AutoLoader.php2011-01-02 06:15:32 UTC (rev 
79478)
+++ trunk/phase3/includes/AutoLoader.php2011-01-02 06:48:07 UTC (rev 
79479)
@@ -166,6 +166,7 @@
'MessageCache' = 'includes/MessageCache.php',
'MimeMagic' = 'includes/MimeMagic.php',
'MWException' = 'includes/Exception.php',
+   'MWFunction' = 'includes/MWFunction.php',
'MWHttpRequest' = 'includes/HttpFunctions.php',
'MWMemcached' = 'includes/memcached-client.php',
'MWNamespace' = 'includes/Namespace.php',

Added: trunk/phase3/includes/MWFunction.php
===
--- trunk/phase3/includes/MWFunction.php(rev 0)
+++ trunk/phase3/includes/MWFunction.php2011-01-02 06:48:07 UTC (rev 
79479)
@@ -0,0 +1,52 @@
+?php
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+class MWFunction {
+   
+   protected static function cleanCallback( $callback ) {
+   
+   if( is_string( $callback ) ) {
+   if ( in_string( '::', $callback ) ) {
+   //PHP 5.1 cannot use call_user_func( 
'Class::Method' )
+   //It can only handle only call_user_func( 
array( 'Class', 'Method' ) )
+   $callback = explode( '::', $callback, 2);
+   }
+   }
+   
+   return $callback;
+   }
+   
+   public static function call( $callback ) {
+   $callback = self::cleanCallback( $callback );
+   
+   $args = func_get_args();
+   
+   return call_user_func_array( 'call_user_func', $args );
+   
+   }
+   
+   public static function callArray( $callback, $params ) {
+   
+   $callback = self::cleanCallback( $callback );
+   return call_user_func_array( $callback, $params );
+   
+   }
+   
+}


Property changes on: trunk/phase3/includes/MWFunction.php
___
Added: svn:eol-style
   + native

Modified: trunk/phase3/includes/WebStart.php
===
--- trunk/phase3/includes/WebStart.php  2011-01-02 06:15:32 UTC (rev 79478)
+++ trunk/phase3/includes/WebStart.php  2011-01-02 06:48:07 UTC (rev 79479)
@@ -96,12 +96,8 @@
 
 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
# Use a callback function to configure MediaWiki
-   $callback = MW_CONFIG_CALLBACK;
-   # PHP 5.1 doesn't support class::method for call_user_func, so split 
it
-   if ( strpos( $callback, '::' ) !== false ) {
-   $callback = explode( '::', $callback, 2);
-   }
-   call_user_func( $callback );
+   MWFunction::call( MW_CONFIG_CALLBACK );
+   
 } else {
if ( !defined('MW_CONFIG_FILE') )
define('MW_CONFIG_FILE', $IP/LocalSettings.php);

Modified: trunk/phase3/maintenance/doMaintenance.php
===
--- trunk/phase3/maintenance/doMaintenance.php  2011-01-02 06:15:32 UTC (rev 
79478)
+++ trunk/phase3/maintenance/doMaintenance.php  2011-01-02 06:48:07 UTC (rev 
79479)
@@ -65,12 +65,7 @@
 
 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
# Use a callback function to configure MediaWiki

[MediaWiki-CVS] SVN: [79368] trunk/phase3

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79368

Revision: 79368
Author:   soxred93
Date: 2010-12-31 20:42:39 + (Fri, 31 Dec 2010)
Log Message:
---
More work on getting SQLite to work with unit tests. DB Prefix changing is now 
static to allow for external classes to change it.

Modified Paths:
--
trunk/phase3/includes/db/CloneDatabase.php
trunk/phase3/includes/db/DatabaseSqlite.php
trunk/phase3/tests/phpunit/MediaWikiTestCase.php

Modified: trunk/phase3/includes/db/CloneDatabase.php
===
--- trunk/phase3/includes/db/CloneDatabase.php  2010-12-31 20:39:45 UTC (rev 
79367)
+++ trunk/phase3/includes/db/CloneDatabase.php  2010-12-31 20:42:39 UTC (rev 
79368)
@@ -91,14 +91,15 @@
# works correctly across DB engines, we need to change 
the pre-
# fix back and forth so tableName() works right.

-   $this-changePrefix( $this-oldTablePrefix );
+   self::changePrefix( $this-oldTablePrefix );
$oldTableName = $this-db-tableName( $tbl );

-   $this-changePrefix( $this-newTablePrefix );
+   self::changePrefix( $this-newTablePrefix );
$newTableName = $this-db-tableName( $tbl );
 
if( $this-dropCurrentTables  !in_array( 
$this-db-getType(), array( 'postgres' ) ) ) {
$this-db-dropTable( $tbl, __METHOD__ );
+   wfDebug( Dropping 
{$this-newTablePrefix}{$oldTableName}\n, __METHOD__ );
//Dropping the oldTable because the prefix was 
changed
}
 
@@ -116,12 +117,12 @@
 */
public function destroy( $dropTables = false ) {
if( $dropTables ) {
-   $this-changePrefix( $this-newTablePrefix );
+   self::changePrefix( $this-newTablePrefix );
foreach( $this-tablesToClone as $tbl ) {
$this-db-dropTable( $tbl );
}
}
-   $this-changePrefix( $this-oldTablePrefix );
+   self::changePrefix( $this-oldTablePrefix );
}
 
/**
@@ -130,9 +131,9 @@
 * @param  $prefix
 * @return void
 */
-   protected function changePrefix( $prefix ) {
+   public static function changePrefix( $prefix ) {
global $wgDBprefix;
-   wfGetLBFactory()-forEachLB( array( $this, 'changeLBPrefix' ), 
array( $prefix ) );
+   wfGetLBFactory()-forEachLB( array( 'CloneDatabase', 
'changeLBPrefix' ), array( $prefix ) );
$wgDBprefix = $prefix;
}
 
@@ -141,8 +142,8 @@
 * @param  $prefix
 * @return void
 */
-   public function changeLBPrefix( $lb, $prefix ) {
-   $lb-forEachOpenConnection( array( $this, 'changeDBPrefix' ), 
array( $prefix ) );
+   public static function changeLBPrefix( $lb, $prefix ) {
+   $lb-forEachOpenConnection( array( 'CloneDatabase', 
'changeDBPrefix' ), array( $prefix ) );
}
 
/**
@@ -150,7 +151,7 @@
 * @param  $prefix
 * @return void
 */
-   public function changeDBPrefix( $db, $prefix ) {
+   public static function changeDBPrefix( $db, $prefix ) {
$db-tablePrefix( $prefix );
}
 }

Modified: trunk/phase3/includes/db/DatabaseSqlite.php
===
--- trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-31 20:39:45 UTC (rev 
79367)
+++ trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-31 20:42:39 UTC (rev 
79368)
@@ -595,6 +595,7 @@
}
 
function duplicateTableStructure( $oldName, $newName, $temporary = 
false, $fname = 'DatabaseSqlite::duplicateTableStructure' ) {
+   
$res = $this-query( SELECT sql FROM sqlite_master WHERE 
tbl_name='$oldName' AND type='table', $fname );
$obj = $this-fetchObject( $res );
if ( !$obj ) {

Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 20:39:45 UTC 
(rev 79367)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 20:42:39 UTC 
(rev 79368)
@@ -5,7 +5,6 @@
public $regex = '';
public $runDisabled = false;

-   protected static $databaseSetupDone = false;
protected $db;
protected $dbClone;
protected $oldTablePrefix;
@@ -24,8 +23,10 @@

if( $this-needsDB() ) {

-   $this-destroyDBCheck();
+   $this-db = wfGetDB

[MediaWiki-CVS] SVN: [79370] trunk/phase3/tests/phpunit/MediaWikiTestCase.php

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79370

Revision: 79370
Author:   soxred93
Date: 2010-12-31 20:47:48 + (Fri, 31 Dec 2010)
Log Message:
---
Solved problem with SQLite: Globals were getting stored, and when a PDO 
reference is transferred, as is the case with SQLite, it serializes the globals.

Modified Paths:
--
trunk/phase3/tests/phpunit/MediaWikiTestCase.php

Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 20:43:27 UTC 
(rev 79369)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 20:47:48 UTC 
(rev 79370)
@@ -17,6 +17,9 @@
 
$this-data = $data;
$this-dataName = $dataName;
+   
+   $this-backupGlobals = false;
+$this-backupStaticAttributes = false;
}

function run( PHPUnit_Framework_TestResult $result = NULL ) {


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79371] trunk/phase3

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79371

Revision: 79371
Author:   soxred93
Date: 2010-12-31 21:01:17 + (Fri, 31 Dec 2010)
Log Message:
---
I made MySQL work, and broke SQLite in the process. I fix SQLite, and made 
MySQL break. Fixing MySQL again, hoping that SQLite works too. :)

Modified Paths:
--
trunk/phase3/includes/db/CloneDatabase.php
trunk/phase3/tests/phpunit/MediaWikiTestCase.php

Modified: trunk/phase3/includes/db/CloneDatabase.php
===
--- trunk/phase3/includes/db/CloneDatabase.php  2010-12-31 20:47:48 UTC (rev 
79370)
+++ trunk/phase3/includes/db/CloneDatabase.php  2010-12-31 21:01:17 UTC (rev 
79371)
@@ -96,7 +96,7 @@

self::changePrefix( $this-newTablePrefix );
$newTableName = $this-db-tableName( $tbl );
-
+   
if( $this-dropCurrentTables  !in_array( 
$this-db-getType(), array( 'postgres' ) ) ) {
$this-db-dropTable( $tbl, __METHOD__ );
wfDebug( Dropping 
{$this-newTablePrefix}{$oldTableName}\n, __METHOD__ );

Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 20:47:48 UTC 
(rev 79370)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 21:01:17 UTC 
(rev 79371)
@@ -25,17 +25,27 @@
function run( PHPUnit_Framework_TestResult $result = NULL ) {

if( $this-needsDB() ) {
+   
+   global $wgDBprefix;

$this-db = wfGetDB( DB_MASTER );
+   $this-oldTablePrefix = $wgDBprefix;

$this-destroyDB();

$this-initDB();
$this-addCoreDBData();
$this-addDBData();
+   
+   parent::run( $result );
+   
+   $this-destroyDB();
}
+   else {
+   parent::run( $result );

-   parent::run( $result );
+   }
+   
}

function __destruct() {
@@ -82,15 +92,13 @@
throw new MWException( 'Cannot run unit tests, the 
database prefix is already unittest_' );
}
 
-   $this-oldTablePrefix = $wgDBprefix;
-
$tables = $this-listTables();

$prefix = $dbType != 'oracle' ? 'unittest_' : 'ut_';
-
+   
$this-dbClone = new CloneDatabase( $this-db, $tables, $prefix 
);
$this-dbClone-cloneTableStructure();
-
+   
if ( $dbType == 'oracle' )
$this-db-query( 'BEGIN FILL_WIKI_INFO; END;' );
 


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79374] trunk/phase3/tests/phpunit/MediaWikiTestCase.php

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79374

Revision: 79374
Author:   soxred93
Date: 2010-12-31 21:10:36 + (Fri, 31 Dec 2010)
Log Message:
---
Add check to make sure only MySQL and SQLite are used at the moment. These two 
are the only ones with the listTables() function, and the only ones that are 
tested.

Modified Paths:
--
trunk/phase3/tests/phpunit/MediaWikiTestCase.php

Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 21:09:27 UTC 
(rev 79373)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 21:10:36 UTC 
(rev 79374)
@@ -9,6 +9,11 @@
protected $dbClone;
protected $oldTablePrefix;
protected $useTemporaryTables = true;
+   
+   protected $supportedDBs = array(
+   'mysql',
+   'sqlite'
+   );
 
function  __construct( $name = null, array $data = array(), $dataName = 
'' ) {
if ($name !== null) {
@@ -29,6 +34,9 @@
global $wgDBprefix;

$this-db = wfGetDB( DB_MASTER );
+   
+   $this-checkDbIsSupported();
+   
$this-oldTablePrefix = $wgDBprefix;

$this-destroyDB();
@@ -174,5 +182,11 @@
return $tables;

}
+   
+   protected function checkDbIsSupported() {
+   if( !in_array( $this-db-getType(), $this-supportedDBs ) ) {
+   throw new MWException( $this-db-getType() .  is not 
currently supported for unit testing. );
+   }
+   }
 }
 


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79375] trunk/phase3/tests/phpunit

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79375

Revision: 79375
Author:   soxred93
Date: 2010-12-31 21:40:26 + (Fri, 31 Dec 2010)
Log Message:
---
-If $this-db does not exist, skip destroying the DB
-Fix ApiTest errors due to DB rewrite

Modified Paths:
--
trunk/phase3/tests/phpunit/MediaWikiTestCase.php
trunk/phase3/tests/phpunit/includes/api/ApiSetup.php
trunk/phase3/tests/phpunit/includes/api/ApiTest.php

Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 21:10:36 UTC 
(rev 79374)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 21:40:26 UTC 
(rev 79375)
@@ -132,6 +132,10 @@
//Temporary tables seem to be broken ATM, delete anyway
}

+   if( is_null( $this-db ) ) {
+   return;
+   }
+   
if( $this-db-getType() == 'oracle' ) {
$tables = $this-db-listTables( 'ut_', __METHOD__ );
}

Modified: trunk/phase3/tests/phpunit/includes/api/ApiSetup.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiSetup.php2010-12-31 
21:10:36 UTC (rev 79374)
+++ trunk/phase3/tests/phpunit/includes/api/ApiSetup.php2010-12-31 
21:40:26 UTC (rev 79375)
@@ -1,8 +1,8 @@
 ?php
 
 abstract class ApiTestSetup extends MediaWikiTestCase {
-   protected static $user;
-   protected static $sysopUser;
+   protected $user;
+   protected $sysopUser;
protected static $apiUrl;
 
function setUp() {
@@ -14,7 +14,7 @@
$wgContLang = Language::factory( 'en' );
$wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
$wgRequest = new FauxRequest( array() );
-   self::setupUser();
+   $this-setupUser();
}
 
protected function doApiRequest( $params, $data = null ) {
@@ -31,13 +31,13 @@
return $data;
}
 
-   static function setupUser() {
-   if ( self::$user == null || self::$sysopUser == null ) {
-   self::$user = new UserWrapper( 'User for MediaWiki 
automated tests', User::randomPassword() );
-   self::$sysopUser = new UserWrapper( 'Sysop for 
MediaWiki automated tests', User::randomPassword(), 'sysop' );
+   function setupUser() {
+   if ( $this-user == null || $this-sysopUser == null ) {
+   $this-user = new UserWrapper( 'User for MediaWiki 
automated tests', User::randomPassword() );
+   $this-sysopUser = new UserWrapper( 'Sysop for 
MediaWiki automated tests', User::randomPassword(), 'sysop' );
}
 
-   $GLOBALS['wgUser'] = self::$sysopUser-user;
+   $GLOBALS['wgUser'] = $this-sysopUser-user;
}
 }
 

Modified: trunk/phase3/tests/phpunit/includes/api/ApiTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiTest.php 2010-12-31 21:10:36 UTC 
(rev 79374)
+++ trunk/phase3/tests/phpunit/includes/api/ApiTest.php 2010-12-31 21:40:26 UTC 
(rev 79375)
@@ -79,7 +79,7 @@
 */
function testApiLoginNoName() {
$data = $this-doApiRequest( array( 'action' = 'login',
-   'lgname' = '', 'lgpassword' = self::$user-password,
+   'lgname' = '', 'lgpassword' = $this-user-password,
) );
$this-assertEquals( 'NoName', $data[0]['login']['result'] );
}
@@ -87,7 +87,7 @@
function testApiLoginBadPass() {
global $wgServer;
 
-   $user = self::$user;
+   $user = $this-user;
 
if ( !isset( $wgServer ) ) {
$this-markTestIncomplete( 'This test needs $wgServer 
to be set in LocalSettings.php' );
@@ -130,7 +130,7 @@
$this-markTestIncomplete( 'This test needs $wgServer 
to be set in LocalSettings.php' );
}
 
-   $user = self::$user;
+   $user = $this-user;
 
$ret = $this-doApiRequest( array(
action = login,
@@ -174,8 +174,8 @@
$req = MWHttpRequest::factory( self::$apiUrl . 
?action=loginformat=xml,
array( method = POST,
postData = array(
-   lgname = self::$user-userName,
-   lgpassword = self::$user-password ) ) );
+   lgname = $this-user-userName,
+   lgpassword = $this-user-password ) ) );
$req-execute();
 
libxml_use_internal_errors( true );
@@ -190,8

[MediaWiki-CVS] SVN: [79376] trunk/phase3/tests/phpunit/MediaWikiTestCase.php

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79376

Revision: 79376
Author:   soxred93
Date: 2010-12-31 21:51:21 + (Fri, 31 Dec 2010)
Log Message:
---
For some reason tableExists() is being unreliable, which is resulting in tables 
not being dropped that _should_ be dropped. Drop them anyway and ignore the 
errors.

Modified Paths:
--
trunk/phase3/tests/phpunit/MediaWikiTestCase.php

Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 21:40:26 UTC 
(rev 79375)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-31 21:51:21 UTC 
(rev 79376)
@@ -144,9 +144,10 @@
}

foreach ( $tables as $table ) {
-   if( $this-db-tableExists( `$table` ) ) {
+   try {
$sql = $this-db-getType() == 'oracle' ? DROP 
TABLE $table DROP CONSTRAINTS : DROP TABLE `$table`;
$this-db-query( $sql, __METHOD__ );
+   } catch( Exception $e ) {
}
}



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79377] trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79377

Revision: 79377
Author:   soxred93
Date: 2010-12-31 22:08:13 + (Fri, 31 Dec 2010)
Log Message:
---
Solve 1 test by changing static variables to non-static

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php

Modified: trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php
===
--- trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php 2010-12-31 
21:51:21 UTC (rev 79376)
+++ trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php 2010-12-31 
22:08:13 UTC (rev 79377)
@@ -2,16 +2,15 @@
 
 /**
  * @group Database
- * @group Destructive
  */
 class TitlePermissionTest extends MediaWikiTestCase {
-   static $title;
-   static $user;
-   static $anonUser;
-   static $userUser;
-   static $altUser;
-   static $userName;
-   static $altUserName;
+   protected $title;
+   protected $user;
+   protected $anonUser;
+   protected $userUser;
+   protected $altUser;
+   protected $userName;
+   protected $altUserName;
 
function setUp() {
global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, 
$wgContLang, $wgLang, $wgMessageCache;
@@ -22,57 +21,59 @@
$wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
$wgContLang = $wgLang = Language::factory( 'en' );
 
-   self::$userName = Useruser;
-   self::$altUserName = Altuseruser;
+   $this-userName = Useruser;
+   $this-altUserName = Altuseruser;
date_default_timezone_set( $wgLocaltimezone );
$wgLocalTZoffset = date( Z ) / 60;
 
-   self::$title = Title::makeTitle( NS_MAIN, Main Page );
-   if ( !isset( self::$userUser ) || !( self::$userUser instanceOf 
User ) ) {
-   self::$userUser = User::newFromName( self::$userName );
-
-   if ( !self::$userUser-getID() ) {
-   self::$userUser = User::createNew( 
self::$userName, array(
+   $this-title = Title::makeTitle( NS_MAIN, Main Page );
+   if ( !isset( $this-userUser ) || !( $this-userUser instanceOf 
User ) ) {
+   $this-userUser = User::newFromName( $this-userName );
+   
+   if ( !$this-userUser-getID() ) {
+   $this-userUser = User::createNew( 
$this-userName, array(
email = t...@example.com,
real_name = Test User ) );
+   $this-userUser-load();
}
-
-   self::$altUser = User::newFromName( self::$altUserName 
);
-   if ( !self::$altUser-getID() ) {
-   self::$altUser = User::createNew( 
self::$altUserName, array(
+   
+   $this-altUser = User::newFromName( $this-altUserName 
);
+   if ( !$this-altUser-getID() ) {
+   $this-altUser = User::createNew( 
$this-altUserName, array(
email = altt...@example.com,
real_name = Test User Alt ) );
+   $this-altUser-load();
}
 
-   self::$anonUser = User::newFromId( 0 );
+   $this-anonUser = User::newFromId( 0 );
 
-   self::$user = self::$userUser;
+   $this-user = $this-userUser;
}
}
 
function setUserPerm( $perm ) {
if ( is_array( $perm ) ) {
-   self::$user-mRights = $perm;
+   $this-user-mRights = $perm;
} else {
-   self::$user-mRights = array( $perm );
+   $this-user-mRights = array( $perm );
}
}
 
function setTitle( $ns, $title = Main_Page ) {
-   self::$title = Title::makeTitle( $ns, $title );
+   $this-title = Title::makeTitle( $ns, $title );
}
 
function setUser( $userName = null ) {
if ( $userName === 'anon' ) {
-   self::$user = self::$anonUser;
-   } else if ( $userName === null || $userName === self::$userName 
) {
-   self::$user = self::$userUser;
+   $this-user = $this-anonUser;
+   } else if ( $userName === null || $userName === $this-userName 
) {
+   $this-user = $this-userUser;
} else {
-   self::$user = self::$altUser;
+   $this-user = $this-altUser;
}
 
global $wgUser

[MediaWiki-CVS] SVN: [79378] trunk/phase3/tests/phpunit/includes/api/ApiWatchTest.php

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79378

Revision: 79378
Author:   soxred93
Date: 2010-12-31 22:34:20 + (Fri, 31 Dec 2010)
Log Message:
---
Forgot to change the other API tests

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/api/ApiWatchTest.php

Modified: trunk/phase3/tests/phpunit/includes/api/ApiWatchTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiWatchTest.php2010-12-31 
22:08:13 UTC (rev 79377)
+++ trunk/phase3/tests/phpunit/includes/api/ApiWatchTest.php2010-12-31 
22:34:20 UTC (rev 79378)
@@ -15,8 +15,8 @@
function testLogin() {
$data = $this-doApiRequest( array(
'action' = 'login',
-   'lgname' = self::$sysopUser-userName,
-   'lgpassword' = self::$sysopUser-password ) );
+   'lgname' = $this-sysopUser-userName,
+   'lgpassword' = $this-sysopUser-password ) );
 
$this-assertArrayHasKey( login, $data[0] );
$this-assertArrayHasKey( result, $data[0]['login'] );
@@ -26,8 +26,8 @@
$data = $this-doApiRequest( array(
'action' = 'login',
lgtoken = $token,
-   lgname = self::$sysopUser-userName,
-   lgpassword = self::$sysopUser-password ), $data );
+   lgname = $this-sysopUser-userName,
+   lgpassword = $this-sysopUser-password ), $data );
 
$this-assertArrayHasKey( login, $data[0] );
$this-assertArrayHasKey( result, $data[0]['login'] );
@@ -38,7 +38,7 @@
}
 
function testGettingToken() {
-   foreach ( array( self::$user, self::$sysopUser ) as $user ) {
+   foreach ( array( $this-user, $this-sysopUser ) as $user ) {
$this-getUserTokens( $user );
}
}
@@ -79,7 +79,7 @@
}
 
function testGetToken() {
-   return $this-getUserTokens( self::$sysopUser );
+   return $this-getUserTokens( $this-sysopUser );
}
 
/**


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79405] USERINFO/soxred93

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79405

Revision: 79405
Author:   soxred93
Date: 2011-01-01 01:43:05 + (Sat, 01 Jan 2011)
Log Message:
---
update my userinfo

Modified Paths:
--
USERINFO/soxred93

Modified: USERINFO/soxred93
===
--- USERINFO/soxred93   2011-01-01 01:19:29 UTC (rev 79404)
+++ USERINFO/soxred93   2011-01-01 01:43:05 UTC (rev 79405)
@@ -1,6 +1,6 @@
 name: X!
 email: soxre...@gmail.com
 url: http://toolserver.org/~soxred93/
-irc: [X]
-wiki: http://en.wikipedia.org/wiki/User:Soxred93
+irc: Soxred93, Yetanotherx, variants
+wiki: http://en.wikipedia.org/wiki/User:X!
 languages spoken: English


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79411] trunk/phase3/tests

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79411

Revision: 79411
Author:   soxred93
Date: 2011-01-01 03:39:37 + (Sat, 01 Jan 2011)
Log Message:
---
Start work on porting ParserTests completely into PHPunit.
Disable temporary tables, a few reports of them not working. The tables get 
deleted anyway, so why risk it?

Modified Paths:
--
trunk/phase3/tests/phpunit/MediaWikiTestCase.php
trunk/phase3/tests/testHelpers.inc

Added Paths:
---
trunk/phase3/tests/phpunit/includes/parser/NewParserHelpers.php
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2011-01-01 03:17:43 UTC 
(rev 79410)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2011-01-01 03:39:37 UTC 
(rev 79411)
@@ -107,6 +107,7 @@
$prefix = $dbType != 'oracle' ? 'unittest_' : 'ut_';

$this-dbClone = new CloneDatabase( $this-db, $tables, $prefix 
);
+   $this-dbClone-useTemporaryTables( false ); //reported 
problems with temp tables, disabling until fixed
$this-dbClone-cloneTableStructure();

if ( $dbType == 'oracle' )

Added: trunk/phase3/tests/phpunit/includes/parser/NewParserHelpers.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserHelpers.php 
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserHelpers.php 
2011-01-01 03:39:37 UTC (rev 79411)
@@ -0,0 +1,199 @@
+?php
+
+class ParserTestFileIterator implements Iterator {
+
+   protected $file;
+   protected $fh;
+   protected $parserTest; /* An instance of ParserTest (parserTests.php) 
or MediaWikiParserTest (phpunit) */
+   protected $index = 0;
+   protected $test;
+   protected $lineNum;
+   protected $eof;
+
+   function __construct( $file, $parserTest ) {
+   global $IP;
+
+   $this-file = $file;
+   $this-fh = fopen( $this-file, rt );
+
+   if ( !$this-fh ) {
+   wfDie( Couldn't open file '$file'\n );
+   }
+
+   $this-parserTest = $parserTest;
+   //$this-parserTest-showRunFile( wfRelativePath( $this-file, 
$IP ) );
+
+   $this-lineNum = $this-index = 0;
+   }
+
+   function rewind() {
+   if ( fseek( $this-fh, 0 ) ) {
+   wfDie( Couldn't fseek to the start of '$this-file'\n 
);
+   }
+
+   $this-index = -1;
+   $this-lineNum = 0;
+   $this-eof = false;
+   $this-next();
+
+   return true;
+   }
+
+   function current() {
+   return $this-test;
+   }
+
+   function key() {
+   return $this-index;
+   }
+
+   function next() {
+   if ( $this-readNextTest() ) {
+   $this-index++;
+   return true;
+   } else {
+   $this-eof = true;
+   }
+   }
+
+   function valid() {
+   return $this-eof != true;
+   }
+
+   function readNextTest() {
+   $data = array();
+   $section = null;
+
+   while ( false !== ( $line = fgets( $this-fh ) ) ) {
+   $this-lineNum++;
+   $matches = array();
+
+   if ( preg_match( '/^!!\s*(\w+)/', $line, $matches ) ) {
+   $section = strtolower( $matches[1] );
+
+   if ( $section == 'endarticle' ) {
+   if ( !isset( $data['text'] ) ) {
+   wfDie( 'endarticle' without 
'text' at line {$this-lineNum} of $this-file\n );
+   }
+
+   if ( !isset( $data['article'] ) ) {
+   wfDie( 'endarticle' without 
'article' at line {$this-lineNum} of $this-file\n );
+   }
+
+   $this-parserTest-addArticle( 
$this-parserTest-removeEndingNewline( $data['article'] ), $data['text'], 
$this-lineNum );
+   
+   
+   $data = array();
+   $section = null;
+
+   continue;
+   }
+
+   if ( $section == 'endhooks' ) {
+   if ( !isset( $data['hooks'] ) ) {
+   wfDie( 'endhooks

[MediaWiki-CVS] SVN: [79412] trunk/phase3/tests/phpunit/includes/parser

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79412

Revision: 79412
Author:   soxred93
Date: 2011-01-01 03:45:39 + (Sat, 01 Jan 2011)
Log Message:
---
I really, really hate SVN right now

Property Changed:

trunk/phase3/tests/phpunit/includes/parser/NewParserHelpers.php
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php


Property changes on: 
trunk/phase3/tests/phpunit/includes/parser/NewParserHelpers.php
___
Added: svn:eol-style
   + native


Property changes on: 
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79414] trunk/phase3/tests/phpunit

2010-12-31 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79414

Revision: 79414
Author:   soxred93
Date: 2011-01-01 06:49:00 + (Sat, 01 Jan 2011)
Log Message:
---
Add parsertest specific help to PHPUnit.php

Modified Paths:
--
trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php
trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php

Modified: trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php
===
--- trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php  2011-01-01 
05:53:04 UTC (rev 79413)
+++ trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php  2011-01-01 
06:49:00 UTC (rev 79414)
@@ -4,13 +4,10 @@

static $additionalOptions = array( 
'regex=' = false, 
-   'record' = false,
'file=' = false,
'keep-uploads' = false,
);

-   //Fixme: These aren't shown on the --help menu
-
public function __construct() {
foreach( self::$additionalOptions as $option = $default ) {
$this-longOptions[$option] = $option . 'Handler';
@@ -31,4 +28,19 @@
}
}

+   public function showHelp() {
+   parent::showHelp();
+   
+   print EOT
+
+ParserTest-specific options:
+
+  --regex=regexOnly run parser tests that match the given regex
+  --file=filename  Prints the version and exits.
+  --keep-uploads   Re-use the same upload directory for each test, 
don't delete it
+  
+
+EOT;
+   }
+   
 }

Modified: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 05:53:04 UTC (rev 79413)
+++ trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
2011-01-01 06:49:00 UTC (rev 79414)
@@ -24,10 +24,6 @@

//Setup CLI arguments
if ( $this-getCliArg( 'regex=' ) ) {
-   if ( $this-getCliArg( 'record' ) ) {
-   echo Warning: --record cannot be used with 
--regex, disabling --record\n;
-   $this-setCliArg( 'record', false );
-   }
$this-regex = $this-getCliArg( 'regex=' );
} else {
# Matches anything


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79272] trunk/phase3

2010-12-30 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79272

Revision: 79272
Author:   soxred93
Date: 2010-12-30 17:30:35 + (Thu, 30 Dec 2010)
Log Message:
---
-Destroy the DB automatically when initting the DB
-Add $force option to wfSetVar
-More work on getting SQLite to work

Modified Paths:
--
trunk/phase3/includes/GlobalFunctions.php
trunk/phase3/includes/db/CloneDatabase.php
trunk/phase3/includes/db/Database.php
trunk/phase3/includes/db/DatabaseSqlite.php
trunk/phase3/tests/phpunit/MediaWikiTestCase.php

Modified: trunk/phase3/includes/GlobalFunctions.php
===
--- trunk/phase3/includes/GlobalFunctions.php   2010-12-30 17:29:33 UTC (rev 
79271)
+++ trunk/phase3/includes/GlobalFunctions.php   2010-12-30 17:30:35 UTC (rev 
79272)
@@ -1287,10 +1287,11 @@
 /**
  * Sets dest to source and returns the original value of dest
  * If source is NULL, it just returns the value, it doesn't set the variable
+ * If force is true, it will set the value even if source is NULL
  */
-function wfSetVar( $dest, $source ) {
+function wfSetVar( $dest, $source, $force = false ) {
$temp = $dest;
-   if ( !is_null( $source ) ) {
+   if ( !is_null( $source ) || $force ) {
$dest = $source;
}
return $temp;

Modified: trunk/phase3/includes/db/CloneDatabase.php
===
--- trunk/phase3/includes/db/CloneDatabase.php  2010-12-30 17:29:33 UTC (rev 
79271)
+++ trunk/phase3/includes/db/CloneDatabase.php  2010-12-30 17:30:35 UTC (rev 
79272)
@@ -85,12 +85,16 @@
 * Clone the table structure
 */
public function cloneTableStructure() {
+   
+   sort($this-tablesToClone);
+   
foreach( $this-tablesToClone as $tbl ) {
# Clean up from previous aborted run.  So that table 
escaping
# works correctly across DB engines, we need to change 
the pre-
# fix back and forth so tableName() works right.
$this-changePrefix( $this-oldTablePrefix );
$oldTableName = $this-db-tableName( $tbl );
+   
$this-changePrefix( $this-newTablePrefix );
$newTableName = $this-db-tableName( $tbl );
 
@@ -99,7 +103,9 @@
}
 
# Create new table
+   wfDebug( Duplicating $oldTableName to 
$newTableName\n, __METHOD__ );
$this-db-duplicateTableStructure( $oldTableName, 
$newTableName, $this-useTemporaryTables );
+   
}
}
 

Modified: trunk/phase3/includes/db/Database.php
===
--- trunk/phase3/includes/db/Database.php   2010-12-30 17:29:33 UTC (rev 
79271)
+++ trunk/phase3/includes/db/Database.php   2010-12-30 17:30:35 UTC (rev 
79272)
@@ -288,7 +288,7 @@
}
 
function tablePrefix( $prefix = null ) {
-   return wfSetVar( $this-mTablePrefix, $prefix );
+   return wfSetVar( $this-mTablePrefix, $prefix, true );
}
 
/**

Modified: trunk/phase3/includes/db/DatabaseSqlite.php
===
--- trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-30 17:29:33 UTC (rev 
79271)
+++ trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-30 17:30:35 UTC (rev 
79272)
@@ -629,8 +629,11 @@
$vars = get_object_vars($table);
$table = array_pop( $vars );

-   if( empty( $prefix ) || strpos( $table, $prefix ) === 0 
) {
-   $endArray[] = $table;
+   if( !$prefix || strpos( $table, $prefix ) === 0 ) {
+   if ( strpos( $table, 'sqlite_' ) !== 0 ) {
+   $endArray[] = $table;
+   }
+   
}
}


Modified: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
===
--- trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-30 17:29:33 UTC 
(rev 79271)
+++ trunk/phase3/tests/phpunit/MediaWikiTestCase.php2010-12-30 17:30:35 UTC 
(rev 79272)
@@ -12,24 +12,33 @@
protected $useTemporaryTables = true;
 
function  __construct( $name = null, array $data = array(), $dataName = 
'' ) {
-if ($name !== null) {
-$this-setName($name);
-}
+   if ($name !== null) {
+   $this-setName($name);
+   }
 
-$this-data = $data;
-$this-dataName = $dataName;
+   $this-data

[MediaWiki-CVS] SVN: [79314] trunk/phase3/includes/db/CloneDatabase.php

2010-12-30 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79314

Revision: 79314
Author:   soxred93
Date: 2010-12-31 02:18:25 + (Fri, 31 Dec 2010)
Log Message:
---
Use $oldTableName in CloneDatabase. The dropTable() appends the prefix, so 
$oldTableName becomes $newTableName

Modified Paths:
--
trunk/phase3/includes/db/CloneDatabase.php

Modified: trunk/phase3/includes/db/CloneDatabase.php
===
--- trunk/phase3/includes/db/CloneDatabase.php  2010-12-31 02:13:41 UTC (rev 
79313)
+++ trunk/phase3/includes/db/CloneDatabase.php  2010-12-31 02:18:25 UTC (rev 
79314)
@@ -85,21 +85,21 @@
 * Clone the table structure
 */
public function cloneTableStructure() {
-   
-   sort($this-tablesToClone);

foreach( $this-tablesToClone as $tbl ) {
# Clean up from previous aborted run.  So that table 
escaping
# works correctly across DB engines, we need to change 
the pre-
# fix back and forth so tableName() works right.
+   
$this-changePrefix( $this-oldTablePrefix );
$oldTableName = $this-db-tableName( $tbl );

$this-changePrefix( $this-newTablePrefix );
$newTableName = $this-db-tableName( $tbl );
-
+   
if( $this-dropCurrentTables  !in_array( 
$this-db-getType(), array( 'postgres') ) ) {
-   $this-db-dropTable( $newTableName, __METHOD__ 
);
+   $this-db-dropTable( $oldTableName, __METHOD__ 
);
+   //Dropping the oldTable because the prefix was 
changed
}
 
# Create new table
@@ -107,6 +107,7 @@
$this-db-duplicateTableStructure( $oldTableName, 
$newTableName, $this-useTemporaryTables );

}
+   
}
 
/**


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79184] trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest .php

2010-12-29 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79184

Revision: 79184
Author:   soxred93
Date: 2010-12-29 16:40:31 + (Wed, 29 Dec 2010)
Log Message:
---
Self-reverting my reversion of r79154 in r79158. The old version is flawed and 
broken beyond belief. At least this version works.

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php

Modified: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2010-12-29 16:24:59 UTC (rev 79183)
+++ trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2010-12-29 16:40:31 UTC (rev 79184)
@@ -3,72 +3,62 @@
 require_once( dirname( __FILE__ ) . '/ParserHelpers.php' );
 require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
 
+/**
+ * @group Parser
+ * @group Destructive
+ * @group Database
+ */
 class MediaWikiParserTest extends MediaWikiTestCase {
public $count;  // Number of tests in the suite.
-   public $backend;// ParserTestSuiteBackend instance
public $articles = array(); // Array of test articles defined by 
the tests
-
-   public function __construct() {
-   parent::__construct();
-   $this-backend = new ParserTestSuiteBackend;
-   $this-setName( 'Parser tests' );
-   }
-
-   public static function suite() {
-   global $IP;
-
-   $tester = new self;
-   $tester-suite = new PHPUnit_Framework_TestSuite('Parser 
Tests');
+   protected $pt;
+   
+   function setUp() {
+   global $wgContLang;
+   $wgContLang = Language::factory( 'en' );

-   //Fixme: Use all the wgParserTestFiles (or whatever that global 
was...)
-   $iter = new TestFileIterator( 
$IP/tests/parser/parserTests.txt, $tester );
-   $tester-count = 0;
-
-   foreach ( $iter as $test ) {
-   $tester-suite-addTest( new ParserUnitTest( $tester, 
$test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) );
-   $tester-count++;
+   $this-pt = new PHPUnitParserTest;
+   $this-pt-setupDatabase();
+   
+   }
+   
+   function tearDown() {
+   if( is_object( $this-pt )  $this-pt instanceof 
PHPUnitParserTest ) {
+   $this-pt-teardownDatabase();
+   $this-pt = null;
}
-
-   return $tester-suite;
}
 
-   public function count() {
-   return $this-count;
-   }
-
-   public function toString() {
-   return MediaWiki Parser Tests;
-   }
-
-   public function getBackend() {
-   return $this-backend;
-   }
-
-   public function getIterator() {
-   return $this-iterator;
-   }
-
-   public function publishTestArticles() {
-   if ( empty( $this-articles ) ) {
-   return;
-   }
-
-   foreach ( $this-articles as $name = $text ) {
-   $title = Title::newFromText( $name );
-
-   if ( $title-getArticleID( Title::GAID_FOR_UPDATE ) == 
0 ) {
-   ParserTest::addArticle( $name, $text );
+   
+   public function testParserTests() {
+   //global $IP;
+   //$wgParserTestFiles = array( 
$IP/tests/parser/testparserTests.txt );
+   
+   global $wgParserTestFiles;
+   
+   foreach( $wgParserTestFiles as $file ) {
+   
+   $iter = new TestFileIterator( $file, $this-pt );
+   
+   try {
+   foreach( $iter as $test ) {
+   $r = $this-pt-runTest( $test['test'], 
$test['input'],
+   $test['result'], 
$test['options'], $test['config']
+   );
+   
+   $this-assertTrue( $r, 'Parser test ' . 
$test['test'] );
+   
+   }
+   } 
+   catch( DBQueryError $e ) {
+   $this-assertTrue( false, 'Parser test ' . 
$test['test'] . ' (error: ' . $e-getMessage() . ')' );
+   //This is annoying... it always stops on error 
and doesn't go to the next one.
+   continue;
}
+   
}
-   $this-articles = array();
+   
}
 
-   public function addArticle( $name

Re: [Toolserver-l] i18n and toolserver subdomains

2010-12-29 Thread Soxred93
I'm just going to throw this out there, because it's been bugging me today.

It is i18n. Not i10n. There is no such thing as i10n. There is i18n, for 
internalization, and l10n, for localization.

End rant.

-X!
___
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org)
https://lists.wikimedia.org/mailman/listinfo/toolserver-l
Posting guidelines for this list: 
https://wiki.toolserver.org/view/Mailing_list_etiquette


Re: [Wikitech-l] How would you disrupt Wikipedia?

2010-12-29 Thread Soxred93
Of course, you have to remember that Wikipedia is a top 10 website. Wikia is a 
top 200 website. hot articles just don't scale that well to a wiki like 
Wikipedia. It's fundamentally flawed.

On the flip side, an Etherpad-like feature would be nice.

-X!

On Dec 29, 2010, at 6:41 PM, Ryan Kaldari wrote:

 I would steal some of the better ideas from Wikia like the hot article 
 lists, user polls, user avatars, and throw in some real-time 
 collaboration software a la Etherpad.
 
 Ryan Kaldari
 
 On 12/28/10 11:31 PM, Neil Kandalgaonkar wrote:
 I've been inspired by the discussion David Gerard and Brion Vibber
 kicked off, and I think they are headed in the right direction.
 
 But I just want to ask a separate, but related question.
 
 Let's imagine you wanted to start a rival to Wikipedia. Assume that you
 are motivated by money, and that venture capitalists promise you can be
 paid gazillions of dollars if you can do one, or many, of the following:
 
 1 - Become a more attractive home to the WP editors. Get them to work on
 your content.
 
 2 - Take the free content from WP, and use it in this new system. But
 make it much better, in a way Wikipedia can't match.
 
 3 - Attract even more readers, or perhaps a niche group of
 super-passionate readers that you can use to build a new community.
 
 In other words, if you had no legacy, and just wanted to build something
 from zero, how would you go about creating an innovation that was
 disruptive to Wikipedia, in fact something that made Wikipedia look like
 Friendster or Myspace compared to Facebook?
 
 And there's a followup question to this -- but you're all smart people
 and can guess what it is.
 
 
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[MediaWiki-CVS] SVN: [79107] trunk/phase3/tests/phpunit/includes

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79107

Revision: 79107
Author:   soxred93
Date: 2010-12-28 15:13:42 + (Tue, 28 Dec 2010)
Log Message:
---
assertType() is deprecated, switching usages tp assertInternalType() and 
assertInstanceOf()

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/GlobalTest.php
trunk/phase3/tests/phpunit/includes/MessageTest.php
trunk/phase3/tests/phpunit/includes/api/ApiTest.php

Modified: trunk/phase3/tests/phpunit/includes/GlobalTest.php
===
--- trunk/phase3/tests/phpunit/includes/GlobalTest.php  2010-12-28 14:40:15 UTC 
(rev 79106)
+++ trunk/phase3/tests/phpunit/includes/GlobalTest.php  2010-12-28 15:13:42 UTC 
(rev 79107)
@@ -63,7 +63,7 @@
 
function testTime() {
$start = wfTime();
-   $this-assertType( 'float', $start );
+   $this-assertInternalType( 'float', $start );
$end = wfTime();
$this-assertTrue( $end  $start, Time is running backwards! 
);
}

Modified: trunk/phase3/tests/phpunit/includes/MessageTest.php
===
--- trunk/phase3/tests/phpunit/includes/MessageTest.php 2010-12-28 14:40:15 UTC 
(rev 79106)
+++ trunk/phase3/tests/phpunit/includes/MessageTest.php 2010-12-28 15:13:42 UTC 
(rev 79107)
@@ -21,8 +21,8 @@
}
 
function testKey() {
-   $this-assertType( 'Message', wfMessage( 'mainpage' ) );
-   $this-assertType( 'Message', wfMessage( 'i-dont-exist-evar' ) 
);
+   $this-assertInstanceOf( 'Message', wfMessage( 'mainpage' ) );
+   $this-assertInstanceOf( 'Message', wfMessage( 
'i-dont-exist-evar' ) );
$this-assertEquals( 'Main Page', wfMessage( 'mainpage' 
)-text() );
$this-assertEquals( 'lt;i-dont-exist-evargt;', wfMessage( 
'i-dont-exist-evar' )-text() );
}

Modified: trunk/phase3/tests/phpunit/includes/api/ApiTest.php
===
--- trunk/phase3/tests/phpunit/includes/api/ApiTest.php 2010-12-28 14:40:15 UTC 
(rev 79106)
+++ trunk/phase3/tests/phpunit/includes/api/ApiTest.php 2010-12-28 15:13:42 UTC 
(rev 79107)
@@ -70,7 +70,7 @@
 
libxml_use_internal_errors( true );
$sxe = simplexml_load_string( $resp );
-   $this-assertNotType( bool, $sxe );
+   $this-assertNotInternalType( bool, $sxe );
$this-assertThat( $sxe, $this-isInstanceOf( 
SimpleXMLElement ) );
}
 
@@ -101,7 +101,7 @@
 
$result = $ret[0];
 
-   $this-assertNotType( bool, $result );
+   $this-assertNotInternalType( bool, $result );
$a = $result[login][result];
$this-assertEquals( NeedToken, $a );
 
@@ -117,7 +117,7 @@
 
$result = $ret[0];
 
-   $this-assertNotType( bool, $result );
+   $this-assertNotInternalType( bool, $result );
$a = $result[login][result];
 
$this-assertEquals( WrongPass, $a );
@@ -140,8 +140,8 @@
);
 
$result = $ret[0];
-   $this-assertNotType( bool, $result );
-   $this-assertNotType( null, $result[login] );
+   $this-assertNotInternalType( bool, $result );
+   $this-assertNotInternalType( null, $result[login] );
 
$a = $result[login][result];
$this-assertEquals( NeedToken, $a );
@@ -157,7 +157,7 @@
 
$result = $ret[0];
 
-   $this-assertNotType( bool, $result );
+   $this-assertNotInternalType( bool, $result );
$a = $result[login][result];
 
$this-assertEquals( Success, $a );
@@ -180,9 +180,9 @@
 
libxml_use_internal_errors( true );
$sxe = simplexml_load_string( $req-getContent() );
-   $this-assertNotType( bool, $sxe );
+   $this-assertNotInternalType( bool, $sxe );
$this-assertThat( $sxe, $this-isInstanceOf( 
SimpleXMLElement ) );
-   $this-assertNotType( null, $sxe-login[0] );
+   $this-assertNotInternalType( null, $sxe-login[0] );
 
$a = $sxe-login[0]-attributes()-result[0];
$this-assertEquals( ' result=NeedToken', $a-asXML() );
@@ -220,7 +220,7 @@
$req-execute();
libxml_use_internal_errors( true );
$sxe = simplexml_load_string( $req-getContent() );
-   $this-assertNotType( bool, $sxe );
+   $this-assertNotInternalType( bool, $sxe );
$this-assertThat( $sxe, $this-isInstanceOf( 
SimpleXMLElement ) );
$a = $sxe-query[0]-pages[0]-page[0]-attributes();
}


___
MediaWiki-CVS

[MediaWiki-CVS] SVN: [79109] trunk/phase3

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79109

Revision: 79109
Author:   soxred93
Date: 2010-12-28 17:15:50 + (Tue, 28 Dec 2010)
Log Message:
---
It's here! It's finally here! The skies are falling, pigs have sprouted wings, 
and it's pretty cold in hell!

-Add a working PHPUnit test that instantiates a new DB, adds set data, and 
deleted when done.
-Add listTables() to the Database classes (only MySql and SQLite use it, and 
only MySQL is tested)

Modified Paths:
--
trunk/phase3/includes/db/Database.php
trunk/phase3/includes/db/DatabaseMysql.php
trunk/phase3/includes/db/DatabaseSqlite.php
trunk/phase3/tests/phpunit/bootstrap.php

Added Paths:
---
trunk/phase3/tests/phpunit/includes/NewDBTest.php

Modified: trunk/phase3/includes/db/Database.php
===
--- trunk/phase3/includes/db/Database.php   2010-12-28 15:54:51 UTC (rev 
79108)
+++ trunk/phase3/includes/db/Database.php   2010-12-28 17:15:50 UTC (rev 
79109)
@@ -2288,6 +2288,16 @@
function duplicateTableStructure( $oldName, $newName, $temporary = 
false, $fname = 'DatabaseBase::duplicateTableStructure' ) {
throw new MWException( 'DatabaseBase::duplicateTableStructure 
is not implemented in descendant class' );
}
+   
+   /**
+* List all tables on the database
+*
+* @param $prefix Only show tables with this prefix, e.g. mw_
+* @param $fname String: calling function name
+*/
+   function listTables( $prefix = null, $fname = 
'DatabaseBase::listTables' ) {
+   throw new MWException( 'DatabaseBase::listTables is not 
implemented in descendant class' );
+   }
 
/**
 * Return MW-style timestamp used for MySQL schema

Modified: trunk/phase3/includes/db/DatabaseMysql.php
===
--- trunk/phase3/includes/db/DatabaseMysql.php  2010-12-28 15:54:51 UTC (rev 
79108)
+++ trunk/phase3/includes/db/DatabaseMysql.php  2010-12-28 17:15:50 UTC (rev 
79109)
@@ -530,6 +530,29 @@
}
$this-query( $query, $fname );
}
+   
+   /**
+* List all tables on the database
+*
+* @param $prefix Only show tables with this prefix, e.g. mw_
+* @param $fname String: calling function name
+*/
+   function listTables( $prefix = null, $fname = 
'DatabaseMysql::listTables' ) {
+   $result = $this-query( SHOW TABLES, $fname);
+   
+   $endArray = array();
+   
+   foreach( $result as $table ) {  
+   $vars = get_object_vars($table);
+   $table = array_pop( $vars );
+   
+   if( strpos( $table, $prefix ) === 0 || is_null( $prefix 
) ) {
+   $endArray[] = $table;
+   }
+   }
+   
+   return $endArray;
+   }
 
public function dropTable( $tableName, $fName = 
'DatabaseMysql::dropTable' ) {
if( !$this-tableExists( $tableName ) ) {

Modified: trunk/phase3/includes/db/DatabaseSqlite.php
===
--- trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-28 15:54:51 UTC (rev 
79108)
+++ trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-28 17:15:50 UTC (rev 
79109)
@@ -608,6 +608,34 @@
$sql = preg_replace( '/\b' . preg_quote( $oldName ) . '\b/', 
$newName, $sql, 1 );
return $this-query( $sql, $fname );
}
+   
+   
+   /**
+* List all tables on the database
+*
+* @param $prefix Only show tables with this prefix, e.g. mw_
+* @param $fname String: calling function name
+*/
+   function listTables( $prefix = null, $fname = 
'DatabaseSqlite::listTables' ) {
+   $result = $this-select(
+   'sqlite_master',
+   'name',
+   type='TABLE'
+   );
+   
+   $endArray = array();
+   
+   foreach( $result as $table ) {  
+   $vars = get_object_vars($table);
+   $table = array_pop( $vars );
+   
+   if( strpos( $table, $prefix ) === 0 || is_null( $prefix 
) ) {
+   $endArray[] = $table;
+   }
+   }
+   
+   return $endArray;
+   }
 
 } // end DatabaseSqlite class
 

Modified: trunk/phase3/tests/phpunit/bootstrap.php
===
--- trunk/phase3/tests/phpunit/bootstrap.php2010-12-28 15:54:51 UTC (rev 
79108)
+++ trunk/phase3/tests/phpunit/bootstrap.php2010-12-28 17:15

[MediaWiki-CVS] SVN: [79119] trunk/phase3/includes/db

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79119

Revision: 79119
Author:   soxred93
Date: 2010-12-28 18:30:03 + (Tue, 28 Dec 2010)
Log Message:
---
Fix r79109: listTables() does not work without a prefix, and verified that 
SQLite works now

Modified Paths:
--
trunk/phase3/includes/db/DatabaseMysql.php
trunk/phase3/includes/db/DatabaseSqlite.php

Modified: trunk/phase3/includes/db/DatabaseMysql.php
===
--- trunk/phase3/includes/db/DatabaseMysql.php  2010-12-28 18:23:43 UTC (rev 
79118)
+++ trunk/phase3/includes/db/DatabaseMysql.php  2010-12-28 18:30:03 UTC (rev 
79119)
@@ -546,7 +546,7 @@
$vars = get_object_vars($table);
$table = array_pop( $vars );

-   if( strpos( $table, $prefix ) === 0 || is_null( $prefix 
) ) {
+   if( empty( $prefix ) || strpos( $table, $prefix ) === 0 
) {
$endArray[] = $table;
}
}

Modified: trunk/phase3/includes/db/DatabaseSqlite.php
===
--- trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-28 18:23:43 UTC (rev 
79118)
+++ trunk/phase3/includes/db/DatabaseSqlite.php 2010-12-28 18:30:03 UTC (rev 
79119)
@@ -620,7 +620,7 @@
$result = $this-select(
'sqlite_master',
'name',
-   type='TABLE'
+   type='table'
);

$endArray = array();
@@ -629,7 +629,7 @@
$vars = get_object_vars($table);
$table = array_pop( $vars );

-   if( strpos( $table, $prefix ) === 0 || is_null( $prefix 
) ) {
+   if( empty( $prefix ) || strpos( $table, $prefix ) === 0 
) {
$endArray[] = $table;
}
}


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79123] trunk/phase3/tests/phpunit

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79123

Revision: 79123
Author:   soxred93
Date: 2010-12-28 18:47:09 + (Tue, 28 Dec 2010)
Log Message:
---
NewDBTest does not need the function anymore.
Fixed bug that caused a catchable fatal error (fix from r79117)

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/NewDBTest.php
trunk/phase3/tests/phpunit/suites/ExtensionsTestSuite.php

Modified: trunk/phase3/tests/phpunit/includes/NewDBTest.php
===
--- trunk/phase3/tests/phpunit/includes/NewDBTest.php   2010-12-28 18:44:32 UTC 
(rev 79122)
+++ trunk/phase3/tests/phpunit/includes/NewDBTest.php   2010-12-28 18:47:09 UTC 
(rev 79123)
@@ -19,8 +19,6 @@
User::newFromName( 
'UTSysop' ) );
}

-   function needsDB() { return true; }
-
function testBootstrapCreation() {

$article = new Article( Title::newFromText(UTPage) );

Modified: trunk/phase3/tests/phpunit/suites/ExtensionsTestSuite.php
===
--- trunk/phase3/tests/phpunit/suites/ExtensionsTestSuite.php   2010-12-28 
18:44:32 UTC (rev 79122)
+++ trunk/phase3/tests/phpunit/suites/ExtensionsTestSuite.php   2010-12-28 
18:47:09 UTC (rev 79123)
@@ -26,7 +26,7 @@
  * Needed to avoid warnings like 'No tests found in class 
ExtensionsTestSuite.'
  * when no extensions with tests are used.
  */
-class DummyExtensionsTest extends MediaWikiTestCase {
+class DummyExtensionsTest extends PHPUnit_Framework_TestCase {
public function testNothing() {

}


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79125] trunk/phase3/tests/phpunit/includes/BlockTest.php

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79125

Revision: 79125
Author:   soxred93
Date: 2010-12-28 19:12:27 + (Tue, 28 Dec 2010)
Log Message:
---
Add BlockTest unit test

Added Paths:
---
trunk/phase3/tests/phpunit/includes/BlockTest.php

Added: trunk/phase3/tests/phpunit/includes/BlockTest.php
===
--- trunk/phase3/tests/phpunit/includes/BlockTest.php   
(rev 0)
+++ trunk/phase3/tests/phpunit/includes/BlockTest.php   2010-12-28 19:12:27 UTC 
(rev 79125)
@@ -0,0 +1,38 @@
+?php
+
+class BlockTest extends MediaWikiTestCase {
+   
+   private $block;
+   
+   function setUp() {
+   global $wgContLang;
+   $wgContLang = Language::factory( 'en' );
+   }
+
+   function tearDown() {
+   }
+   
+   function addDBData() {
+   $user = User::newFromName( 'UTBlockee' );
+   $user-addToDatabase();
+   $user-setPassword( 'UTBlockeePassword' );
+   
+   $user-saveSettings();
+   
+   $this-block = new Block( 'UTBlockee', 1, 0,
+   'Parce que', wfTimestampNow()
+   );
+
+   $this-block-insert();
+   }
+   
+   function testInitializerFunctionsReturnCorrectBlock() {
+   
+   $this-assertTrue( $this-block-equals( 
Block::newFromDB('UTBlockee') ), newFromDB() returns the same block as the one 
that was made);
+   
+   $this-assertTrue( $this-block-equals( Block::newFromID( 1 ) 
), newFromID() returns the same block as the one that was made);
+   
+   }
+
+}
+


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79126] trunk/phase3/tests/phpunit/includes/BlockTest.php

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79126

Revision: 79126
Author:   soxred93
Date: 2010-12-28 19:27:34 + (Tue, 28 Dec 2010)
Log Message:
---
Add test to supplement Bug 26425 (followup to r79013)

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/BlockTest.php

Modified: trunk/phase3/tests/phpunit/includes/BlockTest.php
===
--- trunk/phase3/tests/phpunit/includes/BlockTest.php   2010-12-28 19:12:27 UTC 
(rev 79125)
+++ trunk/phase3/tests/phpunit/includes/BlockTest.php   2010-12-28 19:27:34 UTC 
(rev 79126)
@@ -2,7 +2,7 @@
 
 class BlockTest extends MediaWikiTestCase {

-   private $block;
+   private $block, $madeAt;

function setUp() {
global $wgContLang;
@@ -13,15 +13,19 @@
}

function addDBData() {
+   
$user = User::newFromName( 'UTBlockee' );
-   $user-addToDatabase();
-   $user-setPassword( 'UTBlockeePassword' );
+   if( $user-getID() == 0 ) {
+   $user-addToDatabase();
+   $user-setPassword( 'UTBlockeePassword' );

-   $user-saveSettings();
+   $user-saveSettings();
+   }

$this-block = new Block( 'UTBlockee', 1, 0,
-   'Parce que', wfTimestampNow()
+   'Parce que'
);
+   $this-madeAt = wfTimestamp( TS_MW );
 
$this-block-insert();
}
@@ -33,6 +37,15 @@
$this-assertTrue( $this-block-equals( Block::newFromID( 1 ) 
), newFromID() returns the same block as the one that was made);

}
+   
+   /**
+* per bug 26425
+*/
+   function testBug26425BlockTimestampDefaultsToTime() {
+   
+   $this-assertEquals( $this-madeAt, $this-block-mTimestamp, 
If no timestamp is specified, the block is recorded as time());
+   
+   }
 
 }
 


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [79154] trunk/phase3/tests/phpunit

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79154

Revision: 79154
Author:   soxred93
Date: 2010-12-29 02:23:51 + (Wed, 29 Dec 2010)
Log Message:
---
Make MediaWikiParserTest work now in PHPUnit. There are still a few bugs, such 
as stopping tests if one fails,
lack of fuzz testing and other parser test options, and the DB creation is 
still a little flaky.
A MediaWikiPHPUnitCommand class had to be created to allow for custom CLI 
parameters.

Modified Paths:
--
trunk/phase3/tests/phpunit/bootstrap.php
trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php
trunk/phase3/tests/phpunit/phpunit.php
trunk/phase3/tests/phpunit/suite.xml

Added Paths:
---
trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php

Added: trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php
===
--- trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php  
(rev 0)
+++ trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php  2010-12-29 
02:23:51 UTC (rev 79154)
@@ -0,0 +1,19 @@
+?php
+
+class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
+
+   public function __construct() {
+   $this-longOptions['verbose'] = 'verboseHandler';
+   }
+   
+   public static function main( $exit = true ) {
+$command = new self;
+$command-run($_SERVER['argv'], $exit);
+}
+
+   protected function verboseHandler($value) {
+   global $additionalMWCLIArgs;
+   $additionalMWCLIArgs['verbose'] = true;
+   }
+
+}

Modified: trunk/phase3/tests/phpunit/bootstrap.php
===
--- trunk/phase3/tests/phpunit/bootstrap.php2010-12-29 02:04:30 UTC (rev 
79153)
+++ trunk/phase3/tests/phpunit/bootstrap.php2010-12-29 02:23:51 UTC (rev 
79154)
@@ -43,7 +43,7 @@
 /* Classes */
 
 abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
-   protected $suite;
+   public $suite;
public $regex = '';
public $runDisabled = false;

@@ -53,11 +53,13 @@
protected $oldTablePrefix;
protected $useTemporaryTables = true;
 
-   function __construct( PHPUnit_Framework_TestSuite $suite = null ) {
-   if ( null !== $suite ) {
-   $this-suite = $suite;
-   }
-   parent::__construct();
+   function  __construct( $name = null, array $data = array(), $dataName = 
'' ) {
+if ($name !== null) {
+$this-setName($name);
+}
+
+$this-data = $data;
+$this-dataName = $dataName;

if( $this-needsDB()  !is_object( $this-dbClone ) ) {
$this-initDB();
@@ -80,6 +82,7 @@

//Make sysop user
$user = User::newFromName( 'UTSysop' );
+   
if ( $user-idForName() == 0 ) {
$user-addToDatabase();
$user-setPassword( 'UTSysopPassword' );
@@ -140,7 +143,7 @@
 
if ( $dbType == 'oracle' ) {
# Insert 0 user to prevent FK violations
-
+   
# Anonymous user
$this-db-insert( 'user', array(
'user_id' = 0,
@@ -149,7 +152,7 @@

}

-   private function destroyDB() {
+   protected function destroyDB() {
if ( !self::$databaseSetupDone ) {
return;
}

Modified: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2010-12-29 02:04:30 UTC (rev 79153)
+++ trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2010-12-29 02:23:51 UTC (rev 79154)
@@ -3,71 +3,62 @@
 require_once( dirname( __FILE__ ) . '/ParserHelpers.php' );
 require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
 
+/**
+ * @group Parser
+ * @group Destructive
+ * @group Database
+ */
 class MediaWikiParserTest extends MediaWikiTestCase {
public $count;  // Number of tests in the suite.
-   public $backend;// ParserTestSuiteBackend instance
public $articles = array(); // Array of test articles defined by 
the tests
-
-   public function __construct() {
-   $suite = new PHPUnit_Framework_TestSuite('Parser Tests');
-   parent::__construct($suite);
-   $this-backend = new ParserTestSuiteBackend;
-   $this-setName( 'Parser tests' );
+   protected $pt;
+   
+   function setUp() {
+   global $wgContLang

[MediaWiki-CVS] SVN: [79158] trunk/phase3/tests/phpunit/includes/parser

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79158

Revision: 79158
Author:   soxred93
Date: 2010-12-29 03:35:17 + (Wed, 29 Dec 2010)
Log Message:
---
Partial revert of r79154. hexmode asserts that these work, even though I keep 
getting OK (0 tests, 0 assertions)

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php

Modified: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
===
--- trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2010-12-29 03:34:01 UTC (rev 79157)
+++ trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php  
2010-12-29 03:35:17 UTC (rev 79158)
@@ -3,62 +3,72 @@
 require_once( dirname( __FILE__ ) . '/ParserHelpers.php' );
 require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
 
-/**
- * @group Parser
- * @group Destructive
- * @group Database
- */
 class MediaWikiParserTest extends MediaWikiTestCase {
public $count;  // Number of tests in the suite.
+   public $backend;// ParserTestSuiteBackend instance
public $articles = array(); // Array of test articles defined by 
the tests
-   protected $pt;
-   
-   function setUp() {
-   global $wgContLang;
-   $wgContLang = Language::factory( 'en' );
+
+   public function __construct() {
+   parent::__construct();
+   $this-backend = new ParserTestSuiteBackend;
+   $this-setName( 'Parser tests' );
+   }
+
+   public static function suite() {
+   global $IP;
+
+   $tester = new self;
+   $tester-suite = new PHPUnit_Framework_TestSuite('Parser 
Tests');

-   $this-pt = new PHPUnitParserTest;
-   $this-pt-setupDatabase();
-   
-   }
-   
-   function tearDown() {
-   if( is_object( $this-pt )  $this-pt instanceof 
PHPUnitParserTest ) {
-   $this-pt-teardownDatabase();
-   $this-pt = null;
+   //Fixme: Use all the wgParserTestFiles (or whatever that global 
was...)
+   $iter = new TestFileIterator( 
$IP/tests/parser/parserTests.txt, $tester );
+   $tester-count = 0;
+
+   foreach ( $iter as $test ) {
+   $tester-suite-addTest( new ParserUnitTest( $tester, 
$test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) );
+   $tester-count++;
}
+
+   return $tester-suite;
}
 
-   
-   public function testParserTests() {
-   //global $IP;
-   //$wgParserTestFiles = array( 
$IP/tests/parser/testparserTests.txt );
-   
-   global $wgParserTestFiles;
-   
-   foreach( $wgParserTestFiles as $file ) {
-   
-   $iter = new TestFileIterator( $file, $this-pt );
-   
-   try {
-   foreach( $iter as $test ) {
-   $r = $this-pt-runTest( $test['test'], 
$test['input'],
-   $test['result'], 
$test['options'], $test['config']
-   );
-   
-   $this-assertTrue( $r, 'Parser test ' . 
$test['test'] );
-   
-   }
-   } 
-   catch( DBQueryError $e ) {
-   $this-assertTrue( false, 'Parser test ' . 
$test['test'] . ' (error: ' . $e-getMessage() . ')' );
-   //This is annoying... it always stops on error 
and doesn't go to the next one.
-   continue;
+   public function count() {
+   return $this-count;
+   }
+
+   public function toString() {
+   return MediaWiki Parser Tests;
+   }
+
+   public function getBackend() {
+   return $this-backend;
+   }
+
+   public function getIterator() {
+   return $this-iterator;
+   }
+
+   public function publishTestArticles() {
+   if ( empty( $this-articles ) ) {
+   return;
+   }
+
+   foreach ( $this-articles as $name = $text ) {
+   $title = Title::newFromText( $name );
+
+   if ( $title-getArticleID( Title::GAID_FOR_UPDATE ) == 
0 ) {
+   ParserTest::addArticle( $name, $text );
}
-   
}
-   
+   $this-articles = array

[MediaWiki-CVS] SVN: [79164] trunk/phase3/tests/phpunit

2010-12-28 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79164

Revision: 79164
Author:   soxred93
Date: 2010-12-29 05:38:11 + (Wed, 29 Dec 2010)
Log Message:
---
-Set configuration automatically if not set. This allows for evasion of the 
makefile, ergo, more control.
-Remove instances of @covers; they were breaking code-coverage

Modified Paths:
--
trunk/phase3/tests/phpunit/includes/IPTest.php
trunk/phase3/tests/phpunit/phpunit.php

Modified: trunk/phase3/tests/phpunit/includes/IPTest.php
===
--- trunk/phase3/tests/phpunit/includes/IPTest.php  2010-12-29 05:34:45 UTC 
(rev 79163)
+++ trunk/phase3/tests/phpunit/includes/IPTest.php  2010-12-29 05:38:11 UTC 
(rev 79164)
@@ -6,7 +6,6 @@
 class IPTest extends MediaWikiTestCase {
/**
 *  not sure it should be tested with boolean false. hashar 20100924
-* @covers IP:isIPAddress()
 */
public function testisIPAddress() {
$this-assertFalse( IP::isIPAddress( false ), 'Boolean false is 
not an IP' );
@@ -35,9 +34,6 @@
}
}
 
-   /**
-* @covers IP::isIPv6()
-*/
public function testisIPv6() {
$this-assertFalse( IP::isIPv6( ':fc:100::' ), 'IPv6 starting 
with lone :' );
$this-assertFalse( IP::isIPv6( 'fc:100:::' ), 'IPv6 ending 
with a :::' );
@@ -81,9 +77,6 @@
$this-assertTrue( IP::isIPv6( 'fc:100:a:d:1:e:ac:0' ) );
}
 
-   /**
-* @covers IP::isIPv4()
-*/
public function testisIPv4() {
$this-assertFalse( IP::isIPv4( false ), 'Boolean false is not 
an IP' );
$this-assertFalse( IP::isIPv4( true  ), 'Boolean true is not 
an IP' );
@@ -99,9 +92,6 @@
$this-assertTrue( IP::isIPv4( '74.24.52.13/20', 'IPv4 range' ) 
);
}
 
-   /**
-* @covers IP::isValid()
-*/
public function testValidIPs() {
foreach ( range( 0, 255 ) as $i ) {
$a = sprintf( %03d, $i );
@@ -123,9 +113,6 @@
}
}
 
-   /**
-* @covers IP::isValid()
-*/
public function testInvalidIPs() {
// Out of range...
foreach ( range( 256, 999 ) as $i ) {
@@ -173,9 +160,6 @@
}
}
 
-   /**
-* @covers IP::isValidBlock()
-*/
public function testValidBlocks() {
$valid = array(
'116.17.184.5/32',
@@ -196,9 +180,6 @@
}
}
 
-   /**
-* @covers IP::isValidBlock()
-*/
public function testInvalidBlocks() {
$invalid = array(
'116.17.184.5/33',
@@ -221,7 +202,6 @@
 
/**
 * test wrapper around ip2long which might return -1 or false depending 
on PHP version
-* @covers IP::toUnsigned()
 */
public function testip2longWrapper() {
// fixme : add more tests ?
@@ -230,9 +210,6 @@
$this-assertFalse( IP::toUnSigned( $i ) );
}
 
-   /**
-* @covers IP::isPublic()
-*/
public function testPrivateIPs() {
$private = array( 'fc::3', 'fc::ff', '::1', '10.0.0.1', 
'172.16.0.1', '192.168.0.1' );
foreach ( $private as $p ) {
@@ -252,9 +229,6 @@
$this-assertEquals( $expected, long2ip( $parse[0] ), network 
shifting $CIDR );
}
 
-   /**
-* @covers IP::hexToQuad()
-*/
public function testHexToQuad() {
$this-assertEquals( '0.0.0.1', IP::hexToQuad( 
'0001' ) );
$this-assertEquals( '255.0.0.0'  , IP::hexToQuad( 
'FF00' ) );
@@ -267,9 +241,6 @@
$this-assertEquals( '0.0.255.0'   , IP::hexToQuad( 'FF00' ) );
}
 
-   /**
-* @covers IP::hexToOctet()
-*/
public function testHexToOctet() {
$this-assertEquals( '0:0:0:0:0:0:0:1',
IP::hexToOctet( '0001' ) );
@@ -293,7 +264,6 @@
/*
 * IP::parseCIDR() returns an array containing a signed IP address
 * representing the network mask and the bit mask.
-* @covers IP::parseCIDR()
 */
function testCIDRParsing() {
$this-assertFalseCIDR( '192.0.2.0' , missing mask);

Modified: trunk/phase3/tests/phpunit/phpunit.php
===
--- trunk/phase3/tests/phpunit/phpunit.php  2010-12-29 05:34:45 UTC (rev 
79163)
+++ trunk/phase3/tests/phpunit/phpunit.php  2010-12-29 05:38:11 UTC (rev 
79164)
@@ -14,14 +14,18 @@
 // Set a flag which can be used to detect when other scripts have been entered 
through this entry point or not
 define( 'MW_PHPUNIT_TEST', true );
 
-$options = array

[MediaWiki-CVS] SVN: [79098] trunk/phase3/tests/phpunit/README

2010-12-27 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79098

Revision: 79098
Author:   soxred93
Date: 2010-12-28 04:08:25 + (Tue, 28 Dec 2010)
Log Message:
---
Wrong URL in README

Modified Paths:
--
trunk/phase3/tests/phpunit/README

Modified: trunk/phase3/tests/phpunit/README
===
--- trunk/phase3/tests/phpunit/README   2010-12-28 01:59:41 UTC (rev 79097)
+++ trunk/phase3/tests/phpunit/README   2010-12-28 04:08:25 UTC (rev 79098)
@@ -49,5 +49,5 @@
 
 A guide to writing unit tests for MediaWiki can be found at:
 
-   http://mediawiki.org/wiki/wiki/Unit_Testing
+   http://mediawiki.org/wiki/Unit_Testing
 


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


Re: [Wikitech-l] Alternative to opendir() functions?

2010-12-24 Thread Soxred93
In the HISTORY file:

* glob() is horribly unreliable and doesn't work on some systems, including 
free.fr shared hosting. No longer using it in Language::getLanguageNames() 

-X!

On Dec 24, 2010, at 12:24 PM, Brion Vibber wrote:

 Glob works too I think.
 
 -- brion
 On Dec 23, 2010 12:06 PM, Ilmari Karonen nos...@vyznev.net wrote:
 On 12/22/2010 12:16 AM, Platonides wrote:
 
 We are only using opendir for getting a full directory list.
 
 That's a good point. Perhaps what we need is simply a utility method to
 list all files in a directory.
 
 In fact, I just realized that PHP already has one. It's called
 scandir(). Its only flaw IMO is that it doesn't automatically skip the
 current and parent dir entries, but you could always do something like
 
 $files = array_diff( scandir( $dir ), array( '.', '..' ) );
 
 to accomplish that cleanly (or use preg_grep() to remove all dotfiles if
 you prefer).
 
 --
 Ilmari Karonen
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[MediaWiki-CVS] SVN: [78903] trunk/phase3

2010-12-23 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/78903

Revision: 78903
Author:   soxred93
Date: 2010-12-23 18:20:13 + (Thu, 23 Dec 2010)
Log Message:
---
Per discussion on mailing list, modifying some uses of 
opendir()/readdir()/closedir() to use new sfFinder class. 

Modified Paths:
--
trunk/phase3/includes/AutoLoader.php
trunk/phase3/includes/filerepo/ForeignAPIFile.php
trunk/phase3/includes/filerepo/LocalFile.php
trunk/phase3/languages/Language.php

Modified: trunk/phase3/includes/AutoLoader.php
===
--- trunk/phase3/includes/AutoLoader.php2010-12-23 18:14:55 UTC (rev 
78902)
+++ trunk/phase3/includes/AutoLoader.php2010-12-23 18:20:13 UTC (rev 
78903)
@@ -476,7 +476,10 @@
# includes/libs
'IEContentAnalyzer' = 'includes/libs/IEContentAnalyzer.php',
'Spyc' = 'includes/libs/spyc.php',
-
+   'sfFinder' = 'includes/libs/sfFinder.php',
+   'sfGlobToRegex' = 'includes/libs/sfFinder.php',
+   'sfNumberCompare' = 'includes/libs/sfFinder.php',
+   
# includes/media
'BitmapHandler' = 'includes/media/Bitmap.php',
'BitmapHandler_ClientOnly' = 'includes/media/Bitmap_ClientOnly.php',

Modified: trunk/phase3/includes/filerepo/ForeignAPIFile.php
===
--- trunk/phase3/includes/filerepo/ForeignAPIFile.php   2010-12-23 18:14:55 UTC 
(rev 78902)
+++ trunk/phase3/includes/filerepo/ForeignAPIFile.php   2010-12-23 18:20:13 UTC 
(rev 78903)
@@ -168,16 +168,9 @@
$files = array();
$dir = $this-getThumbPath( $this-getName() );
if ( is_dir( $dir ) ) {
-   $handle = opendir( $dir );
-   if ( $handle ) {
-   while ( false !== ( $file = readdir($handle) ) 
) {
-   if ( $file{0} != '.'  ) {
-   $files[] = $file;
-   }
-   }
-   closedir( $handle );
-   }
+   $files = array_map( 'basename', 
sfFinder::type('file')-maxdepth(0)-discard('.*')-in($dir) );
}
+   
return $files;
}


Modified: trunk/phase3/includes/filerepo/LocalFile.php
===
--- trunk/phase3/includes/filerepo/LocalFile.php2010-12-23 18:14:55 UTC 
(rev 78902)
+++ trunk/phase3/includes/filerepo/LocalFile.php2010-12-23 18:20:13 UTC 
(rev 78903)
@@ -599,19 +599,9 @@
$dir = $this-getThumbPath();
 
if ( is_dir( $dir ) ) {
-   $handle = opendir( $dir );
-
-   if ( $handle ) {
-   while ( false !== ( $file = readdir( $handle ) 
) ) {
-   if ( $file { 0 } != '.' ) {
-   $files[] = $file;
-   }
-   }
-
-   closedir( $handle );
-   }
+   $files = array_map( 'basename', 
sfFinder::type('file')-maxdepth(0)-discard('.*')-in($dir) );
}
-
+   
return $files;
}
 

Modified: trunk/phase3/languages/Language.php
===
--- trunk/phase3/languages/Language.php 2010-12-23 18:14:55 UTC (rev 78902)
+++ trunk/phase3/languages/Language.php 2010-12-23 18:20:13 UTC (rev 78903)
@@ -476,14 +476,14 @@
 
global $IP;
$names = array();
-   $dir = opendir( $IP/languages/messages );
-   while ( false !== ( $file = readdir( $dir ) ) ) {
+   
+   foreach( sfFinder::type('file')-maxdepth(0)-in( 
$IP/languages/messages ) as $file ) {
$code = self::getCodeFromFileName( $file, 'Messages' );
if ( $code  isset( $allNames[$code] ) ) {
$names[$code] = $allNames[$code];
}
}
-   closedir( $dir );
+   
return $names;
}
 


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [78904] trunk/phase3/includes/libs/sfFinder.php

2010-12-23 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/78904

Revision: 78904
Author:   soxred93
Date: 2010-12-23 18:22:10 + (Thu, 23 Dec 2010)
Log Message:
---
Followup to r78903: Forgot to svn add

Added Paths:
---
trunk/phase3/includes/libs/sfFinder.php

Added: trunk/phase3/includes/libs/sfFinder.php
===
--- trunk/phase3/includes/libs/sfFinder.php (rev 0)
+++ trunk/phase3/includes/libs/sfFinder.php 2010-12-23 18:22:10 UTC (rev 
78904)
@@ -0,0 +1,824 @@
+?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) 2004-2006 Fabien Potencier fabien.potenc...@symfony-project.com
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+
+/**
+ *
+ * Allow to build rules to find files and directories.
+ *
+ * All rules may be invoked several times, except for -in() method.
+ * Some rules are cumulative (-name() for example) whereas others are 
destructive
+ * (most recent value is used, -maxdepth() method for example).
+ *
+ * All methods return the current sfFinder object to allow easy chaining:
+ *
+ * $files = sfFinder::type('file')-name('*.php')-in(.);
+ *
+ * Interface loosely based on perl File::Find::Rule module.
+ *
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
+ * @author Fabien Potencier fabien.potenc...@symfony-project.com
+ * @versionSVN: $Id$
+ */
+class sfFinder
+{
+  protected $type   = 'file';
+  protected $names  = array();
+  protected $prunes = array();
+  protected $discards   = array();
+  protected $execs  = array();
+  protected $mindepth   = 0;
+  protected $sizes  = array();
+  protected $maxdepth   = 100;
+  protected $relative   = false;
+  protected $follow_link= false;
+  protected $sort   = false;
+  protected $ignore_version_control = true;
+
+  /**
+   * Sets maximum directory depth.
+   *
+   * Finder will descend at most $level levels of directories below the 
starting point.
+   *
+   * @param  int $level
+   * @return sfFinder current sfFinder object
+   */
+  public function maxdepth($level)
+  {
+$this-maxdepth = $level;
+
+return $this;
+  }
+
+  /**
+   * Sets minimum directory depth.
+   *
+   * Finder will start applying tests at level $level.
+   *
+   * @param  int $level
+   * @return sfFinder current sfFinder object
+   */
+  public function mindepth($level)
+  {
+$this-mindepth = $level;
+
+return $this;
+  }
+
+  public function get_type()
+  {
+return $this-type;
+  }
+
+  /**
+   * Sets the type of elements to returns.
+   *
+   * @param  string $name  directory or file or any (for both file and 
directory)
+   * @return sfFinder new sfFinder object
+   */
+  public static function type($name)
+  {
+$finder = new self();
+return $finder-setType($name);
+  }
+  /**
+   * Sets the type of elements to returns.
+   *
+   * @param  string $name  directory or file or any (for both file and 
directory)
+   * @return sfFinder Current object
+   */
+  public function setType($name)
+  {
+$name = strtolower($name);
+
+if (substr($name, 0, 3) === 'dir')
+{
+  $this-type = 'directory';
+
+  return $this;
+}
+if ($name === 'any')
+{
+  $this-type = 'any';
+
+  return $this;
+}
+
+  $this-type = 'file';
+
+return $this;
+  }
+
+  /*
+   * glob, patterns (must be //) or strings
+   */
+  protected function to_regex($str)
+  {
+if (preg_match('/^(!)?([^a-zA-Z0-9]).+?\\2[ims]?$/', $str))
+{
+  return $str;
+}
+
+return sfGlobToRegex::glob_to_regex($str);
+  }
+
+  protected function args_to_array($arg_list, $not = false)
+  {
+$list = array();
+$nbArgList = count($arg_list);
+for ($i = 0; $i  $nbArgList; $i++)
+{
+  if (is_array($arg_list[$i]))
+  {
+foreach ($arg_list[$i] as $arg)
+{
+  $list[] = array($not, $this-to_regex($arg));
+}
+  }
+  else
+  {
+$list[] = array($not, $this-to_regex($arg_list[$i]));
+  }
+}
+
+return $list;
+  }
+
+  /**
+   * Adds rules that files must match.
+   *
+   * You can use patterns (delimited with / sign), globs or simple strings.
+   *
+   * $finder-name('*.php')
+   * $finder-name('/\.php$/') // same as above
+   * $finder-name('test.php')
+   *
+   * @param  list   a list of patterns, globs or strings
+   * @return sfFinder Current object
+   */
+  public function name()
+  {
+$args = func_get_args();
+$this-names = array_merge($this-names, $this-args_to_array($args));
+
+return $this;
+  }
+
+  /**
+   * Adds rules that files must not match.
+   *
+   * @see-name()
+   * @param  list   a list of patterns, globs or strings

[MediaWiki-CVS] SVN: [78905] trunk/phase3/includes/libs/sfFinder.php

2010-12-23 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/78905

Revision: 78905
Author:   soxred93
Date: 2010-12-23 18:24:40 + (Thu, 23 Dec 2010)
Log Message:
---
Followup to r78903: Add SVN props

Property Changed:

trunk/phase3/includes/libs/sfFinder.php


Property changes on: trunk/phase3/includes/libs/sfFinder.php
___
Added: svn:eol-style
   + native


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [78906] trunk/phase3/includes/libs/sfFinder.php

2010-12-23 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/78906

Revision: 78906
Author:   soxred93
Date: 2010-12-23 18:28:25 + (Thu, 23 Dec 2010)
Log Message:
---
Followup to r78903: Add proper SVN info

Modified Paths:
--
trunk/phase3/includes/libs/sfFinder.php

Modified: trunk/phase3/includes/libs/sfFinder.php
===
--- trunk/phase3/includes/libs/sfFinder.php 2010-12-23 18:24:40 UTC (rev 
78905)
+++ trunk/phase3/includes/libs/sfFinder.php 2010-12-23 18:28:25 UTC (rev 
78906)
@@ -25,7 +25,7 @@
  *
  * @license http://www.opensource.org/licenses/mit-license.php MIT License
  * @author Fabien Potencier fabien.potenc...@symfony-project.com
- * @versionSVN: $Id$
+ * @versionSVN: $Id: sfFinder.class.php 30528 2010-08-04 16:25:14Z fabien $
  */
 class sfFinder
 {


___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


Re: [Wikitech-l] Alternative to opendir() functions?

2010-12-21 Thread Soxred93
You can. But the main advantage is less writing, more understanding. I see 
type('file')-name('*.php')-in('/path/') tp be easier to understand than 
RegexIterator(RecursiveIteratorIterator(RecursiveDirectoryIterator('path/to/project/')),
 '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);

BUt we all have our own styles. I would like to see this included, even if 
everyone doesn't use it. The current usage in MW isn't even RDI, it's just 
opendir(), readdir(), etc.

-X!

On Dec 21, 2010, at 7:22 AM, Tim Starling wrote:

 On 21/12/10 15:21, Soxred93 wrote:
 The usage is simple: 
 sfFinder::type('file')-name('*.php')-in('/path/to/dir'); //list
 of PHP files in directory and all subdirectories 
 
 You can use RecursiveDirectoryIterator to do that. There's a cute
 example in the online manual comments.
 
 -- Tim Starling
 
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Alternative to opendir() functions?

2010-12-21 Thread Soxred93
I'm not looking to integrate these frameworks entirely into MediaWiki; I'm just 
talking about this one single file with one single class. (to be fair, it's 3 
classes, but they're all in that one file).

-X!

On Dec 21, 2010, at 9:09 AM, Chad wrote:

 I hate these frameworks, so a big -1 from me.
 
 -Chad
 
 On Dec 20, 2010 11:22 PM, Soxred93 soxre...@gmail.com wrote:
 
 Hi all,
 
 Recently, I've been working with the Symfony web framework [1]. One of the
 classes they include is called the sfFinder class [2], which is a fluid,
 easy-to-use file finder class. It searches for files or directories in the
 filesystem, using a fluid PHP 5 interface. It has no dependancies, so it
 should work fine with MediaWiki. After finding numerous instances of
 opendir(), readdir(), closedir(), etc. in MediaWiki, I thought that it would
 be a good idea to use one centralized class to do all file searching. There
 is only 1 potential issue I see, though. It is MIT licensed, which is GPL
 compatible, so it should be okay to implement it, but I'm not too clear on
 this issue.
 
 
 The usage is simple:
 sfFinder::type('file')-name('*.php')-in('/path/to/dir'); //list of PHP
 files in directory and all subdirectories
 sfFinder::type('file')-name('*.php')-in('/path/to/dir')-recurse(0);
 //list of PHP files in that directory only
 sfFinder::type('dir')-name('foo')-in('/path/to/dir'); //list of
 directories with the name foo
 There is documentation at [3], but it's for an old version. The code is very
 similar though, so most of it should apply to the current version.
 
 
 What would people think of a change like this. I would like to see this
 happen, but I'd like some more opinions before I look into implementing it.
 
 -X!
 
 
 [1] - http://www.symfony-project.org
 [2] -
 http://trac.symfony-project.org/browser/branches/1.4/lib/util/sfFinder.class.php
 [3] - http://www.symfony-project.org/cookbook/1_2/en/finder
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Alternative to opendir() functions?

2010-12-21 Thread Soxred93
 
 Before going into too much detail on the thread, consider what you actually
 need out of a fancy directory iterator. Offhand, I really can't think of
 many places where that even *happens* in MediaWiki... maybe when purging
 thumbnails?
 
I count 10 instances of opendir() exactly in trunk. 

 takes more
 effort than just using things built into PHP (there's at least 3 or for
 directory iterator systems already, including the opendir() stuff, the
 object-oriented variant in the Dir class, and the SPL iterators).

The main part of my push for this is that it isn't a new feature, but an easier 
way to read and write code. Myself, at least, readdir(), opendir(), etc is very 
arcane and confusing (same reason I don't use fopen, etc). RDI and SPL are even 
more confusing. I'm just going from ym own experience here, but I'm just 
thinking that it would be a good addition.

-X!
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[Wikitech-l] Alternative to opendir() functions?

2010-12-20 Thread Soxred93
Hi all,

Recently, I've been working with the Symfony web framework [1]. One of the 
classes they include is called the sfFinder class [2], which is a fluid, 
easy-to-use file finder class. It searches for files or directories in the 
filesystem, using a fluid PHP 5 interface. It has no dependancies, so it should 
work fine with MediaWiki. After finding numerous instances of opendir(), 
readdir(), closedir(), etc. in MediaWiki, I thought that it would be a good 
idea to use one centralized class to do all file searching. There is only 1 
potential issue I see, though. It is MIT licensed, which is GPL compatible, so 
it should be okay to implement it, but I'm not too clear on this issue.


The usage is simple:
sfFinder::type('file')-name('*.php')-in('/path/to/dir'); //list of PHP files 
in directory and all subdirectories
sfFinder::type('file')-name('*.php')-in('/path/to/dir')-recurse(0); //list 
of PHP files in that directory only
sfFinder::type('dir')-name('foo')-in('/path/to/dir'); //list of directories 
with the name foo
There is documentation at [3], but it's for an old version. The code is very 
similar though, so most of it should apply to the current version.


What would people think of a change like this. I would like to see this happen, 
but I'd like some more opinions before I look into implementing it. 

-X!


[1] - http://www.symfony-project.org
[2] - 
http://trac.symfony-project.org/browser/branches/1.4/lib/util/sfFinder.class.php
[3] - http://www.symfony-project.org/cookbook/1_2/en/finder
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Removing test suites from trunk

2010-12-07 Thread Soxred93
 
 I think the idea that only people intending to do development work on
 MediaWiki download from SVN is a bit insane. And as you note, these tests
 are only going to grow in size over time.

This whole discussion is bringing an analogy to a PHP framework that I'm using 
a lot now, symfony [1]. Their SVN is even larger than MediaWiki's. A large part 
of that is for languages (which, by the way, are not only languages, but every 
single culture too), and lots of unit tests. 99.99% of users don't need them, 
but they package them anyway. I think that the whole discussion should be moot, 
as 40MB is not that much in comparison to other codebases. Either way, people 
will need far more than 40MB of space on the server to run a good wiki, and not 
very many people have a server that would have less in the first place.

-X! 
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Removing test suites from trunk

2010-12-06 Thread Soxred93

On Dec 6, 2010, at 5:12 AM, Niklas Laxström wrote:

 On 6 December 2010 08:11, Q overlo...@gmail.com wrote:
 I think better time would be spent decoupling all the languages.  Out
 the 57 megs for an svn export, 41 is the languages directory. Distribute
 the Big $foo, where $foo is some reasonable number of major languages,
 and offer the rest as a seperate dl.

Perhaps an option would be to remove them from phase3, and moving them to a 
separate directory. Then, if someone switches the wiki language to some obscure 
language, or does uselang=dfdjdkgj, or other activity that needs an obscure 
language, it would run a one-time download to the local filesystem. Might be 
too slow, but it's only a 1 time download.

Just an idea.

-X!
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Removing test suites from trunk

2010-12-06 Thread Soxred93
It probably would not be too hard to make an extension to do just that. Just 
modify ExtensionDistributor. 

-X!

On Dec 6, 2010, at 10:02 AM, Platonides platoni...@gmail.com wrote:

 Niklas Laxström wrote:
 This suggestion seems to come up from time to time. I feel it is
 unrealistic. First of all we can't remove them from svn, since they
 have to be there. We could remove them from the tarballs, but please,
 last time I checked the tarball was hardly over 12 megs. Even with
 very slow modem it should take an hour at most to download that. Using
 better compression algorithm would likely shrink it as much as
 removing few languages. The minor languages don't even take as much
 space as the major languages, which usually have more complete
 localisation.
 
 Drawing the line is not easy and would likely cause continuous,
 unnecessary contention, put some languages in a privileged position
 and hurt MediaWiki's top notch i18n and l10n support. Each language is
 special, but you don't see that if you just look at the number of
 speakers. Do we really want hurt one of our greatest advantages?
 
 Besides, it feels silly to talk about this, while we simultaneously
 talk about including some of the most common extensions in the name of
 providing feature complete MediaWiki straight from the box--which is a
 goal I agree with.
 
 -Niklas
 
 A few days ago the issue came up where I was talking with an end user
 who was complaining about MediaWiki being too large (in the server, not
 in the tarball) compared to other apps like wordpress.
 I think there's a use case for providing a mediawiki download where the
 end user can check which languages they want and provide a custom download.
 And/or document how to strip some languages from mediawiki.
 
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] No more syntax errors!

2010-11-30 Thread Soxred93
With my limited svn knowledge I'd say no. Postcommit hooks are a part of svn 
itself, IIRC

I could also be wrong. 

-X!

On Nov 30, 2010, at 10:34 AM, Krinkle krinklem...@gmail.com wrote:

 On Tue, Nov 30, 2010 at 10:19 AM, Chad innocentkil...@gmail.com  
 wrote:
 On Tue, Nov 30, 2010 at 10:04 AM, Chad innocentkil...@gmail.com  
 wrote:
 Hi everybody,
 
 It's kind of silly when we commit php syntax errors to SVN
 (I've done it too). Of course we should all test our code before
 committing, but sometimes we don't--especially when it's a
 one line change and there's No Way It Could Break.
 
 To help us stop making these silly mistakes (and to avoid
 the inevitable complaint and followup), I've added a pre-commit
 hook to SVN.
 
 All changed/added files ending in .inc/.php/.php5 are now
 checked with php -l prior to the transaction completing. You
 should get a fun error message on your local console if you
 commit bad code :)
 
 Let me know if you have any problems with it.
 
 -Chad
 
 
 Disabled temporarily, I'm hitting issues when doing
 a svn del.
 
 -Chad
 
 
 Syntax errors in the pre-commit file.
 
 Oh the irony.
 
 -Chad
 
 if/when this is enabled. Does this require anything from the commiters ?
 Do I need to install something or run a command in addition to or  
 instead of 'svn commit -m  '  ?
 
 Sounds nice as an additional check :)
 
 --
 Krinkle
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Mediawiki-api] best practice for rate limits for accessing the English Wikipedia with the API

2010-11-17 Thread Soxred93
Peachy also does handle maxlag correctly. 

-X!

On Nov 17, 2010, at 10:21 AM, Raymond Yee wrote:

 I use mwclient, which, I think, handles maxlag 
 (https://fisheye.toolserver.org/changelog/Bryan/mwclient/trunk/errors.py?cs=310).
   
 I'm also looking into using mw-peachy, which
 also seems to implement the maxlag parameter 
 (http://www.google.com/codesearch?q=maxlag+package:http://mw-peachy\.googlecode\.comorigq=maxlagbtnG=Search+Trunk)
 
 Am I understanding mwclient's and Peachy's implementation correctly?
 
 Thanks,
 -Raymond
 
 On 11/17/10 10:07 AM, Brad Jorsch wrote:
 On Wed, Nov 17, 2010 at 05:44:57PM +0300, Max Semenik wrote:
 On 17.11.2010, 16:39 Raymond wrote:
 
 2) How would I know when I'm accessing the API too quickly or too
 often?  I read at
 http://www.mediawiki.org/wiki/API:Errors_and_warnings
 that there is ratelimited  error message, but so far, I've not seen that
 error myself.  If I don't get a ratelimited error, does that mean I'm
 doing ok with respect to being a good API citizen.
 Rate limits are for editing and logging in only.
 Also, use and handle maxlag=5 on all queries so your bot will
 automatically pause when the database servers are overloaded. See
 http://www.mediawiki.org/wiki/Manual:Maxlag_parameter
 
 
 ___
 Mediawiki-api mailing list
 Mediawiki-api@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/mediawiki-api


___
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api


[MediaWiki-CVS] SVN: [74560] trunk/extensions/AntiSpoof/AntiSpoof.php

2010-10-09 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74560

Revision: 74560
Author:   soxred93
Date: 2010-10-09 19:30:24 + (Sat, 09 Oct 2010)

Log Message:
---
Use an absolute path instead of a relative path

Modified Paths:
--
trunk/extensions/AntiSpoof/AntiSpoof.php

Modified: trunk/extensions/AntiSpoof/AntiSpoof.php
===
--- trunk/extensions/AntiSpoof/AntiSpoof.php2010-10-09 19:19:54 UTC (rev 
74559)
+++ trunk/extensions/AntiSpoof/AntiSpoof.php2010-10-09 19:30:24 UTC (rev 
74560)
@@ -46,10 +46,10 @@
global $wgExtNewTables, $wgDBtype;
$wgExtNewTables[] = array(
'spoofuser',
-   dirname( __FILE__ ) . '/sql/patch-antispoof.' . 
$wgDBtype . '.sql' );
+   dirname( __FILE__ ) . '/sql/patch-antispoof.' . 
$wgDBtype . '.sql', true );
} else {
$updater-addExtensionUpdate( array( 'addTable', 'spoofuser',
-   dirname( __FILE__ ) . '/sql/patch-antispoof.' . 
$updater-getDB()-getType() . '.sql' ) );
+   dirname( __FILE__ ) . '/sql/patch-antispoof.' . 
$updater-getDB()-getType() . '.sql', true ) );
}
return true;
 }



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [74564] trunk/extensions/Renameuser/Renameuser_body.php

2010-10-09 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74564

Revision: 74564
Author:   soxred93
Date: 2010-10-09 20:18:24 + (Sat, 09 Oct 2010)

Log Message:
---
Fix PHP Strict error

Modified Paths:
--
trunk/extensions/Renameuser/Renameuser_body.php

Modified: trunk/extensions/Renameuser/Renameuser_body.php
===
--- trunk/extensions/Renameuser/Renameuser_body.php 2010-10-09 20:13:47 UTC 
(rev 74563)
+++ trunk/extensions/Renameuser/Renameuser_body.php 2010-10-09 20:18:24 UTC 
(rev 74564)
@@ -313,7 +313,7 @@
}
 
$output = '';
-   $skin = $wgUser-getSkin();
+   $skin = $wgUser-getSkin();
while ( $row = $dbr-fetchObject( $pages ) ) {
$oldPage = Title::makeTitleSafe( 
$row-page_namespace, $row-page_title );
$newPage = Title::makeTitleSafe( 
$row-page_namespace,



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [74566] trunk/extensions/AntiSpoof

2010-10-09 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74566

Revision: 74566
Author:   soxred93
Date: 2010-10-09 20:25:33 + (Sat, 09 Oct 2010)

Log Message:
---
(bug 23812) AntiSpoof updates spoof table on user renaming

Modified Paths:
--
trunk/extensions/AntiSpoof/AntiSpoof.php
trunk/extensions/AntiSpoof/SpoofUser.php

Modified: trunk/extensions/AntiSpoof/AntiSpoof.php
===
--- trunk/extensions/AntiSpoof/AntiSpoof.php2010-10-09 20:24:37 UTC (rev 
74565)
+++ trunk/extensions/AntiSpoof/AntiSpoof.php2010-10-09 20:25:33 UTC (rev 
74566)
@@ -40,6 +40,7 @@
 $wgHooks['AbortNewAccount'][] = 'asAbortNewAccountHook';
 $wgHooks['UserCreateForm'][] = 'asUserCreateFormHook';
 $wgHooks['AddNewAccount'][] = 'asAddNewAccountHook';
+$wgHooks['RenameUserComplete'][] = 'asAddRenameUserHook';
 
 function asUpdateSchema( $updater = null ) {
if ( $updater === null ) {
@@ -130,3 +131,12 @@
$spoof-record();
return true;
 }
+
+/**
+ * On rename, remove the old entry and add the new
+ */
+function asAddRenameUserHook( $uid, $oldName, $newName ) {
+   $spoof = new SpoofUser( $newName );
+   $spoof-update( $oldName );
+   return true;
+}

Modified: trunk/extensions/AntiSpoof/SpoofUser.php
===
--- trunk/extensions/AntiSpoof/SpoofUser.php2010-10-09 20:24:37 UTC (rev 
74565)
+++ trunk/extensions/AntiSpoof/SpoofUser.php2010-10-09 20:25:33 UTC (rev 
74566)
@@ -102,4 +102,17 @@
return false;
}
}
+   
+   public function update( $oldName ) {
+
+   $dbw = wfGetDB( DB_MASTER );
+
+   if( $this-record() ) {
+   $dbw-delete(
+   'spoofuser',
+   array( 'su_name' = $oldName ),
+   __METHOD__
+   );
+   }
+   }
 }



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [74510] trunk/extensions/Renameuser

2010-10-08 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74510

Revision: 74510
Author:   soxred93
Date: 2010-10-08 13:01:40 + (Fri, 08 Oct 2010)

Log Message:
---
=(bug 23819) Add option to suppress redirects when renaming user

Modified Paths:
--
trunk/extensions/Renameuser/Renameuser.i18n.php
trunk/extensions/Renameuser/Renameuser_body.php

Modified: trunk/extensions/Renameuser/Renameuser.i18n.php
===
--- trunk/extensions/Renameuser/Renameuser.i18n.php 2010-10-08 12:45:22 UTC 
(rev 74509)
+++ trunk/extensions/Renameuser/Renameuser.i18n.php 2010-10-08 13:01:40 UTC 
(rev 74510)
@@ -18,6 +18,7 @@
'renameusernew'   = 'New username:',
'renameuserreason'= 'Reason for rename:',
'renameusermove'  = 'Move user and talk pages (and their subpages) 
to new name',
+   'renameusersuppress'  = 'Don\'t create redirects to the new name',
'renameuserreserve'   = 'Block the old username from future use',
'renameuserwarnings'  = 'Warnings:',
'renameuserconfirm'   = 'Yes, rename the user',

Modified: trunk/extensions/Renameuser/Renameuser_body.php
===
--- trunk/extensions/Renameuser/Renameuser_body.php 2010-10-08 12:45:22 UTC 
(rev 74509)
+++ trunk/extensions/Renameuser/Renameuser_body.php 2010-10-08 13:01:40 UTC 
(rev 74510)
@@ -52,10 +52,14 @@
// If nothing given for these flags, assume they are checked
// unless this is a POST submission.
$move_checked = true;
+   $suppress_checked = false;
if ( $wgRequest-wasPosted() ) {
if ( !$wgRequest-getCheck( 'movepages' ) ) {
$move_checked = false;
}
+   if ( $wgRequest-getCheck( 'suppressredirect' ) ) {
+   $suppress_checked = true;
+   }
}
$warnings = array();
if ( $oun  $nun  !$wgRequest-getCheck( 'confirmaction' )  
) {
@@ -104,6 +108,19 @@
/td
/tr
);
+   
+   if ( $wgUser-isAllowed( 'suppressredirect' ) ) {
+   $wgOut-addHTML( 
+   tr
+   td#160;
+   /td
+   td class='mw-input' .
+   Xml::checkLabel( wfMsg( 
'renameusersuppress' ), 'suppressredirect', 'suppressredirect',
+   
$suppress_checked, array( 'tabindex' = '5' ) ) .
+   /td
+   /tr
+   );
+   }
}
if ( $warnings ) {
$warningsHtml = array();
@@ -288,6 +305,13 @@
),
__METHOD__
);
+   
+   $suppressRedirect = false;
+   var_dump($wgRequest-getCheck( 'suppressredirect' ));
+   if ( $wgRequest-getCheck( 'suppressredirect' )  
$wgUser-isAllowed( 'suppressredirect' ) ) { 
+   $suppressRedirect = true;
+   }
+   var_dump($suppressRedirect);
 
$output = '';
$skin = $wgUser-getSkin();
@@ -301,7 +325,7 @@
$output .= 'li 
class=mw-renameuser-pe' . wfMsgHtml( 'renameuser-page-exists', $link ) . 
'/li';
} else {
$success = $oldPage-moveTo( $newPage, 
false, wfMsgForContent( 'renameuser-move-log',
-   $oldusername-getText(), 
$newusername-getText() ) );
+   $oldusername-getText(), 
$newusername-getText() ), !$suppressRedirect );
if ( $success === true ) {
$oldLink = 
$skin-makeKnownLinkObj( $oldPage, '', 'redirect=no' );
$newLink = 
$skin-makeKnownLinkObj( $newPage );



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [74511] trunk/extensions/Renameuser/Renameuser_body.php

2010-10-08 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74511

Revision: 74511
Author:   soxred93
Date: 2010-10-08 13:02:47 + (Fri, 08 Oct 2010)

Log Message:
---
fix r74510: remove debugging code

Modified Paths:
--
trunk/extensions/Renameuser/Renameuser_body.php

Modified: trunk/extensions/Renameuser/Renameuser_body.php
===
--- trunk/extensions/Renameuser/Renameuser_body.php 2010-10-08 13:01:40 UTC 
(rev 74510)
+++ trunk/extensions/Renameuser/Renameuser_body.php 2010-10-08 13:02:47 UTC 
(rev 74511)
@@ -307,11 +307,10 @@
);

$suppressRedirect = false;
-   var_dump($wgRequest-getCheck( 'suppressredirect' ));
+   
if ( $wgRequest-getCheck( 'suppressredirect' )  
$wgUser-isAllowed( 'suppressredirect' ) ) { 
$suppressRedirect = true;
}
-   var_dump($suppressRedirect);
 
$output = '';
$skin = $wgUser-getSkin();



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


Re: [Wikitech-l] Balancing MediaWiki Core/Extensions

2010-09-28 Thread Soxred93
That seems like a good idea. I would love to see this in action. 

-X!


Sent from my iPod

On Sep 28, 2010, at 8:11 PM, Krinkle krinklem...@gmail.com wrote:

 Perhaps the new installer could contain that as an option during the  
 inital setup.
 Like a two or three-column thing with a bunch of checkboxes.
 
 Language:English [\/]
 Default theme(X) Vector  (_) Monobook  (_) Foobar
 Common Extension:[X] ParserFunctions[X] SpecialInterwiki
[X] Cite.php[X] CharInsert
[X] CategoryTree
 
 etc. you get the idea
 
 Op 29 sep 2010, om 01:15 heeft Platonides het volgende geschreven:
 
 Chad wrote:
 On Tue, Sep 21, 2010 at 11:34 PM, Trevor Parscal wrote:
 when to move features out of core and into an extension or
 out of an extension and into core.
 
 
 I don't think anyone's commented on the former (everyone's been
 talking about pushing in, not pulling out). IMO, the conditions for
 splitting something into an extension
 
 A) Not a lot of people use it anyway (hard to gauge)
 B) It probably shouldn't have been in core in the first place (eg:  
 AskSQL)
 
 So far, the only successful case I can think of offhand for splitting
 an extension out was AskSQL, but it's a perfect example of what
 should happen.
 
 DumpHTML was also split from core. texvc should have been moved out of
 core, but since that would change things set there from the  
 mwbeginning,
 nobody did it yet.
 
 
 
 1. This is a very valid and important goal, but am unconvinced and
merging extensions into core is the only way to achieve it. We
can, for instance, take advantage the new installer that demon  
 is
working on which has the ability to automate the installation of
extensions at setup-time.
 
 
 Quick note on the installer. It only enables extensions that already
 reside in your extensions folder. Since we don't distribute any with
 the default package, this might not be terribly useful. More awesome
 is Jeroen's GSoC work on extension management. Something to look
 at post-1.17 branch though.
 
 I think the point is to start shipping mediawiki with common  
 extensions
 there.
 
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l
 
 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[MediaWiki-CVS] SVN: [72737] trunk/phase3/includes/DefaultSettings.php

2010-09-10 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72737

Revision: 72737
Author:   soxred93
Date: 2010-09-10 19:13:07 + (Fri, 10 Sep 2010)

Log Message:
---
Followup to r72736: Alphabetical order

Modified Paths:
--
trunk/phase3/includes/DefaultSettings.php

Modified: trunk/phase3/includes/DefaultSettings.php
===
--- trunk/phase3/includes/DefaultSettings.php   2010-09-10 19:12:14 UTC (rev 
72736)
+++ trunk/phase3/includes/DefaultSettings.php   2010-09-10 19:13:07 UTC (rev 
72737)
@@ -4369,8 +4369,8 @@
  * the API help page.
  */
 $wgPageProps = array(
+   'defaultsort' = 'Value of the {{DEFAULTSORT}} tag',
'displaytitle' = 'Value of the {{DISPLAYTITLE}} tag',
-   'defaultsort' = 'Value of the {{DEFAULTSORT}} tag',
'hiddencat' = 'Whether or not the page has a category with the 
__HIDDENCAT__ magic word',
 );
 



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [72738] trunk/phase3/includes/DefaultSettings.php

2010-09-10 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72738

Revision: 72738
Author:   soxred93
Date: 2010-09-10 19:14:13 + (Fri, 10 Sep 2010)

Log Message:
---
Fix r72737: Oops. I fail

Modified Paths:
--
trunk/phase3/includes/DefaultSettings.php

Modified: trunk/phase3/includes/DefaultSettings.php
===
--- trunk/phase3/includes/DefaultSettings.php   2010-09-10 19:13:07 UTC (rev 
72737)
+++ trunk/phase3/includes/DefaultSettings.php   2010-09-10 19:14:13 UTC (rev 
72738)
@@ -4369,8 +4369,8 @@
  * the API help page.
  */
 $wgPageProps = array(
+   'displaytitle' = 'Value of the {{DISPLAYTITLE}} tag',
'defaultsort' = 'Value of the {{DEFAULTSORT}} tag',
-   'displaytitle' = 'Value of the {{DISPLAYTITLE}} tag',
'hiddencat' = 'Whether or not the page has a category with the 
__HIDDENCAT__ magic word',
 );
 



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


Re: [Wikitech-l] New committers

2010-08-25 Thread soxred93
As did I. I expect to see some good work now, Jan Paul! But really,  
welcome!

-X!

On Aug 25, 2010, at 1:28 AM, MZMcBride wrote:

 Tim Starling wrote:
 Extension access:
 * Jan Paul Posma (janpaul123): Sentence-level editing

 This is awesome. I really enjoyed the proof-of-concept. :-)

 MZMcBride



 ___
 Wikitech-l mailing list
 Wikitech-l@lists.wikimedia.org
 https://lists.wikimedia.org/mailman/listinfo/wikitech-l


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] New password hashing proposal

2010-08-19 Thread soxred93

 On Thu, Aug 19, 2010 at 10:50 AM, Ryan Lane rlan...@gmail.com wrote:
 We could do a less secure, but more-secure-than-passwords  
 alternative,
 which is to use email or SMS as a one time password device. SMS is
 obviously more secure than email, but would require us to ask people
 for their phone numbers.

I don't do SMS, and I'm sure I'm not the only one who would rather  
not pay to get a password.

-X!

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


[MediaWiki-CVS] SVN: [70854] trunk/extensions/Distribution/api/ApiQueryExtensions.php

2010-08-11 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70854

Revision: 70854
Author:   soxred93
Date: 2010-08-11 07:59:36 + (Wed, 11 Aug 2010)

Log Message:
---
Use current code conventions

Modified Paths:
--
trunk/extensions/Distribution/api/ApiQueryExtensions.php

Modified: trunk/extensions/Distribution/api/ApiQueryExtensions.php
===
--- trunk/extensions/Distribution/api/ApiQueryExtensions.php2010-08-11 
07:51:48 UTC (rev 70853)
+++ trunk/extensions/Distribution/api/ApiQueryExtensions.php2010-08-11 
07:59:36 UTC (rev 70854)
@@ -53,10 +53,6 @@
public function execute() {
// Get the requests parameters.
$params = $this-extractRequestParams();
-
-   if ( !isset( $params['value'] ) ) {
-   $this-dieUsageMsg( array( 'missingparam', 'value' ) );
-   }

$this-addTables( 'distribution_units' );

@@ -137,6 +133,7 @@
),
'value' = array(
ApiBase::PARAM_TYPE = 'string',
+   ApiBase::PARAM_REQUIRED = true,
),  
);
}



___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


[MediaWiki-CVS] SVN: [70855] trunk/extensions/Distribution/api/ApiQueryExtensions.php

2010-08-11 Thread soxred93
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70855

Revision: 70855
Author:   soxred93
Date: 2010-08-11 08:02:05 + (Wed, 11 Aug 2010)

Log Message:
---
Remove unnecessary error (followup to r70853 and r70854) 

Modified Paths:
--
trunk/extensions/Distribution/api/ApiQueryExtensions.php

Modified: trunk/extensions/Distribution/api/ApiQueryExtensions.php
===
--- trunk/extensions/Distribution/api/ApiQueryExtensions.php2010-08-11 
07:59:36 UTC (rev 70854)
+++ trunk/extensions/Distribution/api/ApiQueryExtensions.php2010-08-11 
08:02:05 UTC (rev 70855)
@@ -168,7 +168,6 @@
 */
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
-   array( 'missingparam', 'value' ),
) );
}   




___
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs


  1   2   3   >