Commit graph

55 commits

Author SHA1 Message Date
Brian Wolff
f631c16e84 Fix some warnings from phan-taint-check
Change-Id: I58af7bc21f4c6b77dbda689faa904b53705fe576
2018-08-13 23:00:06 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Kunal Mehta
06ca92eb8c Re-enable MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals sniff
Disable it in specific files and places where there are legitimate uses
to access $_GET and $_POST directly.

For EditPage, which wants to output $_POST for debugging information,
introduce WebRequest::getPostValues() as a wrapper, matching the
existing ::getQueryValues().

Change-Id: I2cb0a7012fb7ed29dcd720056b42f56508ddc5fa
2018-05-19 15:07:25 -07:00
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02:00
WMDE-Fisch
ae3419f532 Replace some of the deprecated wfGetLBFactory() calls
Change-Id: I87aa0ebe273706438f1634167de8c60f51432878
2017-02-07 14:41:09 +01:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aaron Schulz
032bed0c2f Make AjaxDispatcher commit transactions before responding
Some extension code appears to have sanity commit() calls
to work around this in places, which is the wrong solution.

Note that there was always the post-send commit, just not
the pre-send one that normal requests have.

Change-Id: I410a1f1097daa4f43481d1b0afbe7f467b86d254
2016-01-12 21:24:37 +00:00
umherirrender
6b24d10b6d Fix some line indent of string concat
Change-Id: I5883c9cd57d106168648b4502051b4b49046fea2
2015-06-19 20:52:43 +02:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Kunal Mehta
6e12c4bf95 AjaxDispatcher: Use Config instead of globals
Also removed a usage of $wgUser, and converted
AjaxResponse to use Config.

Change-Id: Ia9a1e17da26908b81f7f9691445ff75db2fdefb1
2014-08-25 19:20:30 -07:00
umherirrender
4ee680a8b3 Fixed spacing
- Removed spaces after not operator (!)
- Removed spaces inside array index
- use tab as indent instead of spaces
- Add newline at end of file
- Removed spaces after casts

Change-Id: I9ba17c4385fcb43d38998d45f89cf42952bc791b
2014-07-24 11:53:04 +02:00
MatmaRex
df8ec1e216 No spaces after (casts)
Also removed some unnecessary ones. I think I've caught them all.

The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.

Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
2013-09-04 20:05:43 +02:00
Brad Jorsch
76623e75da Add User::isEveryoneAllowed function
User::groupHasPermission is used for various purposes, from checking
whether it makes sense to show a "hide logged-in users" on
Special:NewPages to showing different error messages in some places when
'user' or 'autoconfirmed' is allowed the action to avoiding unstubbing
$wgUser to check $wgUser->isAllowed( 'read' ) in the common case where
'read' permission is granted to everyone.

For the OAuth work, we need to be able to catch that last type of use
without interfering with the others. This change introduces
User::isEveryoneAllowed() to be used for that type of check, which both
makes sure the right granted to '*' isn't revoked from any group and
calls a hook to allow extensions to indicate that they might remove the
right.

Change-Id: Idfee1b4d0613aaf52e143164acd6022459415c49
2013-07-12 11:18:15 -04:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
Alexandre Emsenhuber
059b64c649 Don't unset() $wgOut in AjaxDispatcher.
It's now totally useless since we are storing it
in the RequestContext object, so this won't prevent
the MediaWiki class to use it.

Change-Id: I10a15a16769f8f208c13bfb9ad38738562c11eac
2012-07-29 21:58:03 +02:00
Alexandre Emsenhuber
bc61dc4d96 explode()'ing the callback is no longer needed in AjaxDispatcher.
This is only needed in PHP<5.2.3, as we require PHP 5.3.2+,
this is no longer the case.

Change-Id: I6fa210a96f854d12d9713172a31ed5a71d3d4a69
2012-07-17 16:28:58 +02:00
mrbluesky
1aead61d4c Add and fix comments in some includes files
Change-Id: If781ad1a9eeba8310cef97dc9786685e8b265fa1
2012-05-24 20:42:56 +02:00
Alexandre Emsenhuber
44ec396481 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ife63db5d36d833de4e0944f9b79ab0f80e7b84c5
2012-05-22 20:43:10 +02:00
Sam Reed
7141742914 * (bug 32276) Skins were generating output using the internal page title which would allow anonymous users to determine wheter a page exists, potentially leaking private data. In fact, the curid and oldid request parameters would
allow page titles to be enumerated even when they are not guessable.
* (bug 32616) action=ajax requests were dispatched to the relevant internal functions without any read permission checks being done. This could lead to data leakage on private wikis.
2011-11-28 23:18:55 +00:00
Chad Horohoe
e830370858 Kill AjaxFunctions.php. The only thing using this was FCKEditor, so I moved js_unescape() over to it.
Roan: "So what does it do?"
Me: "Converts stuff encoded with JS's escape() back into a normal string, according to the docs."
Roan: "That sounds like a workaround for bad design"
2011-07-14 20:38:28 +00:00
Platonides
49074e8a56 Yet more additions of wfProfileOut() 2011-02-10 16:39:53 +00:00
Alexandre Emsenhuber
0fdb7455af Use the AutoLoader to load the AjaxDispatcher class 2010-12-08 10:00:25 +00:00
Aryeh Gregor
a6aac77d16 Revert r70960 "AjaxDispatcher, now ~30 lines shorter and not using $_GET or $_POST"
Broke CategoryTree, see code review for the error message.
2010-08-13 21:39:51 +00:00
Chad Horohoe
5806e63383 AjaxDispatcher, now ~30 lines shorter and not using $_GET or $_POST 2010-08-12 14:34:54 +00:00
Siebrand Mazeland
5c1630efa7 Ran stylize.php, removed trailing whitespace, updated indentation and code formatting. 2010-05-30 14:28:54 +00:00
Siebrand Mazeland
f8b1c4cfb7 Random indentation and code formatting updates. No functional changes. 2010-02-14 22:07:30 +00:00
Chad Horohoe
a4e5e935b6 Mass convert NULL -> null. Left strings and comments alone, obviously. 2009-12-11 21:07:27 +00:00
Daniel Kinzler
ef0d2694e2 adding debug messages to ajax dispatcher 2008-06-28 19:40:14 +00:00
Alexandre Emsenhuber
087a9f70c5 WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>

Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage

One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
Alexandre Emsenhuber
1bbb162e8b Stop profiling before ending the function 2008-05-05 19:39:30 +00:00
Siebrand Mazeland
79d5225c0e * remove end of line whitespace
* remove empty lines at end of file
* remove "?>" where still present
2008-04-14 07:45:50 +00:00
Tim Starling
80991043a9 * De-crappified JS upload dest check feature. Converted to sajax framework. Comprehensive destination checking like the previous behaviour on submission. 500ms typing delay for rate limiting, response cache. Don't display the warning on submission if the user has already seen it via AJAX.
* Added support for static member functions as AJAX callbacks.
* Moved all upload-related javascript to upload.js.
* Needs artwork, see TODO in upload.js.
* Removed UploadForm::showSuccess() as per wikitech-l discussion. Redirect to description page unconditionally.
2007-07-01 18:24:47 +00:00
Aryeh Gregor
a15c419b3d Remove ?>'s from files. They're pointless, and just asking for people to mess with the files and add trailing whitespace. (Yes, I looked over every one and reverted those that were bogus. Slash-enter a million times in less worked well enough, although it was a bit mind-numbing.) 2007-06-29 01:19:14 +00:00
Antoine Musso
db835165c2 * AjaxDispatcher : use a switch()
* Add doxygen comments.
2007-05-05 00:06:20 +00:00
Nick Jenkins
bd23ec29c6 Doc tweaks:
* Seems like an opportune time to introduce "@addtogroup Media" documentation tags.
* Merge "@addtogroup Metadata" (used by Exif.php) into "@addtogroup Media".
* Few more moving comment blocks to above classes.
2007-04-24 06:53:31 +00:00
Antoine Musso
343420d0ad Convert whitespaces to tabulations 2007-04-21 14:44:56 +00:00
Nick Jenkins
f9619da3f0 Yet more doc tweaks:
* Add @addtogroup tags to various classes, to try and group conceptually-related classes together.
* Add brief descriptions to various Special pages, thanks to Phil Boswell.
* Moving some docs to be right above the classes they represent, so that they are picked up.
2007-04-20 08:55:14 +00:00
Nick Jenkins
113bb1c772 Documentation tweaks to help documentation systems (Doxygen + PHPDocumentor)
pick up the appropriate tags, and documentation blobs for classes. This is 
the same as per r20769, but with the grouping changes (e.g. removing "@{{") omitted.
Please be advised that more related documentation tweaks may follow later - e.g. 
Doxygen generates a log file of warnings that is 574 Kb in size, when run over 
the just the trunk/phase3 code ... eek! Thankfully, much of that is just 
whining about functions without documentation   ;-)
2007-04-04 05:22:37 +00:00
Brion Vibber
3a6ac5a3c3 Revert r20769: we don't use PHPDocumentor anymore, we use doxygen.
If making mass changes to tweak to its preferences, probably better to do it for the tool we actually generate docs with. :)
2007-03-28 14:16:43 +00:00
Nick Jenkins
5fef2333d4 PHPDocumentor [http://en.wikipedia.org/wiki/PhpDocumentor] documentation tweaking stuff.
Minor doc tweaks to prevent some PHPDocumentor warnings or errors when run on the includes/ directory. PHPDocumentor uses a syntax very similar to javadoc - mostly we already use this, but there were a few scattered places that were adjusted to make them consistent with the rest of the code. In practical terms, these changes were made:
* @url becomes @link
* @fixme becomes @todo
* HTML tags in descriptions must be closed / balanced.
* @bug was removed (where the bug was long fixed), or changed into a @todo (in the few situations where the bug was still pending)
* @obsolete becomes @deprecated
* Things like "/**@{{" and "/**@}}*/" which cause "unknown tag" warnings were removed
* @access must be a valid access level.
* @desc tag not needed, removed.
* Doesn't seem to like @licence, will accept @license however.
* Use full comment block notation in a few places (i.e. open block with "/**", start each line with " *", and end block with " */")

Then additional to this, to get some class docs associated with their respective classes:
* Moved some docs to right above those classes (deleting blank lines, or moving descriptions from the file headers)
* Marked some classes without docs as "@todo document"
* (done up to "class MIMEsearchPage" on the "classtrees_MediaWiki.html" page for the includes/ directory)
2007-03-28 08:53:02 +00:00
Brion Vibber
2d5ac3c276 * Add 'charset' to Content-Type headers on various HTTP error responses
to forestall additional UTF-7-autodetect XSS issues. Probably not an
  issue on Apache 2.0+, but most servers send only 'text/html' by default
  when the script didn't specify more details.
    This fixes an issue with the Ajax interface error message on MSIE when
  $wgUseAjax is enabled (not default configuration); this UTF-7 variant
  on a previously fixed attack vector was discovered by Moshe BA from BugSec:
  http://www.bugsec.com/articles.php?Security=24

* Trackback responses now specify XML content type
2007-02-21 01:02:47 +00:00
Antoine Musso
b144fcb85d Rename constructors to __constructor 2007-01-20 13:34:31 +00:00
Antoine Musso
1d84c78096 whitespaces killing 2007-01-09 20:25:28 +00:00
Nick Jenkins
351452fab3 One more E_STRICT warning tweak for http://192.168.0.64/wiki/index.php?action=ajax (i.e. no 'rs' argument supplied) :
* Strict Standards: Undefined index: rs in includes/AjaxDispatcher.php on line 38

Q: Should / could the AjaxDispatcher constructor maybe be using the $wgRequest global instead of accessing $_POST and $_GET directly?
2007-01-09 09:51:53 +00:00
Nick Jenkins
b74d985232 Testing AJAX watch/unwatch, with E_STRICT error_reporting:
Prevent :
* Strict Standards: Non-static method Title::newFromID() should not be called statically in includes/AjaxFunctions.php on line 147
[stopped AJAX watch/unwatch working for me, as I have errors being logged to the page output]

E_STRICT warnings on truncated GET input (e.g. http://192.168.0.64/wiki/index.php?action=ajax&rs=wfAjaxWatch&rsargs[]=1 , rather than http://192.168.0.64/wiki/index.php?action=ajax&rs=wfAjaxWatch&rsargs[]=1&rsargs[]=u ), prevent by specifying default $watch value of "" (which should result in an error '<err#>' response, which is probably fine).
* Strict Standards: Missing argument 2 for wfAjaxWatch() in includes/AjaxFunctions.php on line 138
* Strict Standards: Undefined variable: watch in includes/AjaxFunctions.php on line 142

E_STRICT warnings on another truncated GET input ( http://192.168.0.64/wiki/index.php?action=ajax&rs=wfAjaxWatch&rsargs= ), prevent by specifying default $pageID value of "" (which again should result in an error '<err#>' response because it's not numeric, which is probably fine).
* Strict Standards: Missing argument 1 for wfAjaxWatch() in includes/AjaxFunctions.php on line 138

E_STRICT warning on bad GET input - "rs" as array, not as a string - (e.g. http://192.168.0.64/wiki/index.php?action=ajax&rs[]= ), adding explicit cast to string:
* Strict Standards: htmlspecialchars() expects parameter 1 to be string, array given in includes/AjaxDispatcher.php on line 58
2007-01-09 07:05:34 +00:00
Nick Jenkins
f22fcfb835 Prevent XSS / arbitrary HTML injection via unescaped "rs" parameter. Proof-of-Concept attack: http://localhost/wiki/index.php?action=ajax&rs=%3Cscript%3Ealert(%22Ownage%20-%20All%20your%20base%20are%20belong%20to%20me!%22);%3C/script%3E , which will result in this executable JavaScript output: "unknown function <script>alert("Ownage - All your base are belong to me!");</script>" 2007-01-09 06:36:39 +00:00
Aryeh Gregor
69ea9bcf9b (bug 7169) Use Ajax to watch/unwatch articles. Patch by Dan Li with some modification by me. 2006-12-26 23:53:34 +00:00
Tim Starling
3005679b0e * Removed lots of explicit require_once statements. The autoloader should theoretically be faster, because it always uses an absolute path, eliminating the need for a search, and it is never called unnecessarily. Absolute paths are also more robust in the face of odd configurations or usage patterns. Moved a few constants around to support this, they always have to be available before the method call.
* Deleted DatabaseMysql.php, no longer necessary, database classes are autoloaded. 
* Moved wfGetMimeMagic() to MimeMagic::singleton()
* Fixed a couple of __CLASS__.'::'.__FUNCTION__ things.
2006-10-03 13:00:52 +00:00
Daniel Kinzler
6584cef207 Revamped ajax interface, see release notes.
Note: wfSajaxSearch is broken (unrelated to these changes)
2006-08-29 15:43:34 +00:00