77
88namespace PhpMyAdmin ;
99
10- use PhpMyAdmin \ConfigStorage \Relation ;
1110use PhpMyAdmin \Error \ErrorHandler ;
1211use PhpMyAdmin \Routing \Routing ;
1312use Traversable ;
1716use function in_array ;
1817use function is_array ;
1918use function is_object ;
20- use function is_scalar ;
2119use function json_encode ;
2220use function json_last_error ;
2321
@@ -44,12 +42,9 @@ class Footer
4442 */
4543 private bool $ isEnabled = true ;
4644
47- private Relation $ relation ;
48-
4945 public function __construct (private readonly Template $ template , private readonly Config $ config )
5046 {
5147 $ this ->scripts = new Scripts ($ this ->template );
52- $ this ->relation = new Relation (DatabaseInterface::getInstance ());
5348 }
5449
5550 /**
@@ -160,32 +155,6 @@ public function getErrorMessages(): string
160155 return $ retval ;
161156 }
162157
163- /**
164- * Saves query in history
165- */
166- private function setHistory (): void
167- {
168- if (
169- (
170- isset ($ _REQUEST ['no_history ' ])
171- && is_scalar ($ _REQUEST ['no_history ' ])
172- && (string ) $ _REQUEST ['no_history ' ] !== ''
173- )
174- || ! empty ($ GLOBALS ['error_message ' ])
175- || empty ($ GLOBALS ['sql_query ' ])
176- || ! DatabaseInterface::getInstance ()->isConnected ()
177- ) {
178- return ;
179- }
180-
181- $ this ->relation ->setHistory (
182- Current::$ database ,
183- Current::$ table ,
184- $ this ->config ->selectedServer ['user ' ],
185- $ GLOBALS ['sql_query ' ],
186- );
187- }
188-
189158 /**
190159 * Disables the rendering of the footer
191160 */
@@ -228,36 +197,35 @@ public function getScripts(): Scripts
228197 */
229198 public function getDisplay (): string
230199 {
231- $ this ->setHistory ();
232- if ($ this ->isEnabled ) {
233- if (! $ this ->isAjax && ! $ this ->isMinimal ) {
234- if (Core::getEnv ('SCRIPT_NAME ' ) !== '' ) {
235- $ url = $ this ->getSelfUrl ();
236- }
200+ if (! $ this ->isEnabled ) {
201+ return '' ;
202+ }
237203
238- $ this ->scripts ->addCode ('window.Console.debugSqlInfo = ' . $ this ->getDebugMessage () . '; ' );
239- $ errorMessages = $ this ->getErrorMessages ();
240- $ scripts = $ this ->scripts ->getDisplay ();
204+ if (! $ this ->isAjax && ! $ this ->isMinimal ) {
205+ if (Core::getEnv ('SCRIPT_NAME ' ) !== '' ) {
206+ $ url = $ this ->getSelfUrl ();
207+ }
241208
242- if ( $ this ->config -> config -> debug -> demo ) {
243- $ gitRevisionInfo = $ this ->getGitRevisionInfo ();
244- }
209+ $ this -> scripts -> addCode ( ' window.Console.debugSqlInfo = ' . $ this ->getDebugMessage () . ' ; ' );
210+ $ errorMessages = $ this ->getErrorMessages ();
211+ $ scripts = $ this -> scripts -> getDisplay ();
245212
246- $ footer = Config::renderFooter ();
213+ if ($ this ->config ->config ->debug ->demo ) {
214+ $ gitRevisionInfo = $ this ->getGitRevisionInfo ();
247215 }
248216
249- return $ this ->template ->render ('footer ' , [
250- 'is_ajax ' => $ this ->isAjax ,
251- 'is_minimal ' => $ this ->isMinimal ,
252- 'self_url ' => $ url ?? null ,
253- 'error_messages ' => $ errorMessages ?? '' ,
254- 'scripts ' => $ scripts ?? '' ,
255- 'is_demo ' => $ this ->config ->config ->debug ->demo ,
256- 'git_revision_info ' => $ gitRevisionInfo ?? [],
257- 'footer ' => $ footer ?? '' ,
258- ]);
217+ $ footer = Config::renderFooter ();
259218 }
260219
261- return '' ;
220+ return $ this ->template ->render ('footer ' , [
221+ 'is_ajax ' => $ this ->isAjax ,
222+ 'is_minimal ' => $ this ->isMinimal ,
223+ 'self_url ' => $ url ?? null ,
224+ 'error_messages ' => $ errorMessages ?? '' ,
225+ 'scripts ' => $ scripts ?? '' ,
226+ 'is_demo ' => $ this ->config ->config ->debug ->demo ,
227+ 'git_revision_info ' => $ gitRevisionInfo ?? [],
228+ 'footer ' => $ footer ?? '' ,
229+ ]);
262230 }
263231}
0 commit comments