Problem installing/upgrading Sitebar
Closed this issue · 20 comments
Hi
I'm having a slight problem trying to upgrade an old 3.4 version of Sitebar. I've not been using sitebar for a while and I've recently upgraded to php7 (on CentOS7). I cloned the current version, moved the directory to the correct location the loaded the sitebar page an got the following message:
Your software version 3.6 differs from the database version 3.4.
I hit the upgrade button and that appeared to work but the message then changed to:
our software version 3.6 differs from the database version 3.5
The nect screen has a 'missing' upgrade button, I can't seem to get past this point. I tried that on my sitebar DB which is on a Percona Galera cluster (version 5.7) without success, I then tried this on a stand-alone percona server (also 5.7) and had the same problem. This also happens if I try to install from scratch with a new database.
The current install software versions are these:
php -v
PHP 7.2.4 (cli) (built: Mar 27 2018 17:23:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologie
nginx -v
nginx version: nginx/1.14.0
php-fpm -v
PHP 7.2.4 (fpm-fcgi) (built: Mar 27 2018 17:25:50)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Have I missed some step during the install or is this a bug?
Thanks in advance.
Bill
Oops, sorry. I forgot to add migration files. Can you pull and try again?
Hi
Thanks for your quick reply, a bit of progress but not quite resolved.
If i try a connection to the existing db/user on my percona cluster I get the following:
Invalid query: 1062: Duplicate entry '' for key 'PRIMARY'
INSERT INTO sitebar_session (uid, code, created, expires, ip) VALUES (5, '', now() , 0, '')
If I try to configure a new db/user on the single percona server I get:
Incorrect datetime value: '0000-00-00 00:00:00' for column 'visited' at row 1 [ UPDATE sitebar_user
SET visited
= NULL WHERE visited
= '0000-00-00 00:00:00']
Duplicate column name 'last_ip' [ ALTER TABLE sitebar_user
ADD last_ip
VARCHAR(15) DEFAULT NULL AFTER visits
]
then a reload shows the following:
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given [database.inc.php line 543]
If I try the setup screen I get the same mysqli message and a login attempt gives the same message for the clean install:
A login attempt gives:
Invalid query: 1062: Duplicate entry '' for key 'PRIMARY'
INSERT INTO sitebar_session (uid, code, created, expires, ip) VALUES (1, '', now() , 0, '')
Let me know if I've missed anything or what I've posted doesn't make sense.
Regards
Bill
I'm afraid you will have to fix your database manually. Can you show me output of select @@sql_mode;
, so I can help you?
Please pull and go to inc/database.inc.php
- change define( 'SB_CURRENT_RELEASE', '3.6');
to 3.5. Reload Sitebar. Downgrade. Change back to 3.6. Upgrade. You may need to do it twice, but it should get you thru.
But the problem with the sitebar_session
is very strange. Primary key is the code, which is just some generated number and IP is took from $_SERVER['REMOTE_ADDR']
, not sure how you can get this.
Here's the output of the command that you wanted:
mysql> select @@sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------------------------------------------------------+
I'm a bit busy this morning and I'll give the other post a go later today, thanks for your help. :)
Regards
Bill
I've just done the steps you suggested and I can now get the initial login page. When I login I'm still getting this:
Invalid query: 1062: Duplicate entry '' for key 'PRIMARY'
INSERT INTO sitebar_session (uid, code, created, expires, ip)
VALUES (5, '', now() , 0, '')
This is with a connection to my single percona server, reloading the page just gives the same error. This was a clean install of sitebar with the steps you suggested and no database defined on the percona server.
Just for the sake of completeness for this server the output of the command you wanted is this:
mysql> select @@sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
That is the same as for the galera cluster servers with the pre-existing db and users.
Regards
Bill
I'm afraid you will have to debug the code in inc/usermanager.inc.php
near line 977. We need var_dump()
of the data being insert into database.
I'd really like to get this working and I don't mind doing whatever is needed but as you can probably guess I'm just a novice.
Where do you want the var_dump() statement in the code, like this:
$this->db->insert('sitebar_session', array(
var_dump(),
'uid' => $this->uid,
'code' => $code,
'created' => array('now' => null),
'expires' => $expires,
'ip' => $_SERVER['REMOTE_ADDR']
));
Also, where does it put the output? I'm assuming that it should produce some output when I go to the sitebar page?
Regards
Bill
After a bit of trail & error, is this what you needed?
potentially sensitive data
Invalid query: 1062: Duplicate entry '' for key 'PRIMARY'
INSERT INTO sitebar_session (uid, code, created, expires, ip)
VALUES (1, '', now() , 0, '')
Can you send me output of?
var_dump($code); var_dump($_SERVER);
Thanks for the data, I deleted the comment with potentially sensitive data but I have it to analyze.
Thanks for that and I look forward to hearing what's wrong, if you need anything else just let me know.
Please try adding in inc/database.inc.php
on line 416:
echo mysqli_character_set_name($this->connection);exit();
. I assume it will be empty. SiteBar does not work properly with character sets, so I cannot fix it in the code now, but you can try replacing this code with: mysqli_set_charset($this->connection, 'utf8');
or use 'latin1'
instead.
OK, I've tried those changes. The character set to my cluster db & the single server was utf8, I reset my sitebar to use the single percona server. I removed the db the recreated it with a charset and collation of latin1/latin1_swedish_ci It connects and gets to the 'create tables' bit, which I do, after that I create a user and try to login and get the following:
array(43) { ["TEMP"]=> string(4) "/tmp" ["TMPDIR"]=> string(4) "/tmp" ["TMP"]=> string(4) "/tmp" ["PATH"]=> string(28) "/usr/local/bin:/usr/bin:/bin" ["HOSTNAME"]=> string(0) "" ["USER"]=> string(5) "nginx" ["HOME"]=> string(16) "/var/cache/nginx" ["HTTP_UPGRADE_INSECURE_REQUESTS"]=> string(1) "1" ["HTTP_CONNECTION"]=> string(10) "keep-alive" ["HTTP_COOKIE"]=> string(40) "SB3NODES=Y1%3AY2%3AY5%3A%21; SB3COOKIE=1" ["HTTP_CONTENT_LENGTH"]=> string(4) "1268" ["HTTP_CONTENT_TYPE"]=> string(86) "multipart/form-data; boundary=---------------------------57715532212130725081208017607" ["HTTP_REFERER"]=> string(66) "http://sitebar.domain.com/command.php?command=Log%20In" ["HTTP_ACCEPT_ENCODING"]=> string(13) "gzip, deflate" ["HTTP_ACCEPT_LANGUAGE"]=> string(26) "en-GB,en-US;q=0.7,en;q=0.3" ["HTTP_ACCEPT"]=> string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8" ["HTTP_USER_AGENT"]=> string(68) "Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0" ["HTTP_HOST"]=> string(30) "sitebar.domain.com" ["REDIRECT_STATUS"]=> string(3) "200" ["REQUEST_SCHEME"]=> string(4) "http" ["SERVER_NAME"]=> string(30) "sitebar.domain.com" ["SERVER_PORT"]=> string(2) "80" ["SERVER_ADDR"]=> string(12) "192.168.1.10" ["REMOTE_PORT"]=> string(5) "41870" ["REMOTE_ADDR"]=> string(12) "192.168.1.40" ["SERVER_SOFTWARE"]=> string(12) "nginx/1.14.0" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" ["DOCUMENT_ROOT"]=> string(12) "/opt/sitebar" ["DOCUMENT_URI"]=> string(12) "/command.php" ["REQUEST_URI"]=> string(12) "/command.php" ["PATH_TRANSLATED"]=> string(12) "/opt/sitebar" ["PATH_INFO"]=> string(0) "" ["SCRIPT_NAME"]=> string(12) "/command.php" ["CONTENT_LENGTH"]=> string(4) "1268" ["CONTENT_TYPE"]=> string(86) "multipart/form-data; boundary=---------------------------57715532212130725081208017607" ["REQUEST_METHOD"]=> string(4) "POST" ["QUERY_STRING"]=> string(0) "" ["SCRIPT_FILENAME"]=> string(24) "/opt/sitebar/command.php" ["FCGI_ROLE"]=> string(9) "RESPONDER" ["PHP_SELF"]=> string(12) "/command.php" ["REQUEST_TIME_FLOAT"]=> float(1524671014.0692) ["REQUEST_TIME"]=> int(1524671014) } string(32) "e502fd9d9e969380aadf2844f024ccc5" Invalid query: 1062: Duplicate entry '' for key 'PRIMARY'
INSERT INTO sitebar_session (uid, code, created, expires, ip)
VALUES (1, '', now() , 0, '')
I'm assuming that it's sufficient for the db to be latin1, is that correct? The information, performance & sys schema are UTF8.
You will have to go deeper, in inc/database.inc.php
method escapeString
, change for a while the only line to return $str;
. After test please return the original line back.
Hi
I've tried this but unfortunately I'm not sure exactly which line you mean, could you point me to a specific line number?
Sure. It is line number 454.
Thanks, changing that line just throws an error, is that what you expected?
454:
455: return $str;
456: {
457: return mysqli_escape_string($this->connection, str_replace('\0','\\0',$str));
458: }
ParseError
syntax error, unexpected 'return' (T_RETURN), expecting function (T_FUNCTION) or const (T_CONST)
You should replace the return, that is now seen on line 457.