Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pwg_log is not checking if given $page['section'] is part of the enum in the table #945

Closed
pstimpel opened this issue Nov 25, 2018 · 1 comment

Comments

@pstimpel
Copy link
Contributor

pstimpel commented Nov 25, 2018

There are plugins out there setting $page['section'] to something own, like the the Guestbook plugin or the Contactform.

This causes problems with pwg_log. pwg_log only checks of a section was given, and if so it pushed the new row to the database. Now mysql.history.section is an enum with the members

'categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats','additional_page'

This means, the insert fails and prints an ugly warning to the Piwigo page.

Of course IMO it is bad style to abuse section this way, maybe this is based on historic grounds. However, the issue is there and is live. I guess people will not recognize it since it is just a warning which is not shown in most productive environments.

`Warning: [mysql error 1265] Data truncated for column 'section' at row 1

INSERT INTO piwigo_history
(
date,
time,
user_id,
IP,
section,
category_id,
image_id,
image_type,
format_id,
auth_key_id,
tag_ids
)
VALUES
(
CURRENT_DATE,
CURRENT_TIME,
2,
'192.168.0.22',
'guestbook',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
)
; in /media/sf_piwigo/include/dblayer/functions_mysqli.inc.php on line 845`

But it is still a bug. In my opinion this should be fixed by a check inside pwg_log, if the given section is part of the enum. If it is not, just null it and pwg_log will go on. By doing so, all these plugins don't have to be rewritten.

BR,
Peter

@pstimpel
Copy link
Contributor Author

Wrote a fix and made a pull request, maybe this helps.

@plegall plegall closed this as completed in dc40d19 Apr 2, 2019
plegall added a commit that referenced this issue Apr 2, 2019
Hood-fr added a commit to Hood-fr/Piwigo that referenced this issue May 5, 2019
* 2.9:
  cherry-pick 1 commit from translation
  fixes Piwigo#988 no more warning on PHP 7.3 (only for branch 2.9, branch master will get a new version of jshrink)
  next release is 2.9.5
  cherry-pick 16 commits from translation
  (cp dc40d19) fixes Piwigo#945 pwg_log automatically creates a new history.section in the enum, when needed
  (cp 16abd1a) solves issue 945, if plugin developers add their own sections, Piwigo tries to put them into history table. Since the section column is an enum, php issued a warning.
  (cp ab46632) Revert "Include pwg_token in user list POST request (Fixes Piwigo#748) (Piwigo#866)"
  (cp 1646f5e) fixes Piwigo#998 temporary fix for Piwigo Remote Sync compatibility
  (cp b29ab34) fixes Piwigo#972 use an alternative algorithm to discover number of future orphans, with very large albums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants