Commit graph

69 commits

Author SHA1 Message Date
Fomafix
e1630b6a53 PHP: Use short ternary operator (?:) where possible
Change-Id: Idcc7e4fcdd4d8302ceda44bf6d294fa8c2219381
2018-06-11 11:26:35 +02:00
Bartosz Dziewoński
b191e5e860 Use PHP 7 '<=>' operator in 'sort()' callbacks
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.

It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.

* Replace a common pattern like `return $a < $b ? -1 : 1` with the
  new operator (and similar patterns with the variables, the numbers
  or the comparison inverted). Some of the uses were previously not
  correctly handling the variables being equal; this is now
  automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
  $a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
  when both variables are strings, but if any of the variables is not,
  'strcmp()' converts it to a string before comparison, which could
  give different results than '<=>', so changing this would require
  careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
  of the time (returns `1` if `$b` is lesser, and `0` if they are
  equal or `$a` is lesser) but is erroneous.

Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
2018-05-30 18:05:20 -07:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Bartosz Dziewoński
8785e4a5b3 Replace remaining uses of deprecated DB_SLAVE with DB_REPLICA
Change 950cf6016c took care of the most,
but a few remain, either outside of includes/ and maintenance/
directories (which that change was limited to), or in code introduced
afterwards.

Change-Id: I9c363d0219ea7e71cde520faba39406949a36d27
2017-08-05 10:10:26 +00:00
Brad Jorsch
53b4892ffb Warn on session access in profileinfo.php and opensearch_desc.php
These are so simple there will probably be no problems, but let's set
them to 'warn' for a week just to be sure.

Bug: T127233
Change-Id: I04007faaf541f30dcaf2085fa86b45bea1ecb754
2016-05-05 11:35:10 -04: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
Timo Tijhof
6b5dcf8718 profileinfo: Suppress frivolous warning about usort callback
When sorting the profile output by a column (e.g. ms/call) the
following error appears:

> PHP Warning:
> usort(): Array was modified by the user comparison function at profileinfo.php:439

This is a known bug in PHP where usage of certain debug features
can cause usort() to detect reference count change and wrongly
claim that the object was changed.

Change-Id: I89ec0149aae46f51de647cdf6c6d645c45cbc185
2015-11-18 01:30:09 +00:00
Amir E. Aharoni
586c39a8d5 Make lines short to pass phpcs in profileinfo.php
Bug: T102614
Change-Id: I3ed44bab923f90e9ff4575e7ad5553225244effc
2015-09-27 17:06:07 +00:00
Fomafix
dfb38d92e3 Generate valid HTML code on error pages
For img_auth.php see
http://validator.w3.org/check?uri=https%3A%2F%2Fwww.mediawiki.org%2Fw%2Fimg_auth.php;No200=1

For profileinfo.php consistently use "/>" for self-closing elements.

Change-Id: I7e6aad0e7a2a745836adc430e3b2f3be5f31b6bb
2015-02-09 12:04:05 +00:00
Chad Horohoe
dbca12bf93 Stop using $wgProfileToDatabase
Was not completely removed and the remaining bits were mostly
broken. $wgProfiler['output'] = 'db' is the proper way.

Fixes T75917
Change-Id: I36565e2372db2ed49b219cf533ec433e8111c52f
2014-12-03 10:37:03 -08:00
Chad Horohoe
b8d93fb4fd Refactor profiling output from profiling
* Added a standard getFunctionStats() method for Profilers to return
  per function data as maps. This is not toolbar specific like getRawData().
* Cleaned up the interface of SectionProfiler::getFunctionStats() a bit.
* Removed unused cpu_sq, real_sq fields from profiler UDP output.
* Moved getTime/getInitialTime to ProfilerStandard.

Co-Authored-By: Aaron Schulz <aschulz@wikimedia.org>
Change-Id: I266ed82031a434465f64896eb327f3872fdf1db1
2014-11-17 19:26:04 -07:00
addshore
cce7721550 Fix phpcs stuff in profileinfo.php
Change-Id: Ia0709ced1ac6365a0c1f7c14c52d2487041a9c3f
2014-08-11 22:32:04 +01:00
Timo Tijhof
beb1c4a0ec phpcs: More require/include is not a function
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.

Also updated usage in text in documentation and the
installer LocalSettingsGenerator.

Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;

Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
2013-05-21 23:26:28 +02:00
umherirrender
c6894adefc Fixed spacing
Added spaces around some parenthesis

Change-Id: If1e50e2a7b0046e91c0bbce8bf6641d8b2446a1d
2013-05-09 19:48:10 +02:00
Tim Starling
1fe9340bb3 Remove hphpc support and deprecate related functions
hphpc has been superseded by hhvm, so support for hphpc is no longer
needed.

* Continue to use Preprocessor_Hash under HipHop since it is still
  faster under hhvm
* Keep $wgCompiledFiles for now, so that wikihiero doesn't give an error
  before Ic9d1e795 is merged
* Migrate the run-server script and associated configuration file to
  hhvm. Enable EnableStaticContentFromDisk since it doesn't seem
  ridiculously inefficient at first glance. Run from $IP rather than
  $IP/.. since hhvm is apparently not picky about sourcing files from
  outside of the current directory.

Change-Id: Ic3e769f1fbad4f7ad26dd819406796fee48c6b45
2013-05-09 08:28:05 +10:00
Siebrand Mazeland
655f5c6b48 Update code formatting
Change-Id: I8741b5b979e55f38a666961a16c387586a92410e
2013-02-14 13:38:19 +00:00
Antoine Musso
7006e1df93 style: fix up commas in function arguments
Fix up spaces in our function calls, we do not want spaces before a
comma and try to avoid multiple commas whenever possible.

Errors:

* No space found after comma in function call
* Space found before comma in function call

Change-Id: I51aec02016f742422fa60b92ad35ba3f0ef59ba3
2013-02-06 19:30:39 +01:00
Alex Monk
c2c982c4e8 (bug 36537) Rename calls to wfArrayToCGI to wfArrayToCgi
Done with this command:
grep wfArrayToCGI * -R -l -Z | xargs -0 -l sed -i -e 's/wfArrayToCGI/wfArrayToCgi/g' && git checkout -- HISTORY

Change-Id: If7f4d4bfc199289c11c43cf519c2415a1aad1c51
2013-01-28 18:04:20 +00:00
Niklas Laxström
5aee0f411f Allow SQL queries with long field list to wrap
Change-Id: I7ed64a246455a7f2c48e7e120d45d1ebeb929584
2012-12-08 12:12:34 +00:00
Antoine Musso
78978d410b profileinfo links now have anchors
Whenever expanding a section in profileinfo, the browser would sent us
to the top again which would force us to browse down to where we were.
Adding basic anchors send the user directly where he was browsing.

Note that HTML5 let you specify anything as an id as long as there is at
least one character.

Change-Id: I5b55297ce25d5c07b29610798fb39eae16d27f6a
2012-11-19 15:34:34 +01:00
Antoine Musso
6cb171925e profileinfo now has lower lines heights
The 8px padding was a bit too tall, "reduced" that to 0.1em which is
good enough. I have also dropped the line-height which does not have any
purpose when you already apply a padding.

Change-Id: I271eb932e4c70f940ebe3da39731f09c998610bc
2012-11-19 15:31:15 +01:00
aude
4fbaa0b822 update.php now create profiling table when needed
When enabling $wgProfileToDatabase, one would have to manually apply a
patch to the database that would add the `profiling` table. This patch
let update.php creates the table whenever $wgProfileToDatabase is true.

This also provide a SQL patch for SQLite backend and update
profileinfo.php to give some clue about enabling the global and running
update.php

Change-Id: If68a25f7ec2b0fbb61f82a318427abe58a89dae7
2012-11-19 12:38:32 +01:00
Dereckson
33c0d601ca (bug 40531) profileinfo.php: Clean up
* Cleaning whitespaces and quotation
* Improving markup and make valid HTML5
  - <!DOCTYPE html>
  - <meta charset="UTF-8">
* Tune up styles a bit, get rid of 90s narrow pale yellow/cyan
  tables.

Change-Id: Iff36c57ea1baa6462d2b35b7a420cd3919c7e454
2012-09-27 02:56:20 +02:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Platonides
9951f9f9ae trunk/phase3 is now mediawiki/core
Change-Id: Ief2721ee6573a5e54a276c91de636d9e1a678b8b
2012-03-23 17:19:22 +01:00
Niklas Laxström
14b61a69f2 Darker colors for profileinfo
The original colors were indistinguishable on my screen.
Also adds bold on hover, to make it easier to match numbers to line.

