Topic: Generic Mod structure
Hi all,
has anybody noticed that in order to correclty apply all changes easily it would be better to state the mod lines in reverse order?
That is, instead of:
#
#---------[ 5. FIND (line 127) ]----------------------------------------------
#
$cur_closed = $_POST['closed'][$id];
#
#---------[ 6. AFTER, ADD ]---------------------------------------------------
#
$cur_locked = $_POST['locked'][$id];
#
#---------[ 7. FIND (line 141) ]----------------------------------------------
#
if ($cur_admmod_only != '1') $cur_admmod_only = '0';
#
#---------[ 8. AFTER, ADD ]---------------------------------------------------
#
if ($cur_locked != '1') $cur_locked = '0';
#
#---------[ 9. FIND (line 146) ]----------------------------------------------
#
$db->query('UPDATE '....
#
#---------[ 10. REPLACE WITH ]------------------------------------------------
#
$db->query('UPDATE '...
#
writing it so:
#
#---------[ 5. FIND (line 146) ]----------------------------------------------
#
$db->query('UPDATE '....
#
#---------[ 6. REPLACE WITH ]------------------------------------------------
#
$db->query('UPDATE '...
#
#---------[ 7. FIND (line 141) ]----------------------------------------------
#
if ($cur_admmod_only != '1') $cur_admmod_only = '0';
#
#---------[ 8. AFTER, ADD ]---------------------------------------------------
#
if ($cur_locked != '1') $cur_locked = '0';
#
#---------[ 9. FIND (line 127) ]----------------------------------------------
#
$cur_closed = $_POST['closed'][$id];
#
#---------[ 10. AFTER, ADD ]---------------------------------------------------
#
$cur_locked = $_POST['locked'][$id];
#
This way you make sure that when people reach line 127 (after editing lines afterwards), the target code will still be there.
Of course, everyone can do as it pleases him/her, but assuming it's all the same for developers, and if and only if nobody oposes, I propose changing the order in future releases.
If there's a reason why it's done like it's done, I'd like to hear it, since I am curious and I've already learnt a lot about PHP browsing through the code of punBB and some of its mods. Learning doesn't hurt... too much
Greets,
Marc