[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: The dieUsage function has two required arguments.

2018-01-23 Thread Alexia (Code Review)
Alexia has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405902 )

Change subject: The dieUsage function has two required arguments.
..

The dieUsage function has two required arguments.

Change-Id: I97eeba76715088775b50a70b71ee908dd885c78e
---
M api/CargoQueryAPI.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/02/405902/1

diff --git a/api/CargoQueryAPI.php b/api/CargoQueryAPI.php
index 6be5dc5..727f274 100644
--- a/api/CargoQueryAPI.php
+++ b/api/CargoQueryAPI.php
@@ -32,7 +32,7 @@
try {
$queryResults = $sqlQuery->run();
} catch ( Exception $e ) {
-   $this->dieUsage( $e );
+   $this->dieUsage( $e, 'db_error' );
}
 
// Format data as the API requires it.

-- 
To view, visit https://gerrit.wikimedia.org/r/405902
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97eeba76715088775b50a70b71ee908dd885c78e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Add link to create new Cargo table in an obvious location.

2018-01-18 Thread Alexia (Code Review)
Alexia has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405039 )

Change subject: Add link to create new Cargo table in an obvious location.
..

Add link to create new Cargo table in an obvious location.

Change-Id: I87deaf093021ff0509350fdba605f8bb63234624
---
M includes/parserfunctions/CargoDeclare.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/39/405039/1

diff --git a/includes/parserfunctions/CargoDeclare.php 
b/includes/parserfunctions/CargoDeclare.php
index fb67604..0fcd7bc 100644
--- a/includes/parserfunctions/CargoDeclare.php
+++ b/includes/parserfunctions/CargoDeclare.php
@@ -119,6 +119,7 @@
$text .= " [[$pageName|$viewTableMsg]].";
} else {
$text .= ' ' . wfMessage( 'cargo-tablenotcreated' 
)->text();
+   $text .= "\n\n[".$parser->getTitle()->getFullURL( [ 
'action' => 'recreatedata' ] )." ".wfMessage( 'cargo-createdatatable' 
)->parse()."]";
}
 
return $text;

-- 
To view, visit https://gerrit.wikimedia.org/r/405039
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87deaf093021ff0509350fdba605f8bb63234624
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Extension Manifest Converter for v1 to v2.

2017-06-02 Thread Alexia (Code Review)
Alexia has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356954 )

Change subject: Extension Manifest Converter for v1 to v2.
..

Extension Manifest Converter for v1 to v2.

This converts extension manifests from v1 to v2.

Change-Id: I9dba6533a7ce2b8457e5dc1c42f9ecfdce2fa738
---
A maintenance/convertExtensionManifestv1tov2.php
1 file changed, 93 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/54/356954/1

