r112827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112826‎ | r112827 | r112828 >
Date:19:12, 1 March 2012
Author:reedy
Status:ok
Tags:
Comment:
Tidy up return values of envChecks

False is used to to signify a failure mode we need to do stuff for, so returning true is ok in other cases, and makes it explicit
Modified paths:
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/Installer.php
@@ -659,6 +659,7 @@
660660 return false;
661661 }
662662 $this->setVar( '_CompiledDBs', $databases );
 663+ return true;
663664 }
664665
665666 /**
@@ -680,6 +681,7 @@
681682 $this->showError( 'config-brokenlibxml' );
682683 return false;
683684 }
 685+ return true;
684686 }
685687
686688 /**
@@ -694,6 +696,7 @@
695697 $this->showError( 'config-using531', phpversion() );
696698 return false;
697699 }
 700+ return true;
698701 }
699702
700703 /**
@@ -705,6 +708,7 @@
706709 $this->showError( 'config-magic-quotes-runtime' );
707710 return false;
708711 }
 712+ return true;
709713 }
710714
711715 /**
@@ -716,6 +720,7 @@
717721 $this->showError( 'config-magic-quotes-sybase' );
718722 return false;
719723 }
 724+ return true;
720725 }
721726
722727 /**
@@ -727,6 +732,7 @@
728733 $this->showError( 'config-mbstring' );
729734 return false;
730735 }
 736+ return true;
731737 }
732738
733739 /**
@@ -738,16 +744,19 @@
739745 $this->showError( 'config-ze1' );
740746 return false;
741747 }
 748+ return true;
742749 }
743750
744751 /**
745752 * Environment check for safe_mode.
 753+ * @return bool
746754 */
747755 protected function envCheckSafeMode() {
748756 if ( wfIniGetBool( 'safe_mode' ) ) {
749757 $this->setVar( '_SafeMode', true );
750758 $this->showMessage( 'config-safe-mode' );
751759 }
 760+ return true;
752761 }
753762
754763 /**
@@ -759,6 +768,7 @@
760769 $this->showError( 'config-xml-bad' );
761770 return false;
762771 }
 772+ return true;
763773 }
764774
765775 /**
@@ -777,6 +787,7 @@
778788 $this->showError( 'config-pcre-no-utf8' );
779789 return false;
780790 }
 791+ return true;
781792 }
782793
783794 /**
@@ -801,9 +812,8 @@
802813 $this->showMessage( 'config-memory-raised', $limit, $newLimit );
803814 $this->setVar( '_RaiseMemory', true );
804815 }
805 - } else {
806 - return true;
807816 }
 817+ return true;
808818 }
809819
810820 /**
@@ -829,15 +839,18 @@
830840
831841 /**
832842 * Scare user to death if they have mod_security
 843+ * @return bool
833844 */
834845 protected function envCheckModSecurity() {
835846 if ( self::apacheModulePresent( 'mod_security' ) ) {
836847 $this->showMessage( 'config-mod-security' );
837848 }
 849+ return true;
838850 }
839851
840852 /**
841853 * Search for GNU diff3.
 854+ * @return bool
842855 */
843856 protected function envCheckDiff3() {
844857 $names = array( "gdiff3", "diff3", "diff3.exe" );
@@ -851,6 +864,7 @@
852865 $this->setVar( 'wgDiff3', false );
853866 $this->showMessage( 'config-diff3-bad' );
854867 }
 868+ return true;
855869 }
856870
857871 /**
@@ -868,10 +882,11 @@
869883 return true;
870884 } elseif ( function_exists( 'imagejpeg' ) ) {
871885 $this->showMessage( 'config-gd' );
872 - return true;
 886+
873887 } else {
874888 $this->showMessage( 'config-no-scaling' );
875889 }
 890+ return true;
876891 }
877892
878893 /**
@@ -881,6 +896,7 @@
882897 $server = $this->envGetDefaultServer();
883898 $this->showMessage( 'config-using-server', $server );
884899 $this->setVar( 'wgServer', $server );
 900+ return true;
885901 }
886902
887903 /**
@@ -913,6 +929,7 @@
914930 $ext = 'php';
915931 }
916932 $this->setVar( 'wgScriptExtension', ".$ext" );
 933+ return true;
917934 }
918935
919936 /**
@@ -1000,17 +1017,17 @@
10011018 $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
10021019 $safe = !$this->dirIsExecutable( $dir, $url );
10031020
1004 - if ( $safe ) {
1005 - return true;
1006 - } else {
 1021+ if ( !$safe ) {
10071022 $this->showMessage( 'config-uploads-not-safe', $dir );
10081023 }
 1024+ return true;
10091025 }
10101026
10111027 /**
10121028 * Checks if suhosin.get.max_value_length is set, and if so, sets
10131029 * $wgResourceLoaderMaxQueryLength to that value in the generated
10141030 * LocalSettings file
 1031+ * @return bool
10151032 */
10161033 protected function envCheckSuhosinMaxValueLength() {
10171034 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
@@ -1023,6 +1040,7 @@
10241041 $maxValueLength = -1;
10251042 }
10261043 $this->setVar( 'wgResourceLoaderMaxQueryLength', $maxValueLength );
 1044+ return true;
10271045 }
10281046
10291047 /**
@@ -1095,11 +1113,15 @@
10961114 }
10971115 }
10981116
 1117+ /**
 1118+ * @return bool
 1119+ */
10991120 protected function envCheckCtype() {
11001121 if ( !function_exists( 'ctype_digit' ) ) {
11011122 $this->showError( 'config-ctype' );
11021123 return false;
11031124 }
 1125+ return true;
11041126 }
11051127
11061128 /**
@@ -1181,6 +1203,8 @@
11821204 * Checks if scripts located in the given directory can be executed via the given URL.
11831205 *
11841206 * Used only by environment checks.
 1207+ * @param $dir string
 1208+ * @param $url string
11851209 * @return bool|int|string
11861210 */
11871211 public function dirIsExecutable( $dir, $url ) {

Status & tagging log