- $change = $dbr->selectField( 'page', '1', $dbr->makeList( $cWhr, LIST_OR ), __METHOD__ );
- $n = $dbr->selectField( 'page', 'COUNT(*)', $dbr->makeList( $dWhr, LIST_OR ), __METHOD__ );
- if ( $change || $n != count( $dWhr ) ) {
- wfDebugLog( 'StashEdit', "Stale cache for key '$key'; template changed." );
- return false;
+ // Check that no templates used in the output changed...
+ if ( count( $templates ) ) {
+ $res = $dbr->select(
+ 'page',
+ array( 'ns' => 'page_namespace', 'dbk' => 'page_title', 'page_latest' ),
+ $dbr->makeWhereFrom2d( $templates, 'page_namespace', 'page_title' ),
+ __METHOD__
+ );
+ $changed = false;
+ foreach ( $res as $row ) {
+ $changed = $changed || ( $row->page_latest != $templates[$row->ns][$row->dbk] );
+ }
+
+ if ( $changed || $res->numRows() != $templateUses ) {
+ wfDebugLog( 'StashEdit', "Stale cache for key '$key'; template changed." );
+ return false;
+ }