aboutsummaryrefslogtreecommitdiffstats
path: root/includes/rcfeed
Commit message (Collapse)AuthorAgeFilesLines
* Reorg: Migrate WikiMap to WikiMap/ out of includesAmir Sarabadani2023-02-271-0/+1
| | | | | | | And WikiReference Bug: T321882 Change-Id: I60cf4b9ef02b9d58118caa39172677ddfe03d787
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-262-10/+12
| | | | | | | | | | | | | | | | | | | | | Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-0/+1
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* rcfeed: Deprecate $wgRCEngines and RCFeedEngineTimo Tijhof2022-03-087-45/+75
| | | | | | | | | | | | | | | | | | | | | | Follows-up 39a6e3dc4d (I8be497c623c5d92). * Improve documentation all around and advertise 'class' everywhere instead of 'uri'. * Add test coverage for RCFeed::factory(). * Deprecate the $wgRCEngines "uri to class" mapping in favour of specifying "class" directly in $wgRCFeeds. * Deprecate RCFeedEngine in favour of FormattedRCFeed. Convert to class_alias so that UDPRCFeedEngine no longer has to extend the deprecated class name explicitly (for instanceof compat). * Hard-deprecate RecentChange::getEngine. Bug: T250628 Depends-On: Ie939e1d06b9ee2d841ec7256c8d24cc4e7e386dd Change-Id: Ib6758d724c7200404c89c7ab157aa55f1cad9763
* rcfeed: Allow easy mocking of RCFeed::factory objectsTimo Tijhof2022-03-031-0/+3
| | | | | | | | | | This matches what the RecentChange::getEngine method provides, which is deprecated and replaced by this. However, in order to update tests (such as those in EventBus) to the new method, that method first has to support mocking of this kind. Bug: T250628 Change-Id: I126f7c8b117b5d2e66a41ebb314523083e764547
* Don't double-escape the ellipses in Language::truncateForVisual()C. Scott Ananian2022-02-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | It turns out this gets rid of a bunch of suppressed "SecurityCheck-DoubleEscaped" that appear to have been accurate warnings. There seems to have been some confusion about how ::truncateForVisual() is supposed to be used; in particular it is to be passed *unescaped* output, because it is not (generally speaking) safe to truncate HTML-escaped strings. The goal of ::truncateForVisual() is to have a specific number of codepoints in the output for display purposes, the encoding of those codepoints is not an issue (htmlspecialchars can be applied to the *return value*.) If you need a specific number of *bytes* you should be using ::truncateForDatabase(). If you want a certain number of *HTML bytes* then the ::truncateHtml() method is probably what you want. Slightly refactor some code in RevDelLogItem to avoid a false positive. Bug: T301205 Bug: T290624 Change-Id: I893362e049aedfa699043fcf27caf4815196f748
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-102-15/+23
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* Drop User methods which were deprecated since 1.35vladshapik2021-11-121-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The following User methods, deprecated in 1.35, have been removed: - ::isIP, - ::isIPRange, - ::isValidUserName, - ::isUsableName, - ::isCreatableName, - ::getCanonicalName, - ::addAutopromoteOnceGroups, - ::getDefaultOptions, - ::getDefaultOption, - ::getOptions, - ::getBoolOption, - ::getIntOption, - ::setOption - ::listOptionKinds - ::getOptionKinds, - ::resetOptions, - ::getEffectiveGroups, - ::getAutomaticGroups, - ::getFormerGroups User::GETOPTIONS_EXCLUDE_DEFAULTS has been removed, since it is used only in the description of User::getOptions. Bug: T277511 Depends-On: Ida05c22f81b30d9b46678e8ede3d531c38855d83 Change-Id: I72bbc2336f8ddbc66ce67226cd2d5baaa2f807d8
* Fix some @stable for ... annotations to use @stable to ...DannyS7122021-07-081-1/+1
| | | | | Bug: T257789 Change-Id: I3ba94a9d6b739cd57cd57afe5d397963127160a8
* rcfeed: Remove reference assignmentKosta Harlan2021-04-271-1/+1
| | | | | | | It's unclear why this was used but it doesn't seem necessary now. Bug: T281226 Change-Id: I900c6188281862a6bde0c6b061ee7e174a2cac42
* Document hook names in hook interfaces.daniel2020-09-271-0/+3
| | | | | Bug: T258665 Change-Id: Ifddbf57f8aa2e3eb0d5845601376cbafa08ed407
* Replace "@stable for implementation" with "@stable to implement"daniel2020-07-131-1/+1
| | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: I17e5e92e24c708ffc846945a136347670a3a20c7
* Stability annotations for interfaces.daniel2020-07-071-0/+1
| | | | | | | | | Per the Stable Interface Policy, PHP interfaces should not be directly implemented by extensions, unless they are marked to be safe for that purpose. Bug: T247862 Change-Id: Idd5783b70fc00c03d57f5b1a887f0e47c4d7b146
* Hooks::run() call site migrationTim Starling2020-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* docs: Hook interface doc comment reviewapaskulin2020-04-211-5/+7
| | | | | | | | Edited doc comments for hook interfaces to improve consistency and add type hints. Bug: T246855 Change-Id: I38fa802463cd6f39bf5946dbbeb1b3ebaea604b2
* Automatically generated hook interfacesTim Starling2020-04-201-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add hook interfaces which were generated by a script which parses hooks.txt and identifies caller namespaces and directories. Hook interfaces are mostly placed in a Hook/ subdirectory relative to the caller location. When there are callers in multiple directories, a "primary" caller was manually selected. The exceptions to this are: * The source root, maintenance and tests, which use includes/Hook. Test hooks need to be autoloadable in a non-test request so that implementing test interfaces in a generic handler will not fail. * resources uses includes/resourceloader/Hook * The following third-level subdirectories had their hooks placed in the parent ../Hook: * includes/filerepo/file * includes/search/searchwidgets * includes/specials/forms * includes/specials/helpers * includes/specials/pagers Parameters marked as legacy references in hooks.txt are passed by value in the interfaces. Bug: T240307 Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
* Remove hack comment from IRCLineURLReedy2020-03-281-1/+1
| | | | | | | We don't use the hook for this reason anymore, only Flow seems to use it Change-Id: If0cd2a05d469131875bead85da49fb3a1ba3c1e9
* WikiMap: Add WikiMap::getCurrentWikiId() to make common use case easierTimo Tijhof2020-03-031-1/+1
| | | | Change-Id: Ie225ebfc37c824e3167742137bbbc9f64aca5f5e
* Upgrade phan to 0.9.1Daimona Eaytoy2020-01-251-1/+0
| | | | | | | | | | Released just now. Many old suppressions can now be removed. Enabling the issue for undeclared variables is left to do later, given that there are roughly 200 warning. Change-Id: I99462a1e9232d6e75022912e2df82bc2038476ef
* Upgrade phan config to 0.7.1Daimona Eaytoy2019-09-041-1/+0
| | | | | | | | This allows us to remove many suppressions for phan false positives. Bug: T231636 Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065 Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
* Unsuppress other phan issues with low countDaimona Eaytoy2019-08-301-0/+1
| | | | | | | | | And also update approximated counts, which for the most part are lower than reported (hooray!) Bug: T231636 Depends-On: Ica50297ec7c71a81ba2204f9763499da925067bd Change-Id: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
* Fix entites typosZoranzoki212019-08-281-1/+1
| | | | | Bug: T201491 Change-Id: I241fda87b0e53e804f6bdd48eb975a79e9f176d2
* Use [...] instead of array(...) in PHP comments and documentationFomafix2019-06-171-2/+2
| | | | Change-Id: I0c83783051bf35fe785bc01644eeb2946902b6b2
* build: Upgrade mediawiki/mediawiki-phan-config from 0.5.0 to 0.6.0 and make passJames D. Forrester2019-05-131-0/+1
| | | | | | | | Fix five instances of PhanPluginDuplicateConditionalNullCoalescing; escape the rest for now. Bug: T219114 Change-Id: Ic4bb30c43c5315ce6b878b37b432c6e219414f8b
* rcfeed: Replace usage of deprecated class RCFeedEngine (in comments)Derick Alangi2019-04-301-1/+1
| | | | | | | | Doing the replacement for code logic for where it's used is breaking compatibility, the first change set did this but as adviced, let's wait for a while until the class is removed. Change-Id: I3cc0593080f0d51b380c9cdbabc646459e6798e1
* rcfeed: Replace usage of deprecated CommentStore::getStore()Derick Alangi2019-04-191-1/+4
| | | | Change-Id: Icaa475a86becb7ef95304f5df31d3fdcf93168e9
* Fix/suppress misc phan errors (#5)Kunal Mehta2019-04-051-0/+1
| | | | | | Add lots of missing return statements, or remove incorrect doc blocks. Change-Id: I0881e98fbb9d0d4cf79ecc824064d24538055d3f
* rcfeed: Avoid extending/inheriting from a deprecated classDerick Alangi2019-03-251-3/+3
| | | | | | Also, fix if...else syntax with return statement in the if block. Change-Id: If14f0835731f264622cf90fcfd5c7cc850f63050
* Rename WikiMap DB domain ID methods to reduce confusion with web domainsAaron Schulz2019-02-061-1/+1
| | | | | | Those added in this same release do not need alias methods. Change-Id: I05feeb9b0b13afe43aea1f95551965489cdbe094
* Use WikiMap methods for wiki ID logic in more placesAaron Schulz2018-10-291-1/+1
| | | | Change-Id: I25b53576a8fecb7cfb0e4d684f064bebf6c968fc
* Pass $key into CommentStore methods and use MediawikiServicesaddshore2018-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This allows CommentStore to be added to MediaWikiServices without the need of an aditional Factory. This change includes a compatability layer to allow the behaviour from 1.30 to continue to be used while deprecated. CommentStore::newKey has been deprecated. Keys are now passed into the public methods of CommentStore where needed. The following CommentStore methods have had their signatures changed to introduced a $key parameter, but when used in conjunction with CommentStore::newKey behaviour will remain unchanged: * CommentStore::getFields * CommentStore::getJoin * CommentStore::getComment * CommentStore::getCommentLegacy * CommentStore::insert * CommentStore::insertWithTemplate Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
* Merge "Fix a few minor mistakes in PHPDoc tags"jenkins-bot2017-09-151-1/+1
|\
| * Fix a few minor mistakes in PHPDoc tagsThiemo Mättig2017-09-151-1/+1
| | | | | | | | Change-Id: I2d5f876c9945ba21f8748562230170e3c7ea2ff2
* | Improve some parameter docsUmherirrender2017-09-104-0/+14
| | | | | | | | | | | | Add missing @return and @param to function docs and fixed some @param Change-Id: I810727961057cfdcc274428b239af5975c57468d
* | Always put type information before variable name for @var tagsKunal Mehta2017-09-041-1/+1
| | | | | | | | | | | | | | | | | | Like other tags, @var should have the type information before the variable name. <https://docs.phpdoc.org/references/phpdoc/tags/var.html> Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
* | Add `comment` table and code to start using itBrad Jorsch2017-08-301-1/+3
|/ | | | | | | A subsequent patch will remove the old columns. Bug: T166732 Change-Id: Ic3a434c061ed6e443ea072bc62dda09acbeeed7f
* doc: Fix a few Example docs for PHP classesTimo Tijhof2017-07-171-1/+3
| | | | | | | | | | | | | | | | | * "@example" is specifically for creating entries on the "Examples" page produced by Doxygen, which is not specific to individual classes or methods, but rather is meant to be about the software as a whole. There are currently four entries produced there, and they are all broken: - .../src/includes/rcfeed/RedisPubSubFeedEngine.php (unnamed example, broken) - .../src/tests/phpunit/MediaWikiTestCase.php (unnamed example) - 42 (empty page named "42") - user (empty page named "user") * Remove usage and replace with either a regular paragraph that is part of the member/method/class description, or for code examples, use "@par" to create a sub heading, and then a @code-@endcode block. Change-Id: I52c937fef4b377173f6c4dbad9dc4a9f8beae4ee
* rcfeed: Ensure formatter (and other params) is passed to RCFeedEngineTimo Tijhof2017-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | Follows-up 39a6e3dc4d. Class-based feeds are always given their parameters by RCFeed::factory. However because the old getEngine() method insists on creating its own object, the constructor parameters were not given. Add it as optional parameter and pass it through there. This is backwards-compatible still because before the 39a6e3dc4d refactor, an RCFeedEngine also was not given information about any formatter and it was the callers responsibility to format the line before calling send(). CentralAuth still uses it this way and that works fine. The core-caller that expected the construction parameters since 39a6e3dc4d is hereby fixed. The test couldn't catch this because it constructed the class instance there, since PHPUnit does not support a mock class that is instantiated by foreign code, and the parameter is passed there. Bug: T156996 Bug: T157106 Change-Id: I83433cf57b6e040cdb69f3ad8807a999c4f931a5
* rcfeed: FormattedRCFeed constructor should match parent classTimo Tijhof2017-02-021-1/+1
| | | | | | | | | | I intentionally made the constructor parameter optional in the new RCFeed class from 39a6e3dc4d84, however it was not optional in the subclass, which the older classes are now based on top of. Bug: T156996 Change-Id: I05b9e15920bc39f27c402b023d1463cfbdd2efb8
* Refactor RCFeed configuration (backwards compatible)Timo Tijhof2017-02-015-21/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously: * Engines had to be registered in $wgRCEngines. * The RCFeedEngine classes took no constructor arguments and were expected to send whatever text is previously formatted without any information about it. This generic design was flexible in allowing one to use any formatter with any engine with minimal configuration and no need for additional classes. * Each feed configured their destination by setting a 'uri' option that encodes the name of the engine in PHP as the uri scheme. Other uri components had to be used for any other parameters to the engine (host, port, path). While fairly limited, it was sufficient for the default engines in core. Changes: * Allow feed classes to be directly associated with a feed in $wgRCFeeds via a new 'class' option - without the indirection of 'uri' and $wgRCEngines. All options are passed to the given class constructor. This matches the design used elsewhere in MediaWiki. (ObjectCache, FileRepo, FileBackend, JobQueue, LBFactory, etc.) This means we no longer enforce a 1:1 mapping of internet protocols to a specific feed engine, and it allows settings to be passed without being encoded as a URI neccecarily. Main use case for this refactor is EventBus (see I7edc4d57fa), Interestingly, this matches the (then incorrect) documentation written for $wgRCFeeds in 2961884b43 (which mentions an 'engine' property that would do the same thing). * Move the default 'omit' filters and unrestricted 'formatter' handling to a new FormattedRCFeed class, which remains the default. * Deprecate RecentChange::getEngine() in favour of RCFeed::factory(). * Document wgRCEngines as "@since 1.22". Follows 2961884b43, ffc71cb6af. Change-Id: I8be497c623c5d928762e3d3406a388f4d91add9a
* Don't send RC_CATEGORIZE events to the IRC feedKunal Mehta2016-02-181-0/+5
| | | | | Bug: T127360 Change-Id: I21e4c0edf25fc0b7f16ef3029de879d3b7a2923d
* Convert all array() syntax to []Kunal Mehta2016-02-173-13/+13
| | | | | | | | | | 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
* Properly escape \n and \r in IRCColourfulRCFeedFormatterRyan Schmidt2016-01-201-3/+3
| | | | | | | | | | Right now it is possible to emit a raw \n or \r to the UDP feed by encoding it as an HTML entity, e.g. &#10; This could be used for arbitrary IRC command execution in bots which do not subsequently perform their own escaping. This commit changes it so that entities are decoded first before \n and \r are stripped. Change-Id: I3f7005abded3fbafb586754d763a00a4018f0954
* RC: Handle getLine returning null, which breaks Redis engine (at least HHVM)Matthew Flaschen2015-08-181-1/+2
| | | | | Bug: T109544 Change-Id: I02dcfc7a10a74571232a898f1ef348f8dbc48b45
* Encapsulate rc_params handling in RecentChange::parseParamsStephane Bisson2015-06-101-3/+1
| | | | | | | | | | * Make MachineReadableRCFeedFormatter use it * Some unit tests * Also fixed some line-too-long warnings in RecentChange.php Change-Id: I443d14f5d4cdac0945cb9c03608d55745bbb865b
* Create a generic UDP transport classBryan Davis2014-12-151-1/+2
| | | | | | | | | Code moved from MWLoggerLegacyLogger::emit(), which was formerly in wfErrorLog(). Bug: T74572 Bug: T78599 Change-Id: I9e0e63d41bed6ccb468f3a9f1d52f156acc355a8
* Replace wfRunHooks calls with direct Hooks::run callsAaron Schulz2014-12-101-1/+1
| | | | | | * This avoids the overhead of an extra function call Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
* Use safe attribute accessor for RecentChangeBryan Davis2014-09-131-23/+22
| | | | | | | | | | The RecentChange does not guarantee that all attributes are populated. Handily it provides a safe getter function in RecentChange::getAttribute() that will return null with out triggering an undefined index warning for missing attributes. Protects against log spam like "Notice: Undefined index: rc_id". Change-Id: Idee844f0d40a2a084e17f201b5e1501d59a0464d
* Remove various functions and globals deprecated since 1.22 from RecentChangewithoutaname2014-08-121-1/+1
| | | | Change-Id: I5200892e75ffa894133e2e386d53c09536547de9
* Cleanup some docs (includes/[m-r])umherirrender2014-07-241-1/+1
| | | | | | | | | | - Swap "$variable type" to "type $variable" - Added missing types - Fixed spacing inside docs - Makes beginning of @param/@return/@var/@throws in capital - Changed some types to match the more common spelling Change-Id: I8ebfbcea0e2ae2670553822acedde49c1aa7e98d