From: jenkins-bot Date: Fri, 1 Sep 2017 11:18:11 +0000 (+0000) Subject: Merge "Re add wpScrolltop id in EditPage" X-Git-Tag: 1.31.0-rc.0~2240 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=f5b9af121a07ecc674a63cbc65c3a01e9fa7d785;hp=5910fe9d9bdfdef20050694bddc640bcb5ae692c Merge "Re add wpScrolltop id in EditPage" --- diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index c4c56e833f..d38a34d2e1 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -197,6 +197,8 @@ changes to languages because of Phabricator reports. PRIMARY KEYs for increased maintainability: categorylinks, imagelinks, iwlinks, langlinks, log_search, module_deps, objectcache, pagelinks, query_cache, site_stats, templatelinks, text, transcache, user_former_groups, user_properties. +* IDatabase::nextSequenceValue() is no longer needed by any database backends + (formerly it was needed by PostgreSQL and Oracle), and is now deprecated. == Compatibility == MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for diff --git a/autoload.php b/autoload.php index 9d205cb576..eab8e45072 100644 --- a/autoload.php +++ b/autoload.php @@ -1667,6 +1667,7 @@ $wgAutoloadLocalClasses = [ 'Wikimedia\\Rdbms\\MssqlResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/MssqlResultWrapper.php', 'Wikimedia\\Rdbms\\MySQLField' => __DIR__ . '/includes/libs/rdbms/field/MySQLField.php', 'Wikimedia\\Rdbms\\MySQLMasterPos' => __DIR__ . '/includes/libs/rdbms/database/position/MySQLMasterPos.php', + 'Wikimedia\\Rdbms\\NextSequenceValue' => __DIR__ . '/includes/libs/rdbms/database/utils/NextSequenceValue.php', 'Wikimedia\\Rdbms\\PostgresBlob' => __DIR__ . '/includes/libs/rdbms/encasing/PostgresBlob.php', 'Wikimedia\\Rdbms\\PostgresField' => __DIR__ . '/includes/libs/rdbms/field/PostgresField.php', 'Wikimedia\\Rdbms\\ResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php', diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 556fe75547..e2feb1fa7c 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -37,9 +37,6 @@ class DatabaseOracle extends Database { /** @var int The number of rows affected as an integer */ protected $mAffectedRows; - /** @var int */ - private $mInsertId = null; - /** @var bool */ private $ignoreDupValOnIndex = false; @@ -319,12 +316,10 @@ class DatabaseOracle extends Database { return oci_field_name( $stmt, $n ); } - /** - * This must be called after nextSequenceVal - * @return null|int - */ function insertId() { - return $this->mInsertId; + $res = $this->query( "SELECT lastval_pkg.getLastval FROM dual" ); + $row = $this->fetchRow( $res ); + return is_null( $row[0] ) ? null : (int)$row[0]; } /** @@ -649,20 +644,6 @@ class DatabaseOracle extends Database { return preg_replace( '/.*\.(.*)/', '$1', $name ); } - /** - * Return the next in a sequence, save the value for retrieval via insertId() - * - * @param string $seqName - * @return null|int - */ - function nextSequenceValue( $seqName ) { - $res = $this->query( "SELECT $seqName.nextval FROM dual" ); - $row = $this->fetchRow( $res ); - $this->mInsertId = $row[0]; - - return $this->mInsertId; - } - /** * Return sequence_name if table has a sequence * diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php index e262eda635..00b96614f8 100644 --- a/includes/installer/OracleUpdater.php +++ b/includes/installer/OracleUpdater.php @@ -123,6 +123,9 @@ class OracleUpdater extends DatabaseUpdater { [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ], [ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ], + // 1.30 + [ 'doAutoIncrementTriggers' ], + // KEEP THIS AT THE BOTTOM!! [ 'doRebuildDuplicateFunction' ], @@ -273,6 +276,30 @@ class OracleUpdater extends DatabaseUpdater { $this->output( "ok\n" ); } + /** + * Add auto-increment triggers + */ + protected function doAutoIncrementTriggers() { + $this->output( "Adding auto-increment triggers ... " ); + + $meta = $this->db->query( 'SELECT trigger_name FROM user_triggers WHERE table_owner = \'' . + strtoupper( $this->db->getDBname() ) . + '\' AND trigger_name = \'' . + $this->db->tablePrefix() . + 'PAGE_DEFAULT_PAGE_ID\'' + ); + $row = $meta->fetchRow(); + if ( $row['column_name'] ) { + $this->output( "seems to be up to date.\n" ); + + return; + } + + $this->applyPatch( 'patch-auto_increment_triggers.sql', false ); + + $this->output( "ok\n" ); + } + /** * rebuilding of the function that duplicates tables for tests */ diff --git a/includes/libs/rdbms/database/DatabasePostgres.php b/includes/libs/rdbms/database/DatabasePostgres.php index fcfd93700d..ac59bd6171 100644 --- a/includes/libs/rdbms/database/DatabasePostgres.php +++ b/includes/libs/rdbms/database/DatabasePostgres.php @@ -39,8 +39,6 @@ class DatabasePostgres extends Database { /** @var int The number of rows affected as an integer */ protected $mAffectedRows = null; - /** @var int */ - private $mInsertId = null; /** @var float|string */ private $numericVersion = null; /** @var string Connect string to open a PostgreSQL connection */ @@ -352,14 +350,10 @@ class DatabasePostgres extends Database { return pg_field_name( $res, $n ); } - /** - * Return the result of the last call to nextSequenceValue(); - * This must be called after nextSequenceValue(). - * - * @return int|null - */ public function insertId() { - return $this->mInsertId; + $res = $this->query( "SELECT lastval()" ); + $row = $this->fetchRow( $res ); + return is_null( $row[0] ) ? null : (int)$row[0]; } public function dataSeek( $res, $row ) { @@ -776,12 +770,7 @@ __INDEXATTR__; } public function nextSequenceValue( $seqName ) { - $safeseq = str_replace( "'", "''", $seqName ); - $res = $this->query( "SELECT nextval('$safeseq')" ); - $row = $this->fetchRow( $res ); - $this->mInsertId = is_null( $row[0] ) ? null : (int)$row[0]; - - return $this->mInsertId; + return new NextSequenceValue; } /** @@ -1224,6 +1213,8 @@ SQL; $s = pg_escape_bytea( $conn, $s->fetch() ); } return "'$s'"; + } elseif ( $s instanceof NextSequenceValue ) { + return 'DEFAULT'; } return "'" . pg_escape_string( $conn, $s ) . "'"; diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php index 9375efc253..736447f46c 100644 --- a/includes/libs/rdbms/database/IDatabase.php +++ b/includes/libs/rdbms/database/IDatabase.php @@ -1114,15 +1114,20 @@ interface IDatabase { public function anyString(); /** - * Returns an appropriately quoted sequence value for inserting a new row. - * MySQL has autoincrement fields, so this is just NULL. But the PostgreSQL - * subclass will return an integer, and save the value for insertId() + * Deprecated method, calls should be removed. * - * Any implementation of this function should *not* involve reusing - * sequence numbers created for rolled-back transactions. - * See https://bugs.mysql.com/bug.php?id=30767 for details. + * This was formerly used for PostgreSQL and Oracle to handle + * self::insertId() auto-incrementing fields. It is no longer necessary + * since DatabasePostgres::insertId() has been reimplemented using + * `lastval()` and Oracle has been reimplemented using triggers. + * + * Implementations should return null if inserting `NULL` into an + * auto-incrementing field works, otherwise it should return an instance of + * NextSequenceValue and filter it on calls to relevant methods. + * + * @deprecated since 1.30, no longer needed * @param string $seqName - * @return null|int + * @return null|NextSequenceValue */ public function nextSequenceValue( $seqName ); diff --git a/includes/libs/rdbms/database/utils/NextSequenceValue.php b/includes/libs/rdbms/database/utils/NextSequenceValue.php new file mode 100644 index 0000000000..44bf0ddcdd --- /dev/null +++ b/includes/libs/rdbms/database/utils/NextSequenceValue.php @@ -0,0 +1,12 @@ +