Index: branches/wmf/1.17wmf1/maintenance/Maintenance.php |
— | — | @@ -121,18 +121,25 @@ |
122 | 122 | /** |
123 | 123 | * Should we execute the maintenance script, or just allow it to be included |
124 | 124 | * as a standalone class? It checks that the call stack only includes this |
125 | | - * function and a require (meaning was called from the file scope) |
| 125 | + * function and "requires" (meaning was called from the file scope) |
126 | 126 | * |
127 | 127 | * @return Boolean |
128 | 128 | */ |
129 | 129 | public static function shouldExecute() { |
130 | 130 | $bt = debug_backtrace(); |
131 | | - if( count( $bt ) !== 2 ) { |
132 | | - return false; |
| 131 | + if ( count( $bt ) < 2 ) { |
| 132 | + return false; // sanity |
133 | 133 | } |
134 | | - return $bt[1]['function'] == 'require_once' && |
135 | | - $bt[0]['class'] == 'Maintenance' && |
136 | | - $bt[0]['function'] == 'shouldExecute'; |
| 134 | + if ( $bt[0]['class'] !== 'Maintenance' || $bt[0]['function'] !== 'shouldExecute' ) { |
| 135 | + return false; // last call should be to this function |
| 136 | + } |
| 137 | + $includeFuncs = array( 'require_once', 'require', 'include' ); |
| 138 | + for( $i=1; $i < count( $bt ); $i++ ) { |
| 139 | + if ( !in_array( $bt[$i]['function'], $includeFuncs ) ) { |
| 140 | + return false; // previous calls should all be "requires" |
| 141 | + } |
| 142 | + } |
| 143 | + return true; |
137 | 144 | } |
138 | 145 | |
139 | 146 | /** |