DB Error: Duplicate entry 'xxxxxx' for key 'sessions_pkey'

Hi @Umadhar,

It’s session_cookie_path, not session.cookie_path.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Yes, it was my typo, I made changes to session.cookie_path. only.

Any other valuable suggestions? What about on the dedicated IP address to access directly?

I am going to do new installation of the OJS 2.4.7-1 to see if there is any reverse proxy issue to see how it works and come back, So that we can nail this down.

Thanks you and have a good night.

Hi @Umadhar,

You wrote session.cookie_path again – I mean the session_cookie_path setting in your config.inc.php.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Again Typo :(, I did not find session_cookie_path in the config.inc.php, we have only the session_cookie_name. Did you mean shall i set the session_cookie_path explicitly in the config.inc.php?

Even in the SessionManager.inc.php file, we have the following session parameters:

	// Configure PHP session parameters
	ini_set('session.use_trans_sid', 0);
	ini_set('session.save_handler', 'user');
	ini_set('session.serialize_handler', 'php');
	ini_set('session.use_cookies', 1);
	ini_set('session.name', Config::getVar('general', 'session_cookie_name')); // Cookie name
	ini_set('session.cookie_lifetime', 0);
	ini_set('session.cookie_path', $request->getBasePath() . '/');
	ini_set('session.cookie_domain', $request->getServerHost(null, false));
	ini_set('session.gc_probability', 1);
	ini_set('session.gc_maxlifetime', 60 * 60);
	ini_set('session.auto_start', 1);
	ini_set('session.cache_limiter', 'none');

So in the above, do we need to something for the session.cookie_path also?

Hi @gbcriado,

Look in config.TEMPLATE.inc.php for an example of how your session_cookie_path should be configured. If it’s not in your config.inc.php, perhaps that’s because you’re using a configuration file from an older release of OJS?

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher,

How are you?

Yes, i am using the old OJS 2.4.7-1 version, and i found the session_cookie_path in the OJS3 version, I will try out this option today and come back.

I tried seperately and i do not see the duplicate Sessions_Pkey issue but i am having a different issue as following, Could you please trace this out please:

(mysql): SELECT * FROM sessions WHERE session_id = ‘k7uhsgl1sudsp6c24j0o1d56q3’
(mysql): SELECT * FROM site
(mysql): SELECT v.* FROM versions v LEFT JOIN plugin_settings ps ON lower(v.product_class_name) = ps.plugin_name AND ps.setting_name = ‘enabled’ AND ((journal_id = 0) OR v.sitewide = 1) WHERE v.current = 1 AND (ps.setting_value = ‘1’ OR v.lazy_load <> 1)

Fatal error: Call to a member function getId() on null in C:\xampp\htdocs\ojs2\plugins\generic\customLocale\CustomLocalePlugin.inc.php on line 28
(mysql): UPDATE sessions SET user_id = NULL, ip_address = ‘127.0.0.1’, user_agent = ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36’, created = 1497460836, last_used = 1497461939, remember = 0, data = ‘’, domain = ‘ayush.in’ WHERE session_id = ‘k7uhsgl1sudsp6c24j0o1d56q3’

Hi @Umadhar,

Ah, unfortunately the session_cookie_path option will not work in OJS 2.4.7-1.

Can you clarify what version of OJS you’re using on this second installation?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Yes, thats why i did not find the session_cookie_path in the OJS 2.4.7-1 .

For the 2nd installation also i am trying with the OJS 2.4.7-1 as i am afraid of upgrade how many issues i need to face and the problem is not solving hence not going for the upgrade.

What could be the issue for the following Fatal Error:
Fatal error: Call to a member function getId() on null in C:\xampp\htdocs\ojs2\plugins\generic\customLocale\CustomLocalePlugin.inc.php on line 28

Hi @Umadhar,

Your version of plugins/generic/customLocale/CustomLocalePlugin.inc.php seems to be different from the version included with OJS 2.4.7-1. Is it possible that you’re mixing files from different versions?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I did not mix anything except the public/ and files/ folder, and Just the DB. …

I did a check as following for ayushdhara.in:
-bash-4.2$ php tools/upgrade.php check
MIB search path: /var/www/tangenti/data/.snmp/mibs:/opt/alt/net-snmp/usr/share/snmp/mibs
Cannot find module (DCS3RMT-MIB): At line 1 in (none)
Cannot find module (DCS3FRU-MIB): At line 1 in (none)
Cannot find module (MIB-Dell-10892): At line 1 in (none)
Cannot find module (StorageManagement-MIB): At line 1 in (none)
Code version: 2.4.7.1
Database version: 2.4.7.1
Latest version: 3.0.2.0
A newer version is available:
tag: ojs-3_0_2-0
date: 2017-02-01
info: http://pkp.sfu.ca/ojs/
package: http://pkp.sfu.ca/ojs/download/ojs-3.0.2.tar.gz
patch: N/A

Another check on ijapr.in
-bash-4.2$ php tools/upgrade.php check
MIB search path: /var/www/tangenti/data/.snmp/mibs:/opt/alt/net-snmp/usr/share/snmp/mibs
Cannot find module (DCS3RMT-MIB): At line 1 in (none)
Cannot find module (DCS3FRU-MIB): At line 1 in (none)
Cannot find module (MIB-Dell-10892): At line 1 in (none)
Cannot find module (StorageManagement-MIB): At line 1 in (none)
Code version: 2.4.7.1
Database version: 2.4.7.1
Latest version: 3.0.2.0
A newer version is available:
tag: ojs-3_0_2-0
date: 2017-02-01
info: http://pkp.sfu.ca/ojs/
package: http://pkp.sfu.ca/ojs/download/ojs-3.0.2.tar.gz
patch: N/A

The new installation which i am doing version check as follows and this is on my local machine in xamp server:
php tools/upgrade.php check

(mysql): SET NAMES ‘utf8’


(mysql): SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ‘announcementfeedplugin’ AND journal_id = ‘0’


(mysql): SELECT * FROM versions WHERE current = 1


(mysql): SELECT * FROM versions WHERE current = 1 AND product_type = ‘core’ AND product = ‘ojs2’


(mysql): SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ‘backupplugin’ AND journal_id = ‘0’


(mysql): SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ‘booksforreviewplugin’ AND journal_id = ‘0’


(mysql): SELECT setting_name, setting_value, setting_type FROM plugin_settings WHERE plugin_name = ‘browseplugin’ AND journal_id = ‘0’

PHP Fatal error: Call to a member function getId() on null in C:\xampp\htdocs\ojs2\plugins\generic\customLocale\CustomLocalePlugin.inc.php on line 26

Fatal error: Call to a member function getId() on null in C:\xampp\htdocs\ojs2\plugins\generic\customLocale\CustomLocalePlugin.inc.php on line 26

Not sure what the application is expecting here to be set.

Hi @Umadhar,

What is on line 26 in plugins\generic\customLocale\CustomLocalePlugin.inc.php?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

at 26th Line: $journalId = $journal->getId();

Here is that function code:

function register($category, $path) {
	if (parent::register($category, $path)) {
		if ($this->getEnabled()) {
			// Add custom locale data for already registered locale files.
			$locale = AppLocale::getLocale();
			$localeFiles = AppLocale::getLocaleFiles($locale);
			$journal = Request::getJournal();
			$journalId = $journal->getId();
			$publicFilesDir = Config::getVar('files', 'public_files_dir');
			
			$customLocalePathBase = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR;

			import('lib.pkp.classes.file.FileManager');
			$fileManager = new FileManager();
			foreach ($localeFiles as $localeFile) {
				$customLocalePath = $customLocalePathBase . $localeFile->getFilename();
				if ($fileManager->fileExists($customLocalePath)) {
					AppLocale::registerLocaleFile($locale, $customLocalePath, true);
				}
			}

			// Add custom locale data for all locale files registered after this plugin
			HookRegistry::register('PKPLocale::registerLocaleFile', array(&$this, 'addCustomLocale'));
		}

		return true;
	}
	return false;
}

What could be the issue?

Hi @Umadhar,

I’m afraid this isn’t making much sense to me – your installation is an old, stable version of OJS and it’s now showing two errors that I haven’t seen before. Either something is unusual about your server environment, or something is unusual in the way you’ve installed OJS. Is it possible for you to try on another server environment with a fresh installation?

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher,

Hope you are doing good.

Sorry for not responding till now, i did a try in my local and with new hosting, The issue was gone and it did not show up, As you mentioned earlier, it is with the hosting issue only not sure how, i could not figure it out as i have taken long time to set it up.

I would like to thank you for your continued observation and guidance on this without giving up any point of time.

I will start upgrading to the newer versions soon but i am afraid how many issues i will come across with that activity which i need to do for 3 journal systems. If i come across any issues i will be coming to you again :slight_smile:

Thanks again.

  • Umadhar

me got the htaccess file and how to add php_value session.auto_start 0;
?

hello
can you help me to add php_value session.auto_start 0; in htaccess
mail: pmuhammed707@gmail.com

Hi @P_Muhammed,

This is a question for your service provider – it’s not really related to OJS. You might be able to find some useful information on StackOverflow.com.

Regards,
Alec Smecher
Public Knowledge Project Team

i solved the problem
thanks for your response

I got the same error DB Error: Duplicate entry ‘be226c0ugvgbbglukd5lgj1tm1’ for key ‘sessions_pkey’.I have Checked the Php info it show session auto start off.I also Check the error Log it gives below error

[09-Jun-2018 06:30:40 America/Toronto] ojs2 has produced an error
Message: WARNING: ini_set(): A session is active. You cannot change the session module’s ini settings at this time
In file: /home/jeths103/public_html/lib/pkp/classes/session/SessionManager.inc.php
At line: 38
Stacktrace:
Server info:
OS: Linux
PHP Version: 5.6.36
Apache Version: N/A
DB Driver: mysql
DB server version: 5.5.59-cll
[09-Jun-2018 06:30:40 America/Toronto] NOTICE: A session had already been started - ignoring session_start() (/home/jeths103/public_html/lib/pkp/classes/session/SessionManager.inc.php:60)
[09-Jun-2018 06:30:43 America/Toronto] ojs2 has produced an error
Message: WARNING: array_shift() expects parameter 1 to be array, null given
In file: /home/jeths103/public_html/classes/article/Article.inc.php
At line: 142
Stacktrace:
Server info:
OS: Linux
PHP Version: 5.6.36
Apache Version: N/A
DB Driver: mysql
DB server version: 5.5.59-cll

MY OJS Version is 2.4.5.0.Please Help in this problem

Hi @Sanjeev_Kumar,

I would suggest upgrading if possible – OJS 2.4.5 is by now quite old.

Check further up in your log file to see if there are any more entries from the same time; there might be something else that helps narrow down where the session was created.

Regards,
Alec Smecher
Public Knowledge Project Team