Index: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php |
— | — | @@ -11,8 +11,10 @@ |
12 | 12 | } |
13 | 13 | |
14 | 14 | public function execute() { |
| 15 | + wfProfileIn( __METHOD__ ); |
15 | 16 | $titles = $this->getPageSet()->getGoodTitles(); |
16 | 17 | if ( count( $titles ) == 0 ) { |
| 18 | + wfProfileOut( __METHOD__ ); |
17 | 19 | return; |
18 | 20 | } |
19 | 21 | $params = $this->extractRequestParams(); |
— | — | @@ -40,6 +42,7 @@ |
41 | 43 | break; |
42 | 44 | } |
43 | 45 | } |
| 46 | + wfProfileOut( __METHOD__ ); |
44 | 47 | } |
45 | 48 | |
46 | 49 | /** |
— | — | @@ -50,15 +53,18 @@ |
51 | 54 | private function getExcerpt( Title $title, $plainText ) { |
52 | 55 | global $wgMemc; |
53 | 56 | |
| 57 | + wfProfileIn( __METHOD__ ); |
54 | 58 | $page = WikiPage::factory( $title ); |
55 | 59 | $key = wfMemcKey( 'mf', 'excerpt', $plainText, $title->getArticleID(), $page->getLatest() ); |
56 | 60 | $text = $wgMemc->get( $key ); |
57 | 61 | if ( $text !== false ) { |
| 62 | + wfProfileOut( __METHOD__ ); |
58 | 63 | return $text; |
59 | 64 | } |
60 | 65 | $text = $this->parse( $page ); |
61 | 66 | $text = $this->convertText( $text, $title, $plainText ); |
62 | 67 | $wgMemc->set( $key, $text ); |
| 68 | + wfProfileOut( __METHOD__ ); |
63 | 69 | return $text; |
64 | 70 | } |
65 | 71 | |
— | — | @@ -68,6 +74,7 @@ |
69 | 75 | * @return string |
70 | 76 | */ |
71 | 77 | private function parse( WikiPage $page ) { |
| 78 | + wfProfileIn( __METHOD__ ); |
72 | 79 | if ( !$this->parserOptions ) { |
73 | 80 | $this->parserOptions = new ParserOptions( new User( '127.0.0.1' ) ); |
74 | 81 | } |
— | — | @@ -76,7 +83,9 @@ |
77 | 84 | $pout = ParserCache::singleton()->get( $page, $this->parserOptions ); |
78 | 85 | if ( $pout ) { |
79 | 86 | $text = $pout->getText(); |
80 | | - return preg_replace( '/<h[1-6].*$/s', '', $text ); |
| 87 | + $s = preg_replace( '/<h[1-6].*$/s', '', $text ); |
| 88 | + wfProfileOut( __METHOD__ ); |
| 89 | + return $s; |
81 | 90 | } |
82 | 91 | } |
83 | 92 | // in case of cache miss, render just the needed section |
— | — | @@ -86,6 +95,7 @@ |
87 | 96 | $apiParse = new ApiParse( $apiMain, 'parse' ); |
88 | 97 | $apiParse->execute(); |
89 | 98 | $data = $apiParse->getResultData(); |
| 99 | + wfProfileOut( __METHOD__ ); |
90 | 100 | return $data['parse']['text']['*']; |
91 | 101 | } |
92 | 102 | |
— | — | @@ -97,6 +107,7 @@ |
98 | 108 | * @return string |
99 | 109 | */ |
100 | 110 | private function convertText( $text, Title $title, $plainText ) { |
| 111 | + wfProfileIn( __METHOD__ ); |
101 | 112 | $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text, false ), $title, 'XHTML' ); |
102 | 113 | $mf->removeImages(); |
103 | 114 | $mf->remove( array( 'table', 'div', 'sup.reference', 'span.coordinates', 'span.geo-multi-punct', 'span.geo-nondefault' ) ); |
— | — | @@ -111,6 +122,7 @@ |
112 | 123 | if ( $plainText ) { |
113 | 124 | $text = html_entity_decode( $text ); |
114 | 125 | } |
| 126 | + wfProfileOut( __METHOD__ ); |
115 | 127 | return trim( $text ); |
116 | 128 | } |
117 | 129 | |
— | — | @@ -124,8 +136,10 @@ |
125 | 137 | private function trimText( $text, $requestedLength, $plainText ) { |
126 | 138 | global $wgUseTidy; |
127 | 139 | |
| 140 | + wfProfileIn( __METHOD__ ); |
128 | 141 | $length = mb_strlen( $text ); |
129 | 142 | if ( $length <= $requestedLength ) { |
| 143 | + wfProfileOut( __METHOD__ ); |
130 | 144 | return $text; |
131 | 145 | } |
132 | 146 | $pattern = "#^.{{$requestedLength}}[\\w/]*>?#su"; |
— | — | @@ -136,6 +150,7 @@ |
137 | 151 | $text = trim ( MWTidy::tidy( $text ) ); |
138 | 152 | } |
139 | 153 | $text .= wfMessage( 'ellipsis' )->inContentLanguage()->text(); |
| 154 | + wfProfileOut( __METHOD__ ); |
140 | 155 | return $text; |
141 | 156 | } |
142 | 157 | |
Index: trunk/extensions/MobileFrontend/ApiParseExtender.php |
— | — | @@ -57,6 +57,7 @@ |
58 | 58 | */ |
59 | 59 | public static function onAPIAfterExecute( ApiBase &$module ) { |
60 | 60 | if ( $module->getModuleName() == 'parse' ) { |
| 61 | + wfProfileIn( __METHOD__ ); |
61 | 62 | $data = $module->getResultData(); |
62 | 63 | $params = $module->extractRequestParams(); |
63 | 64 | if ( isset( $data['parse']['text'] ) && isset( $params['mobileformat'] ) ) { |
— | — | @@ -84,6 +85,7 @@ |
85 | 86 | |
86 | 87 | $result->addValue( null, $module->getModuleName(), $data['parse'] ); |
87 | 88 | } |
| 89 | + wfProfileOut( __METHOD__ ); |
88 | 90 | } |
89 | 91 | return true; |
90 | 92 | } |