Jump to content
spidometrs

[CONTRIBUTION] Ultimate SEO URLs v2.1 - by Chemo

Recommended Posts

Getting the following errors with the latest version (with the two fixes).

[11-Sep-2018 12:05:52 UTC] PHP Warning:  Use of undefined constant SEO_ENABLED - assumed 'SEO_ENABLED' (this will throw an Error in a future version of PHP) in /home/xxx/public_html/rl/includes/application_top.php on line 298
[11-Sep-2018 12:05:52 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function iconv() in /home/xxx/public_html/rl/includes/classes/seo.class.php:1835
Stack trace:
#0 /home/xxx/public_html/rl/includes/classes/seo.class.php(2036): SEO_URL->strip('Longest Product Na...')
#1 /home/xxx/public_html/rl/includes/classes/seo.class.php(675): SEO_URL->generate_products_cache()
#2 /home/xxx/public_html/rl/includes/application_top.php(301): SEO_URL->__construct('1')
#3 /home/xxx/public_html/rl/index.php(13): require('/home/furwinter...')
#4 {main}
  thrown in /home/xxx/public_html/rl/includes/classes/seo.class.php on line 1835

Any idea how to fix this?

Share this post


Link to post
Share on other sites

It's failing because it can't find the iconv function. Iconv is a php extension so, apparently, that has not been enabled in your php. If your control panel allows you to change extensions you can do it there. Otherwise you will need to ask your host to enable it.

Share this post


Link to post
Share on other sites

@Jack_mcs Thank you. Solved that part instantly. The following persists though.

[11-Sep-2018 17:18:15 UTC] PHP Warning:  Use of undefined constant SEO_ENABLED - assumed 'SEO_ENABLED' (this will throw an Error in a future version of PHP) in /home/xxx/public_html/rl/includes/application_top.php on line 298

This is basically because the module has not been installed correctly. There are no admin settings for it. Previous version did install without any issues. Any ideas what recent change could be causing this?

Share this post


Link to post
Share on other sites

Since you were missing the iconv function I assume your version of php was recently changed. Later versions of php display more warnings than previous ones so that is probably why you are seeing it now. Are you seeing it all of the time or only on the first run?  The following may fix it. Find at the line mentioned in the failure

 if ((!defined(SEO_ENABLED)) || (SEO_ENABLED == 'true')) {

and change it to

 if ((!defined('SEO_ENABLED')) || (SEO_ENABLED == 'true')) {

 

Share this post


Link to post
Share on other sites

@Jack_mcs The server environment has not changed. We just added the PHP extension. The current issue is that the latest version has not installed correctly, i.e. there is no SEO URLs link under Configuration in admin. The settings were there when the previous version was installed. What could be the cause?

The suggested change does fix the undefined constant error. Thank you for that! Need to figure out how to have the module settings back now.

Edited by rulegacy

Share this post


Link to post
Share on other sites

I can't think of a reason why the options are not showing in admin. Are the url's being rewritten? If you know how to do it, please take a look at the database configuration_group and configuration tables to see if there are entries in either for this addon.

Share this post


Link to post
Share on other sites

@Jack_mcs Checked the tables first thing when the lack of add-on settings in admin had been spotted. Nothing was added. URLs are being rewritten correctly. Could you please post the necessary SQL query to do this manually?

Edited by rulegacy

Share this post


Link to post
Share on other sites

The database changes are in the includes/classes/seo.class.php file starting at "function SEO_URL_INSTALLER" so you would need to dig them out. But even if you do that, whatever is stopping it from working will probably prevent future upgrades. I don't have a fix for you so I'm just letting you know to be aware of it.

Share this post


Link to post
Share on other sites

@Jack_mcs Has v16 install been tested on CE? Just tried installing v15. All database tables got added correctly and admin settings are visible. However, the Header Tags SEO and character conversions don't stay in place when selected. Looks like changes to the function that manages DB entries (below) are the cause of our issues with v16. We'd keep v15 but it doesn't work fully either.

                  foreach(array_keys($data) as $columns) {
                    $query .= '`' . $columns . '`, ';
                  }
                  $query = substr($query, 0, -2) . ') values (';
							   
                    foreach($data as $value) {
                      switch ((string)$value) {
                          case 'now()':
                                $query .= 'now(), ';
                                break;
                          case 'null':
                                $query .= 'null, ';
                                break;
                          default:
                                $query .= "'" . $this->Slashes($value) . "', ";
                                break;
                        }
                  }
                  $query = substr($query, 0, -2) . ')';
                } elseif ($action == 'update') {
                  $query = 'UPDATE `' . $table . '` SET ';
                  foreach($data as $columns => $value) {

 

Share this post


Link to post
Share on other sites

Yes, it works fine in CE. I have installed it in many of them though I can't recall if any are running php 7, which I assume you are. If you are and you are able to switch php to version 5.6 it might be worth doing so to isolate the problem. Although @raiwaprovided the updated class file to make it 7.0 compatible and I assume he tested it in a shop running that version first.

Are you seeing any errors in the error_log file or in your control panel? It might be due to some other extension missing from php, though I can't think of which that might be at the moment.

Share this post


Link to post
Share on other sites
53 minutes ago, Jack_mcs said:

Yes, it works fine in CE. I have installed it in many of them though I can't recall if any are running php 7, which I assume you are. If you are and you are able to switch php to version 5.6 it might be worth doing so to isolate the problem. Although @raiwaprovided the updated class file to make it 7.0 compatible and I assume he tested it in a shop running that version first.

Are you seeing any errors in the error_log file or in your control panel? It might be due to some other extension missing from php, though I can't think of which that might be at the moment.

Running this on CE with php 7.2. 

Shopside showing seo urls.

No shop admin side issues

In the error log I see:

 PHP Warning:  Use of undefined constant CHARSET - assumed 'CHARSET' (this will throw an Error in a future version of PHP) in /home/UserName/public_html/includes/classes/seo.class.php on line 1834
 
 That code is:
 
         function strip($string){
                if (CHARSET == 'utf-8') {
                   $string =  iconv("ISO-8859-1", "UTF-8//TRANSLIT", $string);
                }


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

Changing if (CHARSET == 'utf-8') { to if ('CHARSET' == 'utf-8') { should fix it. The ability to use defined names without apostrophes is being removed in php 8 so they are warning about it in 7 to allow time to change the code.

Please post the result of the change here in case others run across this.

Edited by Jack_mcs

Share this post


Link to post
Share on other sites
3 hours ago, Jack_mcs said:

Changing if (CHARSET == 'utf-8') { to if ('CHARSET' == 'utf-8') { should fix it. The ability to use defined names without apostrophes is being removed in php 8 so they are warning about it in 7 to allow time to change the code.

Please post the result of the change here in case others run across this.

I beg to differ. This means you don't have the setting for CHARSET which should be in your language file.

It's telling you the constant isn't defined. If you need to cater for its not being defined, the code would be

if (defined('CHARSET') && CHARSET == 'utf-8') { 

but I don't think that's likely your fix here. Check your language file!


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

PHP 7.2.9 with clean error logs. Admin settings (filter short words, header tags SEO, special characters) keep on getting reset for some reason.

@altoid What PHP extensions are you running?

Share this post


Link to post
Share on other sites
14 hours ago, rulegacy said:

PHP 7.2.9 with clean error logs. Admin settings (filter short words, header tags SEO, special characters) keep on getting reset for some reason.

 @altoid What PHP extensions are you running?

I do not have header tags seo installed.  

regarding extensions, my server into page has a lot of info,  what specifically were you interested in?


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

@altoid Just trying to figure out whether a missing PHP extension is the cause of our issue with the latest add-on version. We are running the following: cli, curl, gd, iconv, mbstring, mysqlnd, posix, xml. This should cover every possible need but who knows...

As for Header Tags SEO, it has been part of core code for a while now. Why not use it?

Share this post


Link to post
Share on other sites
56 minutes ago, rulegacy said:

As for Header Tags SEO, it has been part of core code for a while now. Why not use it?

Just to clarify, Header Tags SEO Reloaded is part of the core code. Not Header Tags SEO. They are different.

Share this post


Link to post
Share on other sites
On 9/13/2018 at 10:28 AM, Jack_mcs said:

Changing if (CHARSET == 'utf-8') { to if ('CHARSET' == 'utf-8') { should fix it. The ability to use defined names without apostrophes is being removed in php 8 so they are warning about it in 7 to allow time to change the code.

Please post the result of the change here in case others run across this.

Hi Jack, I am today getting around to this.  I just made the change you suggested.  I'll monitor the error log for a few days and get back to you.

But I wanted to mention a couple of things.

The error log only showed this warning on one day, 12 Sept.   Why not before and after I don't know.

Secondly, then on 13 Sept I see several PHP notices for this same file.  Only on that day, not before or after.  I don't want to mix issues so I'll list those notices in a separate post once we see what happens over the next few days with issue one.

Thx


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites
On 9/14/2018 at 1:32 PM, rulegacy said:

@altoid Just trying to figure out whether a missing PHP extension is the cause of our issue with the latest add-on version. We are running the following: cli, curl, gd, iconv, mbstring, mysqlnd, posix, xml. This should cover every possible need but who knows...

As for Header Tags SEO, it has been part of core code for a while now. Why not use it?

Working with these extensions is beyond my technical knowledge.  However scanning through my server info, I have those running it seems.


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites
47 minutes ago, altoid said:

The error log only showed this warning on one day, 12 Sept.   Why not before and after I don't know.

Secondly, then on 13 Sept I see several PHP notices for this same file.  Only on that day, not before or after.  I don't want to mix issues so I'll list those notices in a separate post once we see what happens over the next few days with issue one.

Maybe it is due to the caching in this addon? You can clear the cache via the settings and see if that makes a difference In the reporting.

Share this post


Link to post
Share on other sites
23 minutes ago, Jack_mcs said:

Maybe it is due to the caching in this addon? You can clear the cache via the settings and see if that makes a difference In the reporting.

OK...I cleared the cache.  I'll watch the error log and see what happens.  Thx.


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites
33 minutes ago, rulegacy said:

How could we modify the SEO URLs add-on to pull product names from Header Tags SEO Reloaded?

I don't use Header Tags SEO Reloaded so I can't explain how to do that. There is an option for it in Header Tags SEO so you could look up the code I used and change it to load the Reloaded text. 

Share this post


Link to post
Share on other sites
2 hours ago, rulegacy said:

@Jack_mcs How could we modify the SEO URLs add-on to pull product names from Header Tags SEO Reloaded?

@altoid Are you running any other PHP extensions?

sorry, not sure.  There's a lot off info on my server_info page but more than I can sort out the meaning of.


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

Jack, according to the error log so far so good for the undefined constant fix.

Here are the other php notices I see now in the log.

PHP Notice:  Undefined index: path in /home/barkav5/public_html/includes/classes/seo.class.php on line 2605

                if (strpos($this->attributes['SEO_REDIRECT']['URI_PARSED']['path'], '.html') !== FALSE) {
                    $u1 = $this->attributes['SEO_REDIRECT']['URI_PARSED']['path'];

PHP Notice:  Undefined index: path in /home/barkav5/public_html/includes/classes/seo.class.php on line 2642

                if (strpos($this->attributes['SEO_REDIRECT']['URI_PARSED']['path'], '.html') !== FALSE) {
                    $u1 = $this->attributes['SEO_REDIRECT']['URI_PARSED']['path'];
                    
PHP Notice:  Undefined index: path in /home/barkav5/public_html/includes/classes/seo.class.php on line 2713

                if (strpos($this->attributes['SEO_REDIRECT']['URI_PARSED']['path'], '.html') !== FALSE) {
                    $u1 = $this->attributes['SEO_REDIRECT']['URI_PARSED']['path'];
                    
PHP Notice:  Undefined index: path in /home/barkav5/public_html/includes/classes/seo.class.php on line 2743

                                                               else if (($pStart = strpos($this->uri_parsed['path'], "-c-")) !== FALSE) {

 


I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×