Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299389
Change subject: Possibility to cache config in a PHP file ; fixed bug during compilation of the config ...................................................................... Possibility to cache config in a PHP file ; fixed bug during compilation of the config --- M src/MediaWikiFarm.php 1 file changed, 19 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/89/299389/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 2cc8b40..873ab50 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -512,15 +512,20 @@ $this->params['globals'] = false; if( @filemtime( $cacheFile ) >= $oldness && is_string( $cacheFile ) ) { - $cache = @file_get_contents( $cacheFile ); - if ( $cache !== false ) { - $this->params['globals'] = unserialize( $cache ); + if( preg_match( '/\.php$/', $cacheFile ) ) { + $this->params['globals'] = @include $cacheFile; + } + else { + $cache = @file_get_contents( $cacheFile ); + if ( $cache !== false ) { + $this->params['globals'] = unserialize( $cache ); + } } } else { $this->params['globals'] = array(); - $globals &= $this->params['globals']; + $globals =& $this->params['globals']; $globals['general'] = array(); $globals['skins'] = array(); @@ -672,9 +677,16 @@ if( is_string( $cacheFile ) ) { @mkdir( dirname( $cacheFile ) ); $tmpFile = tempnam( dirname( $cacheFile ), basename( $cacheFile ).'.tmp' ); - chmod( $tmpFile, 0640 ); - if( $tmpFile && file_put_contents( $tmpFile, serialize( $globals ) ) ) { - rename( $tmpFile, $cacheFile ); + chmod( $tmpFile, 0744 ); + if( preg_match( '/\.php$/', $cacheFile ) ) { + if( $tmpFile && file_put_contents( $tmpFile, "<?php\n\n// WARNING: file automatically generated: do not modify.\n\nreturn ".var_export( $globals, true ).';' ) ) { + rename( $tmpFile, $cacheFile ); + } + } + else { + if( $tmpFile && file_put_contents( $tmpFile, serialize( $globals ) ) ) { + rename( $tmpFile, $cacheFile ); + } } } } -- To view, visit https://gerrit.wikimedia.org/r/299389 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I387be3677765d9927d11e9142555b989f32cecb2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MediaWikiFarm Gerrit-Branch: master Gerrit-Owner: Seb35 <seb35wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits