~ubuntu-branches/ubuntu/maverick/mediawiki/maverick

« back to all changes in this revision

Viewing changes to includes/api/ApiQuery.php

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Wiltshire, Thorsten Glaser, Jonathan Wiltshire
  • Date: 2010-07-28 12:23:04 UTC
  • mfrom: (16.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100728122304-l7cklondi123hl7v
Tags: 1:1.15.5-1
[ Thorsten Glaser ]
* debian/patches/suppress_warnings.patch: new, suppress warnings
  about session_start() being called twice also in the PHP error
  log, not just MediaWiki’s, for example run from FusionForge

[ Jonathan Wiltshire ]
* New upstream security release:
  - correctly set caching headers to prevent private data leakage
       (closes: #590660, LP: #610782)
  - fix XSS vulnerability in profileinfo.php
       (closes: #590669, LP: #610819)

Show diffs side-by-side

added added

removed removed

Lines of Context:
209
209
                $this->InstantiateModules($modules, 'list', $this->mQueryListModules);
210
210
                $this->InstantiateModules($modules, 'meta', $this->mQueryMetaModules);
211
211
 
 
212
                $cacheMode = 'public';
 
213
 
212
214
                //
213
215
                // If given, execute generator to substitute user supplied data with generated data.
214
216
                //
215
 
                if (isset ($this->params['generator'])) {
216
 
                        $this->executeGeneratorModule($this->params['generator'], $modules);
 
217
                if ( isset ( $this->params['generator'] ) ) {
 
218
                        $generator = $this->newGenerator( $this->params['generator'] );
 
219
                        $params = $generator->extractRequestParams();
 
220
                        $cacheMode = $this->mergeCacheMode( $cacheMode, 
 
221
                                $generator->getCacheMode( $params ) );
 
222
                        $this->executeGeneratorModule( $generator, $modules );
217
223
                } else {
218
224
                        // Append custom fields and populate page/revision information
219
225
                        $this->addCustomFldsToPageSet($modules, $this->mPageSet);
229
235
                // Execute all requested modules.
230
236
                //
231
237
                foreach ($modules as $module) {
 
238
                        $params = $module->extractRequestParams();
 
239
                        $cacheMode = $this->mergeCacheMode( 
 
240
                                $cacheMode, $module->getCacheMode( $params ) );
232
241
                        $module->profileIn();
233
242
                        $module->execute();
234
243
                        wfRunHooks('APIQueryAfterExecute', array(&$module));
235
244
                        $module->profileOut();
236
245
                }
 
246
 
 
247
                // Set the cache mode
 
248
                $this->getMain()->setCacheMode( $cacheMode );
 
249
        }
 
250
 
 
251
        /**
 
252
         * Update a cache mode string, applying the cache mode of a new module to it.
 
253
         * The cache mode may increase in the level of privacy, but public modules 
 
254
         * added to private data do not decrease the level of privacy.
 
255
         */
 
256
        protected function mergeCacheMode( $cacheMode, $modCacheMode ) {
 
257
                if ( $modCacheMode === 'anon-public-user-private' ) {
 
258
                        if ( $cacheMode !== 'private' ) {
 
259
                                $cacheMode = 'anon-public-user-private';
 
260
                        }
 
261
                } elseif ( $modCacheMode === 'public' ) {
 
262
                        // do nothing, if it's public already it will stay public
 
263
                } else { // private
 
264
                        $cacheMode = 'private';
 
265
                }
 
266
                return $cacheMode;
237
267
        }
238
268
 
239
269
        /**
409
439
        }
410
440
 
411
441
        /**
412
 
         * For generator mode, execute generator, and use its output as new
413
 
         * ApiPageSet
414
 
         * @param $generatorName string Module name
415
 
         * @param $modules array of module objects
 
442
         * Create a generator object of the given type and return it
416
443
         */
417
 
        protected function executeGeneratorModule($generatorName, $modules) {
418
 
 
 
444
        public function newGenerator( $generatorName ) {
419
445
                // Find class that implements requested generator
420
446
                if (isset ($this->mQueryListModules[$generatorName])) {
421
447
                        $className = $this->mQueryListModules[$generatorName];
432
458
                $generator = new $className ($this, $generatorName);
433
459
                if (!$generator instanceof ApiQueryGeneratorBase)
434
460
                        $this->dieUsage("Module $generatorName cannot be used as a generator", "badgenerator");
435
 
 
436
461
                $generator->setGeneratorMode();
 
462
                return $generator;
 
463
        }
 
464
 
 
465
        /**
 
466
         * For generator mode, execute generator, and use its output as new
 
467
         * ApiPageSet
 
468
         * @param $generatorName string Module name
 
469
         * @param $modules array of module objects
 
470
         */
 
471
        protected function executeGeneratorModule( $generator, $modules ) {
 
472
                // Generator results
 
473
                $resultPageSet = new ApiPageSet( $this, $this->redirects, $this->convertTitles );
437
474
 
438
475
                // Add any additional fields modules may need
439
476
                $generator->requestExtraData($this->mPageSet);
580
617
        public function getVersion() {
581
618
                $psModule = new ApiPageSet($this);
582
619
                $vers = array ();
583
 
                $vers[] = __CLASS__ . ': $Id: ApiQuery.php 48629 2009-03-20 11:40:54Z catrope $';
 
620
                $vers[] = __CLASS__ . ': $Id: ApiQuery.php 69986 2010-07-27 03:57:39Z tstarling $';
584
621
                $vers[] = $psModule->getVersion();
585
622
                return $vers;
586
623
        }
587
 
}
 
 
b'\\ No newline at end of file'
 
624
}