Error: Use of undefined constant DS

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
bscivolette
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 10 Jun 2015, 21:01

Error: Use of undefined constant DS

Post by bscivolette »

Good Afternoon,

I recently enabled the Open Graph plugin and I found that I receive the following error on every page. Any idea what might be causing it?

Notice: Use of undefined constant DS - assumed 'DS' in C:\inetpub\wwwroot\public\plugins\content\phocaopengraph\phocaopengraph.php on line 114
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Error: Use of undefined constant DS

Post by Jan »

Hi, which version of Joomla! and which version of the plugin you are using, seems like incompatible versions are used.

Jan
If you find Phoca extensions useful, please support the project
User avatar
trombini
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 31 Jan 2016, 19:27
Location: Sao Caetano do Sul - SP - Brazil
Contact:

Re: Error: Use of undefined constant DS

Post by trombini »

Hello I´m new here in this forum but of Joomla not so dumie ;)
Well I had the same problem and after see a lot of post in many websites about this problem here is what I found and hope it help.
Have a time that the DS constant is not more used in Joomla system and is necessary to chage it for DIRECTORY_SEPARATOR
So this plugin in the file root\plugins\content\phocaopengraph\phocaopengraph.php from line 257 to 267 is possible to sse that is used DS. So only replace it with DIRECTORY_SEPARATOR save and upload.
Is a rule in the Joomla development that was not updated in this plugin here. So if anybody knows any developer here please follow up.
Thanks and if I gave some wrong description, please fix me :)
Regards,

Leandro.
HerKle
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 31 Jan 2016, 15:47

Re: Error: Use of undefined constant DS

Post by HerKle »

Hi, I had the same problem today and found this solution – together with the message "The DS constant has been removed in Joomla 3" – on web357[dot]eu to fix it until the plugin follows Joomla's new rules:

Code: Select all

<?php
/* BEGIN: for joomla 3 projects */
JLoader::import( "joomla.version" );
$version = new JVersion();
if (!version_compare( $version->RELEASE, "2.5", "<=")) :
	if (!defined("DS")):
		define("DS", DIRECTORY_SEPARATOR);
	endif;
endif;
/* END: for joomla 3 projects */
?>
This worked for me.
Regards,
Herbert
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Error: Use of undefined constant DS

Post by Jan »

Hi, the standard way is:

- correct all DS to /
- if this is not possible because e.g. of time issues - quick fixes to make the extension working, this code is added:

if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);

This part added to the header of main extension file solves the problem. You don't need to add specific IF conditions, this line solves it everything.

If this line is in 2.5, nothing will change as the DS is defined there, so this line will be ignored
If this line is in 3, the DS will be defined - so in fact - on constant is defined and such solves all the problems.

In this file:
plugins\content\phocaopengraph\phocaopengraph.php

Quick fix:
if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);

or update to the latest version - for now, it is 3.0.4: https://www.phoca.cz/download/category/6 ... aph-plugin

Let me know if updating to the latest helps (the DS was changed to /)

Thank you, Jan
If you find Phoca extensions useful, please support the project
Post Reply