26.4. How to install patches and correct errors

From time to time it occurs that some functions of a certain PHP-Nuke version contain bugs, or that some others are in need of an update. Here we will briefly discuss the most common problems that arise in such situations.

TipUse the Forums!
 

If you are in search of a solution to a common problem, your first move should be to consult a Forum, like those of the authors: PHP-Nuke Forum of spaghettibrain (Claudio), or PHP-Nuke Forum of karakas-online (Chris). Of course, you should always use the search function of the Forums first, before asking a question that has been possibly asked (and answered) many times already.

Here is an example of the installation of a patch:

Generally a patch consists of one or more files that will overwrite the buggy existing ones. The “installation” of the patch is thus nothing more than the simple overwriting of those files: foobar.php (12Kb) will overwrite the existing file foobar.php (13Kb) (notice that the name is the same, but the size differs). It is a good practice not to overwrite the old file, thus deleting it completely, but to move it to something like foobar.old or foobar.orig, so that you can easily restore it, should the new version present unexpected problems.

Example of a manual correction in the code:

Suppose our file consists of a number of lines:

$qdb = "WHERE topic='$new_topic'";
$sql_a = "SELECT topictext FROM ".$prefix."_topics WHERE topicid='$new_topic'";
$result_a = $db->sql_query($sql_a)
$row_a = $db->sql_fetchrow($result_a);
$numrows_a = $db->sql_numrows($result_a);
$topic_title = $row_a[topictext];

and we are told that we must replace the fourth one with

$result_a = $db->sql_query($sql_a);

then, after we do this and save the file, our new file will look like:

$qdb = "WHERE topic='$new_topic'";
$sql_a = "SELECT topictext FROM ".$prefix."_topics WHERE topicid='$new_topic'";
$result_a = $db->sql_query($sql_a);
$row_a = $db->sql_fetchrow($result_a);
$numrows_a = $db->sql_numrows($result_a);
$topic_title = $row_a[topictext];

(Can you see the difference? )

Most decent text editors (see Chapter 11) will display the line number for your orientation during such operations.