aboutsummaryrefslogtreecommitdiffstats
path: root/includes/search
Commit message (Collapse)AuthorAgeFilesLines
* DomainEvent: rename EventIngressBase to DomainEventIngressAaron Schulz2025-04-031-2/+2
| | | | | Bug: T390735 Change-Id: I0ebec537bb15925e8507ee6934cd4a17973c536a
* Use type declaration on undocumented private functionsUmherirrender2025-04-024-5/+7
| | | | Change-Id: I0d8d2237500ed6f18439410c902d47c42e4119bc
* Merge "DomainEvents: Model page state before/after"jenkins-bot2025-03-251-4/+4
|\
| * DomainEvents: Model page state before/afterdaniel2025-03-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - PageStateEvent models a change in page state, so it should provide access to the state before and after What: - add getPageRecordBefore() and getPageRecordAfter() to PageStateEvent - Move getPage() from PageStateEvent down to PageRevisionUpdatedEvent. - Add getPageId() to PageStateEvent. - Add getDeletedPage to PageDeletedEvent Bug: T388588 Depends-On: I76b09f2275a74d02e5701de2082d6b256d6b3b78 Change-Id: I94c52c0314e5dbe9adf82aab732f2e54ca42f686
* | Namespace all remaining files in includes/exceptionJames D. Forrester2025-03-251-0/+1
|/ | | | | | | | | In MediaWiki/Exception, to follow PSR-4 per plural vs. singular (this can be changed later if people really care). Also, move the couple of exceptions in here that were already namespaced in the MW-top-level into the new space. Bug: T353458 Change-Id: I12ed850ae99effb699a6d7ada173f54e72f0570e
* DomainEvents: add listener interfacesdaniel2025-03-201-1/+6
| | | | | | | | | | | | | | Why: - Now that we only support a single invocation mode, we don't need suffixes on the name of the listener method anymore. This allows us to start supporting listener interfaces. What: - Add PageStateListener and PageRevisionUpdatedListener - Add PageMovedListener and PageDeletedListener Bug: T387012 Change-Id: I0ce795136ea0f19689d8d8e9adcc0dde28e67b0f
* Merge "DomainEvents: remove "AfterCommit" suffix from event handlers"jenkins-bot2025-03-201-1/+1
|\
| * DomainEvents: remove "AfterCommit" suffix from event handlersAaron Schulz2025-03-141-1/+1
| | | | | | | | Change-Id: Id206c7c0ee14da988445d988f1bab2441860a65b
* | Namespace all remaining files in includes/filerepoJames D. Forrester2025-03-195-5/+7
| | | | | | | | | | Bug: T353458 Change-Id: I35864ad9bd48701703c51367d62f8ebde963c52d
* | Merge "EventSubscriberBase: rename to EventIngressBase"jenkins-bot2025-03-181-2/+2
|\ \
| * | EventSubscriberBase: rename to EventIngressBasedaniel2025-03-181-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - "ingress" better describes the purpose of objects that use this base class. "subscriber" is merely a mechanism for registering listeners. What: - Rename EventSubscriberBase to EventIngressBase (leaving an alias in place) - Improve documentation of the base class - Clean up some unused code in the base class Bug: T389033 Change-Id: Ib557aea12cc89b7365cabe22a6848c2a38c725ca
* / DomainEvents: Rename getOldRevision and getNewRevisiondaniel2025-03-151-1/+1
|/ | | | | | | | | | | | | Why: - Use consistent naming scheme based on "before" and "after" to represent the change. What: - rename getOldRevision to getLatestRevisionBefore - rename getNewRevision to getLatestRevisionAfter Bug: T388588 Change-Id: I30078f606f457981987d95def5b2aaae181f0690
* DomainEvents: Rename PageEvent and PageUpdatedEventdaniel2025-03-111-5/+5
| | | | | | | | | | | | Why: - clarify naming after modeling discussions What: - Rename PageEvent to PageStateEvent - Rename PageUpdatedEvent to PageRevisionUpdatedEvent. Bug: T388588 Change-Id: I987c93a443d364782e692e2cf71b878ccbc5a2fa
* DeletePage: emit PageDeletedEventdaniel2025-03-102-7/+19
| | | | | | | | | | | | | | | | | | Why: - We want to replace the PageDeletionComplete hook with an event - We want to validate our design for the hierarchical event type system and the modeling of page events. What: - Introduce PageDeletedEvent - Make DeletePage emit PageDeletedEvent - Move update triggers from DeletePage into ingress objects: - search index - message cache - module cache Bug: T379932 Change-Id: I01490fbaf33118eba109aa91908783117ba5aa20
* Split MediaWikiTitleCodecTim Starling2025-03-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | For the linked bug, I would really like GenderCache to use UserOptionsManager. But all user-related services need UserNameUtils which depends on TitleParser, and TitleFormatter needs GenderCache to correctly format NS_USER titles. Having TitleFormatter and TitleParser together in a single class creates an intractable dependency loop. So, split MediaWikiTitleCodec. On Daniel's advice I converted the existing TitleParser and TitleFormatter interfaces to classes. The code was always structured to allow this. Extensions require surprisingly few updates. MediaWikiTitleCodec remains only for its deprecated static methods. The implementations were split cleanly with no need for shared code. The tests did have a little bit of shared code, for round-trip testing, so I added a shared test base class for that. Bug: T386584 Depends-On: Ibf307e953b666d8923bc96a507907421558da378 Depends-On: I47e83e95727e6830500e9af7cff92e7d3f91167e Depends-On: Id9c045864a9dc3c640a896e6b34f516c7e42b050 Change-Id: I3dcce6639ed01c7611a663671c872cec775bdaa2
* DomainEvents: More clearly model null edits and dummy revisionsdaniel2025-02-261-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | Why: - Listeners that want to skip processing if the page content didn't change should generally not skip reconciliation requests. PageUpdatedEvent should offer getters that make this straightforward. What: - Add isNominalContentChange that will return false for dummy revisions but true for null edits. This is the preferred way for listeners to determine whether they can skip redundant processing of page content. - Rename isContentChange to isEffectiveContentChange, to distinguish it from isNominalContentChange. - Rename isRevisionChange to isRevisionHistoryChange, to make it clear that the change affects the sequences of revisions. - Add test cases to PageUpdaterTest asserting the expected update propagation for null edits and dummy revisions. - Change ingress objects so that: - the message cache is updated for null edits - module caches are not cleared for dummy revisions Bug: T383552 Change-Id: Idf6625d3e737e4a225648b0fd81cc929b095d315
* SearchEngine: reset result limit when performing variant searchesDaimona Eaytoy2025-02-211-4/+10
| | | | | | | | | | | | | | Reset the original search limit when performing variant searches, so that the result set does not get truncated (way) more than necessary. The `try ... finally` should be unnecessary, but it's generally advisable to use it to wrap code that messes with the internal state of a class only to reset it after performing a certain operation. Add a regression test to verify the fix. Bug: T386743 Change-Id: I499605b5e0c7b5fc48b919208a1ea3f20fde9d57
* Replace call_user_func with dynamic function callUmherirrender2025-02-132-2/+2
| | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I9ef131032a662a3b8db69aa7079dbd51f88f575a
* Use $string === '' instead of strlen( $string ) === 0Fomafix2025-01-302-2/+2
| | | | | | | | | Add $string === false or $string === null where $string can have other types than a string. Also document null as possible return value in FileRepo. Change-Id: Iaa29ba01c3fd6bea506debdc6f929edfe881c808
* DomainEvent: Typo fixesBartosz Dziewoński2025-01-291-2/+2
| | | | Change-Id: If6013dcde8db6e22e1791d07535a9e47c4535a7b
* PageUpdatedEvent: explicitly model cause and performerdaniel2025-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | This introduces the concept of a "cause" and "performer" into PageUpdatedEvent. Causes are e.g. "edit" or "import" or "move". The performer is the same as the author for edits, but not necessarily for undeletions, moves, etc. Note that cause and performer were already being tracked in DerivedPageDataUpdater for logging purposes. PageUpdatedEvent was modeling the cause using flags. This change formalizes the concept of "cause" and "performer" and ensures it is handled consistently. As an aside, this simplifies some test cases in DerivedPageDataUpdaterTest to avoid confused state. Bug: T383031 Bug: T383095 Change-Id: I79bde5604790636c91848f265fffd81d6348a8b4
* DomainEvent: Support type hierarchiesdaniel2025-01-211-1/+1
| | | | | | | | | | | | | | Why: - It's useful to be able to listen to sets of compatible event types. What: - Make DomainEvents aware of a list of types they are compatible with. - Make EventDispatchEngine dispatch to all compatible listeners, registered for any of the supported types. - Move all page events to their own namespace Bug: T384330 Change-Id: I96bde2cfaf198e409a6ef3a24101ee7d02d57959
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-175-9/+0
| | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-162-6/+0
| | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* Use real type hints for services etc. in includes/search/Bartosz Dziewoński2025-01-0411-159/+50
| | | | | | | | | | | | | | | | | Mostly used find-and-replace: Find: /\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|) Replace with: \3 \1 \4 More could be done, but to keep this patch reasonably sized, I only changed the most obvious and unambiguously correct cases. In some cases, I also removed redundant doc comments on the constructor, and re-ordered the properties to match the constructor. Change-Id: I3c1c59fe0ec660101429c5b7610887c66df4b9c8
* Merge "Replace isset() with null checks"jenkins-bot2024-12-191-2/+2
|\
| * Replace isset() with null checksUmherirrender2024-12-191-2/+2
| | | | | | | | | | | | | | | | | | isset() should only be used to suppress errors, not for null check. When the property is always defined, there is no need to use isset. Found by a new phan plugin (2efea9f989) https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset Change-Id: Ib84b7d71e8308a36409f30ecfd16e9de149e97b3
* | Replace isset() with falsy checksUmherirrender2024-12-191-1/+1
|/ | | | | | | | | isset() should only be used to suppress errors, not for null check. When the property is always defined, there is no need to use isset. Found by a new phan plugin (2efea9f989) https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset Change-Id: I186e799256fbaf5ee77558bd146f9418dd5eaacc
* Introduce ISearchResultSet::isApproximateTotalHitsDavid Causse2024-12-133-3/+27
| | | | | | | | Use for engines that might be able to optimize some queries or installations where the number of total hits is not particular useful. Depends-On: I97e11dacf17bc7633a99078e1bf1a4d3eaee852e Change-Id: I3550063d1b297e4caab3426e3ef66804b985e5fa
* Ensure necessary updates are performed on import and undeletedaniel2024-12-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | In Ice76519 we lost the mechanism for triggering updates for the search index and message cache on import and undeletion. This change restores the trigger for these updates. To achieve this, the logic for instantiating PageUpdatedEvents is moved into DerivedPageDataUpdater. Perhaps the firing of the event can be moved into that class eventually. To improve consistency, the flags field in PageUpdatedEvent is changed from a bitmap corresponding to the flags field in PageUpdater to an array corresponding to the options array in DerivedPageDataUpdater. For regression testing, this change defines new test traits, one for each ingress. These traits define the expected behavior of each ingress in each relevant situation (edit, move, import, and undeletion). Bug: T381225 Bug: T381299 Change-Id: Ib0d1dd143160fb64d42cacfbc75fbb55f5614c1c
* rdbms: fix table prefixing in "FOR UPDATE" clause generation in PostgresAaron Schulz2024-12-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Make SqlPlatform::tableNameWithAlias() include the unqualified table name as an alias if doing so is not redundant. This assures that the default alias from JoinGroupBase::addJoin(), equal to the unqualified table name, will be usable in SQL (regardless of table prefixes). Clean up use of identifier quotes for sqlite_master tables. The called methods expect unqualified names and a passthrough exception already exists for sqlite_* tables. Use "block_target.bt_user" directly in ApiQueryBlocks and BlockPager, instead of using addIdentifierQuotes(). The "block_target" alias is automatically added to the SQL by the rdbms layer when it's not clearly redundant, so it is always safe to use block_target.bt_user. Also, there is no reason for aliases to include quote characters. They are supposed to be simple alphanumerics like column names. This makes it easy for tableNameWithAlias() to avoid redundant aliases by checking tableName(). Avoid unneeded quotes around pg_catalog.* table names in the Postgres installer. The relevant documentation of methods like selectField() is that the table names be unqualified (no quotes nor dots), though dots are still supported internally for compatibility reasons and ease of querying schemas like pg_catalog and information_schema. Change-Id: Ic7d7826da31f49915141692cb3bd84ed1e872e96
* search: Move SearchUpdate.php to /includes/search directoryTimo Tijhof2024-11-262-1/+208
| | | | | | | | | | | | | | | | | | | | The class was introduced for and is exclusively used by the Search component, and is already documented as part of the Search docgroup. It was placed under the deferred directory because, 10+ years ago, we used to treat MediaWiki as something that (mostly) a single team can maintain and look after, but this has changed a lot since then. * Mark the class as internal. I can't think of a use case outside of core, and indeed it has no references outside core (per Codesearch/Everywhere). Follows-up Ibd40734b9, which namespaced this class under Deferred. Remove both the global class alias and the Deferred alias, since the class is now internal and requires no back compat aliases. Bug: T364652 Change-Id: I48937dcda4144e5e039c38a2e336f8361e2d492d
* DomainEventEmitter: migrate logic from DerivedDataUpdaterdaniel2024-11-221-0/+54
| | | | | | | | | Migrates the following updates from DerivedDataUpdater to ServiceWiring: - SearchUpdate - MessageCache Bug: T378936 Change-Id: Ice7651900423e25f8c907c9f4c5e47085ef9edf0
* Use ParserOutput::getLinkList() internallyC. Scott Ananian2024-11-151-14/+21
| | | | | | | | This replaces the internal uses of the deprecated ParserOutput::get* methods and isolates the ParserOutput internal representation from most of the users. Change-Id: I32df68714ffdf2f0745b974f47bc3ccceef1f41c
* Merge "Correct SQLite support for language variants"jenkins-bot2024-11-041-0/+5
|\
| * Correct SQLite support for language variantsDerk-Jan Hartman2024-11-041-0/+5
| | | | | | | | | | | | | | | | | | Search matching was broken if you had a language variant enabled. This was because it treated it as an implied AND instead of an OR match. Bug: T378710 Change-Id: I790d30b080c71ca556e79b0576e88fe451258a35
* | Merge "Sort namespaces list vertically on Special:Search"jenkins-bot2024-11-021-7/+2
|\ \ | |/ |/|
| * Sort namespaces list vertically on Special:SearchSaint Johann2024-11-021-7/+2
| | | | | | | | | | | | | | | | | | Currently, the patch makes previous 4-column layout into whatever amount of columns can fit the block. If that is necessary to restore to what it was before, it can be done with CSS adjustment. Spacing is also improved a bit considering OOUI adds 12px margin-top by default, which is close to 1em (14px) added by Special:Search. This patch increases it to 1.5em for readability. Bug: T377900 Change-Id: Ic9f4c513bf58e08f4e8eab40f0e2a4a54d1972d8
* | Merge "Use ++ and -- rather than += 1 and -= 1"jenkins-bot2024-10-231-2/+2
|\ \ | |/ |/|
| * Use ++ and -- rather than += 1 and -= 1Reedy2024-10-171-2/+2
| | | | | | | | Change-Id: I27b9a19ab952ede1267921bd042af0fe1c89e228
* | Use namespaced classesUmherirrender2024-10-212-0/+2
|/ | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: I73fb416573f5af600e529d224b5beb5d2e3d27d3
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-168-12/+12
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* Remove meaningless @var documentation from constantsthiemowmde2024-10-092-2/+2
| | | | | | | | | A constant is not a variable. The type is hard-coded via the value and can never change. While the extra @var probably doesn't hurt much, it's redundant and error-prone and can't provide any additional information. Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
* Add namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-271-0/+1
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* Remove unchecked exception annotationsAdam Wight2024-09-171-1/+0
| | | | | | | | | | | | | | | Callers should not catch an unchecked exception, so it doesn't belong in a function signature. Unchecked exceptions indicate a coding error, which by definition the code will not be able to handle correctly. If any of these exceptions were supposed to be in response to an edge case, user input, or initial conditions, then they should be changed to a runtime error. If the exception class cannot be changed, then the annotation should include a comment explaining its purpose and prognosis. Bug: T240672 Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
* Migrate all uses of deprecated URL global functions to use wfGetUrlUtils()James D. Forrester2024-09-101-1/+2
| | | | | | | | | | | | | | wfGetUrlUtils() is also deprecated, but less so, so we can do this first and then properly replace the individual uses with dependency injection in local pieces of work. Also: * Switching Parser::getExternalLinkRel to UrlUtils::matchesDomainList exposed a type error in media.txt where $wgNoFollowDomainExceptions was set to a string (which is invalid) instead of an array. Bug: T319340 Change-Id: Icb512d7241954ee155b64c57f3782b86acfd9a4c
* Merge "Avoid use of deprecated wfExpandUrl in various places"jenkins-bot2024-09-102-2/+6
|\
| * Avoid use of deprecated wfExpandUrl in various placesEbrahim Byagowi2024-09-092-2/+6
| | | | | | | | | | Bug: T319340 Change-Id: I98e8e3a8fd135a554a85f6399033756c88ea415f
* | Merge "search: Simplify host name logic in InterwikiSearchResultSetWidget"jenkins-bot2024-09-091-12/+9
|\ \
| * | search: Simplify host name logic in InterwikiSearchResultSetWidgetTimo Tijhof2024-09-071-12/+9
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * footerHtml() contained seemingly unused logic for extracting the host name for use in the "search-interwiki-resultset-link" message. This was added during in change I9498a070da (T307468, 0d1184e501). It seems to be a left-over from the "search-interwiki-default" message that Special:Search used previously. Overrides for specific wikis are now in the heading based on the the "search-interwiki-custom" message, which feeds customCaptions which takes precedence over the entire message, instead of requiring wikis to e.g. switch/if-case inside wikitext based on "$1" or something. The qqq.json entry for "search-interwiki-resultset-link" mentions no parameters, and none of the translations use it either. I've also checked WikimediaMessages extension, en.wikipedia.org, Commons, and Wikidata in case they use the parameter there, but found nothing. * headerHtml() used wfExpandUrl() combined with wfParseUrl(). This is problematic for Phan analysis since both can fail and technically require a fallback. This is currently tolerated by Phan because it doesn't yet understand that `false[key]` yields the same kind of warning PHP as `null[key]`. https://github.com/phan/phan/issues/4879 It seems this code has evolved over the years into what it is now, and it's not clear that this is all intentional or by design. In 2011, r95011 (92ff782a9) changed this code from parse_url to wfParseUrl to handle protocol-relative URLs, which has long been fixed in PHP: https://3v4l.org/sSkfX. In 2017, If78cb0c29a (6e155624fa) changed further switched from Title->getUrl() to Interwiki->getURL() with wfExpandUrl() to handle same-site destinations, e.g. when an interwiki is on the same domain, and defined on Special:Interwiki without any hostname. The code had a note saying: "hostname of the other wiki which might suck if there are many wikis on one hostname" which appears to remain true today. I've changed this all back to parse_url(), with an explicit fallback to $iwPrefix for invalid urls or same-site interwikis. If we want to display the current domain name there instead, we can do that explicitly by falling back go $wgServerName instead. * Fix potential escaping problem by pasing $caption to element() instead of rawElement() since in headerHtml() at least one of the values in the assignment chain caption is plain text, not escaped HTML. Move escaping down to the last mile by storing plain text instead. Idem for footerHtml(), although that one is safe and simple as-is, I've switched it similarly to plain text and let Html::element do the escaping. Change-Id: I3281e12ee52af168f85cdb12ac4d53fc25c9f38d