Commit graph

37504 commits

Author SHA1 Message Date
Krinkle
39cb0c19d5 Use .prop instead of .attr where appropriate
* Although jQuery covers for us in most cases (since .prop didn't exist before jQuery 1.6 and many people abused .attr in laziness of doing their own loop and setting the property manually). It's better to know what we're doing and call the function we intend to call. Both because jQuery may decide to stop rerouting common mistakes to .prop and because it makes code more readable.

* Aside from switching to prop, for boolean properties also replacing null/undefined with false and 'propname' with true. This is no longer being covered by jQuery when using prop directly (as it shouldn't). When an element is created the HTML specification says that the attribute should be set to it's name (ie. '<foo selected="selected">'), the properties however must remain boolean.

* Changing the attribute value for a boolean property (ie. checkbox.setAttribute( 'checked', 'checked' ) does not make the checkbox enabled. All it does is set the attribute. The reason this works with jQuery's attr() is because jQuery calls .prop internally after a bunch of checking inside attr().


-- Reference --
The list of keys that .attr and .removeAttr jQuery is currently (as of jQuery 1.6.1) remapping to use .prop and .removeProp can be found here:
b22c904652/src/attributes.js (L425)
{
	tabindex: "tabIndex",
	readonly: "readOnly",
	"for": "htmlFor",
	"class": "className",
	maxlength: "maxLength",
	cellspacing: "cellSpacing",
	cellpadding: "cellPadding",
	rowspan: "rowSpan",
	colspan: "colSpan",
	usemap: "useMap",
	frameborder: "frameBorder",
	contenteditable: "contentEditable"
}
In addition to those, jQuery also maps these boolean properties to .prop when they are passed to .attr:
	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,

(source: b22c904652/src/attributes.js (L9) )
2011-08-12 21:19:45 +00:00
Derk-Jan Hartman
69bde7f3ae Update the Html5 void elements and boolean attributes, in accordance with the latest draft. 2011-08-12 21:04:25 +00:00
Aaron Schulz
7cb4d69d9d Changed PopulateImageSha1 to use LoggedUpdateMaintenance and added it to $postDatabaseUpdateMaintenance 2011-08-12 20:37:35 +00:00
Krinkle
e30c3a7bb5 Fix bug in jquery.byteLimit.js for Safari 4
* Browsers should ignore the maxLength when the .value is set manually through JavaScript, but for some reason Safari 4 (not 5 and later) is enforcing the limit even when the value property is set from JavaScript. Usually this bug doesn't become visible in this module because the byteLength can't be lower than the number of characters, so we'd never see the bug. However since r94066 we're supporting callbacks, and callbacks could do anything to the calculation, including but not limited to making the string that is being checked shorter (ie. suppose maxLength/byteLimit is 8, value is 'User:Sam', and callback filters like "return new mw.Title(val).getName()". If we set it to 'User:Samp' (+p) then Safari 4 would chop the value, because the total string is longer than 8. Whereas all other browsers ignore maxLength (like they should) and let it be and would allow our callback to happen and instead give byteLimit 'Samp' which is length 4 and we still have 4 more characters to go until we reach 8.

The fix is easy, simply do not set the maxLength property if there's a callback.
2011-08-12 20:34:23 +00:00
Daniel Friesen
17289de2db Touch up Title::get[Full|Local]URL. This concept of "if not an existing interwiki getFullURL calls getLocalURL" and "if external (interwiki) getLocalURL calls getFullURL" is ridiculous. In fact if mInterwiki just happens to not be '' and not exist, you create infinite recursion and php dies.
Instead of having getFullURL and getLocalURL call each other, move the interwiki workload into getLocalURL, and make getFullURL simply call getLocalURL then expand it (use the wf method in case it's already a full url) and append the fragment to it.
2011-08-12 19:55:03 +00:00
Aaron Schulz
8991eea8fb More to r94370:
* Fixed hard-coded output message (use $table)
* Removed doPopulateRevSha1 from SqliteUpdater.php too (didn't notice someone added this)
2011-08-12 19:24:08 +00:00
Daniel Friesen
0139030f2b Improve the ability for extensions to participate in how MediaWiki handles url paths:
- Allow extensions to hook into WebRequest::getPathInfo and add to or alter the way titles are extracted from paths
- Add a $variant argument to the GetLocalURL hook; It's always had $query, but never had $variant. As a result extensions using GetLocalURL never new if getLocalURL and have the possibility of trying to change the url in cases where they shouldn't and as a result breaking links on wiki with language variants.
- Add GetLocalURL::Internal hook for non-interwiki links. These kinds of links internally use a ugly hack for action=render and an extension using GetLocalURL can be buggy in render mode if they don't re-implement the same ugly hack that MW does. This ::Internal hook runs before the hack does so extension authors don't need to be exposed to our ugly hacky code.
- Add GetLocalURL::Article hook specifically for url tweaks to pretty urls (ie: Only when we would apply $wgArticlePath); This hook avoids the need for extensions that only want to tweak pretty url output. This hook avoids the need to make a bunch of tests for things like !$title->isExternal(), $query == '', and $variant === false which getLocalURL does and could potentially change in the future making wider GetLocalURL hooks change in function requiring extension updates.
2011-08-12 19:23:43 +00:00
Roan Kattouw
d0d89f4297 Instead of using some hacky regexes, just use wfParseUrl() in WikiMap::getDisplayName(). This should make protocol-relative URLs behave correctly as well, and fix bug 29965 2011-08-12 19:19:34 +00:00
Aaron Schulz
18f5bf2c95 * Added LoggedUpdateMaintenance subclass
* Moved PopulateRevisionLength/PopulateRevisionSha1 scripts to $postDatabaseUpdateMaintenance
* Fixed bogus "{$prefix}_sha1 != ''" comparison (r94362)
* Removed unneeded NOT NULL check (speeds up script a bit) from populateRevisionSha1 script
* Various code cleanups
2011-08-12 19:11:04 +00:00
Aaron Schulz
86c7992100 * Added Revision::getSha1 function
* Try to populate mSha1 when a Revision is made from an array (as rev_len does)
2011-08-12 17:29:57 +00:00
Aaron Schulz
40f7928918 Give notice about missing text 2011-08-12 17:13:28 +00:00
Aaron Schulz
537a6eb680 Fix for r94289: we want to skip rows with non-empty sha1, not non-NULL (which is impossible) 2011-08-12 16:50:03 +00:00
Krinkle
efa078493f Renaming qunit test files to end in ".test.js" (finally!)
* There shouldn't be two files with the same name in core, especially not the module and the test suite. Previously postponed due to compatibility with our TestSwarm script, that has been fixed now.

* Had to modify the files in the same commit since the module name is referenced inside the test suite in the module() call, which is the hint for QUnit when filtering is done through the ?filter= parameter.

* As has been added to the conventions, there must be only one module() call per test suite file and it MUST match "filename without .test.js". Otherwise the module will not be submitted to TestSwarm (which glob()'s at the /suites/ directory and extracts test-suite-module-names from the filenames).
2011-08-12 16:02:03 +00:00
Jeroen De Dauw
ee2b4ad57b added doc 2011-08-12 15:42:23 +00:00
Krinkle
f539ed6bab Follow-up r94325: Fix name in module() as well, otherwise TestSwarm chokes 2011-08-12 15:18:41 +00:00
Daniel Friesen
b7474f0743 Followup r94349; Interwiki::getURL used $title != null to test if the $title arg was passed and should be substituted. However "" == null, so as a result switching to using the argument broke [[mw:]] style interwiki links without an article title.
Update the Interwiki::getURL code to use isset(), and update the comment to tell pre-1.19 supporting extensions to do the entire urlencoding and $1 substitution on their own since Interwiki::getURL was essentially buggy and broken before now.
2011-08-12 14:55:25 +00:00
Roan Kattouw
0be8934126 Guard against parse_url() returning weird things in wfParseUrl(). This is not a problem in practice unless you mess up your local copy badly enough that it tries to do wfParseUrl("%0Ahttp://example.com") like mine just did, but wfParseUrl() should handle all invalid input gracefully without throwing notices. 2011-08-12 14:45:37 +00:00
Robin Pepermans
894bdaabe4 Fix r91886 thanks to johnduhart: check if it is an IP *before* stripping subpages, otherwise IP range blocking does not work 2011-08-12 14:32:05 +00:00
Daniel Friesen
d5dfd2b066 Update Interwiki::getURL's first argument so that it's properly urlencoded when replacements are made.
Scanning all of core and all the extensions we have in svn, it doesn't look like anyone makes any calls to Interwiki::getURL using the argument so this should be safe enough to clean up the api.
Also update Title::getFullURL to make use of the first arg now.
2011-08-12 14:10:37 +00:00
Krinkle
81b67318aa Updating jquery.form from upstream
* Source: e77e287c80
2011-08-12 14:05:12 +00:00
Krinkle
2c856bc11f Updating jquery.qunit from upstream
* Source: 75dae0b9b8
2011-08-12 14:03:05 +00:00
Roan Kattouw
7e13964a02 (bug 30236) Links like [[//example.com Link text]] were parsed as an internal link rather than an external link surrounded by brackets, like [[http://example.com Link text]]. Was caused by another pointless \b directly preceding wfUrlProtocols() in a regex. Also add a parser test for the [[http://example.com Link text]] case (the existing test only covered [[http://example.com]]) and add protocol-relative counterparts for both tests. 2011-08-12 13:32:06 +00:00
Max Semenik
b87c77ebb7 Follow-up r94289: SQLite support, unbreaks tests 2011-08-12 13:16:06 +00:00
Antoine Musso
a2b7e0e79e RN populateSha1.php renamed (r94291)
(fix r94328)
2011-08-12 11:47:36 +00:00
Krinkle
7d569319c7 more ajaxCategories fixes based on review in r93351 CR
* Html-escaping unescaped message in summaryHolder 
* Check for errors in the API response
* Pass true for existence of redirect origin and value of 'exists' for target (instead of backwards)
* Comment fixes
2011-08-12 11:35:50 +00:00
Daniel Friesen
f0af2085f2 Use [] instead of new Array. 2011-08-12 10:25:16 +00:00
Daniel Friesen
57c33820a9 Use a regex when checking for external urls. It's concise and DRY, less prone to bugs like "Whoops I got that hardcoded length int wrong and created a condition that'll never be true",... and it's 4 time faster ;) 2011-08-12 10:20:17 +00:00
Roan Kattouw
975666e7d5 Fix copy-paste mistake in r94289 2011-08-12 10:00:09 +00:00
Daniel Friesen
7e8f5f1e8f Fix usage of the jQuery global in a few spots.
- jQuery changed to $ in some files because there is a closure that creates a locally scoped $, but the jQuery var is globally scoped, meaning using jQuery instead of $ inside that closure could result in interacting with a different instance of jQuery than the uses of $ in that same closure.
- In mwExtension wrap the code inside a closure which it is missing. Also take this chance to fix the whitespace style `fn( arg )` instead of `fn(arg)` on the isArray I added.
This is partially a followup to r94331.

Note: The jquery plugins inside the jquery/ folder look fine for use of jQuery within closures, except for mockjax.
2011-08-12 09:27:16 +00:00
Daniel Friesen
033b9cd5e2 Use jQuery's $.isArray, not instanceof Array. The later has troubles with cross-frame Array instances, and doesn't use the ES5 native method. 2011-08-12 08:40:34 +00:00
Krinkle
2aff6544d6 Reverting r93751 per r93751 CR. 2011-08-12 08:21:22 +00:00
Antoine Musso
782f76ed20 RN populateImageSha1.php renamed (r94291) 2011-08-12 08:16:15 +00:00
Krinkle
b7ac406fd9 Apply lowerCamelCase to files for constructors as well.
(Follows-up r94230)
2011-08-12 06:41:55 +00:00
Sam Reed
8dc7b8889f Whitespace
Documentation
2011-08-11 23:58:29 +00:00
Mark A. Hershberger
c5a6747c1a w/s 2011-08-11 22:35:49 +00:00
Platonides
1fde3687d4 Fix case of the new file added in r94289
Produced the following fatal on Unix systems when trying to update:
Warning: require(maintenance/PopulateRevisionSha1.php): failed to open stream: No such file or directory in includes/AutoLoader.php on line 922
Fatal error: require(): Failed opening required 'maintenance/PopulateRevisionSha1.php' in includes/AutoLoader.php on line 922
2011-08-11 22:32:29 +00:00
Aaron Schulz
4e507929fb Renamed image sha1 population script to be more concise 2011-08-11 22:00:42 +00:00
Aaron Schulz
1689b6ec10 Follow-up r94289: code changes to fill the new fields on insertion and select them 2011-08-11 21:54:46 +00:00
Aaron Schulz
606872436b * Added rev_sha1 and ar_sha1 columns to revision/archive tables (useful for bug 25312)
* Created a script to populate these fields (doesn't handle archive rows without ar_rev_id set though)
2011-08-11 21:52:54 +00:00
Alexandre Emsenhuber
1eff26d193 * Use local context instead of global variables
* Call Linker methods statically
2011-08-11 21:10:30 +00:00
Thomas Gries
d7b0108f1f code cosmetics: moved the closing td to a new line 2011-08-11 20:57:57 +00:00
Thomas Gries
9a93faf4d4 correction of Mixed tabs and spaces (2 tabs and 4 spaces), should use just tabs for indentation 2011-08-11 20:47:25 +00:00
Raimond Spekking
1fea43a13f Localisation update for core and extension messages from translatewiki.net (2011-08-11 19:50:00) 2011-08-11 20:12:53 +00:00
Robin Pepermans
a2ea0dcae0 remove stuff accidentally committed in r94279 2011-08-11 20:03:53 +00:00
Robin Pepermans
165519fdf5 * CategoryPage.php: fix the "category-empty" message per comment on r91518, it was outside the bodyContent. And do not convert interface text.
* Parser.php: Apparently that was a much bigger bug: do not convert interface text going through the parser either.
* Preferences.php: Do not convert the user signature.
For this bug in action, see e.g. http://sr.wikipedia.org/sr-ec/Посебно:Подешавањ?uselang=en (e.g. "Username" -> "Усернаме")
2011-08-11 19:58:23 +00:00
Mark A. Hershberger
3224372562 Fix Bug #30322 “SVG metadata is read incorrectly” by applying supplied patch 2011-08-11 19:51:51 +00:00
Krinkle
9c52dda64b Solve undefined-message problem by removing it all together. I've moved the .containsCat() check to before the $link.length/createCatLink code, now it's always defined.
(Follows-up r93351, r94268)
2011-08-11 19:14:34 +00:00
Sam Reed
559f97a800 I think 3 and a half years is long enough for the redirection to be left around 2011-08-11 19:10:22 +00:00
Krinkle
fa5f572bd8 ajaxCategories fixes based on review in r93351 CR:
* Using typeof check in clean()
* Use mw.Title to get page title from fullpagename instead of split(':')
* replaceNowikis() and restoreNowikis()
 - Improve documentation
 - Moved dash in the UNIQUEKEY to between the id and the incrementing integer, and made it start with an empty string (so that all following concatenations are toString'ed).
* makeCaseInsensitive(): Moved the wgCaseSensitiveNamespaces-check out and wrapped it around the caller instead. Also cached the outcome of "Is category namespace sensitive ?".
* createButton(): text-argument is indeed text, not html. Applying html-escaping.
* resolveRedirects():
 - Replace access to private property _name of mw.Title with function getMainText().
* handleCategoryAdd() and handleEditLink():
 - Restructure title-handling (no local replace() calls and clean(), let mw.Title handle it)
 - Renaming arguments and documenting them better
 - Renaming local variables and removing redundant parts
 - Preserving sortkey as sortkey as long as possible without the pipe
 - Calling the combination of sortkey and leading pipe 'suffix' instead of, also, sortkey.
* createCatLink():
 - Remove the sanitizing here, the string passed is already clean as it comes from mw.Title now
 - Using .text() instead of .append( which is .html-like), category names can contain special characters.
* containsCat():
 - Using $.each instead of [].filter. Stopping after first match.
* buildRegex(): Allow whitespace before namespace colon, and allow whitespace after category name (but before ]] and |..]])

Additional changes not for any function in particular:
* Literally return null in $.map callbacks.
* Using the existence-system of mw.Title instead of passing around booleans everywhere
** Removed 'exists' argument from the resolveRedirects() and handleCategoryAdd() functions, instead checking .exists() of the mw.Title object.
* Passing and using mw.Title objects where possible instead of converting back and forth between strings and objects etc.
* Using "TitleObj.getUrl()" instead of "catUrl( titleString )". Removed now unused catUrl() function.
* To improve readability, renamed local uses of 'var that = this' to 'var ajaxcat = this'.
* Syntax error fixes (.parent -> .parent())
* Merging var statements
* Renamed generic members of 'stash' from 'stash.summaries' to 'stash.dialogDescriptions' and 'stash.shortSum' to 'stash.editSummaries'. dialogDescription is always HTML (input should be escaped before hand)
2011-08-11 19:01:39 +00:00
Victor Vasiliev
d636fac2d8 Allow extensions to add pages with non-wikitext display by adding two new
hooks (generalizing the code already used for CSS/JS pages).
2011-08-11 17:21:31 +00:00