MediaWiki  1.29.1
DatabaseOracle.php
Go to the documentation of this file.
1 <?php
29 
33 class DatabaseOracle extends Database {
35  protected $mLastResult = null;
36 
38  protected $mAffectedRows;
39 
41  private $mInsertId = null;
42 
44  private $ignoreDupValOnIndex = false;
45 
47  private $sequenceData = null;
48 
50  private $defaultCharset = 'AL32UTF8';
51 
53  private $mFieldInfoCache = [];
54 
55  function __construct( array $p ) {
57 
58  if ( $p['tablePrefix'] == 'get from global' ) {
59  $p['tablePrefix'] = $wgDBprefix;
60  }
61  $p['tablePrefix'] = strtoupper( $p['tablePrefix'] );
62  parent::__construct( $p );
63  Hooks::run( 'DatabaseOraclePostInit', [ $this ] );
64  }
65 
66  function __destruct() {
67  if ( $this->mOpened ) {
68  MediaWiki\suppressWarnings();
69  $this->close();
70  MediaWiki\restoreWarnings();
71  }
72  }
73 
74  function getType() {
75  return 'oracle';
76  }
77 
78  function implicitGroupby() {
79  return false;
80  }
81 
82  function implicitOrderby() {
83  return false;
84  }
85 
95  function open( $server, $user, $password, $dbName ) {
97  if ( !function_exists( 'oci_connect' ) ) {
98  throw new DBConnectionError(
99  $this,
100  "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n " .
101  "(Note: if you recently installed PHP, you may need to restart your webserver\n " .
102  "and database)\n" );
103  }
104 
105  $this->close();
106  $this->mUser = $user;
107  $this->mPassword = $password;
108  // changed internal variables functions
109  // mServer now holds the TNS endpoint
110  // mDBname is schema name if different from username
111  if ( !$server ) {
112  // backward compatibillity (server used to be null and TNS was supplied in dbname)
113  $this->mServer = $dbName;
114  $this->mDBname = $user;
115  } else {
116  $this->mServer = $server;
117  if ( !$dbName ) {
118  $this->mDBname = $user;
119  } else {
120  $this->mDBname = $dbName;
121  }
122  }
123 
124  if ( !strlen( $user ) ) { # e.g. the class is being loaded
125  return null;
126  }
127 
128  if ( $wgDBOracleDRCP ) {
129  $this->setFlag( DBO_PERSISTENT );
130  }
131 
132  $session_mode = $this->mFlags & DBO_SYSDBA ? OCI_SYSDBA : OCI_DEFAULT;
133 
134  MediaWiki\suppressWarnings();
135  if ( $this->mFlags & DBO_PERSISTENT ) {
136  $this->mConn = oci_pconnect(
137  $this->mUser,
138  $this->mPassword,
139  $this->mServer,
140  $this->defaultCharset,
141  $session_mode
142  );
143  } elseif ( $this->mFlags & DBO_DEFAULT ) {
144  $this->mConn = oci_new_connect(
145  $this->mUser,
146  $this->mPassword,
147  $this->mServer,
148  $this->defaultCharset,
149  $session_mode
150  );
151  } else {
152  $this->mConn = oci_connect(
153  $this->mUser,
154  $this->mPassword,
155  $this->mServer,
156  $this->defaultCharset,
157  $session_mode
158  );
159  }
160  MediaWiki\restoreWarnings();
161 
162  if ( $this->mUser != $this->mDBname ) {
163  // change current schema in session
164  $this->selectDB( $this->mDBname );
165  }
166 
167  if ( !$this->mConn ) {
168  throw new DBConnectionError( $this, $this->lastError() );
169  }
170 
171  $this->mOpened = true;
172 
173  # removed putenv calls because they interfere with the system globaly
174  $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
175  $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
176  $this->doQuery( 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS=\'.,\'' );
177 
178  return $this->mConn;
179  }
180 
186  protected function closeConnection() {
187  return oci_close( $this->mConn );
188  }
189 
190  function execFlags() {
191  return $this->mTrxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
192  }
193 
194  protected function doQuery( $sql ) {
195  wfDebug( "SQL: [$sql]\n" );
196  if ( !StringUtils::isUtf8( $sql ) ) {
197  throw new InvalidArgumentException( "SQL encoding is invalid\n$sql" );
198  }
199 
200  // handle some oracle specifics
201  // remove AS column/table/subquery namings
202  if ( !$this->getFlag( DBO_DDLMODE ) ) {
203  $sql = preg_replace( '/ as /i', ' ', $sql );
204  }
205 
206  // Oracle has issues with UNION clause if the statement includes LOB fields
207  // So we do a UNION ALL and then filter the results array with array_unique
208  $union_unique = ( preg_match( '/\/\* UNION_UNIQUE \*\/ /', $sql ) != 0 );
209  // EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
210  // you have to select data from plan table after explain
211  $explain_id = MWTimestamp::getLocalInstance()->format( 'dmYHis' );
212 
213  $sql = preg_replace(
214  '/^EXPLAIN /',
215  'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR',
216  $sql,
217  1,
218  $explain_count
219  );
220 
221  MediaWiki\suppressWarnings();
222 
223  $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
224  if ( $stmt === false ) {
225  $e = oci_error( $this->mConn );
226  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
227 
228  return false;
229  }
230 
231  if ( !oci_execute( $stmt, $this->execFlags() ) ) {
232  $e = oci_error( $stmt );
233  if ( !$this->ignoreDupValOnIndex || $e['code'] != '1' ) {
234  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
235 
236  return false;
237  }
238  }
239 
240  MediaWiki\restoreWarnings();
241 
242  if ( $explain_count > 0 ) {
243  return $this->doQuery( 'SELECT id, cardinality "ROWS" FROM plan_table ' .
244  'WHERE statement_id = \'' . $explain_id . '\'' );
245  } elseif ( oci_statement_type( $stmt ) == 'SELECT' ) {
246  return new ORAResult( $this, $stmt, $union_unique );
247  } else {
248  $this->mAffectedRows = oci_num_rows( $stmt );
249 
250  return true;
251  }
252  }
253 
254  function queryIgnore( $sql, $fname = '' ) {
255  return $this->query( $sql, $fname, true );
256  }
257 
262  function freeResult( $res ) {
263  if ( $res instanceof ResultWrapper ) {
264  $res = $res->result;
265  }
266 
267  $res->free();
268  }
269 
274  function fetchObject( $res ) {
275  if ( $res instanceof ResultWrapper ) {
276  $res = $res->result;
277  }
278 
279  return $res->fetchObject();
280  }
281 
286  function fetchRow( $res ) {
287  if ( $res instanceof ResultWrapper ) {
288  $res = $res->result;
289  }
290 
291  return $res->fetchRow();
292  }
293 
298  function numRows( $res ) {
299  if ( $res instanceof ResultWrapper ) {
300  $res = $res->result;
301  }
302 
303  return $res->numRows();
304  }
305 
310  function numFields( $res ) {
311  if ( $res instanceof ResultWrapper ) {
312  $res = $res->result;
313  }
314 
315  return $res->numFields();
316  }
317 
318  function fieldName( $stmt, $n ) {
319  return oci_field_name( $stmt, $n );
320  }
321 
326  function insertId() {
327  return $this->mInsertId;
328  }
329 
334  function dataSeek( $res, $row ) {
335  if ( $res instanceof ORAResult ) {
336  $res->seek( $row );
337  } else {
338  $res->result->seek( $row );
339  }
340  }
341 
342  function lastError() {
343  if ( $this->mConn === false ) {
344  $e = oci_error();
345  } else {
346  $e = oci_error( $this->mConn );
347  }
348 
349  return $e['message'];
350  }
351 
352  function lastErrno() {
353  if ( $this->mConn === false ) {
354  $e = oci_error();
355  } else {
356  $e = oci_error( $this->mConn );
357  }
358 
359  return $e['code'];
360  }
361 
362  function affectedRows() {
363  return $this->mAffectedRows;
364  }
365 
374  function indexInfo( $table, $index, $fname = __METHOD__ ) {
375  return false;
376  }
377 
378  function indexUnique( $table, $index, $fname = __METHOD__ ) {
379  return false;
380  }
381 
382  function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
383  if ( !count( $a ) ) {
384  return true;
385  }
386 
387  if ( !is_array( $options ) ) {
388  $options = [ $options ];
389  }
390 
391  if ( in_array( 'IGNORE', $options ) ) {
392  $this->ignoreDupValOnIndex = true;
393  }
394 
395  if ( !is_array( reset( $a ) ) ) {
396  $a = [ $a ];
397  }
398 
399  foreach ( $a as &$row ) {
400  $this->insertOneRow( $table, $row, $fname );
401  }
402  $retVal = true;
403 
404  if ( in_array( 'IGNORE', $options ) ) {
405  $this->ignoreDupValOnIndex = false;
406  }
407 
408  return $retVal;
409  }
410 
411  private function fieldBindStatement( $table, $col, &$val, $includeCol = false ) {
412  $col_info = $this->fieldInfoMulti( $table, $col );
413  $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
414 
415  $bind = '';
416  if ( is_numeric( $col ) ) {
417  $bind = $val;
418  $val = null;
419 
420  return $bind;
421  } elseif ( $includeCol ) {
422  $bind = "$col = ";
423  }
424 
425  if ( $val == '' && $val !== 0 && $col_type != 'BLOB' && $col_type != 'CLOB' ) {
426  $val = null;
427  }
428 
429  if ( $val === 'NULL' ) {
430  $val = null;
431  }
432 
433  if ( $val === null ) {
434  if ( $col_info != false && $col_info->isNullable() == 0 && $col_info->defaultValue() != null ) {
435  $bind .= 'DEFAULT';
436  } else {
437  $bind .= 'NULL';
438  }
439  } else {
440  $bind .= ':' . $col;
441  }
442 
443  return $bind;
444  }
445 
453  private function insertOneRow( $table, $row, $fname ) {
455 
456  $table = $this->tableName( $table );
457  // "INSERT INTO tables (a, b, c)"
458  $sql = "INSERT INTO " . $table . " (" . implode( ',', array_keys( $row ) ) . ')';
459  $sql .= " VALUES (";
460 
461  // for each value, append ":key"
462  $first = true;
463  foreach ( $row as $col => &$val ) {
464  if ( !$first ) {
465  $sql .= ', ';
466  } else {
467  $first = false;
468  }
469  if ( $this->isQuotedIdentifier( $val ) ) {
470  $sql .= $this->removeIdentifierQuotes( $val );
471  unset( $row[$col] );
472  } else {
473  $sql .= $this->fieldBindStatement( $table, $col, $val );
474  }
475  }
476  $sql .= ')';
477 
478  $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
479  if ( $stmt === false ) {
480  $e = oci_error( $this->mConn );
481  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
482 
483  return false;
484  }
485  foreach ( $row as $col => &$val ) {
486  $col_info = $this->fieldInfoMulti( $table, $col );
487  $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
488 
489  if ( $val === null ) {
490  // do nothing ... null was inserted in statement creation
491  } elseif ( $col_type != 'BLOB' && $col_type != 'CLOB' ) {
492  if ( is_object( $val ) ) {
493  $val = $val->fetch();
494  }
495 
496  // backward compatibility
497  if ( preg_match( '/^timestamp.*/i', $col_type ) == 1 && strtolower( $val ) == 'infinity' ) {
498  $val = $this->getInfinity();
499  }
500 
501  $val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val;
502  if ( oci_bind_by_name( $stmt, ":$col", $val, -1, SQLT_CHR ) === false ) {
503  $e = oci_error( $stmt );
504  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
505 
506  return false;
507  }
508  } else {
510  $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB );
511  if ( $lob[$col] === false ) {
512  $e = oci_error( $stmt );
513  throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
514  }
515 
516  if ( is_object( $val ) ) {
517  $val = $val->fetch();
518  }
519 
520  if ( $col_type == 'BLOB' ) {
521  $lob[$col]->writeTemporary( $val, OCI_TEMP_BLOB );
522  oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, OCI_B_BLOB );
523  } else {
524  $lob[$col]->writeTemporary( $val, OCI_TEMP_CLOB );
525  oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, OCI_B_CLOB );
526  }
527  }
528  }
529 
530  MediaWiki\suppressWarnings();
531 
532  if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
533  $e = oci_error( $stmt );
534  if ( !$this->ignoreDupValOnIndex || $e['code'] != '1' ) {
535  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
536 
537  return false;
538  } else {
539  $this->mAffectedRows = oci_num_rows( $stmt );
540  }
541  } else {
542  $this->mAffectedRows = oci_num_rows( $stmt );
543  }
544 
545  MediaWiki\restoreWarnings();
546 
547  if ( isset( $lob ) ) {
548  foreach ( $lob as $lob_v ) {
549  $lob_v->free();
550  }
551  }
552 
553  if ( !$this->mTrxLevel ) {
554  oci_commit( $this->mConn );
555  }
556 
557  return oci_free_statement( $stmt );
558  }
559 
560  function nativeInsertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__,
561  $insertOptions = [], $selectOptions = []
562  ) {
563  $destTable = $this->tableName( $destTable );
564  if ( !is_array( $selectOptions ) ) {
565  $selectOptions = [ $selectOptions ];
566  }
567  list( $startOpts, $useIndex, $tailOpts, $ignoreIndex ) =
568  $this->makeSelectOptions( $selectOptions );
569  if ( is_array( $srcTable ) ) {
570  $srcTable = implode( ',', array_map( [ $this, 'tableName' ], $srcTable ) );
571  } else {
572  $srcTable = $this->tableName( $srcTable );
573  }
574 
575  $sequenceData = $this->getSequenceData( $destTable );
576  if ( $sequenceData !== false &&
577  !isset( $varMap[$sequenceData['column']] )
578  ) {
579  $varMap[$sequenceData['column']] = 'GET_SEQUENCE_VALUE(\'' . $sequenceData['sequence'] . '\')';
580  }
581 
582  // count-alias subselect fields to avoid abigious definition errors
583  $i = 0;
584  foreach ( $varMap as &$val ) {
585  $val = $val . ' field' . ( $i++ );
586  }
587 
588  $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
589  " SELECT $startOpts " . implode( ',', $varMap ) .
590  " FROM $srcTable $useIndex $ignoreIndex ";
591  if ( $conds != '*' ) {
592  $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
593  }
594  $sql .= " $tailOpts";
595 
596  if ( in_array( 'IGNORE', $insertOptions ) ) {
597  $this->ignoreDupValOnIndex = true;
598  }
599 
600  $retval = $this->query( $sql, $fname );
601 
602  if ( in_array( 'IGNORE', $insertOptions ) ) {
603  $this->ignoreDupValOnIndex = false;
604  }
605 
606  return $retval;
607  }
608 
609  public function upsert( $table, array $rows, array $uniqueIndexes, array $set,
610  $fname = __METHOD__
611  ) {
612  if ( !count( $rows ) ) {
613  return true; // nothing to do
614  }
615 
616  if ( !is_array( reset( $rows ) ) ) {
617  $rows = [ $rows ];
618  }
619 
620  $sequenceData = $this->getSequenceData( $table );
621  if ( $sequenceData !== false ) {
622  // add sequence column to each list of columns, when not set
623  foreach ( $rows as &$row ) {
624  if ( !isset( $row[$sequenceData['column']] ) ) {
625  $row[$sequenceData['column']] =
626  $this->addIdentifierQuotes( 'GET_SEQUENCE_VALUE(\'' .
627  $sequenceData['sequence'] . '\')' );
628  }
629  }
630  }
631 
632  return parent::upsert( $table, $rows, $uniqueIndexes, $set, $fname );
633  }
634 
635  function tableName( $name, $format = 'quoted' ) {
636  /*
637  Replace reserved words with better ones
638  Using uppercase because that's the only way Oracle can handle
639  quoted tablenames
640  */
641  switch ( $name ) {
642  case 'user':
643  $name = 'MWUSER';
644  break;
645  case 'text':
646  $name = 'PAGECONTENT';
647  break;
648  }
649 
650  return strtoupper( parent::tableName( $name, $format ) );
651  }
652 
653  function tableNameInternal( $name ) {
654  $name = $this->tableName( $name );
655 
656  return preg_replace( '/.*\.(.*)/', '$1', $name );
657  }
658 
665  function nextSequenceValue( $seqName ) {
666  $res = $this->query( "SELECT $seqName.nextval FROM dual" );
667  $row = $this->fetchRow( $res );
668  $this->mInsertId = $row[0];
669 
670  return $this->mInsertId;
671  }
672 
679  private function getSequenceData( $table ) {
680  if ( $this->sequenceData == null ) {
681  $result = $this->doQuery( "SELECT lower(asq.sequence_name),
682  lower(atc.table_name),
683  lower(atc.column_name)
684  FROM all_sequences asq, all_tab_columns atc
685  WHERE decode(
686  atc.table_name,
687  '{$this->mTablePrefix}MWUSER',
688  '{$this->mTablePrefix}USER',
689  atc.table_name
690  ) || '_' ||
691  atc.column_name || '_SEQ' = '{$this->mTablePrefix}' || asq.sequence_name
692  AND asq.sequence_owner = upper('{$this->mDBname}')
693  AND atc.owner = upper('{$this->mDBname}')" );
694 
695  while ( ( $row = $result->fetchRow() ) !== false ) {
696  $this->sequenceData[$row[1]] = [
697  'sequence' => $row[0],
698  'column' => $row[2]
699  ];
700  }
701  }
702  $table = strtolower( $this->removeIdentifierQuotes( $this->tableName( $table ) ) );
703 
704  return ( isset( $this->sequenceData[$table] ) ) ? $this->sequenceData[$table] : false;
705  }
706 
714  function textFieldSize( $table, $field ) {
715  $fieldInfoData = $this->fieldInfo( $table, $field );
716 
717  return $fieldInfoData->maxLength();
718  }
719 
720  function limitResult( $sql, $limit, $offset = false ) {
721  if ( $offset === false ) {
722  $offset = 0;
723  }
724 
725  return "SELECT * FROM ($sql) WHERE rownum >= (1 + $offset) AND rownum < (1 + $limit + $offset)";
726  }
727 
728  function encodeBlob( $b ) {
729  return new Blob( $b );
730  }
731 
732  function decodeBlob( $b ) {
733  if ( $b instanceof Blob ) {
734  $b = $b->fetch();
735  }
736 
737  return $b;
738  }
739 
740  function unionQueries( $sqls, $all ) {
741  $glue = ' UNION ALL ';
742 
743  return 'SELECT * ' . ( $all ? '' : '/* UNION_UNIQUE */ ' ) .
744  'FROM (' . implode( $glue, $sqls ) . ')';
745  }
746 
747  function wasDeadlock() {
748  return $this->lastErrno() == 'OCI-00060';
749  }
750 
751  function duplicateTableStructure( $oldName, $newName, $temporary = false,
752  $fname = __METHOD__
753  ) {
754  $temporary = $temporary ? 'TRUE' : 'FALSE';
755 
756  $newName = strtoupper( $newName );
757  $oldName = strtoupper( $oldName );
758 
759  $tabName = substr( $newName, strlen( $this->mTablePrefix ) );
760  $oldPrefix = substr( $oldName, 0, strlen( $oldName ) - strlen( $tabName ) );
761  $newPrefix = strtoupper( $this->mTablePrefix );
762 
763  return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', " .
764  "'$oldPrefix', '$newPrefix', $temporary ); END;" );
765  }
766 
767  function listTables( $prefix = null, $fname = __METHOD__ ) {
768  $listWhere = '';
769  if ( !empty( $prefix ) ) {
770  $listWhere = ' AND table_name LIKE \'' . strtoupper( $prefix ) . '%\'';
771  }
772 
773  $owner = strtoupper( $this->mDBname );
774  $result = $this->doQuery( "SELECT table_name FROM all_tables " .
775  "WHERE owner='$owner' AND table_name NOT LIKE '%!_IDX\$_' ESCAPE '!' $listWhere" );
776 
777  // dirty code ... i know
778  $endArray = [];
779  $endArray[] = strtoupper( $prefix . 'MWUSER' );
780  $endArray[] = strtoupper( $prefix . 'PAGE' );
781  $endArray[] = strtoupper( $prefix . 'IMAGE' );
782  $fixedOrderTabs = $endArray;
783  while ( ( $row = $result->fetchRow() ) !== false ) {
784  if ( !in_array( $row['table_name'], $fixedOrderTabs ) ) {
785  $endArray[] = $row['table_name'];
786  }
787  }
788 
789  return $endArray;
790  }
791 
792  public function dropTable( $tableName, $fName = __METHOD__ ) {
793  $tableName = $this->tableName( $tableName );
794  if ( !$this->tableExists( $tableName ) ) {
795  return false;
796  }
797 
798  return $this->doQuery( "DROP TABLE $tableName CASCADE CONSTRAINTS PURGE" );
799  }
800 
801  function timestamp( $ts = 0 ) {
802  return wfTimestamp( TS_ORACLE, $ts );
803  }
804 
812  public function aggregateValue( $valuedata, $valuename = 'value' ) {
813  return $valuedata;
814  }
815 
819  public function getSoftwareLink() {
820  return '[{{int:version-db-oracle-url}} Oracle]';
821  }
822 
826  function getServerVersion() {
827  // better version number, fallback on driver
828  $rset = $this->doQuery(
829  'SELECT version FROM product_component_version ' .
830  'WHERE UPPER(product) LIKE \'ORACLE DATABASE%\''
831  );
832  $row = $rset->fetchRow();
833  if ( !$row ) {
834  return oci_server_version( $this->mConn );
835  }
836 
837  return $row['version'];
838  }
839 
847  function indexExists( $table, $index, $fname = __METHOD__ ) {
848  $table = $this->tableName( $table );
849  $table = strtoupper( $this->removeIdentifierQuotes( $table ) );
850  $index = strtoupper( $index );
851  $owner = strtoupper( $this->mDBname );
852  $sql = "SELECT 1 FROM all_indexes WHERE owner='$owner' AND index_name='{$table}_{$index}'";
853  $res = $this->doQuery( $sql );
854  if ( $res ) {
855  $count = $res->numRows();
856  $res->free();
857  } else {
858  $count = 0;
859  }
860 
861  return $count != 0;
862  }
863 
870  function tableExists( $table, $fname = __METHOD__ ) {
871  $table = $this->tableName( $table );
872  $table = $this->addQuotes( strtoupper( $this->removeIdentifierQuotes( $table ) ) );
873  $owner = $this->addQuotes( strtoupper( $this->mDBname ) );
874  $sql = "SELECT 1 FROM all_tables WHERE owner=$owner AND table_name=$table";
875  $res = $this->doQuery( $sql );
876  if ( $res && $res->numRows() > 0 ) {
877  $exists = true;
878  } else {
879  $exists = false;
880  }
881 
882  $res->free();
883 
884  return $exists;
885  }
886 
897  private function fieldInfoMulti( $table, $field ) {
898  $field = strtoupper( $field );
899  if ( is_array( $table ) ) {
900  $table = array_map( [ $this, 'tableNameInternal' ], $table );
901  $tableWhere = 'IN (';
902  foreach ( $table as &$singleTable ) {
903  $singleTable = $this->removeIdentifierQuotes( $singleTable );
904  if ( isset( $this->mFieldInfoCache["$singleTable.$field"] ) ) {
905  return $this->mFieldInfoCache["$singleTable.$field"];
906  }
907  $tableWhere .= '\'' . $singleTable . '\',';
908  }
909  $tableWhere = rtrim( $tableWhere, ',' ) . ')';
910  } else {
911  $table = $this->removeIdentifierQuotes( $this->tableNameInternal( $table ) );
912  if ( isset( $this->mFieldInfoCache["$table.$field"] ) ) {
913  return $this->mFieldInfoCache["$table.$field"];
914  }
915  $tableWhere = '= \'' . $table . '\'';
916  }
917 
918  $fieldInfoStmt = oci_parse(
919  $this->mConn,
920  'SELECT * FROM wiki_field_info_full WHERE table_name ' .
921  $tableWhere . ' and column_name = \'' . $field . '\''
922  );
923  if ( oci_execute( $fieldInfoStmt, $this->execFlags() ) === false ) {
924  $e = oci_error( $fieldInfoStmt );
925  $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ );
926 
927  return false;
928  }
929  $res = new ORAResult( $this, $fieldInfoStmt );
930  if ( $res->numRows() == 0 ) {
931  if ( is_array( $table ) ) {
932  foreach ( $table as &$singleTable ) {
933  $this->mFieldInfoCache["$singleTable.$field"] = false;
934  }
935  } else {
936  $this->mFieldInfoCache["$table.$field"] = false;
937  }
938  $fieldInfoTemp = null;
939  } else {
940  $fieldInfoTemp = new ORAField( $res->fetchRow() );
941  $table = $fieldInfoTemp->tableName();
942  $this->mFieldInfoCache["$table.$field"] = $fieldInfoTemp;
943  }
944  $res->free();
945 
946  return $fieldInfoTemp;
947  }
948 
955  function fieldInfo( $table, $field ) {
956  if ( is_array( $table ) ) {
957  throw new DBUnexpectedError( $this, 'DatabaseOracle::fieldInfo called with table array!' );
958  }
959 
960  return $this->fieldInfoMulti( $table, $field );
961  }
962 
963  protected function doBegin( $fname = __METHOD__ ) {
964  $this->mTrxLevel = 1;
965  $this->doQuery( 'SET CONSTRAINTS ALL DEFERRED' );
966  }
967 
968  protected function doCommit( $fname = __METHOD__ ) {
969  if ( $this->mTrxLevel ) {
970  $ret = oci_commit( $this->mConn );
971  if ( !$ret ) {
972  throw new DBUnexpectedError( $this, $this->lastError() );
973  }
974  $this->mTrxLevel = 0;
975  $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
976  }
977  }
978 
979  protected function doRollback( $fname = __METHOD__ ) {
980  if ( $this->mTrxLevel ) {
981  oci_rollback( $this->mConn );
982  $this->mTrxLevel = 0;
983  $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
984  }
985  }
986 
987  function sourceStream(
988  $fp,
989  callable $lineCallback = null,
990  callable $resultCallback = null,
991  $fname = __METHOD__, callable $inputCallback = null
992  ) {
993  $cmd = '';
994  $done = false;
995  $dollarquote = false;
996 
997  $replacements = [];
998  // Defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}';
999  while ( !feof( $fp ) ) {
1000  if ( $lineCallback ) {
1001  call_user_func( $lineCallback );
1002  }
1003  $line = trim( fgets( $fp, 1024 ) );
1004  $sl = strlen( $line ) - 1;
1005 
1006  if ( $sl < 0 ) {
1007  continue;
1008  }
1009  if ( '-' == $line[0] && '-' == $line[1] ) {
1010  continue;
1011  }
1012 
1013  // Allow dollar quoting for function declarations
1014  if ( substr( $line, 0, 8 ) == '/*$mw$*/' ) {
1015  if ( $dollarquote ) {
1016  $dollarquote = false;
1017  $line = str_replace( '/*$mw$*/', '', $line ); // remove dollarquotes
1018  $done = true;
1019  } else {
1020  $dollarquote = true;
1021  }
1022  } elseif ( !$dollarquote ) {
1023  if ( ';' == $line[$sl] && ( $sl < 2 || ';' != $line[$sl - 1] ) ) {
1024  $done = true;
1025  $line = substr( $line, 0, $sl );
1026  }
1027  }
1028 
1029  if ( $cmd != '' ) {
1030  $cmd .= ' ';
1031  }
1032  $cmd .= "$line\n";
1033 
1034  if ( $done ) {
1035  $cmd = str_replace( ';;', ";", $cmd );
1036  if ( strtolower( substr( $cmd, 0, 6 ) ) == 'define' ) {
1037  if ( preg_match( '/^define\s*([^\s=]*)\s*=\s*\'\{\$([^\}]*)\}\'/', $cmd, $defines ) ) {
1038  $replacements[$defines[2]] = $defines[1];
1039  }
1040  } else {
1041  foreach ( $replacements as $mwVar => $scVar ) {
1042  $cmd = str_replace( '&' . $scVar . '.', '`{$' . $mwVar . '}`', $cmd );
1043  }
1044 
1045  $cmd = $this->replaceVars( $cmd );
1046  if ( $inputCallback ) {
1047  call_user_func( $inputCallback, $cmd );
1048  }
1049  $res = $this->doQuery( $cmd );
1050  if ( $resultCallback ) {
1051  call_user_func( $resultCallback, $res, $this );
1052  }
1053 
1054  if ( false === $res ) {
1055  $err = $this->lastError();
1056 
1057  return "Query \"{$cmd}\" failed with error code \"$err\".\n";
1058  }
1059  }
1060 
1061  $cmd = '';
1062  $done = false;
1063  }
1064  }
1065 
1066  return true;
1067  }
1068 
1069  function selectDB( $db ) {
1070  $this->mDBname = $db;
1071  if ( $db == null || $db == $this->mUser ) {
1072  return true;
1073  }
1074  $sql = 'ALTER SESSION SET CURRENT_SCHEMA=' . strtoupper( $db );
1075  $stmt = oci_parse( $this->mConn, $sql );
1076  MediaWiki\suppressWarnings();
1077  $success = oci_execute( $stmt );
1078  MediaWiki\restoreWarnings();
1079  if ( !$success ) {
1080  $e = oci_error( $stmt );
1081  if ( $e['code'] != '1435' ) {
1082  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1083  }
1084 
1085  return false;
1086  }
1087 
1088  return true;
1089  }
1090 
1091  function strencode( $s ) {
1092  return str_replace( "'", "''", $s );
1093  }
1094 
1095  function addQuotes( $s ) {
1097  if ( isset( $wgContLang->mLoaded ) && $wgContLang->mLoaded ) {
1098  $s = $wgContLang->checkTitleEncoding( $s );
1099  }
1100 
1101  return "'" . $this->strencode( $s ) . "'";
1102  }
1103 
1104  public function addIdentifierQuotes( $s ) {
1105  if ( !$this->getFlag( DBO_DDLMODE ) ) {
1106  $s = '/*Q*/' . $s;
1107  }
1108 
1109  return $s;
1110  }
1111 
1112  public function removeIdentifierQuotes( $s ) {
1113  return strpos( $s, '/*Q*/' ) === false ? $s : substr( $s, 5 );
1114  }
1115 
1116  public function isQuotedIdentifier( $s ) {
1117  return strpos( $s, '/*Q*/' ) !== false;
1118  }
1119 
1120  private function wrapFieldForWhere( $table, &$col, &$val ) {
1122 
1123  $col_info = $this->fieldInfoMulti( $table, $col );
1124  $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
1125  if ( $col_type == 'CLOB' ) {
1126  $col = 'TO_CHAR(' . $col . ')';
1127  $val = $wgContLang->checkTitleEncoding( $val );
1128  } elseif ( $col_type == 'VARCHAR2' ) {
1129  $val = $wgContLang->checkTitleEncoding( $val );
1130  }
1131  }
1132 
1133  private function wrapConditionsForWhere( $table, $conds, $parentCol = null ) {
1134  $conds2 = [];
1135  foreach ( $conds as $col => $val ) {
1136  if ( is_array( $val ) ) {
1137  $conds2[$col] = $this->wrapConditionsForWhere( $table, $val, $col );
1138  } else {
1139  if ( is_numeric( $col ) && $parentCol != null ) {
1140  $this->wrapFieldForWhere( $table, $parentCol, $val );
1141  } else {
1142  $this->wrapFieldForWhere( $table, $col, $val );
1143  }
1144  $conds2[$col] = $val;
1145  }
1146  }
1147 
1148  return $conds2;
1149  }
1150 
1151  function selectRow( $table, $vars, $conds, $fname = __METHOD__,
1152  $options = [], $join_conds = []
1153  ) {
1154  if ( is_array( $conds ) ) {
1155  $conds = $this->wrapConditionsForWhere( $table, $conds );
1156  }
1157 
1158  return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds );
1159  }
1160 
1170  $preLimitTail = $postLimitTail = '';
1171  $startOpts = '';
1172 
1173  $noKeyOptions = [];
1174  foreach ( $options as $key => $option ) {
1175  if ( is_numeric( $key ) ) {
1176  $noKeyOptions[$option] = true;
1177  }
1178  }
1179 
1180  $preLimitTail .= $this->makeGroupByWithHaving( $options );
1181 
1182  $preLimitTail .= $this->makeOrderBy( $options );
1183 
1184  if ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
1185  $postLimitTail .= ' FOR UPDATE';
1186  }
1187 
1188  if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) {
1189  $startOpts .= 'DISTINCT';
1190  }
1191 
1192  if ( isset( $options['USE INDEX'] ) && !is_array( $options['USE INDEX'] ) ) {
1193  $useIndex = $this->useIndexClause( $options['USE INDEX'] );
1194  } else {
1195  $useIndex = '';
1196  }
1197 
1198  if ( isset( $options['IGNORE INDEX'] ) && !is_array( $options['IGNORE INDEX'] ) ) {
1199  $ignoreIndex = $this->ignoreIndexClause( $options['IGNORE INDEX'] );
1200  } else {
1201  $ignoreIndex = '';
1202  }
1203 
1204  return [ $startOpts, $useIndex, $preLimitTail, $postLimitTail, $ignoreIndex ];
1205  }
1206 
1207  public function delete( $table, $conds, $fname = __METHOD__ ) {
1208  if ( is_array( $conds ) ) {
1209  $conds = $this->wrapConditionsForWhere( $table, $conds );
1210  }
1211  // a hack for deleting pages, users and images (which have non-nullable FKs)
1212  // all deletions on these tables have transactions so final failure rollbacks these updates
1213  $table = $this->tableName( $table );
1214  if ( $table == $this->tableName( 'user' ) ) {
1215  $this->update( 'archive', [ 'ar_user' => 0 ],
1216  [ 'ar_user' => $conds['user_id'] ], $fname );
1217  $this->update( 'ipblocks', [ 'ipb_user' => 0 ],
1218  [ 'ipb_user' => $conds['user_id'] ], $fname );
1219  $this->update( 'image', [ 'img_user' => 0 ],
1220  [ 'img_user' => $conds['user_id'] ], $fname );
1221  $this->update( 'oldimage', [ 'oi_user' => 0 ],
1222  [ 'oi_user' => $conds['user_id'] ], $fname );
1223  $this->update( 'filearchive', [ 'fa_deleted_user' => 0 ],
1224  [ 'fa_deleted_user' => $conds['user_id'] ], $fname );
1225  $this->update( 'filearchive', [ 'fa_user' => 0 ],
1226  [ 'fa_user' => $conds['user_id'] ], $fname );
1227  $this->update( 'uploadstash', [ 'us_user' => 0 ],
1228  [ 'us_user' => $conds['user_id'] ], $fname );
1229  $this->update( 'recentchanges', [ 'rc_user' => 0 ],
1230  [ 'rc_user' => $conds['user_id'] ], $fname );
1231  $this->update( 'logging', [ 'log_user' => 0 ],
1232  [ 'log_user' => $conds['user_id'] ], $fname );
1233  } elseif ( $table == $this->tableName( 'image' ) ) {
1234  $this->update( 'oldimage', [ 'oi_name' => 0 ],
1235  [ 'oi_name' => $conds['img_name'] ], $fname );
1236  }
1237 
1238  return parent::delete( $table, $conds, $fname );
1239  }
1240 
1250  function update( $table, $values, $conds, $fname = __METHOD__, $options = [] ) {
1252 
1253  $table = $this->tableName( $table );
1254  $opts = $this->makeUpdateOptions( $options );
1255  $sql = "UPDATE $opts $table SET ";
1256 
1257  $first = true;
1258  foreach ( $values as $col => &$val ) {
1259  $sqlSet = $this->fieldBindStatement( $table, $col, $val, true );
1260 
1261  if ( !$first ) {
1262  $sqlSet = ', ' . $sqlSet;
1263  } else {
1264  $first = false;
1265  }
1266  $sql .= $sqlSet;
1267  }
1268 
1269  if ( $conds !== [] && $conds !== '*' ) {
1270  $conds = $this->wrapConditionsForWhere( $table, $conds );
1271  $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
1272  }
1273 
1274  $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql );
1275  if ( $stmt === false ) {
1276  $e = oci_error( $this->mConn );
1277  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1278 
1279  return false;
1280  }
1281  foreach ( $values as $col => &$val ) {
1282  $col_info = $this->fieldInfoMulti( $table, $col );
1283  $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
1284 
1285  if ( $val === null ) {
1286  // do nothing ... null was inserted in statement creation
1287  } elseif ( $col_type != 'BLOB' && $col_type != 'CLOB' ) {
1288  if ( is_object( $val ) ) {
1289  $val = $val->getData();
1290  }
1291 
1292  if ( preg_match( '/^timestamp.*/i', $col_type ) == 1 && strtolower( $val ) == 'infinity' ) {
1293  $val = '31-12-2030 12:00:00.000000';
1294  }
1295 
1296  $val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val;
1297  if ( oci_bind_by_name( $stmt, ":$col", $val ) === false ) {
1298  $e = oci_error( $stmt );
1299  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1300 
1301  return false;
1302  }
1303  } else {
1305  $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB );
1306  if ( $lob[$col] === false ) {
1307  $e = oci_error( $stmt );
1308  throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
1309  }
1310 
1311  if ( is_object( $val ) ) {
1312  $val = $val->getData();
1313  }
1314 
1315  if ( $col_type == 'BLOB' ) {
1316  $lob[$col]->writeTemporary( $val );
1317  oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, SQLT_BLOB );
1318  } else {
1319  $lob[$col]->writeTemporary( $val );
1320  oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, OCI_B_CLOB );
1321  }
1322  }
1323  }
1324 
1325  MediaWiki\suppressWarnings();
1326 
1327  if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
1328  $e = oci_error( $stmt );
1329  if ( !$this->ignoreDupValOnIndex || $e['code'] != '1' ) {
1330  $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1331 
1332  return false;
1333  } else {
1334  $this->mAffectedRows = oci_num_rows( $stmt );
1335  }
1336  } else {
1337  $this->mAffectedRows = oci_num_rows( $stmt );
1338  }
1339 
1340  MediaWiki\restoreWarnings();
1341 
1342  if ( isset( $lob ) ) {
1343  foreach ( $lob as $lob_v ) {
1344  $lob_v->free();
1345  }
1346  }
1347 
1348  if ( !$this->mTrxLevel ) {
1349  oci_commit( $this->mConn );
1350  }
1351 
1352  return oci_free_statement( $stmt );
1353  }
1354 
1355  function bitNot( $field ) {
1356  // expecting bit-fields smaller than 4bytes
1357  return 'BITNOT(' . $field . ')';
1358  }
1359 
1360  function bitAnd( $fieldLeft, $fieldRight ) {
1361  return 'BITAND(' . $fieldLeft . ', ' . $fieldRight . ')';
1362  }
1363 
1364  function bitOr( $fieldLeft, $fieldRight ) {
1365  return 'BITOR(' . $fieldLeft . ', ' . $fieldRight . ')';
1366  }
1367 
1368  function getDBname() {
1369  return $this->mDBname;
1370  }
1371 
1372  function getServer() {
1373  return $this->mServer;
1374  }
1375 
1376  public function buildGroupConcatField(
1377  $delim, $table, $field, $conds = '', $join_conds = []
1378  ) {
1379  $fld = "LISTAGG($field," . $this->addQuotes( $delim ) . ") WITHIN GROUP (ORDER BY $field)";
1380 
1381  return '(' . $this->selectSQLText( $table, $fld, $conds, null, [], $join_conds ) . ')';
1382  }
1383 
1389  public function buildStringCast( $field ) {
1390  return 'CAST ( ' . $field . ' AS VARCHAR2 )';
1391  }
1392 
1393  public function getInfinity() {
1394  return '31-12-2030 12:00:00.000000';
1395  }
1396 }
DBO_PERSISTENT
const DBO_PERSISTENT
Definition: defines.php:14
DatabaseOracle\insert
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
Definition: DatabaseOracle.php:382
DatabaseOracle\numFields
numFields( $res)
Definition: DatabaseOracle.php:310
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:45
DatabaseOracle\encodeBlob
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
Definition: DatabaseOracle.php:728
DatabaseOracle\__construct
__construct(array $p)
Constructor and database handle and attempt to connect to the DB server.
Definition: DatabaseOracle.php:55
StringUtils\isUtf8
static isUtf8( $value)
Test whether a string is valid UTF-8.
Definition: StringUtils.php:41
query
For a write query
Definition: database.txt:26
DatabaseOracle\$mAffectedRows
int $mAffectedRows
The number of rows affected as an integer.
Definition: DatabaseOracle.php:38
DatabaseOracle\lastErrno
lastErrno()
Get the last error number.
Definition: DatabaseOracle.php:352
DatabaseOracle\dropTable
dropTable( $tableName, $fName=__METHOD__)
Delete a table.
Definition: DatabaseOracle.php:792
Wikimedia\Rdbms\Database\$mConn
resource null $mConn
Database connection.
Definition: Database.php:92
DatabaseOracle\bitOr
bitOr( $fieldLeft, $fieldRight)
Definition: DatabaseOracle.php:1364
DatabaseOracle\nextSequenceValue
nextSequenceValue( $seqName)
Return the next in a sequence, save the value for retrieval via insertId()
Definition: DatabaseOracle.php:665
is
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------ Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server. Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It 's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use. Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves. The master writes thequery to the binlog when the transaction is committed. The slaves pollthe binlog and start executing the query as soon as it appears. They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes. Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load. MediaWiki 's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database. All edits and other write operations will berefused, with an error returned to the user. This gives the slaves achance to catch up. Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order. A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests. This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it. Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in "lagged slave mode". Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode(). The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time. Multi-row INSERT ...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it 's not practical to guarantee a low-lagenvironment. Lag will usually be less than one second, but mayoccasionally be up to 30 seconds. For scalability, it 's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer. So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn 't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum. In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------ Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks. By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent. Locks willbe held from the time when the query is done until the commit. So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction. Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
captcha-old.count
count
Definition: captcha-old.py:225
DatabaseOracle\doCommit
doCommit( $fname=__METHOD__)
Issues the COMMIT command to the database server.
Definition: DatabaseOracle.php:968
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1954
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
DatabaseOracle\strencode
strencode( $s)
Wrapper for addslashes()
Definition: DatabaseOracle.php:1091
DatabaseOracle\affectedRows
affectedRows()
Get the number of rows affected by the last write query.
Definition: DatabaseOracle.php:362
DatabaseOracle\textFieldSize
textFieldSize( $table, $field)
Returns the size of a text field, or -1 for "unlimited".
Definition: DatabaseOracle.php:714
FROM
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to and or sell copies of the and to permit persons to whom the Software is furnished to do subject to the following WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR ARISING FROM
Definition: MIT-LICENSE.txt:10
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
DatabaseOracle\wrapFieldForWhere
wrapFieldForWhere( $table, &$col, &$val)
Definition: DatabaseOracle.php:1120
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
DatabaseOracle\tableNameInternal
tableNameInternal( $name)
Definition: DatabaseOracle.php:653
DatabaseOracle\buildGroupConcatField
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
Definition: DatabaseOracle.php:1376
DatabaseOracle\fieldInfoMulti
fieldInfoMulti( $table, $field)
Function translates mysql_fetch_field() functionality on ORACLE.
Definition: DatabaseOracle.php:897
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:36
DatabaseOracle\$mInsertId
int $mInsertId
Definition: DatabaseOracle.php:41
$s
$s
Definition: mergeMessageFileList.php:188
DatabaseOracle\addIdentifierQuotes
addIdentifierQuotes( $s)
Quotes an identifier using backticks or "double quotes" depending on the database type.
Definition: DatabaseOracle.php:1104
$res
$res
Definition: database.txt:21
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
DatabaseOracle\limitResult
limitResult( $sql, $limit, $offset=false)
Construct a LIMIT query with optional offset.
Definition: DatabaseOracle.php:720
$success
$success
Definition: NoLocalSettings.php:44
DatabaseOracle\doRollback
doRollback( $fname=__METHOD__)
Issues the ROLLBACK command to the database server.
Definition: DatabaseOracle.php:979
DatabaseOracle\duplicateTableStructure
duplicateTableStructure( $oldName, $newName, $temporary=false, $fname=__METHOD__)
Creates a new table with structure copied from existing table.
Definition: DatabaseOracle.php:751
$wgDBOracleDRCP
$wgDBOracleDRCP
Set true to enable Oracle DCRP (supported from 11gR1 onward)
Definition: DefaultSettings.php:2040
return
return[ 'DBLoadBalancerFactory'=> function(MediaWikiServices $services) { $mainConfig=$services->getMainConfig();$lbConf=MWLBFactory::applyDefaultConfig($mainConfig->get( 'LBFactoryConf'), $mainConfig, $services->getConfiguredReadOnlyMode());$class=MWLBFactory::getLBFactoryClass( $lbConf);return new $class( $lbConf);}, 'DBLoadBalancer'=> function(MediaWikiServices $services) { return $services->getDBLoadBalancerFactory() ->getMainLB();}, 'SiteStore'=> function(MediaWikiServices $services) { $rawSiteStore=new DBSiteStore( $services->getDBLoadBalancer());$cache=wfGetCache(wfIsHHVM() ? CACHE_ACCEL :CACHE_ANYTHING);return new CachingSiteStore( $rawSiteStore, $cache);}, 'SiteLookup'=> function(MediaWikiServices $services) { $cacheFile=$services->getMainConfig() ->get( 'SitesCacheFile');if( $cacheFile !==false) { return new FileBasedSiteLookup( $cacheFile);} else { return $services->getSiteStore();} }, 'ConfigFactory'=> function(MediaWikiServices $services) { $registry=$services->getBootstrapConfig() ->get( 'ConfigRegistry');$factory=new ConfigFactory();foreach( $registry as $name=> $callback) { $factory->register( $name, $callback);} return $factory;}, 'MainConfig'=> function(MediaWikiServices $services) { return $services->getConfigFactory() ->makeConfig( 'main');}, 'InterwikiLookup'=> function(MediaWikiServices $services) { global $wgContLang;$config=$services->getMainConfig();return new ClassicInterwikiLookup($wgContLang, $services->getMainWANObjectCache(), $config->get( 'InterwikiExpiry'), $config->get( 'InterwikiCache'), $config->get( 'InterwikiScopes'), $config->get( 'InterwikiFallbackSite'));}, 'StatsdDataFactory'=> function(MediaWikiServices $services) { return new BufferingStatsdDataFactory(rtrim( $services->getMainConfig() ->get( 'StatsdMetricPrefix'), '.'));}, 'EventRelayerGroup'=> function(MediaWikiServices $services) { return new EventRelayerGroup( $services->getMainConfig() ->get( 'EventRelayerConfig'));}, 'SearchEngineFactory'=> function(MediaWikiServices $services) { return new SearchEngineFactory( $services->getSearchEngineConfig());}, 'SearchEngineConfig'=> function(MediaWikiServices $services) { global $wgContLang;return new SearchEngineConfig( $services->getMainConfig(), $wgContLang);}, 'SkinFactory'=> function(MediaWikiServices $services) { $factory=new SkinFactory();$names=$services->getMainConfig() ->get( 'ValidSkinNames');foreach( $names as $name=> $skin) { $factory->register( $name, $skin, function() use( $name, $skin) { $class="Skin$skin";return new $class( $name);});} $factory->register( 'fallback', 'Fallback', function() { return new SkinFallback;});$factory->register( 'apioutput', 'ApiOutput', function() { return new SkinApi;});return $factory;}, 'WatchedItemStore'=> function(MediaWikiServices $services) { $store=new WatchedItemStore($services->getDBLoadBalancer(), new HashBagOStuff([ 'maxKeys'=> 100]), $services->getReadOnlyMode());$store->setStatsdDataFactory( $services->getStatsdDataFactory());return $store;}, 'WatchedItemQueryService'=> function(MediaWikiServices $services) { return new WatchedItemQueryService( $services->getDBLoadBalancer());}, 'CryptRand'=> function(MediaWikiServices $services) { $secretKey=$services->getMainConfig() ->get( 'SecretKey');return new CryptRand(['wfHostname', 'wfWikiID', function() use( $secretKey) { return $secretKey ?:'';}], defined( 'MW_CONFIG_FILE') ?[MW_CONFIG_FILE] :[], LoggerFactory::getInstance( 'CryptRand'));}, 'CryptHKDF'=> function(MediaWikiServices $services) { $config=$services->getMainConfig();$secret=$config->get( 'HKDFSecret') ?:$config->get( 'SecretKey');if(! $secret) { throw new RuntimeException("Cannot use MWCryptHKDF without a secret.");} $context=[microtime(), getmypid(), gethostname()];$cache=$services->getLocalServerObjectCache();if( $cache instanceof EmptyBagOStuff) { $cache=ObjectCache::getLocalClusterInstance();} return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm'), $cache, $context, $services->getCryptRand());}, 'MediaHandlerFactory'=> function(MediaWikiServices $services) { return new MediaHandlerFactory($services->getMainConfig() ->get( 'MediaHandlers'));}, 'MimeAnalyzer'=> function(MediaWikiServices $services) { $logger=LoggerFactory::getInstance( 'Mime');$mainConfig=$services->getMainConfig();$params=['typeFile'=> $mainConfig->get( 'MimeTypeFile'), 'infoFile'=> $mainConfig->get( 'MimeInfoFile'), 'xmlTypes'=> $mainConfig->get( 'XMLMimeTypes'), 'guessCallback'=> function( $mimeAnalyzer, &$head, &$tail, $file, &$mime) use( $logger) { $deja=new DjVuImage( $file);if( $deja->isValid()) { $logger->info(__METHOD__ . ": detected $file as image/vnd.djvu\n");$mime='image/vnd.djvu';return;} Hooks::run('MimeMagicGuessFromContent', [ $mimeAnalyzer, &$head, &$tail, $file, &$mime]);}, 'extCallback'=> function( $mimeAnalyzer, $ext, &$mime) { Hooks::run( 'MimeMagicImproveFromExtension', [ $mimeAnalyzer, $ext, &$mime]);}, 'initCallback'=> function( $mimeAnalyzer) { Hooks::run( 'MimeMagicInit', [ $mimeAnalyzer]);}, 'logger'=> $logger];if( $params['infoFile']==='includes/mime.info') { $params['infoFile']=__DIR__ . "/libs/mime/mime.info";} if( $params['typeFile']==='includes/mime.types') { $params['typeFile']=__DIR__ . "/libs/mime/mime.types";} $detectorCmd=$mainConfig->get( 'MimeDetectorCommand');if( $detectorCmd) { $params['detectCallback']=function( $file) use( $detectorCmd) { return wfShellExec("$detectorCmd " . wfEscapeShellArg( $file));};} return new MimeMagic( $params);}, 'ProxyLookup'=> function(MediaWikiServices $services) { $mainConfig=$services->getMainConfig();return new ProxyLookup($mainConfig->get( 'SquidServers'), $mainConfig->get( 'SquidServersNoPurge'));}, 'Parser'=> function(MediaWikiServices $services) { $conf=$services->getMainConfig() ->get( 'ParserConf');return ObjectFactory::constructClassInstance( $conf['class'], [ $conf]);}, 'LinkCache'=> function(MediaWikiServices $services) { return new LinkCache($services->getTitleFormatter(), $services->getMainWANObjectCache());}, 'LinkRendererFactory'=> function(MediaWikiServices $services) { return new LinkRendererFactory($services->getTitleFormatter(), $services->getLinkCache());}, 'LinkRenderer'=> function(MediaWikiServices $services) { global $wgUser;if(defined( 'MW_NO_SESSION')) { return $services->getLinkRendererFactory() ->create();} else { return $services->getLinkRendererFactory() ->createForUser( $wgUser);} }, 'GenderCache'=> function(MediaWikiServices $services) { return new GenderCache();}, '_MediaWikiTitleCodec'=> function(MediaWikiServices $services) { global $wgContLang;return new MediaWikiTitleCodec($wgContLang, $services->getGenderCache(), $services->getMainConfig() ->get( 'LocalInterwikis'));}, 'TitleFormatter'=> function(MediaWikiServices $services) { return $services->getService( '_MediaWikiTitleCodec');}, 'TitleParser'=> function(MediaWikiServices $services) { return $services->getService( '_MediaWikiTitleCodec');}, 'MainObjectStash'=> function(MediaWikiServices $services) { $mainConfig=$services->getMainConfig();$id=$mainConfig->get( 'MainStash');if(!isset( $mainConfig->get( 'ObjectCaches')[$id])) { throw new UnexpectedValueException("Cache type \"$id\" is not present in \$wgObjectCaches.");} return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches')[$id]);}, 'MainWANObjectCache'=> function(MediaWikiServices $services) { $mainConfig=$services->getMainConfig();$id=$mainConfig->get( 'MainWANCache');if(!isset( $mainConfig->get( 'WANObjectCaches')[$id])) { throw new UnexpectedValueException("WAN cache type \"$id\" is not present in \$wgWANObjectCaches.");} $params=$mainConfig->get( 'WANObjectCaches')[$id];$objectCacheId=$params['cacheId'];if(!isset( $mainConfig->get( 'ObjectCaches')[$objectCacheId])) { throw new UnexpectedValueException("Cache type \"$objectCacheId\" is not present in \$wgObjectCaches.");} $params['store']=$mainConfig->get( 'ObjectCaches')[$objectCacheId];return \ObjectCache::newWANCacheFromParams( $params);}, 'LocalServerObjectCache'=> function(MediaWikiServices $services) { $mainConfig=$services->getMainConfig();if(function_exists( 'apc_fetch')) { $id='apc';} elseif(function_exists( 'apcu_fetch')) { $id='apcu';} elseif(function_exists( 'xcache_get') &&wfIniGetBool( 'xcache.var_size')) { $id='xcache';} elseif(function_exists( 'wincache_ucache_get')) { $id='wincache';} else { $id=CACHE_NONE;} if(!isset( $mainConfig->get( 'ObjectCaches')[$id])) { throw new UnexpectedValueException("Cache type \"$id\" is not present in \$wgObjectCaches.");} return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches')[$id]);}, 'VirtualRESTServiceClient'=> function(MediaWikiServices $services) { $config=$services->getMainConfig() ->get( 'VirtualRestConfig');$vrsClient=new VirtualRESTServiceClient(new MultiHttpClient([]));foreach( $config['paths'] as $prefix=> $serviceConfig) { $class=$serviceConfig['class'];$constructArg=isset( $serviceConfig['options']) ? $serviceConfig['options'] :[];$constructArg+=$config['global'];$vrsClient->mount( $prefix, [ 'class'=> $class, 'config'=> $constructArg]);} return $vrsClient;}, 'ConfiguredReadOnlyMode'=> function(MediaWikiServices $services) { return new ConfiguredReadOnlyMode( $services->getMainConfig());}, 'ReadOnlyMode'=> function(MediaWikiServices $services) { return new ReadOnlyMode($services->getConfiguredReadOnlyMode(), $services->getDBLoadBalancer());},]
Definition: ServiceWiring.php:426
ORAField
Definition: ORAField.php:5
DatabaseOracle\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
Definition: DatabaseOracle.php:801
Wikimedia\Rdbms\Database\getFlag
getFlag( $flag)
Returns a boolean whether the flag $flag is set for this connection.
Definition: Database.php:629
DatabaseOracle\aggregateValue
aggregateValue( $valuedata, $valuename='value')
Return aggregated value function call.
Definition: DatabaseOracle.php:812
$wgDBprefix
$wgDBprefix
Table name prefix.
Definition: DefaultSettings.php:1827
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
LIST_AND
const LIST_AND
Definition: Defines.php:41
DatabaseOracle\listTables
listTables( $prefix=null, $fname=__METHOD__)
List all tables on the database.
Definition: DatabaseOracle.php:767
DatabaseOracle\execFlags
execFlags()
Definition: DatabaseOracle.php:190
DatabaseOracle\$defaultCharset
string $defaultCharset
Character set for Oracle database.
Definition: DatabaseOracle.php:50
DatabaseOracle\fieldName
fieldName( $stmt, $n)
Get a field name in a result object.
Definition: DatabaseOracle.php:318
DatabaseOracle\selectDB
selectDB( $db)
Change the current database.
Definition: DatabaseOracle.php:1069
DatabaseOracle\freeResult
freeResult( $res)
Frees resources associated with the LOB descriptor.
Definition: DatabaseOracle.php:262
DatabaseOracle\tableExists
tableExists( $table, $fname=__METHOD__)
Query whether a given table exists (in the given schema, or the default mw one if not given)
Definition: DatabaseOracle.php:870
DatabaseOracle\lastError
lastError()
Get a description of the last error.
Definition: DatabaseOracle.php:342
DatabaseOracle\removeIdentifierQuotes
removeIdentifierQuotes( $s)
Definition: DatabaseOracle.php:1112
DatabaseOracle\getDBname
getDBname()
Get the current DB name.
Definition: DatabaseOracle.php:1368
tableName
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for tableName() and addQuotes(). You will need both of them. ------------------------------------------------------------------------ Basic query optimisation ------------------------------------------------------------------------ MediaWiki developers who need to write DB queries should have some understanding of databases and the performance issues associated with them. Patches containing unacceptably slow features will not be accepted. Unindexed queries are generally not welcome in MediaWiki
DatabaseOracle\numRows
numRows( $res)
Definition: DatabaseOracle.php:298
Wikimedia\Rdbms\Database\setFlag
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
Definition: Database.php:602
code
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline code
Definition: hooks.txt:23
$limit
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition: hooks.txt:1049
DatabaseOracle\getServerVersion
getServerVersion()
Definition: DatabaseOracle.php:826
DatabaseOracle\getServer
getServer()
Get the server hostname or IP address.
Definition: DatabaseOracle.php:1372
DatabaseOracle\update
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
Definition: DatabaseOracle.php:1250
DatabaseOracle\$ignoreDupValOnIndex
bool $ignoreDupValOnIndex
Definition: DatabaseOracle.php:44
message
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
Definition: hooks.txt:2114
DatabaseOracle
Definition: DatabaseOracle.php:33
DatabaseOracle\fetchRow
fetchRow( $res)
Definition: DatabaseOracle.php:286
DatabaseOracle\doBegin
doBegin( $fname=__METHOD__)
Issues the BEGIN command to the database server.
Definition: DatabaseOracle.php:963
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:2179
DatabaseOracle\doQuery
doQuery( $sql)
The DBMS-dependent part of query()
Definition: DatabaseOracle.php:194
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:999
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
DatabaseOracle\getSequenceData
getSequenceData( $table)
Return sequence_name if table has a sequence.
Definition: DatabaseOracle.php:679
DatabaseOracle\wasDeadlock
wasDeadlock()
Determines if the last failure was due to a deadlock.
Definition: DatabaseOracle.php:747
DatabaseOracle\addQuotes
addQuotes( $s)
Adds quotes and backslashes.
Definition: DatabaseOracle.php:1095
way
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when you must cause when started running for such interactive use in the most ordinary way
Definition: COPYING.txt:87
DatabaseOracle\fetchObject
fetchObject( $res)
Definition: DatabaseOracle.php:274
$line
$line
Definition: cdb.php:58
DatabaseOracle\$sequenceData
bool array $sequenceData
Definition: DatabaseOracle.php:47
DatabaseOracle\buildStringCast
buildStringCast( $field)
Definition: DatabaseOracle.php:1389
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2122
e
in this case you re responsible for computing and outputting the entire conflict i e
Definition: hooks.txt:1398
DatabaseOracle\decodeBlob
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
Definition: DatabaseOracle.php:732
DBO_DDLMODE
const DBO_DDLMODE
Definition: defines.php:16
DatabaseOracle\unionQueries
unionQueries( $sqls, $all)
Construct a UNION query This is used for providing overload point for other DB abstractions not compa...
Definition: DatabaseOracle.php:740
DatabaseOracle\indexInfo
indexInfo( $table, $index, $fname=__METHOD__)
Returns information about an index If errors are explicitly ignored, returns NULL on failure.
Definition: DatabaseOracle.php:374
DatabaseOracle\wrapConditionsForWhere
wrapConditionsForWhere( $table, $conds, $parentCol=null)
Definition: DatabaseOracle.php:1133
DBO_SYSDBA
const DBO_SYSDBA
Definition: defines.php:15
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1956
DatabaseOracle\__destruct
__destruct()
Run a few simple sanity checks and close dangling connections.
Definition: DatabaseOracle.php:66
DatabaseOracle\makeSelectOptions
makeSelectOptions( $options)
Returns an optional USE INDEX clause to go after the table, and a string to go at the end of the quer...
Definition: DatabaseOracle.php:1169
DatabaseOracle\indexExists
indexExists( $table, $index, $fname=__METHOD__)
Query whether a given index exists.
Definition: DatabaseOracle.php:847
DatabaseOracle\dataSeek
dataSeek( $res, $row)
Definition: DatabaseOracle.php:334
Wikimedia\Rdbms\DBUnexpectedError
Definition: DBUnexpectedError.php:27
DatabaseOracle\getSoftwareLink
getSoftwareLink()
Definition: DatabaseOracle.php:819
ORAResult
The oci8 extension is fairly weak and doesn't support oci_num_rows, among other things.
Definition: ORAResult.php:11
DatabaseOracle\queryIgnore
queryIgnore( $sql, $fname='')
Definition: DatabaseOracle.php:254
DatabaseOracle\getInfinity
getInfinity()
Find out when 'infinity' is.
Definition: DatabaseOracle.php:1393
Wikimedia\Rdbms\Database\close
close()
Closes a database connection.
Definition: Database.php:726
DatabaseOracle\open
open( $server, $user, $password, $dbName)
Usually aborts on failure.
Definition: DatabaseOracle.php:95
DatabaseOracle\$mLastResult
resource $mLastResult
Definition: DatabaseOracle.php:35
DatabaseOracle\nativeInsertSelect
nativeInsertSelect( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[])
Definition: DatabaseOracle.php:560
DatabaseOracle\isQuotedIdentifier
isQuotedIdentifier( $s)
Returns if the given identifier looks quoted or not according to the database convention for quoting ...
Definition: DatabaseOracle.php:1116
DatabaseOracle\sourceStream
sourceStream( $fp, callable $lineCallback=null, callable $resultCallback=null, $fname=__METHOD__, callable $inputCallback=null)
Read and execute commands from an open file handle.
Definition: DatabaseOracle.php:987
DatabaseOracle\insertId
insertId()
This must be called after nextSequenceVal.
Definition: DatabaseOracle.php:326
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
DatabaseOracle\fieldInfo
fieldInfo( $table, $field)
Definition: DatabaseOracle.php:955
Wikimedia\Rdbms\DBConnectionError
Definition: DBConnectionError.php:26
DatabaseOracle\closeConnection
closeConnection()
Closes a database connection, if it is open Returns success, true if already closed.
Definition: DatabaseOracle.php:186
DatabaseOracle\bitNot
bitNot( $field)
Definition: DatabaseOracle.php:1355
DatabaseOracle\getType
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
Definition: DatabaseOracle.php:74
DatabaseOracle\indexUnique
indexUnique( $table, $index, $fname=__METHOD__)
Definition: DatabaseOracle.php:378
DatabaseOracle\implicitGroupby
implicitGroupby()
Returns true if this database does an implicit sort when doing GROUP BY.
Definition: DatabaseOracle.php:78
DatabaseOracle\$mFieldInfoCache
array $mFieldInfoCache
Definition: DatabaseOracle.php:53
DBO_DEFAULT
const DBO_DEFAULT
Definition: defines.php:13
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
DatabaseOracle\implicitOrderby
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
Definition: DatabaseOracle.php:82
MWTimestamp\getLocalInstance
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
Definition: MWTimestamp.php:204
DatabaseOracle\bitAnd
bitAnd( $fieldLeft, $fieldRight)
Definition: DatabaseOracle.php:1360
DatabaseOracle\fieldBindStatement
fieldBindStatement( $table, $col, &$val, $includeCol=false)
Definition: DatabaseOracle.php:411
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
DatabaseOracle\selectRow
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Single row SELECT wrapper.
Definition: DatabaseOracle.php:1151
array
the array() calling protocol came about after MediaWiki 1.4rc1.
ORAField\tableName
tableName()
Name of table this field belongs to.
Definition: ORAField.php:26
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
Wikimedia\Rdbms\Blob
Definition: Blob.php:5
DatabaseOracle\insertOneRow
insertOneRow( $table, $row, $fname)
Definition: DatabaseOracle.php:453