[dev] Best practice to add my changes and keep the ability to install future updates

Hendrik lists at object.earth
Mon Jan 11 01:29:36 UTC 2016


Hello List,


thank you very much for all of your efforts, creating and maintaining
this amazing software project.

I am new to Horde and its components. Setting it up was easier than
expected and things work just fine.

Now I would like to extend and change some functionality, but I am
lacking information about the best practices.
And that is why I am writing to you.

For example, I would like to change this function:

Horde_Auth::genRandomPassword()

found in php/Horde/Auth.php at line 316:

    /**
     * Generates a random, hopefully pronounceable, password. This can
be used
     * when resetting automatically a user's password.
     *
     * @return string A random password
     */
    public static function genRandomPassword()
    {
        /* Alternate consonant and vowel random chars with two random
numbers
         * at the end. This should produce a fairly pronounceable
password. */
        return substr(self::CONSONANTS, mt_rand(0,
strlen(self::CONSONANTS) - 1), 1) .
            substr(self::VOWELS, mt_rand(0, strlen(self::VOWELS) - 1), 1) .
            substr(self::CONSONANTS, mt_rand(0, strlen(self::CONSONANTS)
- 1), 1) .
            substr(self::VOWELS, mt_rand(0, strlen(self::VOWELS) - 1), 1) .
            substr(self::CONSONANTS, mt_rand(0, strlen(self::CONSONANTS)
- 1), 1) .
            substr(self::NUMBERS, mt_rand(0, strlen(self::NUMBERS) - 1),
1) .
            substr(self::NUMBERS, mt_rand(0, strlen(self::NUMBERS) - 1), 1);
    }




Of course I could simply change this function so it does exactly what I
want.
But as soon as I install an update, I assume, my changes might get undone.

Since this function does not contain a hook I am wondering, what's the
best practice to add my changes and keep the ability to install future
updates?


Thank you for your time and attention,

Hendrik


More information about the dev mailing list