• Problem Solving – verse 15 – The right change?

    Problem Solving – verse 15 – The right change?
    4. We know you're really busy,
    you have a full work load
    but please try to remember...
    "Are you sure you changed the code?"
    

    Summary

    Using a Windows editor against an ftp’ed file can lead to unexpected results!

    Background

    I recently edited a file using FileZilla to make a one line change to undo an erroneous fix to one of my plugins ( oik ). Rather than simply change the line in error, I decided to comment it out using a double slash comment then add the replacement line.


    // $args['ID'] = $post_id;
    $args['post_parent'] = $post_id;
     

    It looked like I’d made the right change. But it wasn’t fixing the problem. The same code change was working locally, but it wasn’t making any difference on the real website.

    I thought that perhaps there was some other change that I’d made locally which wasn’t duplicated on the server. So I extracted the code and ran a file compare. Then it became obvious.

    expected source verses unexpected two line double slash comment

    I thought I’d edited the file to create a single double slash comment for the original line and added a new line. But I hadn’t noticed that the file I was editing had Unix line endings, so the new line wasn’t really a new line. Had I simply changed the original line this problem would not have occurred.

    Reproducing the problem

    Having fixed the problem I edited the file again. This time the Unix line endings had been fixed. So I reproduced the problem in another file.

    1. Choose a file in FileZilla
    2. Select View/Edit
    3. Change the file
    4. Save to the server
    5. Edit the file in WordPress plugin editor – to show it’s not right
    6. Edit the file again using FileZilla

    editing a unix line ending file in Windows

    editing in the plugin editor

    re-editing the unix file in Windows – CRLF OK now

    Moral of the story

    Check that the code change that you made is really the change you intended to make.

    See also


    , ,

    Published:

    Last updated:

    December 21, 2014

Categories

Tide times from tidetimes.org.uk

Tide Times & Heights for Langstone Harbour on
9th August 2022
02:38 Low Tide ( 1.67m )
09:44 High Tide ( 4.32m )
15:10 Low Tide ( 1.73m )
22:13 High Tide ( 4.53m )

Tide times from tidetimes.org.uk

Tide Times & Heights for Northney on
9th August 2022
02:47 Low Tide ( 1.11m )
09:54 High Tide ( 4.08m )
15:15 Low Tide ( 1.16m )
22:14 High Tide ( 4.33m )
WordPress version:6.0.1
Gutenberg version:13.7.3

[clone]

[cloned]