Page MenuHomePhabricator

SFAutoeditAPI: makeRandomNumber() no longer member of SFUtils but SFAutoeditAPI itself
Closed, InvalidPublic

Description

In SemanticForms/includes/SF_AutoeditAPI.php there are two calls to
SFUtils::makeRandomNumber()

This function is no longer a member of SFUtils (since commit https://phabricator.wikimedia.org/rESFOd448b005c1688437b6392577625dc94497a6fe24) but is a static member of SFAutoeditAPI itself.

So the code has to be changed to reflect this. My solution for SF 3.6 was this:

--- extensions/SemanticForms/includes/SF_AutoeditAPI.php.orig   2016-06-23 08:58:30.385285472 +0200
+++ extensions/SemanticForms/includes/SF_AutoeditAPI.php        2016-06-23 09:04:18.110354976 +0200
@@ -709,7 +709,7 @@
                                $isRandom = true;
                                $randomNumHasPadding = array_key_exists( 2, $matches );
                                $randomNumDigits = ( array_key_exists( 3, $matches ) ? $matches[3] : $randomNumDigits );
-                               $titleNumber = SFUtils::makeRandomNumber( $randomNumDigits, $randomNumHasPadding );
+                               $titleNumber = $this->makeRandomNumber( $randomNumDigits, $randomNumHasPadding );
                        } else if ( preg_match( '/{num.*start[_]*=[_]*([^;]*).*}/', $targetName, $matches ) ) {
                                // get unique number start value
                                // from target name; if it's not
@@ -753,7 +753,7 @@
                                        if ( $numAttemptsAtTitle > 20 ) {
                                                $randomNumDigits++;
                                        }
-                                       $titleNumber = SFUtils::makeRandomNumber( $randomNumDigits, $randomNumHasPadding );
+                                       $titleNumber = $this->makeRandomNumber( $randomNumDigits, $randomNumHasPadding );
                                }
                                // If title number is blank, change it to 2;
                                // otherwise, increment it, and if necessary

I chose to use $this-> but maybe self:: or static:: are better ways to do it?

Event Timeline

Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJun 23 2016, 7:25 AM
Yaron_Koren closed this task as Invalid.Jun 23 2016, 11:25 AM

This was already fixed, on June 1 - you probably just need to upgrade your code. Sorry abut the problem.