X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdb%2FDatabaseError.php;h=4cd02b1f6113e9a90c8f0612134b57fb68b3fe28;hp=e6c285e7a8b2e5930b3f54261cc48c4d8acb80e7;hb=98585221d685e7cfcb5a3bb0d766c6cd431f2b05;hpb=f4a5507a966861a56e072dd7434fce9d933b3eaf diff --git a/includes/db/DatabaseError.php b/includes/db/DatabaseError.php index e6c285e7a8..4cd02b1f61 100644 --- a/includes/db/DatabaseError.php +++ b/includes/db/DatabaseError.php @@ -78,6 +78,10 @@ class DBExpectedError extends DBError { return $s; } + function getPageTitle() { + return $this->msg( 'databaseerror', 'Database error' ); + } + /** * @return string */ @@ -167,7 +171,7 @@ class DBConnectionError extends DBExpectedError { if ( $wgShowHostnames || $wgShowSQLErrors ) { $info = str_replace( - '$1', Html::element( 'span', array( 'dir' => 'ltr' ), $this->error ), + '$1', Html::element( 'span', [ 'dir' => 'ltr' ], $this->error ), htmlspecialchars( $this->msg( 'dberr-info', '(Cannot access the database: $1)' ) ) ); } else { @@ -217,7 +221,7 @@ class DBConnectionError extends DBExpectedError { // Cached version on file system? if ( $cache !== null ) { // Hack: extend the body for error messages - $cache = str_replace( array( '', '' ), '', $cache ); + $cache = str_replace( [ '', '' ], '', $cache ); // Add cache notice... $cache .= '
' . htmlspecialchars( $this->msg( 'dberr-cachederror', @@ -362,7 +366,7 @@ class DBQueryError extends DBExpectedError { */ protected function getHTMLContent() { $key = 'databaseerror-text'; - $s = Html::element( 'p', array(), $this->msg( $key, $this->getFallbackMessage( $key ) ) ); + $s = Html::element( 'p', [], $this->msg( $key, $this->getFallbackMessage( $key ) ) ); $details = $this->getTechnicalDetails(); if ( $details ) { @@ -370,7 +374,7 @@ class DBQueryError extends DBExpectedError { foreach ( $details as $key => $detail ) { $s .= str_replace( '$1', call_user_func_array( 'Html::element', $detail ), - Html::element( 'li', array(), + Html::element( 'li', [], $this->msg( $key, $this->getFallbackMessage( $key ) ) ) ); @@ -411,18 +415,18 @@ class DBQueryError extends DBExpectedError { protected function getTechnicalDetails() { global $wgShowHostnames, $wgShowSQLErrors; - $attribs = array( 'dir' => 'ltr' ); - $details = array(); + $attribs = [ 'dir' => 'ltr' ]; + $details = []; if ( $wgShowSQLErrors ) { - $details['databaseerror-query'] = array( - 'div', array( 'class' => 'mw-code' ) + $attribs, $this->sql ); + $details['databaseerror-query'] = [ + 'div', [ 'class' => 'mw-code' ] + $attribs, $this->sql ]; } if ( $wgShowHostnames || $wgShowSQLErrors ) { $errorMessage = $this->errno . ' ' . $this->error; - $details['databaseerror-function'] = array( 'code', $attribs, $this->fname ); - $details['databaseerror-error'] = array( 'samp', $attribs, $errorMessage ); + $details['databaseerror-function'] = [ 'code', $attribs, $this->fname ]; + $details['databaseerror-error'] = [ 'samp', $attribs, $errorMessage ]; } return $details; @@ -433,14 +437,14 @@ class DBQueryError extends DBExpectedError { * @return string English message text */ private function getFallbackMessage( $key ) { - $messages = array( + $messages = [ 'databaseerror-text' => 'A database query error has occurred. This may indicate a bug in the software.', 'databaseerror-textcl' => 'A database query error has occurred.', 'databaseerror-query' => 'Query: $1', 'databaseerror-function' => 'Function: $1', 'databaseerror-error' => 'Error: $1', - ); + ]; return $messages[$key]; } @@ -456,4 +460,13 @@ class DBUnexpectedError extends DBError { * @ingroup Database */ class DBReadOnlyError extends DBExpectedError { + function getPageTitle() { + return $this->msg( 'readonly', 'Database is locked' ); + } +} + +/** + * @ingroup Database + */ +class DBTransactionError extends DBExpectedError { }