MediaWiki REL1_35
PatchFileLocation.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\DB;
24
25use RuntimeException;
27
33trait PatchFileLocation {
34
55 protected function getSqlPatchPath( IDatabase $db, $name, $patchDir = null ) {
56 $dbType = $db->getType();
57
58 if ( $patchDir === null ) {
59 $patchDir = $GLOBALS['IP'] . '/maintenance';
60 }
61
62 $paths = [
63
64 // For a small number of patch files, closely associated with code,
65 // e.g. for unit tests:
66 "$patchDir/$name.$dbType.sql",
67
68 // For a large number of patch files, e.g. for schema updates of extensions:
69 "$patchDir/$dbType/$name.sql",
70
71 // For MediaWiki core schema update patches:
72 "$patchDir/$dbType/archives/$name.sql",
73
74 // Database-agnostic fallback:
75 "$patchDir/$name.sql",
76
77 // Database-agnostic fallback for MediaWiki core schema update patches:
78 "$patchDir/archives/$name.sql"
79 ];
80
81 foreach ( $paths as $p ) {
82 if ( file_exists( $p ) ) {
83 return $p;
84 }
85 }
86
87 throw new RuntimeException( "No SQL script matching $name could be found in $patchDir" );
88 }
89
90}
$GLOBALS['IP']
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
getType()
Get the type of the DBMS (e.g.