Change-Id: I8e1ae3f123ad0ff57cb7531026f7ae8f83f79c67
2012-03-23 09:26:25 +00:00
Alexandre Emsenhuber
8217e2658e Fix database table name, it is 'profiling', not 'profileinfo' 2012-01-21 16:45:32 +00:00
Platonides
3741f8d428 Added type hints 2011-12-15 22:42:16 +00:00
Chad Horohoe
018e6d5f3d Show a more useful message when someone tries enabling profileinfo but hasn't created the table yet 2011-09-08 14:53:07 +00:00
Tim Starling
ff1dc8a175 HipHop improvements:
* Added the ability to compile extensions. The build process is bootstrapped by running MediaWiki in interpreted mode. Extension setup file inclusions are slightly modified in a way that makes them register themselves for compilation. Then the same LocalSettings.php uses the compiled extension setup file when the compiled binary runs.
* Tested with Cite and ParserFunctions. The code which lets you have an extensions directory in a place other than $IP/../extensions is untested.
* Simplified WebStart.php slightly by using a custom $_SERVER variable to mark compiled mode. It will break if you don't use the supplied server.conf, but that will break a lot of things so don't do that.
* Fixed the core web entry points to include WebStart.php in compiled mode instead of interpreted.
* Made the build directory configurable. This is mostly so that I can grep the source tree without seeing loads of generated C++.
* In server.conf, added a rewrite rule allowing a /wiki/$1 article path.
* Removed server.conf log file location "/dev/stdout", breaks when you switch user
* Disable static content cache, breaks horribly when you set SourceRoot to a directory containing 7GB of files.
* Rewrote the run-server script in PHP, mostly to support the configurable build directory feature.
* Added an option to the run-server script to allow running in interpreted (hphpi) mode.
2011-05-30 13:49:09 +00:00
Niklas Laxström
0b53892e72 Add a content type and encoding header to profileinfo.php, encoding was borked 2011-02-11 19:28:04 +00:00
Sam Reed
6b3b915353 Big attack on unused variables... 2010-10-14 20:53:04 +00:00
Platonides
8a0282e238 Move some globals into the class. 2010-09-29 16:05:46 +00:00
Chad Horohoe
9e6c7cc8ef Get rid of PHP4-style constructors 2010-08-30 16:52:51 +00:00
Alexandre Emsenhuber
db966a52af Put copyright notice in the standard place (and added @file) 2010-08-07 14:35:18 +00:00
Tim Starling
f21fdea9e5 * Rewrote r69952, profileinfo.php XSS fix. It was probably safe, but it seemed very confused about the order of escaping operations. The whole MediaWiki framework is available, including wfArrayToCGI(), there's no need for unconventional code.
* Renamed makeurl() to something more descriptive and less likely to conflict with extensions.
2010-07-27 02:39:32 +00:00
Platonides
f3a89bb4d0 Close the web page when it is disabled.
Fix XSS in filter parameter. Normal setups (with $wgEnableProfileInfo = false) are not affected.
2010-07-26 17:41:14 +00:00
Aryeh Gregor
74a21f3bd1 Remove most named character references from output
Recommit of r66254 to trunk.  This was just

find extensions phase3 -iname '*.php' \! -iname '*.i18n.php' \! -iname 'Messages*.php' \! -iname '*_Messages.php' -exec sed -i 's/&nbsp;/\&#160;/g;s/&mdash;/―/g;s/&bull;/•/g;s/&aacute;/á/g;s/&acute;/´/g;s/&agrave;/à/g;s/&alpha;/α/g;s/&auml;/ä/g;s/&ccedil;/ç/g;s/&copy;/©/g;s/&darr;/↓/g;s/&deg;/°/g;s/&eacute;/é/g;s/&ecirc;/ê/g;s/&euml;/ë/g;s/&egrave;/è/g;s/&euro;/€/g;s/&harr;//g;s/&hellip;/…/g;s/&iacute;/í/g;s/&igrave;/ì/g;s/&larr;/←/g;s/&ldquo;/“/g;s/&middot;/·/g;s/&minus;/−/g;s/&ndash;/–/g;s/&oacute;/ó/g;s/&ocirc;/ô/g;s/&oelig;/œ/g;s/&ograve;/ò/g;s/&otilde;/õ/g;s/&ouml;/ö/g;s/&pound;/£/g;s/&prime;/′/g;s/&Prime;/″/g;s/&raquo;/»/g;s/&rarr;/→/g;s/&rdquo;/”/g;s/&Sigma;/Σ/g;s/&times;/×/g;s/&uacute;/ú/g;s/&uarr;/↑/g;s/&uuml;/ü/g;s/&yen;/¥/g' {} +

followed by reading over every single line of the resulting diff and
fixing a whole bunch of false positives.  The reason for this change is
given in <http://lists.wikimedia.org/pipermail/wikitech-l/2010-April/047617.html>.
I cleared it with Tim and Brion on IRC before committing.  It might
cause a few problems, but I tried to be careful; please report any
issues.

I skipped all messages files.  I plan to make a follow-up commit that
alters wfMsgExt() with 'escapenoentities' to sanitize all the entities.
That way, the only messages that will be problems will be ones that
output raw HTML, and we want to get rid of those anyway.

This should get rid of all named entities everywhere except messages.  I
skipped a few things like &nbsp that I noticed in manual inspection,
because they weren't well-formed XML anyway.

Also, to everyone who uses non-breaking spaces when they could use a
normal space, or nothing at all, or CSS padding: I still hate you.  Die.
2010-05-30 17:33:59 +00:00
Chad Horohoe
d0ff1e57ff * (bug 14201) Set $wgDBadminuser/$wgDBadminpassword during setup
* (bug 18768) Remove AdminSettings requirements. Maintenance environment will still load it if it exists, but it's not required for anything
2009-07-23 00:31:37 +00:00
Brion Vibber
1c9773bd01 Revert r52336 "Merge maintenance-work branch:"
Seems to have broken a bunch of stuff. Don't commit giant non-critical changes that break Setup.php and all maint scripts. Thanks!
2009-06-24 02:49:24 +00:00
Chad Horohoe
59b60fc311 Merge maintenance-work branch:
* (bug 16322) Allow maint scripts to accept DB user/pass over input or params if no AdminSettings.php
* (bug 18768) Remove AdminSettings.php from MediaWiki core
* (bug 19157) createAndPromote error on bad password
* (bug 14201) Create AdminSettings.php during wiki installation, in the same way as LocalSettings.php
* Introduce new Maintenance class framework and port a good number of scripts over; the ones that are left are a little more complicated. Read the docs.
* Not deleting "unused" files yet, don't want to break everything at once :)
2009-06-24 02:02:37 +00:00
Alexandre Emsenhuber
58beeaa183 Tweaks to profileinfo.php:
* whitespaces fixes
* changed "<form method="profiling.php">" to "<form method="get" action="profileinfo.php">" since "method" should be either "get" or "post" and the script's name was incorrect
2009-05-29 16:48:12 +00:00
Alexandre Emsenhuber
768b6aa491 Per Tim's comment on r50192: $res->free(); is useless and should not be used 2009-05-28 19:56:19 +00:00
Alexandre Emsenhuber
fe535c030d * (bug 6802) profileinfo.php now also work on other database servers than MySQL
Based on patches by Robert Treat (http://bug-attachment.wikimedia.org/attachment.cgi?id=2311) and Karun Dambiec (http://bug-attachment.wikimedia.org/attachment.cgi?id=6083)
2009-05-04 18:35:49 +00:00
Aaron Schulz
d67b431f5a Set $wgProfileToDatabase = false 2008-12-10 03:59:43 +00:00
Brion Vibber
29e1b9a6ae * Less verbose errors from profileinfo.php when not configured 2008-11-17 18:53:35 +00:00
Alexandre Emsenhuber
24075418fb Warning: ini_set() [ref.outcontrol]: Cannot change zlib.output_compression - headers already sent in profileinfo.php on line 58 2008-09-23 18:23:09 +00:00
Aaron Schulz
7934561780 disable compression 2008-08-18 02:36:34 +00:00
Brion Vibber
d59abb95f7 don't need CSS units on non-CSS border attribute 2008-04-30 21:25:19 +00:00
Aaron Schulz
046bb8f4db More tweaks 2008-04-29 16:50:29 +00:00