Commit graph

40 commits

Author SHA1 Message Date
Umherirrender
a4caa4d0c6 build: Updating mediawiki/mediawiki-codesniffer to 22.0.0
Added spaces around .
Removed empty return statement which are not required
Removed return after phpunit markTestIncomplete,
which is throwing to exit the test, no need for a return

Change-Id: I2c80b965ee52ba09949e70ea9e7adfc58a1d89ce
2018-09-16 15:51:11 +00:00
C. Scott Ananian
11b90976ca Hard deprecate support for Parsoid v1 API
This was soft deprecated by f5c874cbaf in
May 2015, and support for the v1 API was removed from Parsoid in May 2016,
but the compatibility code has persisted zombie-like in core.

Hard deprecate this now, to warn anyone who might still be using ancient
copies of Visual Editor and Parsoid, and then we can slice the code out
in the next MW release.

Bug: T100681
Change-Id: I68e0ab5b38f31b7708ba6f075dcb3328dde118d1
2018-07-13 14:12:32 -07: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
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
Max Semenik
369b3fa977 Normalize PHPDoc attributes
Change-Id: I83e686d099de0ff0aacda7e332972e1c7ee49f04
2018-03-16 22:59:15 -07:00
jenkins-bot
45a6ddfcd0 Merge "Improve some parameter docs" 2017-09-10 22:57:48 +00: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
Gergő Tisza
6bdfe84095 Minor fixes to ParsoidVirtualRESTService
* fix URL standardization (follow-up to I675f8252a2)
* avoid warning when timeout is not provided

Change-Id: I2a6c099f52f78017f92de4c078e79de04f230dda
2017-09-07 03:13:17 +00:00
Gergő Tisza
a3c61d717e Fix RestbaseVirtualRESTService URL standardization
The regex /?$ will add a second slash to URLs which already end
in a slash (since it will match both the trailing slash and the
empty position after it), which is enough to trip up HyperSwitch.

Change-Id: I675f8252a2496ace4d6c364a869776dff604df59
2017-08-26 00:32:15 +00:00
Aaron Schulz
82e2c924e4 Remove "@author Aaron Schulz" annotations
Bug: T139301
Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
2017-06-27 15:24:14 -07:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
Timo Tijhof
50a035cd6b Clean up get_class($this) -> static::class in /includes/cache and /includes/libs
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I22c62851bcc88405f4bdd77258d6e28ec1a14924
2017-03-07 21:06:06 +00: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
Max Semenik
2b51bd1847 Fix function name case
Change-Id: Ibd4f682d2ed8500a50d85aae38f17281646f7c2d
2016-09-26 15:32:54 -07:00
jenkins-bot
7abf23c194 Merge "RestbaseVirtualRESTService: Support production URL layout" 2016-08-25 15:04:33 +00:00
Aaron Schulz
64b8debbff VirtualRESTServiceClient management cleanups
* Add getVirtualRESTServiceClient() to MediaWikiServices.
* Support auto-mounting services that are usable by the
  main MediaWikiServices instance.
* Support lazy-loading in mount(), where only class/args
  are set until the service is needed. This avoids excess
  overhead.

Change-Id: I5c22be59664b3f5716c957e2c3d7c8e70d5fdc6c
2016-08-24 03:21:28 +00:00
Aaron Schulz
67ed0f0c0d Fix IDEA warning in VirtualRESTServiceClient
The value was overridden before usage.

Change-Id: If79890dd9a878358133882c41c5fd234ebed012c
2016-08-21 16:18:56 -07:00
Niklas Laxström
b58bc25a99 RestbaseVirtualRESTService: Support production URL layout
Bug: T138088
Change-Id: Iba5a900e8ffd444b174ffdf93f8f5f007108a35b
2016-07-20 15:06:13 +02:00
Aaron Schulz
bfbd0322db virtualrest: Small doc fix
Change-Id: Ie162eb88b4afc492b10c75f00b9725767e21ffeb
2016-04-12 21:10:45 +00:00
Bartosz Dziewoński
c161c46d26 Improve code suffering from PHP 5.3's lack of support for foo()[]
I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored
everything involving isset(), unset() or array assigments, then
skimmed through the remaining results and changed things where they
made sense. These changes were not automated, so please review them.

Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538
2016-02-28 22:49:20 +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
C. Scott Ananian
f422d00970 Rename RESTBase1/Parsoid3 bodyOnly parameter to body_only
The old `bodyOnly` name was deprecated on 2015-09-09.

Bug: T114185
Change-Id: If1fe919672dec4ca281c7f72bfd769a4bcaa5047
2015-09-30 10:27:04 -04:00
Kunal Mehta
476d99b99b Use tab instead of spaces in ParsoidVirtualRESTService
Spotted by phpcs

Change-Id: Iab3b1e7aa69f84d0655d54c7c64d2681e0662af4
2015-09-23 13:31:04 -07:00
C. Scott Ananian
195ea84883 Provide VRS objects with a name for more informative debugging/logging
Bug: T112330
Change-Id: Iaa3af55ebc426d54e8bef94dba5415bc535e096b
2015-09-14 14:42:28 -04:00
Matthew Flaschen
bff922cc5f Fix notice when restbaseCompat is omitted
Change-Id: I61042b326b989a4e3250f4a170d76048bdafcbd3
2015-09-01 23:50:05 -04:00
C. Scott Ananian
f5c874cbaf Use Parsoid v3 API; emulate the RESTBase v1 API
Update the ParsoidVirtualRESTService and the
RestbaseVirtualRESTService to use Parsoid's v3 API, instead of the
deprecated v1/v2 APIs.  Since Visual Editor still issues requests
using the Parsoid v1 API, convert Parsoid v1 API requests into Parsoid
v3 API requests when needed for a smooth transition.  We also add
support for converting RESTBase v1 API requests to Parsoid v3 API
requests.

The next step will be to convert Visual Editor to issue RESTBase v1
API requests (https://gerrit.wikimedia.org/r/217995), and then the
Parsoid v1 conversion code added here can be removed (T100681).

Tested Parsoid v1->v3 conversion, Parsoid v1->RESTBase conversion,
plus Parsoid v3 and RESTBase v1->Parsoid v3 conversion using VE
patched to issue RESTBase v1 API requests.

Bug: T100681
Change-Id: I07ac60cdec7a52ef93187d40099325a069e3239a
2015-08-27 18:41:23 -04:00
Vivek Ghaisas
ec02aba4c0 Change spaces to tabs
Bug: T103243
Change-Id: I145c056ef1b058c9c24b4a402ac9e7778b23e260
2015-06-21 10:00:58 +03:00
Aaron Schulz
a2ea6116af Fixed some <code> tags for doxygen
Change-Id: I550b8760556e4916ee9b63ee244bbbcb4d926142
2015-04-29 06:01:59 +01:00
Marko Obrovac
b13bd0996c Introduce the Restbase Virtual REST Service class
Restbase, the REST content API service, is to be queried instead of
Parsoid by current Parsoid users (most importantly VE). This patch
introduces the Restbase virtual REST service class and transparently
maps Parsoid calls into Restbase ones if parsoidCompat is set when
creating the service object.

Additionally, $wgVirtualRestConfig is introduced in DefaultSettings.php. This
is a first step towards global service configuration and management.

Bug: T89066
Change-Id: I4d4043e5052327bbd789331f1c05b607c45fe7cb
2015-03-09 22:05:58 +01:00
Kunal Mehta
3d11321745 ParsoidVirtualRESTService: Don't use "else if"
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#C_borrowings

Change-Id: Ica51fd60e3da75d3b882cf3172ef7500afeab0db
2015-03-05 16:43:12 +00:00
Gabriel Wicke
03aee0e0cd Fix array index for oldid parameter
This caused an incorrect oldid parameter to be passed to parsoid on html2wt
conversion, resulting in dirty diffs.

Change-Id: If140bbc94f280f9ec5a1c9f6d9c3b4e7a46e1917
2015-01-14 14:06:01 -08:00
Kunal Mehta
9134bcfbb8 Cleanup ParsoidVirtualRESTService
* Remove unused global
* Throw \Exception instead of \MWException since this is in includes/libs/

Change-Id: I2e51d7e25a755b79d14d1814951449f6ce14c68e
2015-01-06 18:11:25 -08:00
jenkins-bot
b5cf0db562 Merge "Make a VirtualRESTService class for Parsoid" 2015-01-07 01:29:44 +00:00
Alex Monk
24409664f1 Make a VirtualRESTService class for Parsoid
So that code to deal with Parsoid can be shared across different extensions.

Relies on I1d57ff24

Bug: T1218
Change-Id: Id658d925b722b885fd425c27f7c4fd2cd02ad0b4
2015-01-07 01:19:45 +00:00
Aaron Schulz
fb009e4f34 Trigger onResponses on non-replacement request too in VirtualRESTServiceClient
Change-Id: I1e550812f3c021c2e2f4246345df2f9dd47d15b8
2015-01-06 21:54:20 +00:00
Reedy
4d9143c7f5 Add lots of @throws
Change-Id: I09d0c13070f966fcf23d2638d8fc1328279a5995
2014-12-24 13:49:20 +00:00
Alex Monk
901b28fb51 Fix error in docs of VirtualRESTServiceClient and MultiHttpClient
err -> error

Change-Id: I758c026599367b282150a513b09d6f6c837a3a80
2014-12-19 21:51:45 +00:00
Alex Monk
a6dadae49f Fix VirtualRESTServiceClient::run
runMulti returns an array of response arrays, not request arrays.

Change-Id: I1d57ff24c43c033d533630c23fe3e1e85b448013
2014-12-19 20:08:31 +00:00
Aaron Schulz
acbdfe48ff Fixed comment typo and other docs tweaks
Change-Id: I0368561611071f0e4722661e7f7c146618f3364a
2014-12-18 17:35:10 -08:00
Aaron Schulz
4d6d11d64b Added VirtualRESTServiceClient/VirtualRESTService classes
* Reference handling cleanup for loops in MultiHttpClient
* Support a slightly more convenient request array format for MultiHttpClient
* Added missing license header to MultiHttpClient

Change-Id: Icc86ed9e4c2ac78363aa7b6f3147253bb59e2afb
2014-04-29 17:01:25 -07:00