Go to the documentation of this file.
53 public function __construct( $id,
$title, $c =
false ) {
54 if ( is_string(
$title ) ) {
63 if ( is_string( $c ) ) {
70 wfDebug(
"SearchUpdate object created with invalid title '$title'\n" );
78 $config = MediaWikiServices::getInstance()->getSearchEngineConfig();
80 if ( $config->getConfig()->get(
'DisableSearchUpdate' ) || !$this->id ) {
84 $seFactory = MediaWikiServices::getInstance()->getSearchEngineFactory();
85 foreach ( $config->getSearchTypes()
as $type ) {
87 if ( !$search->
supports(
'search-update' ) ) {
91 $normalTitle = $this->getNormalizedTitle( $search );
93 if ( $this->getLatestPage() ===
null ) {
94 $search->
delete( $this->
id, $normalTitle );
96 } elseif ( $this->
content ===
false ) {
103 $text = $this->updateText( $text, $search );
106 # Perform the actual update
119 public function updateText( $text,
SearchEngine $se =
null ) {
122 # Language-specific strip/conversion
124 $se = $se ?: MediaWikiServices::getInstance()->newSearchEngine();
125 $lc = $se->legalSearchChars() .
'&#;';
127 $text = preg_replace(
"/<\\/?\\s*[A-Za-z][^>]*?>/",
128 ' ',
$wgContLang->lc(
" " . $text .
" " ) ); # Strip HTML markup
129 $text = preg_replace(
"/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD",
130 "\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings
132 # Strip external URLs
133 $uc =
"A-Za-z0-9_\\/:.,~%\\-+&;#?!=()@\\x80-\\xFF";
134 $protos =
"http|https|ftp|mailto|news|gopher";
135 $pat =
"/(^|[^\\[])({$protos}):[{$uc}]+([^{$uc}]|$)/";
136 $text = preg_replace( $pat,
"\\1 \\3", $text );
138 $p1 =
"/([^\\[])\\[({$protos}):[{$uc}]+]/";
139 $p2 =
"/([^\\[])\\[({$protos}):[{$uc}]+\\s+([^\\]]+)]/";
140 $text = preg_replace( $p1,
"\\1 ", $text );
141 $text = preg_replace( $p2,
"\\1 \\3 ", $text );
143 # Internal image links
144 $pat2 =
"/\\[\\[image:([{$uc}]+)\\.(gif|png|jpg|jpeg)([^{$uc}])/i";
145 $text = preg_replace( $pat2,
" \\1 \\3", $text );
147 $text = preg_replace(
"/([^{$lc}])([{$lc}]+)]]([a-z]+)/",
148 "\\1\\2 \\2\\3", $text ); # Handle [[game]]s
150 # Strip all remaining non-search characters
151 $text = preg_replace(
"/[^{$lc}]+/",
" ", $text );
169 $text = strrev( preg_replace(
"/ s'([{$lc}]+)/",
" s'\\1 \\1", strrev( $text ) ) );
170 $text = strrev( preg_replace(
"/ 's([{$lc}]+)/",
" s\\1", strrev( $text ) ) );
172 # Strip wiki '' and '''
173 $text = preg_replace(
"/''[']*/",
" ", $text );
187 private function getLatestPage() {
188 if ( !isset( $this->
page ) ) {
202 private function getNormalizedTitle(
SearchEngine $search ) {
205 $ns = $this->
title->getNamespace();
206 $title = $this->
title->getText();
210 $t = preg_replace(
"/[^{$lc}]+/",
' ',
$t );
214 $t = preg_replace(
"/([{$lc}]+)'s( |$)/",
"\\1 \\1's ",
$t );
215 $t = preg_replace(
"/([{$lc}]+)s'( |$)/",
"\\1s ",
$t );
217 $t = preg_replace(
"/\\s+/",
' ',
$t );
220 $t = preg_replace(
"/ (png|gif|jpg|jpeg|ogg)$/",
"",
$t );
static legalSearchChars( $type=self::CHARS_ALL)
Get chars legal for search NOTE: usage as static is deprecated and preserved only as BC measure.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
per default it will return the text for text based content
normalizeText( $string)
When overridden in derived class, performs database-specific conversions on text to be used for searc...
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
doUpdate()
Perform the actual work.
Class representing a MediaWiki article and history.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
textAlreadyUpdatedForIndex()
If an implementation of SearchEngine handles all of its own text processing in getTextFromContent() a...
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
namespace and then decline to actually register it file or subcat img or subcat $title
when a variable name is used in a it is silently declared as a new masking the global
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
updateTitle( $id, $title)
Update a search index record's title only.
update( $id, $title, $text)
Create or update the search index record for the given page.
getTextFromContent(Title $t, Content $c=null)
Get the raw text for updating the index from a content object Nicer search backends could possibly do...
static newFromID( $id, $from='fromdb')
Constructor from a page id.
delete( $id, $title)
Delete an indexed page Title should be pre-processed.
Content object implementation for representing flat text.
Contain a class for special pages.
Base interface for content objects.
Represents a title within MediaWiki.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Interface that deferrable updates should implement.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
static create( $type=null)
Load up the appropriate search engine class for the currently active database backend,...
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang