[dev] Best practice to add my changes and keep the ability to install future updates
Michael J Rubinsky
mrubinsk at horde.org
Mon Jan 11 03:33:20 UTC 2016
Quoting Hendrik <lists at object.earth>:
> 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?
For something like this, that has no hook or other possibility to
customize, you will need to create/maintain your own patches and
re-apply after updating. If you have done a lot of customization you
could utilize Git to manage this.
--
mike
The Horde Project
http://www.horde.org
https://www.facebook.com/hordeproject
https://www.twitter.com/hordeproject
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5751 bytes
Desc: S/MIME Signature
URL: <http://lists.horde.org/archives/dev/attachments/20160110/0ad9c63e/attachment.bin>
More information about the dev
mailing list