diff --git a/maintenance/convertExtensionManifestv1tov2.php 
b/maintenance/convertExtensionManifestv1tov2.php
new file mode 100644
index 000..c1629e9
--- /dev/null
+++ b/maintenance/convertExtensionManifestv1tov2.php
@@ -0,0 +1,93 @@
+http://www.curse.com/
+ *
+**/
+
+require_once( __DIR__."/Maintenance.php" );
+
+class convertExtensionManifestv1tov2 extends Maintenance {
+   /**
+* Main Constructor
+*
+* @access  public
+* @return  void
+*/
+   public function __construct() {
+   parent::__construct();
+   $this->mDescription = "Convert Extension Manifest from v1 to 
v2.";
+   $this->addArg( 'path', 'Location to the extension manifest you 
wish to convert.', true );
+   }
+
+   /**
+* Main Execution
+*
+* @access  public
+* @return  void
+*/
+   public function execute() {
+   $file = realpath( $this->getArg( 0 ) );
+   if ( !is_file( $file ) ) {
+   $this->error( "{$file} is not a file.", true );
+   }
+   $json = json_decode( file_get_contents( $file ), true );
+   if ( empty( $json ) || !isset( $json[ 'manifest_version' ] ) ) {
+   $this->error( "{$file} is not a valid extension 
manifest.", true );
+   }
+   if ( $json[ 'manifest_version' ] > 1 ) {
+   $this->error( "{$file} is already greater than version 
1.", true );
+   }
+
+   $this->output( "All config settings will be marked path => 
false and public => false.  Please make corrections manually.\n" );
+
+   $descriptionPrefix = str_replace( ' ', '', ( trim( 
mb_strtolower( $json[ 'name' ], 'UTF-8' ) ) ) );
+   foreach ( $json[ 'config' ] as $key => $value ) {
+   $json[ 'config' ][ $key ] = $this->configV2( $key, 
$value, $descriptionPrefix );
+   }
+   if ( isset( $json[ 'config' ][ '_prefix' ] ) ) {
+   $json[ 'config_prefix' ] = $json[ 'config' ][ '_prefix' 
];
+   unset( $json[ 'config' ][ '_prefix' ] );
+   }
+   $json[ 'manifest_version' ] = 2;
+   $json = FormatJson::encode( $json, "\t", FormatJson::ALL_OK );
+   file_put_contents( $file, $json );
+   $this->output( "Wrote updated manifest.\n" );
+   }
+
+   /**
+* Convert configuration to version 2.
+*
+* @access  private
+* @param   string  Variable Name
+* @param   string  Variable Value
+* @param   string  Prefix for descriptionmsg.
+* @return  array   Configuration
+*/
+   private function configV2( $key, $value, $descriptionPrefix ) {
+   $mergeStrategy = false;
+   if ( is_array( $value ) && isset( $value[ '_merge_strategy' ] ) 
) {
+   $mergeStrategy = $value[ '_merge_strategy' ];
+   unset( $value[ '_merge_strategy' ] );
+   }
+
+   $config = [
+   'value' => $value,
+   'path' => false,
+   'descriptionmsg' => 
$descriptionPrefix.'-config-'.str_replace( ' ', '-', ( trim( mb_strtolower( 
$key, 'UTF-8' ) ) ) ),
+   'public' => false,
+   ];
+
+   if ( $mergeStrategy !== false ) {
+   $config[ 'merge_strategy' ] = $mergeStrategy;
+   }
+   return $config;
+   }
+}
+
+$maintClass = 'convertExtensionManifestv1tov2';
+require_once( RUN_MAINTENANCE_IF_MAIN );

-- 
To view, visit https://gerrit.wikimedia.org/r/356954
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9dba6533a7ce2b8457e5dc1c42f9ecfdce2fa738
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Abstract out the authentication error handling and call try ...

2016-10-21 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/317167

Change subject: Abstract out the authentication error handling and call try 
catch handler.
..

Abstract out the authentication error handling and call try catch handler.

Fixed blpop/brpop/brpoplpush would not always get the correct timeout parameter.
Fixed blpop/brpop/brpoplpush clobbering infinite timeouts.
Redis scan functions require iterator passed by reference.

https://gerrit.wikimedia.org/r/#/c/252455/

Change-Id: I1f827ab23c8d289d90dbdd62a10467c4afed
---
M includes/libs/redis/RedisConnRef.php
1 file changed, 167 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/67/317167/1

diff --git a/includes/libs/redis/RedisConnRef.php 
b/includes/libs/redis/RedisConnRef.php
index f2bb855..4535503 100644
--- a/includes/libs/redis/RedisConnRef.php
+++ b/includes/libs/redis/RedisConnRef.php
@@ -44,6 +44,27 @@
protected $logger;
 
/**
+* No authentication errors.
+*
+* @var constant
+*/
+   const AUTH_NO_ERROR = 200;
+
+   /**
+* Temporary authentication error; recovered by reauthenticating.
+*
+* @var constant
+*/
+   const AUTH_ERROR_TEMPORARY = 201;
+
+   /**
+* Authentication error was permanent and could not be recovered.
+*
+* @var constant
+*/
+   const AUTH_ERROR_PERMANENT = 202;
+
+   /**
 * @param RedisConnectionPool $pool
 * @param string $server
 * @param Redis $conn
@@ -78,44 +99,169 @@
$this->lastError = null;
}
 
+   /**
+* Magic __call handler for most Redis functions.
+*
+* @access  public
+* @param   string  Function Name
+* @param   array   Function Arguments
+* @return  mixed   Results
+* @throws  RedisException
+*/
public function __call( $name, $arguments ) {
-   $conn = $this->conn; // convenience
-
// Work around https://github.com/nicolasff/phpredis/issues/70
$lname = strtolower( $name );
-   if ( ( $lname === 'blpop' || $lname == 'brpop' )
-   && is_array( $arguments[0] ) && isset( $arguments[1] )
+   if (
+   ( $lname === 'blpop' || $lname === 'brpop' || $lname 
=== 'brpoplpush' )
+   && count( $arguments ) > 1
) {
-   $this->pool->resetTimeout( $conn, $arguments[1] + 1 );
-   } elseif ( $lname === 'brpoplpush' && isset( $arguments[2] ) ) {
-   $this->pool->resetTimeout( $conn, $arguments[2] + 1 );
+   // Get timeout off the end since the timeout is always 
required and argument length can vary.
+   $timeout = end( $arguments );
+   ///Only give the additional one second buffer if not 
requesting an infinite timeout.
+   $this->pool->resetTimeout( $this->conn, ( $timeout > 0 
? $timeout + 1 : $timeout ) );
}
 
-   $conn->clearLastError();
+   $res = $this->tryCall( $name, $arguments );
+
+   return $res;
+   }
+
+   /**
+* Do the method call in the common try catch handler.
+*
+* @access  private
+* @param   string  Redis method name.
+* @param   array   Arguments
+* @return  mixed   Results
+* @throws  RedisException
+*/
+   private function tryCall( $method, $arguments ) {
+   $this->conn->clearLastError();
try {
-   $res = call_user_func_array( [ $conn, $name ], 
$arguments );
-   if ( preg_match( '/^ERR operation not permitted\b/', 
$conn->getLastError() ) ) {
-   $this->pool->reauthenticateConnection( 
$this->server, $conn );
-   $conn->clearLastError();
-   $res = call_user_func_array( [ $conn, $name ], 
$arguments );
-   $this->logger->info(
-   "Used automatic re-authentication for 
method '$name'.",
-   [ 'redis_server' => $this->server ]
-   );
+   $res = call_user_func_array( [ $this->conn, $method ], 
$arguments );
+   $authError = $this->handleAuthError();
+   if ( $authError === self::AUTH_ERROR_TEMPORARY ) {
+   $res = call_user_func_array( [ $this->conn, 
$method ], $arguments );
+   }
+   if ( $authError === self::AUTH_ERROR_PERMANENT ) {
+

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Update for 1.28 WMF changes.

2016-10-21 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/317165

Change subject: Update for 1.28 WMF changes.
..

Update for 1.28 WMF changes.

Change-Id: Ia25178a06577654e9577b4d4970e394e90035dd3
---
M includes/libs/redis/RedisConnRef.php
1 file changed, 167 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/65/317165/1

diff --git a/includes/libs/redis/RedisConnRef.php 
b/includes/libs/redis/RedisConnRef.php
index f2bb855..4535503 100644
--- a/includes/libs/redis/RedisConnRef.php
+++ b/includes/libs/redis/RedisConnRef.php
@@ -44,6 +44,27 @@
protected $logger;
 
/**
+* No authentication errors.
+*
+* @var constant
+*/
+   const AUTH_NO_ERROR = 200;
+
+   /**
+* Temporary authentication error; recovered by reauthenticating.
+*
+* @var constant
+*/
+   const AUTH_ERROR_TEMPORARY = 201;
+
+   /**
+* Authentication error was permanent and could not be recovered.
+*
+* @var constant
+*/
+   const AUTH_ERROR_PERMANENT = 202;
+
+   /**
 * @param RedisConnectionPool $pool
 * @param string $server
 * @param Redis $conn
@@ -78,44 +99,169 @@
$this->lastError = null;
}
 
+   /**
+* Magic __call handler for most Redis functions.
+*
+* @access  public
+* @param   string  Function Name
+* @param   array   Function Arguments
+* @return  mixed   Results
+* @throws  RedisException
+*/
public function __call( $name, $arguments ) {
-   $conn = $this->conn; // convenience
-
// Work around https://github.com/nicolasff/phpredis/issues/70
$lname = strtolower( $name );
-   if ( ( $lname === 'blpop' || $lname == 'brpop' )
-   && is_array( $arguments[0] ) && isset( $arguments[1] )
+   if (
+   ( $lname === 'blpop' || $lname === 'brpop' || $lname 
=== 'brpoplpush' )
+   && count( $arguments ) > 1
) {
-   $this->pool->resetTimeout( $conn, $arguments[1] + 1 );
-   } elseif ( $lname === 'brpoplpush' && isset( $arguments[2] ) ) {
-   $this->pool->resetTimeout( $conn, $arguments[2] + 1 );
+   // Get timeout off the end since the timeout is always 
required and argument length can vary.
+   $timeout = end( $arguments );
+   ///Only give the additional one second buffer if not 
requesting an infinite timeout.
+   $this->pool->resetTimeout( $this->conn, ( $timeout > 0 
? $timeout + 1 : $timeout ) );
}
 
-   $conn->clearLastError();
+   $res = $this->tryCall( $name, $arguments );
+
+   return $res;
+   }
+
+   /**
+* Do the method call in the common try catch handler.
+*
+* @access  private
+* @param   string  Redis method name.
+* @param   array   Arguments
+* @return  mixed   Results
+* @throws  RedisException
+*/
+   private function tryCall( $method, $arguments ) {
+   $this->conn->clearLastError();
try {
-   $res = call_user_func_array( [ $conn, $name ], 
$arguments );
-   if ( preg_match( '/^ERR operation not permitted\b/', 
$conn->getLastError() ) ) {
-   $this->pool->reauthenticateConnection( 
$this->server, $conn );
-   $conn->clearLastError();
-   $res = call_user_func_array( [ $conn, $name ], 
$arguments );
-   $this->logger->info(
-   "Used automatic re-authentication for 
method '$name'.",
-   [ 'redis_server' => $this->server ]
-   );
+   $res = call_user_func_array( [ $this->conn, $method ], 
$arguments );
+   $authError = $this->handleAuthError();
+   if ( $authError === self::AUTH_ERROR_TEMPORARY ) {
+   $res = call_user_func_array( [ $this->conn, 
$method ], $arguments );
+   }
+   if ( $authError === self::AUTH_ERROR_PERMANENT ) {
+   throw new RedisException( "There was a 
permanent failure reauthenticating to Redis." );
}
} catch ( RedisException $e ) {
-   $this->pool->resetTimeout( $conn ); // restore
+   $this->postCallCleanup();

[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Add back if()elseif() blocks.

2016-10-19 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316840

Change subject: Add back if()elseif() blocks.
..

Add back if()elseif() blocks.

Change-Id: Id51567450f78c847122bc74d81291bb8ebde89d5
---
M drilldown/CargoFilter.php
1 file changed, 9 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/40/316840/1

diff --git a/drilldown/CargoFilter.php b/drilldown/CargoFilter.php
index 2cb6d9e..dfebdb2 100644
--- a/drilldown/CargoFilter.php
+++ b/drilldown/CargoFilter.php
@@ -126,11 +126,15 @@
$date_field = $this->name;
$timePeriod = $this->getTimePeriod( $fullTextSearchTerm, 
$appliedFilters );
 
-   $fields = [
-   "YEAR($date_field) AS year_field",
-   "MONTH($date_field) AS month_field",
-   "DAYOFMONTH($date_field) AS day_of_month_field"
-   ];
+   if ( $timePeriod == 'day' ) {
+   $fields = "YEAR($date_field) AS year_field, 
MONTH($date_field) AS month_field, DAYOFMONTH($date_field) AS 
day_of_month_field";
+   } elseif ( $timePeriod == 'month' ) {
+   $fields = "YEAR($date_field) AS year_field, 
MONTH($date_field) AS month_field";
+   } elseif ( $timePeriod == 'year' ) {
+   $fields = "YEAR($date_field) AS year_field";
+   } else { // if ( $timePeriod == 'decade' ) {
+   $fields = "YEAR($date_field) AS year_field";
+   }
 
list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( 
$fullTextSearchTerm, $appliedFilters );
$selectOptions = [ 'GROUP BY' => $fields, 'ORDER BY' => $fields 
];

-- 
To view, visit https://gerrit.wikimedia.org/r/316840
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id51567450f78c847122bc74d81291bb8ebde89d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: This fixes all instances of using array indexes instead of f...

2016-10-19 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316831

Change subject: This fixes all instances of using array indexes instead of 
field names for accessing database rows.
..

This fixes all instances of using array indexes instead of field
names for accessing database rows.

Change-Id: I6550d33c4cd440464e99108dbdf57e179df0ecc6
---
M CargoPageData.php
M CargoUtils.php
M drilldown/CargoAppliedFilter.php
M drilldown/CargoFilter.php
M drilldown/CargoSpecialDrilldown.php
M parserfunctions/CargoAttach.php
M specials/CargoRecreateData.php
M specials/CargoTables.php
8 files changed, 51 insertions(+), 46 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/31/316831/1

diff --git a/CargoPageData.php b/CargoPageData.php
index 87a1c88..22002a8 100644
--- a/CargoPageData.php
+++ b/CargoPageData.php
@@ -123,12 +123,12 @@
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select(
'revision',
-   'COUNT(*)',
+   'COUNT(*) as total',
array( 'rev_page' => $title->getArticleID() ),
__METHOD__
);
$row = $dbr->fetchRow( $res );
-   $pageDataValues['_numRevisions'] = $row[0];
+   $pageDataValues['_numRevisions'] = 
intval($row['total']);
}
 
CargoStore::storeAllData( $title, '_pageData', $pageDataValues, 
$tableSchemas['_pageData'] );
diff --git a/CargoUtils.php b/CargoUtils.php
index c8433b1..bd4606e 100644
--- a/CargoUtils.php
+++ b/CargoUtils.php
@@ -132,7 +132,7 @@
$dbw = wfGetDB( DB_MASTER );
$res = $dbw->select( 'cargo_tables', 'main_table' );
while ( $row = $dbw->fetchRow( $res ) ) {
-   $tableNames[] = $row[0];
+   $tableNames[] = $row['main_table'];
}
return $tableNames;
}
diff --git a/drilldown/CargoAppliedFilter.php b/drilldown/CargoAppliedFilter.php
index 906f6e7..a52e926 100644
--- a/drilldown/CargoAppliedFilter.php
+++ b/drilldown/CargoAppliedFilter.php
@@ -176,7 +176,7 @@
$cdb = CargoUtils::getDB();
$res = $cdb->select( $tableName, "DISTINCT " . $value_field );
while ( $row = $cdb->fetchRow( $res ) ) {
-   $possible_values[] = $row[0];
+   $possible_values[] = $row[$value_field];
}
$cdb->freeResult( $res );
return $possible_values;
diff --git a/drilldown/CargoFilter.php b/drilldown/CargoFilter.php
index 9d00922..2cb6d9e 100644
--- a/drilldown/CargoFilter.php
+++ b/drilldown/CargoFilter.php
@@ -47,10 +47,10 @@
$cdb = CargoUtils::getDB();
$date_field = $this->name;
list( $tableNames, $conds, $joinConds ) = $this->getQueryParts( 
$fullTextSearchTerm, $appliedFilters );
-   $res = $cdb->select( $tableNames, array( "MIN($date_field)", 
"MAX($date_field)" ), $conds, null,
+   $res = $cdb->select( $tableNames, array( "MIN($date_field) AS 
min_date", "MAX($date_field) AS max_date" ), $conds, null,
null, $joinConds );
$row = $cdb->fetchRow( $res );
-   $minDate = $row[0];
+   $minDate = $row['min_date'];
if ( is_null( $minDate ) ) {
return null;
}
@@ -61,7 +61,7 @@
$minYear = $minDateParts[0];
$minMonth = $minDay = 0;
}
-   $maxDate = $row[1];
+   $maxDate = $row['max_date'];
$maxDateParts = explode( '-', $maxDate );
if ( count( $maxDateParts ) == 3 ) {
list( $maxYear, $maxMonth, $maxDay ) = $maxDateParts;
@@ -126,51 +126,56 @@
$date_field = $this->name;
$timePeriod = $this->getTimePeriod( $fullTextSearchTerm, 
$appliedFilters );
 
-   if ( $timePeriod == 'day' ) {
-   $fields = "YEAR($date_field), MONTH($date_field), 
DAYOFMONTH($date_field)";
-   } elseif ( $timePeriod == 'month' ) {
-   $fields = "YEAR($date_field), MONTH($date_field)";
-   } elseif ( $timePeriod == 'year' ) {
-   $fields = "YEAR($date_field)";
-   } else { // if ( $timePeriod == 'decade' ) {
-   $fields = "YEAR($date_field)";
-   }
+   $fields = [
+   "YEAR($date_field) AS year_field",
+   "MONTH($date_field) AS month_field",
+   "DAYOFMONTH($date_field) AS 

[MediaWiki-commits] [Gerrit] mediawiki...AbuseFilter[master]: The central DB does not use the proper credentials. This co...

2016-08-02 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/302608

Change subject: The central DB does not use the proper credentials.  This 
corrects that behavior by getting the correct load balancer.
..

The central DB does not use the proper credentials.  This corrects
that behavior by getting the correct load balancer.

Change-Id: Ied0713d079a2cdfe5076f96e6edbc93117154579
---
M AbuseFilter.class.php
M AbuseFilter.hooks.php
M Views/AbuseFilterViewList.php
3 files changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter 
refs/changes/08/302608/1

diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php
index f4ba041..96fc660 100644
--- a/AbuseFilter.class.php
+++ b/AbuseFilter.class.php
@@ -282,7 +282,7 @@
if ( !$wgAbuseFilterCentralDB ) {
return false;
}
-   $dbr = wfGetDB( DB_SLAVE, array(), 
$wgAbuseFilterCentralDB );
+   $dbr = wfGetLBFactory()->getExternalLB( 
$wgAbuseFilterCentralDB )->getConnection( DB_SLAVE );
$filter = $globalIndex;
} else {
$dbr = wfGetDB( DB_SLAVE );
@@ -681,7 +681,7 @@
}
 
if ( count( $globalFilters ) ) {
-   $fdb = wfGetDB( DB_SLAVE, array(), 
$wgAbuseFilterCentralDB );
+   $fdb = wfGetLBFactory()->getExternalLB( 
$wgAbuseFilterCentralDB )->getConnection( DB_SLAVE );
$consequences = $consequences + 
self::loadConsequencesFromDB( $fdb, $globalFilters, 'global-' );
}
 
@@ -1181,7 +1181,7 @@
}
 
global $wgAbuseFilterCentralDB;
-   $fdb = wfGetDB( DB_MASTER, array(), 
$wgAbuseFilterCentralDB );
+   $fdb = wfGetLBFactory()->getExternalLB( 
$wgAbuseFilterCentralDB )->getConnection( DB_MASTER );
 
foreach ( $central_log_rows as $row ) {
$fdb->insert( 'abuse_filter_log', $row, 
__METHOD__ );
@@ -1254,7 +1254,7 @@
 
// Store to text table
if ( $global ) {
-   $dbw = wfGetDB( DB_MASTER, array(), 
$wgAbuseFilterCentralDB );
+   $dbw = wfGetLBFactory()->getExternalLB( 
$wgAbuseFilterCentralDB )->getConnection( DB_MASTER );
} else {
$dbw = wfGetDB( DB_MASTER );
}
@@ -2400,7 +2400,7 @@
return '';
}
 
-   $fdb = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB );
+   $fdb = wfGetLBFactory()->getExternalLB( $wgAbuseFilterCentralDB 
)->getConnection( DB_SLAVE );
 
return $fdb->selectField(
'abuse_filter',
diff --git a/AbuseFilter.hooks.php b/AbuseFilter.hooks.php
index ce30f16..973e7f2 100644
--- a/AbuseFilter.hooks.php
+++ b/AbuseFilter.hooks.php
@@ -255,7 +255,7 @@
 
if ( count( $log_ids ) ) {
global $wgAbuseFilterCentralDB;
-   $fdb = wfGetDB( DB_MASTER, array(), 
$wgAbuseFilterCentralDB );
+   $fdb = wfGetLBFactory()->getExternalLB( 
$wgAbuseFilterCentralDB )->getConnection( DB_MASTER );
 
$fdb->update( 'abuse_filter_log',
array( 'afl_rev_id' => 
$revision->getId() ),
@@ -498,7 +498,7 @@
}
 
if ( $wgAbuseFilterCentralDB && !$wgAbuseFilterIsCentral ) {
-   $dbr = wfGetDB( DB_SLAVE, array(), 
$wgAbuseFilterCentralDB );
+   $dbr = wfGetLBFactory()->getExternalLB( 
$wgAbuseFilterCentralDB )->getConnection( DB_SLAVE );
$where['af_global'] = 1;
$res = $dbr->select(
array( 'abuse_filter_action', 'abuse_filter' ),
diff --git a/Views/AbuseFilterViewList.php b/Views/AbuseFilterViewList.php
index a3f8be7..2c5d472 100644
--- a/Views/AbuseFilterViewList.php
+++ b/Views/AbuseFilterViewList.php
@@ -368,7 +368,7 @@
function __construct( $page, $conds ) {
parent::__construct( $page, $conds );
global $wgAbuseFilterCentralDB;
-   $this->mDb = wfGetDB( DB_SLAVE, array(), 
$wgAbuseFilterCentralDB );
+   $this->mDb = wfGetLBFactory()->getExternalLB( 
$wgAbuseFilterCentralDB )->getConnection( DB_SLAVE );
}
 
function formatValue( $name, $value ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/302608
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied0713d079a2cdfe5076f96e6edbc93117154579
Gerrit-PatchSet: 1
Gerrit-Project: 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Historically the name has been camelCased and this was break...

2016-07-29 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/301848

Change subject: Historically the name has been camelCased and this was breaking 
merges.
..

Historically the name has been camelCased and this was breaking merges.

Change-Id: I90c1f5344ab643b5c718e544597d806cc119337a
---
M includes/specialpage/LoginSignupSpecialPage.php
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/301848/1

diff --git a/includes/specialpage/LoginSignupSpecialPage.php 
b/includes/specialpage/LoginSignupSpecialPage.php
index 5dab221..173ecae 100644
--- a/includes/specialpage/LoginSignupSpecialPage.php
+++ b/includes/specialpage/LoginSignupSpecialPage.php
@@ -997,7 +997,7 @@
'size' => '20',
'placeholder-message' => 
'createacct-reason-ph',
],
-   'extrainput' => [], // placeholder for fields 
coming from the template
+   'extraInput' => [], // placeholder for fields 
coming from the template
'createaccount' => [
// submit button
'type' => 'submit',
@@ -1020,7 +1020,7 @@
'placeholder-message' => 
'userlogin-yourpassword-ph',
],
'domain' => [],
-   'extrainput' => [],
+   'extraInput' => [],
'rememberMe' => [
// option for saving the user token to 
a cookie
'type' => 'check',
@@ -1114,7 +1114,7 @@
}
 
// poor man's associative array_splice
-   $extraInputPos = array_search( 'extrainput', array_keys( 
$fieldDefinitions ), true );
+   $extraInputPos = array_search( 'extraInput', array_keys( 
$fieldDefinitions ), true );
$fieldDefinitions = array_slice( $fieldDefinitions, 0, 
$extraInputPos, true )
+ 
$template->getExtraInputDefinitions()
+ array_slice( 
$fieldDefinitions, $extraInputPos + 1, null, true );
@@ -1294,7 +1294,7 @@
 */
public function addInputItem( $name, $value, $type, $msg, $helptext = 
false ) {
// use the same indexes as UserCreateForm just in case someone 
adds an item manually
-   $this->data['extrainput'][] = [
+   $this->data['extraInput'][] = [
'name' => $name,
'value' => $value,
'type' => $type,
@@ -1310,7 +1310,7 @@
public function getExtraInputDefinitions() {
$definitions = [];
 
-   foreach ( $this->get( 'extrainput', [] ) as $field ) {
+   foreach ( $this->get( 'extraInput', [] ) as $field ) {
$definition = [
'type' => $field['type'] === 'checkbox' ? 
'check' : $field['type'],
'name' => $field['name'],

-- 
To view, visit https://gerrit.wikimedia.org/r/301848
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I90c1f5344ab643b5c718e544597d806cc119337a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Redo this because Gerrit is bad. - change (mediawiki...RegexFunctions)

2016-06-28 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/296416

Change subject: Redo this because Gerrit is bad.
..

Redo this because Gerrit is bad.

Change-Id: Icaaef61c1033e0993e14da6bb3e65eeb853b7b61
---
M RegexFunctions.php
1 file changed, 46 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RegexFunctions 
refs/changes/16/296416/1

diff --git a/RegexFunctions.php b/RegexFunctions.php
index fc1781f..1fa3432 100644
--- a/RegexFunctions.php
+++ b/RegexFunctions.php
@@ -36,11 +36,7 @@
 // how many functions are allowed in a single page? Keep this at least above 3 
for usability
 $wgRegexFunctionsPerPage = 10;
 // should we allow modifiers in the functions, e.g. the /i modifier for 
case-insensitive?
-// This does NOT enable the /e modifier for preg_replace, see the next 
variable for that
 $wgRegexFunctionsAllowModifiers = true;
-// should we allow the /e modifier in preg_replace? Requires AllowModifiers to 
be true.
-// Don't enable this unless you trust every single editor on your wiki, as it 
may open up potential XSS vectors
-$wgRegexFunctionsAllowE = false;
 // should we allow internal options to be set (e.g. (?opts) or (?opts:some 
regex))
 $wgRegexFunctionsAllowOptions = true;
 // limit for rsplit and rreplace functions. -1 is unlimited
@@ -78,41 +74,54 @@
}
$pattern = self::sanitize(
$pattern,
-   $wgRegexFunctionsAllowModifiers,
-   false
+   $wgRegexFunctionsAllowModifiers
);
$num = preg_match(
$pattern, $string, $matches, PREG_OFFSET_CAPTURE, (int) 
$offset
);
-   if( $num === false ) {
+   if ( $num === false ) {
return;
}
-   if( $num === 0 ) {
+   if ( $num === 0 ) {
+   if ( $notfound == '$0' ) {
+   //Return the original string if specified to 
display it with $0.
+   return $string;
+   }
return $notfound;
}
+
// change all backslashes to $
$return = str_replace( '\\', '%$', $return );
-   $return = preg_replace(
-   '/%?\$%?\$([0-9]+)/e',
-   'array_key_exists($1, $matches) ? $matches[$1][1] : 
\'\'',
+   $return = preg_replace_callback(
+   '/%?\$%?\$([0-9]+)/',
+   function ( $_callbackMatches ) use ( $matches ) {
+   return array_key_exists($_callbackMatches[1], 
$matches) ? $matches[$_callbackMatches[1]][1] : '';
+   },
$return
);
-   $return = preg_replace(
-   '/%?\$%?\$\{([0-9]+)\}/e',
-   'array_key_exists($1, $matches) ? $matches[$1][1] : 
\'\'',
+   $return = preg_replace_callback(
+   '/%?\$%?\$\{([0-9]+)\}/',
+   function ( $_callbackMatches ) use ( $matches ) {
+   return array_key_exists($_callbackMatches[1], 
$matches) ? $matches[$_callbackMatches[1]][1] : '';
+   },
$return
);
-   $return = preg_replace(
-   '/%?\$([0-9]+)/e',
-   'array_key_exists($1, $matches) ? $matches[$1][0] : 
\'\'',
+   $return = preg_replace_callback(
+   '/%?\$([0-9]+)/',
+   function ( $_callbackMatches ) use ( $matches ) {
+   return array_key_exists($_callbackMatches[1], 
$matches) ? $matches[$_callbackMatches[1]][0] : '';
+   },
$return
);
-   $return = preg_replace(
-   '/%?\$\{([0-9]+)\}/e',
-   'array_key_exists($1, $matches) ? $matches[$1][0] : 
\'\'',
+   $return = preg_replace_callback(
+   '/%?\$\{([0-9]+)\}/',
+   function ( $_callbackMatches ) use ( $matches ) {
+   return array_key_exists($_callbackMatches[1], 
$matches) ? $matches[$_callbackMatches[1]][0] : '';
+   },
$return
);
$return = str_replace( '%$', '\\', $return );
+
return $return;
}
 
@@ -127,8 +136,7 @@
}
$pattern = self::sanitize(
$pattern,
-   $wgRegexFunctionsAllowModifiers,
-   false
+   $wgRegexFunctionsAllowModifiers

[MediaWiki-commits] [Gerrit] Replace eval modifier with callbacks. - change (mediawiki...RegexFunctions)

2016-06-27 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/296264

Change subject: Replace eval modifier with callbacks.
..

Replace eval modifier with callbacks.

Change-Id: I9fde8ed91aec6f11d193b4f02c5b5d2d200c05df
---
M RegexFunctions.php
1 file changed, 41 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RegexFunctions 
refs/changes/64/296264/1

diff --git a/RegexFunctions.php b/RegexFunctions.php
index fc1781f..144ef80 100644
--- a/RegexFunctions.php
+++ b/RegexFunctions.php
@@ -36,11 +36,7 @@
 // how many functions are allowed in a single page? Keep this at least above 3 
for usability
 $wgRegexFunctionsPerPage = 10;
 // should we allow modifiers in the functions, e.g. the /i modifier for 
case-insensitive?
-// This does NOT enable the /e modifier for preg_replace, see the next 
variable for that
 $wgRegexFunctionsAllowModifiers = true;
-// should we allow the /e modifier in preg_replace? Requires AllowModifiers to 
be true.
-// Don't enable this unless you trust every single editor on your wiki, as it 
may open up potential XSS vectors
-$wgRegexFunctionsAllowE = false;
 // should we allow internal options to be set (e.g. (?opts) or (?opts:some 
regex))
 $wgRegexFunctionsAllowOptions = true;
 // limit for rsplit and rreplace functions. -1 is unlimited
@@ -49,6 +45,7 @@
 $wgRegexFunctionsDisable = array();
 
 class ExtRegexFunctions {
+   public static $rmatches; //Holder for rmatch's matches to pass into 
closure callback function.
private static $num = 0;
private static $modifiers = array(
'i', 'm', 's', 'x', 'A', 'D', 'S', 'U', 'X', 'J', 'u', 'e'
@@ -78,40 +75,39 @@
}
$pattern = self::sanitize(
$pattern,
-   $wgRegexFunctionsAllowModifiers,
-   false
+   $wgRegexFunctionsAllowModifiers
);
$num = preg_match(
$pattern, $string, $matches, PREG_OFFSET_CAPTURE, (int) 
$offset
);
-   if( $num === false ) {
+   if ( $num === false ) {
return;
}
-   if( $num === 0 ) {
+   if ( $num === 0 ) {
+   if ( $notfound == '$0' ) {
+   //Return the original string if specified to 
display it with $0.
+   return $string;
+   } 
return $notfound;
}
+   self::$rmatches = $matches;
// change all backslashes to $
$return = str_replace( '\\', '%$', $return );
-   $return = preg_replace(
-   '/%?\$%?\$([0-9]+)/e',
-   'array_key_exists($1, $matches) ? $matches[$1][1] : 
\'\'',
-   $return
-   );
-   $return = preg_replace(
-   '/%?\$%?\$\{([0-9]+)\}/e',
-   'array_key_exists($1, $matches) ? $matches[$1][1] : 
\'\'',
-   $return
-   );
-   $return = preg_replace(
-   '/%?\$([0-9]+)/e',
-   'array_key_exists($1, $matches) ? $matches[$1][0] : 
\'\'',
-   $return
-   );
-   $return = preg_replace(
-   '/%?\$\{([0-9]+)\}/e',
-   'array_key_exists($1, $matches) ? $matches[$1][0] : 
\'\'',
-   $return
-   );
+   $slashyReplacements = [
+   '/%?\$%?\$([0-9]+)/',
+   '/%?\$%?\$\{([0-9]+)\}/',
+   '/%?\$([0-9]+)/',
+   '/%?\$\{([0-9]+)\}/'
+   ];
+   foreach ( $slashyReplacements as $regex ) {
+   $return = preg_replace_callback(
+   $regex,
+   function ( $_matches ) {
+   return array_key_exists($_matches[1], 
ExtRegexFunctions::$rmatches) ? ExtRegexFunctions::$rmatches[$_matches[1]][0] : 
'';
+   },
+   $return
+   );
+   }
$return = str_replace( '%$', '\\', $return );
return $return;
}
@@ -127,8 +123,7 @@
}
$pattern = self::sanitize(
$pattern,
-   $wgRegexFunctionsAllowModifiers,
-   false
+   $wgRegexFunctionsAllowModifiers
);
$res = preg_split( $pattern, $string, $wgRegexFunctionsLimit );
$p = (int) $piece;
@@ -147,7 +142,7 @@
}
 
public static function 

[MediaWiki-commits] [Gerrit] Fix CS - change (mediawiki/core)

2016-05-26 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/290981

Change subject: Fix CS
..

Fix CS

Change-Id: I86de9b464dc2ac97ddb8de5f984e9f2f02c1ab59
---
M includes/clientpool/RedisConnectionPool.php
1 file changed, 19 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/81/290981/1

diff --git a/includes/clientpool/RedisConnectionPool.php 
b/includes/clientpool/RedisConnectionPool.php
index 9312ee0..2068791 100644
--- a/includes/clientpool/RedisConnectionPool.php
+++ b/includes/clientpool/RedisConnectionPool.php
@@ -409,7 +409,10 @@
 * @param int $timeout Optional
 */
public function resetTimeout( Redis $conn, $timeout = null ) {
-   $conn->setOption( Redis::OPT_READ_TIMEOUT, ( $timeout !== null 
? $timeout : $this->readTimeout ) );
+   $conn->setOption(
+   Redis::OPT_READ_TIMEOUT,
+   ( $timeout !== null ? $timeout : $this->readTimeout )
+   );
}
 
/**
@@ -508,11 +511,13 @@
 * @throws  RedisException
 */
public function __call( $name, $arguments ) {
-   //Work around https://github.com/nicolasff/phpredis/issues/70
+   // Work around https://github.com/nicolasff/phpredis/issues/70
$lname = strtolower( $name );
-   if ( ( $lname === 'blpop' || $lname === 'brpop' || $lname === 
'brpoplpush' ) && count($arguments) > 1 ) {
-   $timeout = end( $arguments ); //Pull the timeout off 
the end since the timeout is always required and the preceding argument length 
can vary.
-   $this->pool->resetTimeout( $this->conn, ( $timeout > 0 
? $timeout + 1 : $timeout ) ); //Only give the additional one second buffer if 
not requesting an infinite timeout.
+   if ( ( $lname === 'blpop' || $lname === 'brpop' || $lname === 
'brpoplpush' ) && count( $arguments ) > 1 ) {
+   // Get timeout off the end since the timeout is always 
required and argument length can vary.
+   $timeout = end( $arguments );
+   ///Only give the additional one second buffer if not 
requesting an infinite timeout.
+   $this->pool->resetTimeout( $this->conn, ( $timeout > 0 
? $timeout + 1 : $timeout ) );
}
 
$res = $this->tryCall( $name, $arguments );
@@ -532,10 +537,10 @@
private function tryCall( $method, $arguments ) {
$this->conn->clearLastError();
try {
-   $res = call_user_func_array( array( $this->conn, 
$method ), $arguments );
+   $res = call_user_func_array( [ $this->conn, $method ], 
$arguments );
$authError = $this->handleAuthError();
if ( $authError === self::AUTH_ERROR_TEMPORARY ) {
-   $res = call_user_func_array( array( 
$this->conn, $method ), $arguments );
+   $res = call_user_func_array( [ $this->conn, 
$method ], $arguments );
}
if ( $authError === self::AUTH_ERROR_PERMANENT ) {
throw new RedisException( "There was a 
permanent failure reauthenticating to Redis." );
@@ -562,7 +567,7 @@
 * @return  array   Results for this pass.
 */
public function scan( &$iterator, $pattern = null, $count = null ) {
-   $res = $this->tryCall( 'scan', array( &$iterator, $pattern, 
$count ) );
+   $res = $this->tryCall( 'scan', [ &$iterator, $pattern, $count ] 
);
 
return $res;
}
@@ -580,7 +585,7 @@
 * @return  array   Results for this pass.
 */
public function sScan( $key, &$iterator, $pattern = null, $count = null 
) {
-   $res = $this->tryCall( 'sScan', array( $key, &$iterator, 
$pattern, $count ) );
+   $res = $this->tryCall( 'sScan', [ $key, &$iterator, $pattern, 
$count ] );
 
return $res;
}
@@ -598,7 +603,7 @@
 * @return  array   Results for this pass.
 */
public function hScan( $key, &$iterator, $pattern = null, $count = null 
) {
-   $res = $this->tryCall( 'hScan', array( $key, &$iterator, 
$pattern, $count ) );
+   $res = $this->tryCall( 'hScan', [ $key, &$iterator, $pattern, 
$count ] );
 
return $res;
}
@@ -616,7 +621,7 @@
 * @return  array   Results for this pass.
 */
public function zScan( $key, &$iterator, $pattern = null, $count = null 
) {
-   $res = $this->tryCall( 'zScan', array( $key, &$iterator, 
$pattern, $count ) );
+   $res = $this->tryCall( 'zScan', [ $key, &$iterator, $pattern, 
$count ] );
 
   

[MediaWiki-commits] [Gerrit] Make the call match the function definition. - change (mediawiki/core)

2016-05-25 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/290741

Change subject: Make the call match the function definition.
..

Make the call match the function definition.

Change-Id: I381fbc9b6ddbf27f4f7a79dc19eec0547e0fddbb
---
M includes/installer/MysqlInstaller.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/41/290741/1

diff --git a/includes/installer/MysqlInstaller.php 
b/includes/installer/MysqlInstaller.php
index 799ca58..1bd3f51 100644
--- a/includes/installer/MysqlInstaller.php
+++ b/includes/installer/MysqlInstaller.php
@@ -540,7 +540,7 @@
 
foreach ( $createHostList as $host ) {
$fullName = $this->buildFullUserName( $dbUser, 
$host );
-   if ( !$this->userDefinitelyExists( $dbUser, 
$host ) ) {
+   if ( !$this->userDefinitelyExists( $host, 
$dbUser ) ) {
try {
$this->db->begin( __METHOD__ );
$this->db->query( "CREATE USER 
$fullName IDENTIFIED BY $escPass", __METHOD__ );

-- 
To view, visit https://gerrit.wikimedia.org/r/290741
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I381fbc9b6ddbf27f4f7a79dc19eec0547e0fddbb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Running a SELECT statement on a missing table causes errors. - change (mediawiki/core)

2015-11-24 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/255294

Change subject: Running a SELECT statement on a missing table causes errors.
..

Running a SELECT statement on a missing table causes errors.

https://phabricator.wikimedia.org/T54294

Change-Id: Ic7bd07e00456b885f1d6bc6e6176b93943b55c9a
---
M includes/db/Database.php
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/94/255294/1

diff --git a/includes/db/Database.php b/includes/db/Database.php
index c0cf067..9636261 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -1816,10 +1816,11 @@
public function tableExists( $table, $fname = __METHOD__ ) {
$table = $this->tableName( $table );
$old = $this->ignoreErrors( true );
-   $res = $this->query( "SELECT 1 FROM $table LIMIT 1", $fname );
+   $res = $this->query( "SHOW TABLES LIKE $table", $fname );
+   $row = $this->fetchRow( $res );
$this->ignoreErrors( $old );
 
-   return (bool)$res;
+   return (bool)$row;
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/255294
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7bd07e00456b885f1d6bc6e6176b93943b55c9a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Redis scan functions require iterator passed by reference. - change (mediawiki/core)

2015-11-11 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/252455

Change subject: Redis scan functions require iterator passed by reference.
..

Redis scan functions require iterator passed by reference.

Change-Id: I158647ab8bc656f6f0afb1ef1f6d2f19b2fb7cb5
---
M includes/clientpool/RedisConnectionPool.php
1 file changed, 16 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/252455/1

diff --git a/includes/clientpool/RedisConnectionPool.php 
b/includes/clientpool/RedisConnectionPool.php
index 64db0d6..4da59de 100644
--- a/includes/clientpool/RedisConnectionPool.php
+++ b/includes/clientpool/RedisConnectionPool.php
@@ -471,24 +471,34 @@
 
public function __call( $name, $arguments ) {
$conn = $this->conn; // convenience
+   $_arguments = $arguments; //Necessary for the iterator 
reference fix below to work.
 
// Work around https://github.com/nicolasff/phpredis/issues/70
$lname = strtolower( $name );
if ( ( $lname === 'blpop' || $lname == 'brpop' )
-   && is_array( $arguments[0] ) && isset( $arguments[1] )
+   && is_array( $_arguments[0] ) && isset( $_arguments[1] )
) {
-   $this->pool->resetTimeout( $conn, $arguments[1] + 1 );
-   } elseif ( $lname === 'brpoplpush' && isset( $arguments[2] ) ) {
-   $this->pool->resetTimeout( $conn, $arguments[2] + 1 );
+   $this->pool->resetTimeout( $conn, $_arguments[1] + 1 );
+   } elseif ( $lname === 'brpoplpush' && isset( $_arguments[2] ) ) 
{
+   $this->pool->resetTimeout( $conn, $_arguments[2] + 1 );
+   }
+
+   if ( $lname === 'scan' || $lname === 'hscan' || $lname === 
'sscan' || $lname === 'zscan' ) {
+   //Work around for iterator reference in scan functions.
+   
//http://stackoverflow.com/questions/8101071/call-user-func-array-with-references
+   $_arguments = array();
+   foreach ( $arguments as $key => $value ) {
+   $_arguments[$key] = &$arguments[$key];
+   }
}
 
$conn->clearLastError();
try {
-   $res = call_user_func_array( array( $conn, $name ), 
$arguments );
+   $res = call_user_func_array( array( $conn, $name ), 
$_arguments );
if ( preg_match( '/^ERR operation not permitted\b/', 
$conn->getLastError() ) ) {
$this->pool->reauthenticateConnection( 
$this->server, $conn );
$conn->clearLastError();
-   $res = call_user_func_array( array( $conn, 
$name ), $arguments );
+   $res = call_user_func_array( array( $conn, 
$name ), $_arguments );
$this->logger->info(
"Used automatic re-authentication for 
method '$name'.",
array( 'redis_server' => $this->server )

-- 
To view, visit https://gerrit.wikimedia.org/r/252455
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I158647ab8bc656f6f0afb1ef1f6d2f19b2fb7cb5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Merge from https://github.com/Alexia/DynamicPageList/tree/3.... - change (mediawiki...DynamicPageList)

2015-02-13 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/190581

Change subject: Merge from https://github.com/Alexia/DynamicPageList/tree/3.0RC1
..

Merge from https://github.com/Alexia/DynamicPageList/tree/3.0RC1

5ddee74 Fix an issue when a completely blank {{#dpl:}} tag was used.  Softly 
ignore blank lines.
04c35eb Piggyback on @vonloxley's commit to fix the other areas inlinetext 
appears.
9302035 Merge pull request #32 from Rezepte-Wiki/master
e13301b Fix inlinetext parameter
c0d71f0 Clean up previous commit for spacing.
2546888 Merge pull request #31 from Rezepte-Wiki/master
c264c7d Preserve case for usernames
bcf9910 Update English messages.
a9e601f Fix * subcategory helper using AND instead of OR for selection.
e2f647a Remove new line.
4359292 Merge pull request #16 from cblair91/patch-8
2c40f6c Fix how logical AND is built so that multiple category inclusion is 
handled correctly.
563a2f2 Fix subcategory generation and make sure the parent category gets added.
1e19e80 Fix getSubcategories function call.  Make sure to return false if the 
magic __call function can not get parameter data.
4ed2f4c Security fix for categoriesminmax.
641b467 I didn't listen to myself last time about var_dump()s.
df39037 Various fixes to category, categorymatch, and categoryregexp.  This 
fixes issues with them either not working or not assembling the logical 
operators in the correct orders.
aa6df5a Don't leave var_dump()s in your code.
8afe08f Simplify ordermethod sortkey query.  All namespaces should be available 
for data representation regardless if it is selected.
a790a4b Rename that function to make sense since the word collation is used 
elsewhere in SQL.
e558a3e Clean this up further with a function.
8d1afeb Bit of code reused clean up.
4c54193 Delete duplicate check and pass $pageTitle through.
25dbf45 Fix some SQL issues.
90dbbea Fix issue with title parameter not setting namespace correctly.
c34a2c8 Make sure to reset $ors when starting new loops.  Remove some extra 
parenthesis that get added to queries.  Fix broken database call.  Fix lists of 
page names being lowercased.  Fix not being able to set multiple of the same 
parameter.
28ba184 Various fixes for parameters that use getPageNameList().
320fbb5 Put that back to the old way.
1479ebd Spelling fix.
2f89d5b Leaner version of header/footer handling.
a0f2609 Scope error.
5450ace It's no longer $0 is it?
26c5034 Fix headers and footers being strtolower()'ed.  Fix headers being set 
to the footer.
12db2f1 Minor language fixes, but languages will need to be entirely redone.
21412c9 Fix parameter error messages.  Sort 
getParametersForFunctionalRichness() results.  Fix titlelt and titlegt 
definitions.
f9da019 Add some missing parameter returns.
8773d34 Fix title parameter.
6ef2147 Merge branch 'master' of github.com:Alexia/DynamicPageList
47da098 Remove new line.
43962fc Merge pull request #13 from cblair91/patch-6
f200b3d Merge pull request #14 from cblair91/patch-7
9b719ce Whoops, didn't quite read that pull request.  That was meant to use the 
object properties.
0251b57 Merge pull request #12 from cblair91/patch-5
ff72f7b Merge pull request #11 from cblair91/patch-4
d0c3c79 Fix spelling mistake
02ae1b1 Unused variable
6635889 Use getHeader() and getFooter()
24e970d Don't you mean setFooter?
5872d61 Fix up spelling mistake @cblair91 pointed out.
508f5cb Add some documentation, remove a few errant new lines, and fix minor 
bug with the improved suit sort.
c929b6e Merge pull request #9 from cblair91/patch-2
b094b1a Wrong way check for null.
67eb2fc Using strtolower makes a cleaner method
424b496 More PHP string fixes
3d800ac PHP string standards for variable use
5113a77 Tidy the arrays up to inline
13e4bc3 Remove new line.
5455fe6 Merge pull request #4 from cblair91/patch-2
b19d152 Spelling mistake
c1805be Spaces to tabs.
f0a9a4e Remove errant new line.
218ac91 Merge pull request #2 from cblair91/patch-1
683f6d9 Fix for array check.
155c503 Fix DPL Version.
622a200 More code standards.
d8df5ed Code standards.
af17ed7 Syntax error.
753c4e4 More code standards.
7e50f21 Code standards.
efc1ad2 Try to merge some LST updates in.
100a415 Add more profiling.  Run LST through code cleaner.
36fed34 DPL managing its own cache was silly.  Use the Parser cache 
intelligently.
bb50be3 Various query fixes and a caching fix.
48caac8 That was an incredibly clever ass-backwards use of a broken switch 
statement ever.
4008e8a Fix some namespacing.  Parameter issues.
8d328e3 More @TODO fixes.  Cast ordermethod as an array for testing against.  
Cast table row as an array for testing.
5fa2704 Fix up a couple more @TODOs.
51e8a28 Merge in from remote and my changes.
e487dfd Update change log.
55f2d24 Bit more code standardization.
c1f52e3 Intval() before putting into SQL.
fa59f25 Minor syntax fix.
d13bf16 Fix up the last of the '@TODO: Fix up this function.' in Query class.  
Restore 

[MediaWiki-commits] [Gerrit] Merge DynamicPageList: Use more standard LIMIT syntax - change (mediawiki...DynamicPageList)

2015-02-13 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/190576

Change subject: Merge DynamicPageList: Use more standard LIMIT syntax
..

Merge DynamicPageList: Use more standard LIMIT syntax

Change-Id: Id58ec60208105bea61a98eb3bc26bccad014596f
---
0 files changed, 0 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DynamicPageList 
refs/changes/76/190576/1


-- 
To view, visit https://gerrit.wikimedia.org/r/190576
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id58ec60208105bea61a98eb3bc26bccad014596f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DynamicPageList
Gerrit-Branch: master
Gerrit-Owner: Alexia was...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Coding Style - change (mediawiki/core)

2014-12-18 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/180817

Change subject: Coding Style
..

Coding Style

Move false condition to beginning of functions per Krinkle's recommendation.

Change-Id: I7e802b87f65f4c0829e5c7ccc436606c9a8c682d
---
M includes/User.php
1 file changed, 28 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/17/180817/1

diff --git a/includes/User.php b/includes/User.php
index 9a5da88..a2e89fa 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -3034,20 +3034,20 @@
 * @return bool
 */
public function addGroup( $group ) {
-   if ( Hooks::run( 'UserAddGroup', array( $this, $group ) ) ) {
-   $dbw = wfGetDB( DB_MASTER );
-   if ( $this-getId() ) {
-   $dbw-insert( 'user_groups',
-   array(
-   'ug_user' = $this-getID(),
-   'ug_group' = $group,
-   ),
-   __METHOD__,
-   array( 'IGNORE' ) );
-   }
-   } else {
+   if ( !Hooks::run( 'UserAddGroup', array( $this, $group ) ) ) {
return false;
}
+   $dbw = wfGetDB( DB_MASTER );
+   if ( $this-getId() ) {
+   $dbw-insert( 'user_groups',
+   array(
+   'ug_user' = $this-getID(),
+   'ug_group' = $group,
+   ),
+   __METHOD__,
+   array( 'IGNORE' ) );
+   }
+
$this-loadGroups();
$this-mGroups[] = $group;
// In case loadGroups was not called before, we now have the 
right twice.
@@ -3072,24 +3072,24 @@
 */
public function removeGroup( $group ) {
$this-load();
-   if ( Hooks::run( 'UserRemoveGroup', array( $this, $group ) ) ) 
{
-   $dbw = wfGetDB( DB_MASTER );
-   $dbw-delete( 'user_groups',
-   array(
-   'ug_user' = $this-getID(),
-   'ug_group' = $group,
-   ), __METHOD__ );
-   // Remember that the user was in this group
-   $dbw-insert( 'user_former_groups',
-   array(
-   'ufg_user' = $this-getID(),
-   'ufg_group' = $group,
-   ),
-   __METHOD__,
-   array( 'IGNORE' ) );
-   } else {
+   if ( !Hooks::run( 'UserRemoveGroup', array( $this, $group ) ) 
) {
return false;
}
+   $dbw = wfGetDB( DB_MASTER );
+   $dbw-delete( 'user_groups',
+   array(
+   'ug_user' = $this-getID(),
+   'ug_group' = $group,
+   ), __METHOD__ );
+   // Remember that the user was in this group
+   $dbw-insert( 'user_former_groups',
+   array(
+   'ufg_user' = $this-getID(),
+   'ufg_group' = $group,
+   ),
+   __METHOD__,
+   array( 'IGNORE' ) );
+
$this-loadGroups();
$this-mGroups = array_diff( $this-mGroups, array( $group ) );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/180817
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7e802b87f65f4c0829e5c7ccc436606c9a8c682d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia was...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] User::addGroup() and User::removeGroup() should return boolean. - change (mediawiki/core)

2014-12-18 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/180821

Change subject: User::addGroup() and User::removeGroup() should return boolean.
..

User::addGroup() and User::removeGroup() should return boolean.

Have the User::addGroup() and User::removeGroup() functions return a boolean 
when their respective hooks return the respective boolean.
Fix the SpecialUserrights page to respect this return vale and update the 
add/remove arrays accordingly.
This resolves an issue where a hook that prevents a group from being added or 
removed still shows that group being changed in the Userrights log.

Change-Id: I7621cc22b04ff41cf67bd434a1f89d31bdc2cffd

Coding Style

Move false condition to beginning of functions per Krinkle's recommendation.

Change-Id: I7e802b87f65f4c0829e5c7ccc436606c9a8c682d

Attempting to Fix Review

Change-Id: I41e0958c98878f404a531047115e3e3c65869944
---
M includes/User.php
M includes/specials/SpecialUserrights.php
2 files changed, 48 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/21/180821/1

diff --git a/includes/User.php b/includes/User.php
index 34af4c5..7519b2e 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -3031,20 +3031,24 @@
 * Add the user to the given group.
 * This takes immediate effect.
 * @param string $group Name of the group to add
+* @return bool
 */
public function addGroup( $group ) {
-   if ( Hooks::run( 'UserAddGroup', array( $this, $group ) ) ) {
-   $dbw = wfGetDB( DB_MASTER );
-   if ( $this-getId() ) {
-   $dbw-insert( 'user_groups',
-   array(
-   'ug_user' = $this-getID(),
-   'ug_group' = $group,
-   ),
-   __METHOD__,
-   array( 'IGNORE' ) );
-   }
+   if ( !Hooks::run( 'UserAddGroup', array( $this, $group ) ) ) {
+   return false;
}
+
+   $dbw = wfGetDB( DB_MASTER );
+   if ( $this-getId() ) {
+   $dbw-insert( 'user_groups',
+   array(
+   'ug_user' = $this-getID(),
+   'ug_group' = $group,
+   ),
+   __METHOD__,
+   array( 'IGNORE' ) );
+   }
+
$this-loadGroups();
$this-mGroups[] = $group;
// In case loadGroups was not called before, we now have the 
right twice.
@@ -3057,31 +3061,37 @@
$this-mRights = null;
 
$this-invalidateCache();
+
+   return true;
}
 
/**
 * Remove the user from the given group.
 * This takes immediate effect.
 * @param string $group Name of the group to remove
+* @return bool
 */
public function removeGroup( $group ) {
$this-load();
-   if ( Hooks::run( 'UserRemoveGroup', array( $this, $group ) ) ) 
{
-   $dbw = wfGetDB( DB_MASTER );
-   $dbw-delete( 'user_groups',
-   array(
-   'ug_user' = $this-getID(),
-   'ug_group' = $group,
-   ), __METHOD__ );
-   // Remember that the user was in this group
-   $dbw-insert( 'user_former_groups',
-   array(
-   'ufg_user' = $this-getID(),
-   'ufg_group' = $group,
-   ),
-   __METHOD__,
-   array( 'IGNORE' ) );
+   if ( !Hooks::run( 'UserRemoveGroup', array( $this, $group ) ) 
) {
+   return false;
}
+
+   $dbw = wfGetDB( DB_MASTER );
+   $dbw-delete( 'user_groups',
+   array(
+   'ug_user' = $this-getID(),
+   'ug_group' = $group,
+   ), __METHOD__ );
+   // Remember that the user was in this group
+   $dbw-insert( 'user_former_groups',
+   array(
+   'ufg_user' = $this-getID(),
+   'ufg_group' = $group,
+   ),
+   __METHOD__,
+   array( 'IGNORE' ) );
+
$this-loadGroups();
   

[MediaWiki-commits] [Gerrit] Have the User::addGroup() and User::removeGroup() functions ... - change (mediawiki/core)

2014-12-16 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/180328

Change subject: Have the User::addGroup() and User::removeGroup() functions 
return a boolean when their respective hooks return the respective boolean.  
Fix the SpecialUserrights page to respect this and update the arrays 
accordingly.
..

Have the User::addGroup() and User::removeGroup() functions return a boolean 
when their respective hooks return the respective boolean.  Fix the 
SpecialUserrights page to respect this and update the arrays accordingly.

Change-Id: I7621cc22b04ff41cf67bd434a1f89d31bdc2cffd
---
M includes/User.php
M includes/specials/SpecialUserrights.php
2 files changed, 20 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/28/180328/1

diff --git a/includes/User.php b/includes/User.php
index bda825f..bec9f67 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -3031,6 +3031,7 @@
 * Add the user to the given group.
 * This takes immediate effect.
 * @param string $group Name of the group to add
+* @return bool
 */
public function addGroup( $group ) {
if ( Hooks::run( 'UserAddGroup', array( $this, $group ) ) ) {
@@ -3044,6 +3045,8 @@
__METHOD__,
array( 'IGNORE' ) );
}
+   } else {
+   return false;
}
$this-loadGroups();
$this-mGroups[] = $group;
@@ -3057,12 +3060,15 @@
$this-mRights = null;
 
$this-invalidateCache();
+
+   return true;
}
 
/**
 * Remove the user from the given group.
 * This takes immediate effect.
 * @param string $group Name of the group to remove
+* @return bool
 */
public function removeGroup( $group ) {
$this-load();
@@ -3081,6 +3087,8 @@
),
__METHOD__,
array( 'IGNORE' ) );
+   } else {
+   return false;
}
$this-loadGroups();
$this-mGroups = array_diff( $this-mGroups, array( $group ) );
@@ -3091,6 +3099,8 @@
$this-mRights = null;
 
$this-invalidateCache();
+
+   return true;
}
 
/**
diff --git a/includes/specials/SpecialUserrights.php 
b/includes/specials/SpecialUserrights.php
index 3e9313c..06b943e 100644
--- a/includes/specials/SpecialUserrights.php
+++ b/includes/specials/SpecialUserrights.php
@@ -246,16 +246,20 @@
 
// remove then add groups
if ( $remove ) {
-   $newGroups = array_diff( $newGroups, $remove );
-   foreach ( $remove as $group ) {
-   $user-removeGroup( $group );
+   foreach ( $remove as $index = $group ) {
+   if ( !$user-removeGroup( $group ) ) {
+   unset($remove[$index]);
+   }
}
+   $newGroups = array_diff( $newGroups, $remove );
}
if ( $add ) {
-   $newGroups = array_merge( $newGroups, $add );
-   foreach ( $add as $group ) {
-   $user-addGroup( $group );
+   foreach ( $add as $index = $group ) {
+   if ( !$user-addGroup( $group ) ) {
+   unset($add[$index]);
+   }
}
+   $newGroups = array_merge( $newGroups, $add );
}
$newGroups = array_unique( $newGroups );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/180328
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7621cc22b04ff41cf67bd434a1f89d31bdc2cffd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia was...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] SpecialPageFactory::getLocalNameFor() can raise a PHP warnin... - change (mediawiki/core)

2013-04-16 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59420


Change subject: SpecialPageFactory::getLocalNameFor() can raise a PHP warning 
when trying to foreach over a null variable.
..

SpecialPageFactory::getLocalNameFor() can raise a PHP warning when trying to 
foreach over a null variable.

Change-Id: I275b124d705bacb0b4ce05579c48bb7d75caa17c
---
M includes/SpecialPageFactory.php
1 file changed, 10 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/20/59420/1

diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php
index a53b901..34eff2f 100644
--- a/includes/SpecialPageFactory.php
+++ b/includes/SpecialPageFactory.php
@@ -551,13 +551,16 @@
} else {
// Try harder in case someone misspelled the correct 
casing
$found = false;
-   foreach ( $aliases as $n = $values ) {
-   if ( strcasecmp( $name, $n ) === 0 ) {
-   wfWarn( Found alias defined for $n 
when searching for  .
-   special page aliases for 
$name. Case mismatch? );
-   $name = $values[0];
-   $found = true;
-   break;
+   //Do a check is $aliases is an array since 
$wgContLang-getSpecialPageAliases(); can return null.
+   if (is_array($aliases)) {
+   foreach ( $aliases as $n = $values ) {
+   if ( strcasecmp( $name, $n ) === 0 ) {
+   wfWarn( Found alias defined 
for $n when searching for  .
+   special page aliases 
for $name. Case mismatch? );
+   $name = $values[0];
+   $found = true;
+   break;
+   }
}
}
if ( !$found ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/59420
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I275b124d705bacb0b4ce05579c48bb7d75caa17c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia was...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Fixed per coding standards and copied the fix over to getAli... - change (mediawiki/core)

2013-04-16 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59520


Change subject: Fixed per coding standards and copied the fix over to 
getAliasList() where the same issue occurs.
..

Fixed per coding standards and copied the fix over to getAliasList() where the 
same issue occurs.

Change-Id: Id83c3e3092d187f29b62a1cbabc6374dd4777f57
---
M includes/SpecialPageFactory.php
1 file changed, 10 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/20/59520/1

diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php
index 34eff2f..e92eaa7 100644
--- a/includes/SpecialPageFactory.php
+++ b/includes/SpecialPageFactory.php
@@ -235,11 +235,15 @@
$missingPages = clone self::getList();
 
self::$mAliases = array();
-   foreach ( $aliases as $realName = $aliasList ) {
-   foreach ( $aliasList as $alias ) {
-   self::$mAliases[$wgContLang-caseFold( 
$alias )] = $realName;
+
+   //Do a check is $aliases is an array since 
$wgContLang-getSpecialPageAliases(); can return null.
+   if ( is_array( $aliases ) ) {
+   foreach ( $aliases as $realName = $aliasList ) 
{
+   foreach ( $aliasList as $alias ) {
+   
self::$mAliases[$wgContLang-caseFold( $alias )] = $realName;
+   }
+   unset( $missingPages-$realName );
}
-   unset( $missingPages-$realName );
}
foreach ( $missingPages as $name = $stuff ) {
self::$mAliases[$wgContLang-caseFold( $name )] 
= $name;
@@ -551,8 +555,9 @@
} else {
// Try harder in case someone misspelled the correct 
casing
$found = false;
+
//Do a check is $aliases is an array since 
$wgContLang-getSpecialPageAliases(); can return null.
-   if (is_array($aliases)) {
+   if ( is_array( $aliases ) ) {
foreach ( $aliases as $n = $values ) {
if ( strcasecmp( $name, $n ) === 0 ) {
wfWarn( Found alias defined 
for $n when searching for  .

-- 
To view, visit https://gerrit.wikimedia.org/r/59520
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id83c3e3092d187f29b62a1cbabc6374dd4777f57
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia was...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] $wgContLang-getSpecialPageAliases(); can return null causin... - change (mediawiki/core)

2013-04-16 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59522


Change subject: $wgContLang-getSpecialPageAliases(); can return null causing 
functions.
..

$wgContLang-getSpecialPageAliases(); can return null causing functions.

$wgContLang-getSpecialPageAliases(); can return null causing functions within 
SpecialPageFactory that rely on it to raise PHP warnings due to trying to 
foreach over a non-array.  This change will prevent the PHP warning from being 
raised and allow those functions' error handling to occur normally.

Change-Id: I2026c25f12798f699ebc306b12173226270fce2e
---
M includes/SpecialPageFactory.php
1 file changed, 17 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/22/59522/1

diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php
index a53b901..f5f87fc 100644
--- a/includes/SpecialPageFactory.php
+++ b/includes/SpecialPageFactory.php
@@ -233,13 +233,15 @@
 
// Objects are passed by reference by default, need to 
create a copy
$missingPages = clone self::getList();
-
self::$mAliases = array();
-   foreach ( $aliases as $realName = $aliasList ) {
-   foreach ( $aliasList as $alias ) {
-   self::$mAliases[$wgContLang-caseFold( 
$alias )] = $realName;
+   //Do a check is $aliases is an array since 
$wgContLang-getSpecialPageAliases(); can return null.
+   if ( is_array( $aliases ) ) {
+   foreach ( $aliases as $realName = $aliasList ) 
{
+   foreach ( $aliasList as $alias ) {
+   
self::$mAliases[$wgContLang-caseFold( $alias )] = $realName;
+   }
+   unset( $missingPages-$realName );
}
-   unset( $missingPages-$realName );
}
foreach ( $missingPages as $name = $stuff ) {
self::$mAliases[$wgContLang-caseFold( $name )] 
= $name;
@@ -551,13 +553,16 @@
} else {
// Try harder in case someone misspelled the correct 
casing
$found = false;
-   foreach ( $aliases as $n = $values ) {
-   if ( strcasecmp( $name, $n ) === 0 ) {
-   wfWarn( Found alias defined for $n 
when searching for  .
-   special page aliases for 
$name. Case mismatch? );
-   $name = $values[0];
-   $found = true;
-   break;
+   //Do a check is $aliases is an array since 
$wgContLang-getSpecialPageAliases(); can return null.
+   if ( is_array( $aliases ) ) {
+   foreach ( $aliases as $n = $values ) {
+   if ( strcasecmp( $name, $n ) === 0 ) {
+   wfWarn( Found alias defined 
for $n when searching for  .
+   special page aliases 
for $name. Case mismatch? );
+   $name = $values[0];
+   $found = true;
+   break;
+   }
}
}
if ( !$found ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/59522
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2026c25f12798f699ebc306b12173226270fce2e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alexia was...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Change settings to not override those set in LocalSettings.p... - change (mediawiki...SphinxSearch)

2013-03-27 Thread Alexia (Code Review)
Alexia has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/56202


Change subject: Change settings to not override those set in LocalSettings.php 
or other custom setting sources. Fixed an issue with userHighlightPrefs() not 
matching the current definition in the User class.  Changed syntax and checking 
to match Mediawiki standards.  Cha
..

Change settings to not override those set in LocalSettings.php or other custom 
setting sources. Fixed an issue with userHighlightPrefs() not matching the 
current definition in the User class.  Changed syntax and checking to match 
Mediawiki standards.  Change-Id: I847ffb16d1738a3c1fa589e65fcda29c06ab0448

Change-Id: Icae224795c80a208c0042853963b3c898c67359e
---
M SphinxMWSearch.php
M SphinxSearch.i18n.php
M SphinxSearch.php
3 files changed, 19 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SphinxSearch 
refs/changes/02/56202/1

diff --git a/SphinxMWSearch.php b/SphinxMWSearch.php
index edb08b8..e3e7547 100644
--- a/SphinxMWSearch.php
+++ b/SphinxMWSearch.php
@@ -179,14 +179,13 @@
}
 
/**
-* Find snippet highlight settings for a given user
+* Find snippet highlight settings for all users
 *
-* @param $user User
 * @return Array contextlines, contextchars
 */
-   public static function userHighlightPrefs( $user ) {
-   $contextlines = $user-getOption( 'contextlines', 2 );
-   $contextchars = $user-getOption( 'contextchars', 75 );
+   public static function userHighlightPrefs() {
+   $contextlines = 2; // Hardcode this. Old defaults sucked. :)
+   $contextchars = 75; // same as above :P
return array( $contextlines, $contextchars );
}
 
diff --git a/SphinxSearch.i18n.php b/SphinxSearch.i18n.php
index fce1668..45ebb27 100644
--- a/SphinxSearch.i18n.php
+++ b/SphinxSearch.i18n.php
@@ -21,8 +21,6 @@
 $messages['qqq'] = array(
'sphinxsearch-desc' = '{{desc|name=Sphinx 
Search|url=http://www.mediawiki.org/wiki/Extension:SphinxSearch}}',
'sphinxPowered' = '$1 is replaced with a text Sphinx inside a link.',
-   'sphinxSearchFailed' = 'Unused at this time. Parameters:
-* $1 - ...',
 );
 
 /** Afrikaans (Afrikaans)
diff --git a/SphinxSearch.php b/SphinxSearch.php
index 2632250..8044cb4 100644
--- a/SphinxSearch.php
+++ b/SphinxSearch.php
@@ -46,16 +46,24 @@
 }
 
 # Host and port on which searchd deamon is running
-$wgSphinxSearch_host = '127.0.0.1';
-$wgSphinxSearch_port = 9312;
+if (!isset($wgSphinxSearch_host)) {
+   $wgSphinxSearch_host = '127.0.0.1';
+}
+if (!isset($wgSphinxSearch_port)  !is_numeric($wgSphinxSearch_port)) {
+   $wgSphinxSearch_port = 9312;
+}
 
 # Main sphinx.conf index to search
-$wgSphinxSearch_index = wiki_main;
+if (!isset($wgSphinxSearch_index)) {
+   $wgSphinxSearch_index = wiki_main;
+}
 
 # By default, we search all available indexes
 # You can also specify them explicitly, e.g
 # $wgSphinxSearch_index_list = wiki_main,wiki_incremental;
-$wgSphinxSearch_index_list = *;
+if (!isset($wgSphinxSearch_index_list)) {
+   $wgSphinxSearch_index_list = *;
+}
 
 # If you have multiple index files, you can specify their weights like this
 # See http://www.sphinxsearch.com/docs/current.html#api-func-setindexweights
@@ -101,7 +109,9 @@
 
 # If true, use SphinxMWSearch for prefix search instead of the core default.
 # This influences results from ApiOpenSearch.
-$wgEnableSphinxPrefixSearch = false;
+if (!isset($wgEnableSphinxPrefixSearch)) {
+   $wgEnableSphinxPrefixSearch = false;
+}
 
 function efSphinxSearchPrefixSetup() {
global $wgHooks, $wgEnableSphinxPrefixSearch;

-- 
To view, visit https://gerrit.wikimedia.org/r/56202
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icae224795c80a208c0042853963b3c898c67359e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SphinxSearch
Gerrit-Branch: master
Gerrit-Owner: Alexia was...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits