/**
* Get a message from the language file, for the content
+ *
+ * @deprecated in 1.18; use wfMessage()
*/
function wfMsgNoDBForContent( $key ) {
+ wfDeprecated( __FUNCTION__ );
global $wgForceUIMsgAsContentMsg;
$args = func_get_args();
array_shift( $args );
* @param $key String
*/
function wfMsgWeirdKey( $key ) {
+ wfDeprecated( __FUNCTION__ );
$source = wfMsgGetKey( $key, false, true, false );
if ( wfEmptyMsg( $key ) ) {
return '';
}
} else {
if ( !$suppressCount ) {
+ // E_DEPRECATED is undefined in PHP 5.2
+ if( !defined( 'E_DEPRECATED' ) ){
+ define( 'E_DEPRECATED', 8192 );
+ }
$originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED ) );
}
++$suppressCount;
}
/**
- * Sleep until the worst slave's replication lag is less than or equal to
- * $maxLag, in seconds. Use this when updating very large numbers of rows, as
+ * Modern version of wfWaitForSlaves(). Instead of looking at replication lag
+ * and waiting for it to go down, this waits for the slaves to catch up to the
+ * master position. Use this when updating very large numbers of rows, as
* in maintenance scripts, to avoid causing too much lag. Of course, this is
* a no-op if there are no slaves.
- *
- * Every time the function has to wait for a slave, it will print a message to
- * that effect (and then sleep for a little while), so it's probably not best
- * to use this outside maintenance scripts in its present form.
- *
- * @param $maxLag Integer
+ *
+ * @param $maxLag Integer (deprecated)
* @param $wiki mixed Wiki identifier accepted by wfGetLB
* @return null
*/
-function wfWaitForSlaves( $maxLag, $wiki = false ) {
- if( $maxLag ) {
- $lb = wfGetLB( $wiki );
- list( $host, $lag ) = $lb->getMaxLag( $wiki );
- while( $lag > $maxLag ) {
- wfSuppressWarnings();
- $name = gethostbyaddr( $host );
- wfRestoreWarnings();
- if( $name !== false ) {
- $host = $name;
- }
- print "Waiting for $host (lagged $lag seconds)...\n";
- sleep( $maxLag );
- list( $host, $lag ) = $lb->getMaxLag();
- }
+function wfWaitForSlaves( $maxLag = false, $wiki = false ) {
+ $lb = wfGetLB( $wiki );
+ // bug 27975 - Don't try to wait for slaves if there are none
+ // Prevents permission error when getting master position
+ if ( $lb->getServerCount() > 1 ) {
+ $dbw = $lb->getConnection( DB_MASTER );
+ $pos = $dbw->getMasterPos();
+ $lb->waitForAll( $pos );
}
}