aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryBase.php
Commit message (Collapse)AuthorAgeFilesLines
* Simplify WHERE conditions with field = '' OR IS NULLUmherirrender2023-07-011-1/+1
| | | | | | Syntax supported since 26235c73 Change-Id: I397c76d4aba753a1629383559b95df86514f19ff
* api: Drop ApiQuery::getNamedDB() and ApiQueryBase::selectNamedDB()Amir Sarabadani2023-06-011-18/+0
| | | | | | | | Both deprecated in 1.39 and hard-deprecated. Unused in production and allow us to clean up dependency of ApiQuery to LB. Depends-On: Ia94618b7f58fcca72e903fd2e2e9f0aaa501ac24 Change-Id: Ie0322e5346b94932a2eddc0b7aad5a384768b888
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* Replace some tivial ??= with even more trivial ??thiemowmde2022-12-231-4/+4
| | | | | | | | | Patch Ifa7a9bc replaced some longer `=== null` constructs with the new ??= operator we have since PHP 7.4. However, some of these can be simplified even more with the ?? operator we have since PHP 7.0. Follow-Up: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b Change-Id: I7b05e723810558bb5437adc97eab54ca04d38c06
* Make use of ??= in more placesDannyS7122022-12-171-9/+4
| | | | | | New feature from PHP 7.4 Change-Id: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b
* api: Deprecate ApiQuery::getNamedDB and ::selectNamedDB()Timo Tijhof2022-08-221-2/+7
| | | | | | | | | | | | | | | | | | The Rdbms library already takes care of caching and re-using connections nowdays. Perhaps in a past where DBConnRef was less common or not yet created this made sense, but we've now adopted that universally. I don't know of a current use case for WMF, given the removal of non-vertical query groups in T263127 (e.g. we keep "api" for all API traffic, but not e.g. something individual classes would change). For now I've documented that in someone does run into this, perhaps in third-party code, that we recommend instead to override getDB() instead of relying on this central mechanism. E.g. overriddet getDB() to return `wfGetDB(DB_REPLICA,'mygroup')`. Bug: T263127 Change-Id: I4c3cc7868f1f4210ee655541eb6a45705c643c70
* Remove ApiQueryBase::prefixedTitlePartToKeyMatěj Suchánek2022-06-171-15/+0
| | | | | | It has been deprecated since 1.35 and it is unused. Change-Id: I27848626f5457dd41726a25520dcf2459b35e95a
* Remove ApiQueryBase::showHiddenUsersAddBlockInfoMatěj Suchánek2022-06-171-18/+0
| | | | | | It has been deprecated since 1.34 and it is unused. Change-Id: I5c879fd3bedef807181b503663b68e3c2956e120
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-1/+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
* api: Fix documenation/types related to null and int typesUmherirrender2022-02-241-2/+2
| | | | | | Found by phan strict checks Change-Id: I2b2ae12ca39d67140f0f3c1cc5066c8ef72716de
* Remove some more comments that literally repeat the codeThiemo Kreuz2021-12-091-4/+4
| | | | | | | | Nothing to learn from these. You can find a longer explanation in the comments in I93751e6. Change-Id: I195aae70fc282b58be5b18160783f27d38605d15
* Remove or replace usages of "sanity"Reedy2021-11-191-1/+1
| | | | | Bug: T254646 Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
* docs: Fix nullable documentation for class propertiesUmherirrender2021-09-241-1/+1
| | | | Change-Id: I6d0577124d852103f485ffdc819876a13f6641c3
* api: Replace deprecated Hooks::isRegistered in ApiQueryBaseUmherirrender2021-06-301-1/+1
| | | | | | Avoid global HookContainer and use the local one Change-Id: I6448915f478015d7f790e1fc0f6c3653917a138f
* Remove some more comments that literally repeat the codeThiemo Kreuz2021-06-181-2/+2
| | | | | | | | | | | | | … including PHPDoc tags like `@return <type> $variableName`. A return value doesn't have a variable name. I can see that some people do this intentionally, repeating the variable name that was used in the final `return $var;` at the end of a method. This can indeed be helpful. I leave a lot of these untouched and removed them only when it's obviously wrong, or does not provide any additional information in addition to what the code already says. Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
* Users with detelerevision right should see private bits of historyHuji2021-03-231-0/+1
| | | | | | | | The web interface of MediaWiki honors this, but the API interface does not. This patch makes them consistent. Bug: T277358 Change-Id: Ia51e8c6a09a999d3fc6b29eea56a682fa8229ffd
* Use Authority and GroupPermissionLookup in Action APICindy Cicalese2021-02-231-2/+1
| | | | | | | | | | | | | | | | | | | Replaces calls directly to PermissionManager with calls to the Authority object available from Context or the GroupPermissionLookup service. This patch does not address use of PermissionManager for blocks. Deprecations: - ApiBase::checkUserRightsAny deprecated passing optional User parameter - ApiBase::checkTitleUserPermissions deprecated passing LinkTarget as first parameter, takes PageIdentity instead Bug: T271462 Bug: T271854 Change-Id: I5d7cac1c28a37e074750c46cda03283980a07fca
* Strict return types for PageIdentitydaniel2021-01-181-1/+1
| | | | | Bug: T208776 Change-Id: I7e71ffc209465b7cca385603d844cd40178485a9
* Remove unnecessary phan issue suppressionAmmarpad2021-01-081-1/+1
| | | | | | | | Make ApiQueryBase::addOption() annotation consistent with SelectQueryBuilder::option() since the ApiQueryBase method is just a wrapper to it. Change-Id: Ib301bce787c8ba89ae8333eb7cfb8d7d287de20c
* Improve custom folding and groupingTim Starling2020-12-231-25/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PHPStorm can use custom folding regions defined in either the VisualStudio style or the NetBeans style. The VisualStudio style is more pleasing to the eye and also works as a vim foldmarker. So get rid of the previous vim foldmarkers, and use region/endregion. region/endregion need to be in a single-line comment which is not a doc comment, and the rest of the comment is used as a region heading (by both PHPStorm and vim). So to retain Doxygen @name tags, it is necessary to repeat the section heading, once in a @name and once in a region. Establish a standard style for this, with a divider and three spaces before the heading, to better set off the heading name in plain text. Besides being the previous vim foldmarker, @{ is also a Doxygen grouping command. However, almost all prior usages of @{ ... @} in this sense were broken for one reason or another. It's necessary for the @{ to be in a doc comment, and DISTRIBUTE_GROUP_DOC doesn't work if any of the individual members in the group are separately documented. @name alone is sufficient to create a Doxygen section when the sections are adjacent, but if there is ungrouped content after the section, it is necessary to use @{ ... @} to avoid having the Doxygen group run on. So I retained, fixed or added @{ ... @} in certain cases. I wasn't able to test the changes to the trait documentation in Doxygen since trait syntax is not recognised and the output is badly broken. Change-Id: I7d819fdb376c861f40bfc01aed74cd3706141b20
* Improve docs in api related classesUmherirrender2020-11-131-1/+1
| | | | Change-Id: I78338d48530f098fa5d36fe84cfd45c0d160f444
* Remove documentation that literally repeats the codeThiemo Kreuz2020-10-271-1/+1
| | | | | | | | | | | | | | | For example, documenting the method getUser() with "get the User object" does not add any information that's not already there. But I have to read the text first to understand that it doesn't document anything that's not already obvious from the code. Some of this is from a time when we had a PHPCS sniff that was complaining when a line like `@param User $user` doesn't end with some descriptive text. Some users started adding text like `@param User $user The User` back then. Let's please remove this. Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
* Merge "Replace "@stable for subclassing" with "@stable to extend""jenkins-bot2020-07-131-1/+1
|\
| * Replace "@stable for subclassing" with "@stable to extend"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: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
* | Merge "Replace "@stable for calling" by "@stable to call""jenkins-bot2020-07-131-1/+1
|\ \
| * | Replace "@stable for calling" by "@stable to call"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: If560596f5e1e0a3da91afc36e656e7c27f040968
* / Replace "@stable for overriding" with "@stable to override"daniel2020-07-131-4/+4
|/ | | | | | | | | | | 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: I5ffbb91882ecce2019ab644839eab5e8fb8a1c5f
* Mark API base classes as extensibledaniel2020-07-081-0/+7
| | | | | | | | This marks API base classes as stable for extending per the Stable Interface Policy. Bug: T247862 Change-Id: I164192ba3d013d8bc98a8b9c6db10e3dd1e58b23
* Hooks::run() call site migrationTim Starling2020-05-301-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* In ApiQueryBase, use a SelectQueryBuilder to store query informationTim Starling2020-05-181-58/+59
| | | | | Bug: T243051 Change-Id: I5bc99ee4b0674a5bc02ff31e3f7182fd7564b848
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-5/+5
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Allow null on ApiQueryBase::addTimestampWhereRangeUmherirrender2019-12-281-4/+4
| | | | | | Also add null to the underlying functions used here Change-Id: I2e45fa449cf4c82d9a0e4323c4ac3ac2155bcadc
* API: Update docs on addWhere() and related methodsBrad Jorsch2019-12-171-6/+25
| | | | Change-Id: I189f0949e20b4e4ee130e3c7961635169853aeb4
* Fix more scalar types in docblocksDaimona Eaytoy2019-12-081-3/+3
| | | | Change-Id: I574d4e261ab986e028c3ce26c4f0ec648b88a2ac
* Don't fail hard on bad titles in the database.daniel2019-11-251-8/+29
| | | | | | | | This updates some code that has been constructing TitleValue directly to use TitleValue::tryNew or TitleParser::makeTitleValueSafe. Bug: T200055 Change-Id: If781fe62213413c8fb847fd9e90f079e2f9ffc9d
* Merge "Run GenderCache for api query modules using ApiQueryBase::addTitleInfo"jenkins-bot2019-11-051-0/+4
|\
| * Run GenderCache for api query modules using ApiQueryBase::addTitleInfoUmherirrender2019-11-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When converting a Title object into a string for user or user talk namespace the gender information are needed. This patch set improves performance on wikis with gender distinction like dewiki or ruwiki by combining the fetch of the information into one query and avoids a query per unique user name. It also avoids false results for request with apihighlimit, because the apihighlimit with 5000 is higher than the query max limit of the GenderCache with 1000 Bug: T200238 Change-Id: Ibe0561b210dbeb654117dad777e839640f51b4e4
* | Minor cleanupsMax Semenik2019-11-031-2/+1
|/ | | | | | | | | * Identifier case * Returning a void function result * Unused variable * Missing documentation Change-Id: Ibfd2fc5ae1d91c7c9c6a34bcd4523384d3bca576
* Fill GenderCache for used pages in action=query&prop=fileusageUmherirrender2019-09-251-0/+37
| | | | | | | | | | | | Add an utility function ApiQueryBase::executeGenderCacheFromResultWrapper GenderCache stops working when there are more than 1000 cache missed and returning the default value (T200238) Fill the cache with all needed users avoids this behaviour and it saves one query per user page. Change-Id: I911dcb160a7b169091b9e8f66fb3908d0f2a1ba4
* API: Use ApiBlockInfoTrait in ApiQueryUsers and AllUsersBrad Jorsch2019-09-181-41/+21
| | | | | | | | | | | | For efficient bulk querying, this means that ApiQueryBase::showHiddenUsersAddBlockInfo() needs to return everything needed by DatabaseBlock::newFromRow(). Since we're rewriting it anyway, we may as well also move ApiQueryBase::showHiddenUsersAddBlockInfo() out into a trait of its own. Bug: T232021 Change-Id: I9c5b17a232ecbfbffefc7e40608cf5684ce8a644
* Deprecate and replace usages of User:isAllowed{All,Any}Petr Pchelko2019-08-211-1/+2
| | | | | Bug: T220191 Change-Id: I197b8fadaa93e7b320fc19c10e3e09387fe09ad2
* Replace User::isAllowed with PermissionManager.Petr Pchelko2019-08-201-1/+1
| | | | | | | | Covers root includes, actions, api, block, changes, changetags, diff and PermissionManager itself. Bug: T220191 Change-Id: Ic027d32f5dd8f4c74865df0c8a9fcf91123c889c
* Clean up spacing of doc commentsUmherirrender2019-08-051-4/+4
| | | | | | Align the doc stars and normalize start and end tokens Change-Id: Ib0d92e128e7b882bb5b838bd00c74fc16ef14303
* Type hint against IResultWrapper in api classesUmherirrender2019-06-191-2/+2
| | | | Change-Id: If3870e6b8d343dd12390f5155d97edbbe080ac77
* Use [...] instead of array(...) in PHP comments and documentationFomafix2019-06-171-1/+1
| | | | Change-Id: I0c83783051bf35fe785bc01644eeb2946902b6b2
* Change array type on ApiQueryBase::addTablesUmherirrender2019-06-071-1/+2
| | | | | | | | | | | | | | | | | This function results in passing its value to IDatabase::select as first parameter $table. The first parameter is documented as string|array, because it can take more complex arrays: * Joins using parentheses for grouping (since MediaWiki 1.31) may be * constructed using nested arrays. For example, * * [ 'tableA', 'nestedB' => [ 'tableB', 'b2' => 'tableB2' ] ] Update the type to allow also passing such complex arrays to this function ApiQueryBase::showHiddenUsersAddBlockInfo() is using this format Change-Id: I8038243545bc1c79a1106ccc3bec7738e63c2e2e
* Fix doc for $item of ApiQueryBase::addPageSubItemUmherirrender2019-05-261-1/+1
| | | | | | ApiResult::addValue defines mixed for $value Change-Id: I31881426ce7cb81f6430cccd4252881a154cd161
* api: Remove deprecated `prepareUrlQuerySearchString()` from coreDerick Alangi2019-05-111-29/+0
| | | | | | | | | | | | This method was deprecated in 1.33 and is no longer used. Usage ===== https://codesearch.wmflabs.org/search/?q=%5CbprepareUrlQuerySearchString%5Cb&i=nope&files=&repos= Bug: T220656 Change-Id: I15a476438f3a579db41a43658e13b6ddc4fc62d4
* Collapse some nested if statementsReedy2019-04-041-6/+4
| | | | Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
* Use (int) rather than intval()Reedy2019-02-251-2/+2
| | | | | Bug: T216969 Change-Id: I4c06716c83b69d128f26fa7f68736808aa2d3d64