THIS IS A RAW UNEDITED REPLY (it needs work for sure

)
Why FIND must not be forced to include the start of the line:There are several obscure reasons I could use but I will not use those in my arguement. There are so many very legitmate reasons that it is not necessary for me to stretch things.
First the principal goal of FIND to use unique elements of a line (or block of lines) to find the part of the code you are looking. We do this with the knowledge that lines may have been changed by a previous MOD installation or we may be looking for lines in a non-subSilver TPL file.
It is completely reasonable to assume that any part of a line may have changed from the default phpBB, whether it be the beginning, middle, or end of the line. Therefore it is necessary to limit the FIND to only what is unique about it and eliminate all other text that could possiblely causes a FIND to fail. But one must remember to not be overzealous in trimming out text or must include additional lines in the FIND to assure that the correct line(s) will be found.
Some folks, especially those that like to comment out a lot of code, support the notion that FIND must be forced to include all of the text from the start of a line until the desired unique element is encountered. Unfortunately this idea is flawed and will needlessly result in FINDs failing to do their job. Several examples follow.
Conditional statementsIn PHP files the most likely instance where the beginning of a line will change is on any conditional statement. For example, it is entirely like that you may be seeing a line like this....
- Code: Select all
if ( $mode == 'editpost' || $mode == 'delete' || $mode == 'poll_delete' )
...but another MOD has changed it somethign like this...
- Code: Select all
if (( $mode == 'editpost' || $mode == 'delete' || $mode == 'poll_delete' ) && ($foo))
...therefore the best way to find this line possiblely may be to reduce the search string down...
- Code: Select all
$mode == 'delete' || $mode == 'poll_delete'
...but there is no doubt here that forcing FIND to include the beginning of the line is going to cause it fail.
Similar things can be said for "while loops" or with variable assignment. For example you may have a while loop that has changed from...
- Code: Select all
while ( $end_counter && $end_html < strlen($message) )
...to...
- Code: Select all
while ( ($end_counter && $end_html < strlen($message)) && ($foo == $bar) )
You may also have a variable assignment like this...
- Code: Select all
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $post_info);
...that gets changed to...
- Code: Select all
$is_auth = ($foo) ? auth(AUTH_ALL, $forum_id, $userdata, $post_info) : $bar ;
...in both these examples there are plenty of unique elements to search for, but forcing the requirement of the beginning of the line will make the FIND fail when it is totally preventable.
SQL statementsTo a lesser degree, SQL statements are also susceptible. Take this for example...
- Code: Select all
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id
$limit_posts_time
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY p.post_time $post_time_order
LIMIT $start, ".$board_config['posts_per_page'];
...in this frequently modified section of code, if anything inserted before u.username or POSTS_TABLE or if the code following WHERE, ORDER BY, OR LIMIT is modified only slightly then the FIND could needlessly fail. For the most part though, authors will probably insert new code in the middle of the line rather than the start, but there is no guarantee. I prefer to give authors as much freedom as possible so they may order things however they want.
The big one! TPL filesThe greatest need for not forcing the use of the start of the line comes from TPL files. It is undeniable that many user have more than just the default subSilver installed. Some of these templates are more similar to subSilver than others. Even an unmodified non-subSilver TPL can have problems being MODed unless there are specific instructions for it. But the goal remains the same of trying to install MODs into all templates even if they are different from subSilver and modified as well.
By forcing the inclusion of the start of the line then you are going to be requiring the inclusion of items such as widths, colspans, alignments, and classes. This is pretty much guaranteeing failure in anything but subSilver. I simply cannot allow this to happen.
But requiring these will even create problems for subSilver once it has been modified. It means that in the following line...
- Code: Select all
<td width="150" align="left" valign="top" class="{postrow.ROW_CLASS}"><span class="name"><a name="{postrow.U_POST_ID}"></a><b>{postrow.POSTER_NAME}</b></span><br /><span class="postdetails">{postrow.POSTER_RANK}<br />{postrow.RANK_IMAGE}{postrow.POSTER_AVATAR}<br /><br />{postrow.POSTER_JOINED}<br />{postrow.POSTER_POSTS}<br />{postrow.POSTER_FROM}</span><br /></td>
...if a previous MOD has changed anything before {postrow.U_POST_ID} (which is the first unique thing about the line) then your FIND will fail. There are just too many elements that people may want to change.
Adding comments to the codeAs I've said before, the core phpBB core code is like a map. We rely on various landmark to FIND our way around. Some folks have the practice of automatically including in their MODs large blocks of duplicate code that matches the original phpBB core code, except it has comments in front. The intention is good, allowing users that manually edit files can see what was changed. However the effect is like adding extra landmarks that don't really exist into our map! Without some way of distinguishing these blocks from the rest of the code, then integrity of our map degrades rapidly. To allow for this practice there must be a standard adopted to inform us that we must not use these lines in our FIND.
-Nuttzy
