Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -133,18 +133,25 @@ |
134 | 134 | /** |
135 | 135 | * Should we execute the maintenance script, or just allow it to be included |
136 | 136 | * as a standalone class? It checks that the call stack only includes this |
137 | | - * function and a require (meaning was called from the file scope) |
| 137 | + * function and "requires" (meaning was called from the file scope) |
138 | 138 | * |
139 | 139 | * @return Boolean |
140 | 140 | */ |
141 | 141 | public static function shouldExecute() { |
142 | 142 | $bt = debug_backtrace(); |
143 | | - if( count( $bt ) !== 2 ) { |
144 | | - return false; |
| 143 | + if ( count( $bt ) < 2 ) { |
| 144 | + return false; // sanity |
145 | 145 | } |
146 | | - return in_array( $bt[1]['function'], array( 'require_once', 'require', 'include' ) ) && |
147 | | - $bt[0]['class'] == 'Maintenance' && |
148 | | - $bt[0]['function'] == 'shouldExecute'; |
| 146 | + if ( $bt[0]['class'] !== 'Maintenance' || $bt[0]['function'] !== 'shouldExecute' ) { |
| 147 | + return false; // last call should be to this function |
| 148 | + } |
| 149 | + $includeFuncs = array( 'require_once', 'require', 'include' ); |
| 150 | + for( $i=1; $i < count( $bt ); $i++ ) { |
| 151 | + if ( !in_array( $bt[$i]['function'], $includeFuncs ) ) { |
| 152 | + return false; // previous calls should all be "requires" |
| 153 | + } |
| 154 | + } |
| 155 | + return true; |
149 | 156 | } |
150 | 157 | |
151 | 158 | /** |