@@ -58,7 +58,7 @@ class Export
5858 /** @var DatabaseInterface */
5959 private $ dbi ;
6060
61- /** @var mixed */
61+ /** @var string */
6262 public $ dumpBuffer = '' ;
6363
6464 /** @var int */
@@ -126,7 +126,7 @@ public function gzencodeNeeded(): bool
126126 *
127127 * @param string $line the insert statement
128128 */
129- public function outputHandler (? string $ line ): bool
129+ public function outputHandler (string $ line ): bool
130130 {
131131 $ GLOBALS ['time_start ' ] = $ GLOBALS ['time_start ' ] ?? null ;
132132 $ GLOBALS ['save_filename ' ] = $ GLOBALS ['save_filename ' ] ?? null ;
@@ -140,7 +140,7 @@ public function outputHandler(?string $line): bool
140140 if ($ GLOBALS ['buffer_needed ' ]) {
141141 $ this ->dumpBuffer .= $ line ;
142142 if ($ GLOBALS ['onfly_compression ' ]) {
143- $ this ->dumpBufferLength += strlen (( string ) $ line );
143+ $ this ->dumpBufferLength += strlen ($ line );
144144
145145 if ($ this ->dumpBufferLength > $ GLOBALS ['memory_limit ' ]) {
146146 if ($ GLOBALS ['output_charset_conversion ' ]) {
@@ -150,14 +150,14 @@ public function outputHandler(?string $line): bool
150150 if ($ GLOBALS ['compression ' ] === 'gzip ' && $ this ->gzencodeNeeded ()) {
151151 // as a gzipped file
152152 // without the optional parameter level because it bugs
153- $ this ->dumpBuffer = gzencode ($ this ->dumpBuffer );
153+ $ this ->dumpBuffer = ( string ) gzencode ($ this ->dumpBuffer );
154154 }
155155
156156 if ($ GLOBALS ['save_on_server ' ]) {
157- $ writeResult = @fwrite ($ GLOBALS ['file_handle ' ], ( string ) $ this ->dumpBuffer );
157+ $ writeResult = @fwrite ($ GLOBALS ['file_handle ' ], $ this ->dumpBuffer );
158158 // Here, use strlen rather than mb_strlen to get the length
159159 // in bytes to compare against the number of bytes written.
160- if ($ writeResult != strlen (( string ) $ this ->dumpBuffer )) {
160+ if ($ writeResult != strlen ($ this ->dumpBuffer )) {
161161 $ GLOBALS ['message ' ] = Message::error (
162162 __ ('Insufficient space to save the file %s. ' )
163163 );
@@ -184,16 +184,16 @@ public function outputHandler(?string $line): bool
184184 $ line = Encoding::convertString ('utf-8 ' , $ GLOBALS ['charset ' ], $ line );
185185 }
186186
187- if ($ GLOBALS ['save_on_server ' ] && mb_strlen (( string ) $ line ) > 0 ) {
187+ if ($ GLOBALS ['save_on_server ' ] && mb_strlen ($ line ) > 0 ) {
188188 if ($ GLOBALS ['file_handle ' ] !== null ) {
189- $ writeResult = @fwrite ($ GLOBALS ['file_handle ' ], ( string ) $ line );
189+ $ writeResult = @fwrite ($ GLOBALS ['file_handle ' ], $ line );
190190 } else {
191191 $ writeResult = false ;
192192 }
193193
194194 // Here, use strlen rather than mb_strlen to get the length
195195 // in bytes to compare against the number of bytes written.
196- if (! $ writeResult || $ writeResult != strlen (( string ) $ line )) {
196+ if (! $ writeResult || $ writeResult != strlen ($ line )) {
197197 $ GLOBALS ['message ' ] = Message::error (
198198 __ ('Insufficient space to save the file %s. ' )
199199 );
@@ -213,7 +213,7 @@ public function outputHandler(?string $line): bool
213213 }
214214 } else {
215215 // We export as html - replace special chars
216- echo htmlspecialchars (( string ) $ line , ENT_COMPAT );
216+ echo htmlspecialchars ($ line , ENT_COMPAT );
217217 }
218218
219219 return true ;
@@ -264,7 +264,7 @@ public function getMemoryLimit(): int
264264 $ memoryLimitNumber = (int ) substr ($ memoryLimit , 0 , -1 );
265265 $ lowerLastChar = strtolower (substr ($ memoryLimit , -1 ));
266266 // 2 MB as default
267- if (empty ( $ memoryLimit) || $ memoryLimit == '-1 ' ) {
267+ if ($ memoryLimit === '' || $ memoryLimit === ' 0 ' || $ memoryLimit = == '-1 ' ) {
268268 $ memoryLimit = 2 * 1024 * 1024 ;
269269 } elseif ($ lowerLastChar === 'm ' ) {
270270 $ memoryLimit = $ memoryLimitNumber * 1024 * 1024 ;
@@ -350,31 +350,31 @@ public function getFilenameAndMimetype(
350350 string $ filenameTemplate
351351 ): array {
352352 if ($ exportType === 'server ' ) {
353- if (! empty ( $ rememberTemplate) ) {
353+ if ($ rememberTemplate !== '' && $ rememberTemplate !== ' 0 ' ) {
354354 $ GLOBALS ['config ' ]->setUserValue (
355355 'pma_server_filename_template ' ,
356356 'Export/file_template_server ' ,
357357 $ filenameTemplate
358358 );
359359 }
360360 } elseif ($ exportType === 'database ' ) {
361- if (! empty ( $ rememberTemplate) ) {
361+ if ($ rememberTemplate !== '' && $ rememberTemplate !== ' 0 ' ) {
362362 $ GLOBALS ['config ' ]->setUserValue (
363363 'pma_db_filename_template ' ,
364364 'Export/file_template_database ' ,
365365 $ filenameTemplate
366366 );
367367 }
368368 } elseif ($ exportType === 'raw ' ) {
369- if (! empty ( $ rememberTemplate) ) {
369+ if ($ rememberTemplate !== '' && $ rememberTemplate !== ' 0 ' ) {
370370 $ GLOBALS ['config ' ]->setUserValue (
371371 'pma_raw_filename_template ' ,
372372 'Export/file_template_raw ' ,
373373 $ filenameTemplate
374374 );
375375 }
376376 } else {
377- if (! empty ( $ rememberTemplate) ) {
377+ if ($ rememberTemplate !== '' && $ rememberTemplate !== ' 0 ' ) {
378378 $ GLOBALS ['config ' ]->setUserValue (
379379 'pma_table_filename_template ' ,
380380 'Export/file_template_table ' ,
@@ -586,7 +586,7 @@ public function exportServer(
586586 array $ aliases ,
587587 string $ separateFiles
588588 ): void {
589- if (! empty ($ dbSelect ) && is_array ( $ dbSelect) ) {
589+ if (is_array ($ dbSelect ) && $ dbSelect !== [] ) {
590590 $ tmpSelect = implode ('| ' , $ dbSelect );
591591 $ tmpSelect = '| ' . $ tmpSelect . '| ' ;
592592 }
@@ -1012,9 +1012,9 @@ public function exportTable(
10121012 // for example, a PDF report
10131013 // if it is a merge table, no data is exported
10141014 if ($ whatStrucOrData === 'data ' || $ whatStrucOrData === 'structure_and_data ' ) {
1015- if (! empty ( $ sqlQuery) ) {
1015+ if ($ sqlQuery !== '' ) {
10161016 // only preg_replace if needed
1017- if (! empty ( $ addQuery) ) {
1017+ if ($ addQuery !== '' ) {
10181018 // remove trailing semicolon before adding a LIMIT
10191019 $ sqlQuery = preg_replace ('%;\s*$% ' , '' , $ sqlQuery );
10201020 }
@@ -1129,7 +1129,7 @@ public function mergeAliases(array $aliases1, array $aliases2): array
11291129 $ val1 = $ db ['alias ' ][0 ];
11301130 $ val2 = $ db ['alias ' ][1 ];
11311131 // Use aliases2 alias if non empty
1132- $ aliases [$ dbName ]['alias ' ] = empty ( $ val2) ? $ val1 : $ val2 ;
1132+ $ aliases [$ dbName ]['alias ' ] = $ val2 !== '' && $ val2 !== null ? $ val2 : $ val1 ;
11331133 }
11341134
11351135 if (! isset ($ db ['tables ' ])) {
@@ -1141,7 +1141,7 @@ public function mergeAliases(array $aliases1, array $aliases2): array
11411141 $ val1 = $ tbl ['alias ' ][0 ];
11421142 $ val2 = $ tbl ['alias ' ][1 ];
11431143 // Use aliases2 alias if non empty
1144- $ aliases [$ dbName ]['tables ' ][$ tableName ]['alias ' ] = empty ( $ val2) ? $ val1 : $ val2 ;
1144+ $ aliases [$ dbName ]['tables ' ][$ tableName ]['alias ' ] = $ val2 !== '' && $ val2 !== null ? $ val2 : $ val1 ;
11451145 }
11461146
11471147 if (! isset ($ tbl ['columns ' ])) {
@@ -1156,7 +1156,7 @@ public function mergeAliases(array $aliases1, array $aliases2): array
11561156 $ val1 = $ colAs [0 ];
11571157 $ val2 = $ colAs [1 ];
11581158 // Use aliases2 alias if non empty
1159- $ aliases [$ dbName ]['tables ' ][$ tableName ]['columns ' ][$ col ] = empty ( $ val2) ? $ val1 : $ val2 ;
1159+ $ aliases [$ dbName ]['tables ' ][$ tableName ]['columns ' ][$ col ] = $ val2 !== '' && $ val2 !== null ? $ val2 : $ val1 ;
11601160 }
11611161 }
11621162 }
0 commit comments