Announcement

#1 2019-09-15 18:43:07

mjakobi
Member
2019-06-10
5

Right way of making changes to PHP-scripts

Hi all,

I've read many posts here saying 'Don't modify core files of PiWiGo bacause you'll probably lose your changes with the next update'. Makes absolutely sense so far.
But what is the right way when I need to make a change to a .php-file?

I've already learned that with .tpl-files it's quite easy to substitute a template with a customised one. But is there a similar way for php-files?

An example to make it more specific:
As I wrote in another post I'd like to show the link "Mail to webmaster" to all users, even to guests. To achieve this I'd need to delete (or comment out) three lines in page_tail.php. How do I do this without editing the .php-file directly?

Can anyone point me into the right direction, please?


Many thanks in advance!
Markus



Piwigo version: 2.9.5
PHP version: 7.2
MySQL version: 5.7
Piwigo URL: http://test.freizeit.pictures

Offline

 

#2 2019-09-25 19:26:56

erAck
Only trying to help
2015-09-06
2023

Re: Right way of making changes to PHP-scripts

mjakobi wrote:

But what is the right way when I need to make a change to a .php-file?

Depends on your expertise..

The most manageable (if it's more than one patch or a more complicated patch) but not easiest way is to add each release's unzipped files into a Git repository and store individual changes as StGit patches or with git stash; when a new release becomes available add all those files to the repository and then apply the StgGit patches and/or git stash objects. Resolve source code conflicts as they arise and commit the resulting (modified) changes as new StGit patches or git stash objects, resetting HEAD, to be used for the next upgrade.

Even better instead of creating your repository of releases could be to track the original Piwigo Git repository and apply your patches against the release tag's commit chain, which might help git to solve some possible merge conflicts in a 3-way merge, and copy the modified files, and again, resetting HEAD, store the new changes as StGit patches or git stash objects for the next upgrade.

If all that is mumbo-jumbo to you or there's only one or two files to change, make a copy of each to be modified file in its original state, for example

cp -p filename.php filename.php.orig

then modify filename.php and when done produce a patch file with

diff -up filename.php.orig filename.php >filename.php.patch

which after upgrading to a new release can be applied with

patch <filename.php.patch

and again any conflicts arising must be resolved and the resulting diff be stored as a new patch for the next upgrade.


Running Piwigo at https://erack.net/gallery/

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact