-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fix all reported bugs #53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this awesome contribution! Some minor changes are needed.
composer.json
Outdated
"preferred-install": "dist" | ||
}, | ||
"type": "prestashop-module" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be kept
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced
config.xml
Outdated
<displayName><![CDATA[Google sitemap]]></displayName> | ||
<version><![CDATA[4.0.0]]></version> | ||
<description><![CDATA[Generate your Google sitemap file]]></description> | ||
<author><![CDATA[Prestashop]]></author> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small typo here
-<author><![CDATA[Prestashop]]></author>
+<author><![CDATA[PrestaShop]]></author>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
config.xml
Outdated
<limited_countries></limited_countries> | ||
</module> | ||
</module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a trailing LF here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry I might be wrong but I cant see the trailing LF 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, fixed here: 724d539
gsitemap-cron.php
Outdated
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2018 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is header for Core files (which are licensed using OSL-3.0 license). Please use the modules header (licensed AFL-3.0) instead: https://devdocs.prestashop.com/1.7/development/coding-standards/#module-files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2018 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the file header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2018 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
views/index.php
Outdated
* | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2018 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2018 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
* International Registered Trademark & Property of PrestaShop SA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
views/templates/admin/index.php
Outdated
* | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2018 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
views/templates/index.php
Outdated
* | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2007-2018 PrestaShop SA | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about the header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
public function emptySitemap($id_shop = 0) | ||
{ | ||
if (!isset($this->context)) { | ||
$this->context = new Context(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be Context::getContext()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not change anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I ? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nop :)
$(document).ready(function() { | ||
|
||
if ($('.gsitemap_metas:checked').length == $('.gsitemap_metas').length) | ||
$('.check').parent('label').children('span').html("{l s='uncheck all' d='Modules.Gsitemap.Admin'}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove tabs in this file please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Thanks a lot again! Awesome work! |
gsitemap.php
Outdated
$this->name = 'gsitemap'; | ||
$this->tab = 'seo'; | ||
$this->version = '4.0.0'; | ||
$this->author = 'Prestashop'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the comment in config.xml, can you please set PrestaShop
in author?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ofc. 👍
@LouiseBonnard can you please have a look at the domains used in this PR? |
@Quetzacoalt91, I can see no domain used here, nor strings to check. Is it? |
They are in the file gsitemap.php, for instance: https://github.com/PrestaShop/gsitemap/pull/53/files#diff-3133bb1114a2b4792863d1d6ec46d8d6R51 |
gsitemap-cron.php
Outdated
@@ -31,27 +31,30 @@ | |||
include(dirname(__FILE__).'/../../config/config.inc.php'); | |||
include(dirname(__FILE__).'/../../init.php'); | |||
/* Check to security tocken */ | |||
if (substr(Tools::encrypt('gsitemap/cron'), 0, 10) != Tools::getValue('token') || !Module::isInstalled('gsitemap')) | |||
die('Bad token'); | |||
if ('cli' != php_sapi_name()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
In some server configuration, when PHP is running in cgi mode per exemple php_sapi_name() will returns cli. You should use the Tools::isPHPCLI() method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the fix correct?
The use of function header() is forbidden; use Tools::redirect() instead
Ping @eternoendless @Quetzacoalt91 @PierreRambaud I made a lot of changes in order to improve the module further. I hope you will consider to merge my changes. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job @mreker! Only a couple small fixes left!
gsitemap-cron.php
Outdated
include(dirname(__FILE__).'/../../config/config.inc.php'); | ||
include(dirname(__FILE__).'/../../init.php'); | ||
/* Check to security tocken */ | ||
if ('cli' != Tools::isPHPCLI()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tools::isPHPCLI()
returns a boolean, so you should change the value your comparing to appropriately.
Either one of these would be fine:
if (!Tools::isPHPCLI()) {
if (false === Tools::isPHPCLI()) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
gsitemap.php
Outdated
'gsitemap_feed_exists' => file_exists($this->normalizeDirectory(_PS_ROOT_DIR_).'index_sitemap.xml'), | ||
'gsitemap_last_export' => Configuration::get('GSITEMAP_LAST_EXPORT'), | ||
'gsitemap_frequency' => Configuration::get('GSITEMAP_FREQUENCY'), | ||
'gsitemap_store_url' => 'http'.(Configuration::get('PS_SSL_ENABLED') ? 's' : '').'://'.Tools::getShopDomain(false, true).__PS_BASE_URI__, | ||
'gsitemap_store_url' => $this->context->link->getBaseLink(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to take it one step further, you can store $this->context->link->getBaseLink()
in a variable to avoid multiple calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this ? 11265f6
gsitemap.php
Outdated
$admin_folder = str_replace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_); | ||
$admin_folder = Tools::substr($admin_folder, 1); | ||
header('location: http'.(Configuration::get('PS_SSL_ENABLED') ? 's' : '').'://'.Tools::getShopDomain(false, true).__PS_BASE_URI__.$admin_folder.'/index.php?tab=AdminModules&configure=gsitemap&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module='.$this->tab.'&module_name=gsitemap&continue=1&type='.$new_link['type'].'&lang='.$lang.'&index='.$index.'&id='.(int)$id_obj.'&id_shop='.$this->context->shop->id); | ||
Tools::redirectAdmin($this->context->link->getBaseLink().'index.php?tab=AdminModules&configure=gsitemap&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module='.$this->tab.'&module_name=gsitemap&continue=1&type='.$new_link['type'].'&lang='.$lang.'&index='.$index.'&id='.(int)$id_obj.'&id_shop='.$this->context->shop->id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out, getBaseLink()
will get you a link to your front office instead of the admin. This can be further simplified if you use getAdminLink()
:
Tools::redirectAdmin(
$this->context->link->getAdminLink(
'AdminModules',
true,
array(),
array(
'tab_module' => $this->tab
'module_name' => $this->name,
'continue' => 1,
'type' => $new_link['type'],
'lang' => $lang,
'index' => $index,
'id' => (int)$id_obj,
'id_shop' => $this->context->shop->id,
)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't understand. Can you make a commit, then I will check how exactly you solve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace the whole line with what @eternoendless sent to you =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I did that I get an error. I can't remember the error right now. I can reproduce the error and send a screenshot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tools::redirectAdmin(
$this->context->link->getAdminLink(
'AdminModules',
true,
array(),
array(
'tab_module' => $this->tab
'module_name' => $this->name,
'continue' => 1,
'type' => $new_link['type'],
'lang' => $lang,
'index' => $index,
'id' => (int)$id_obj,
'id_shop' => $this->context->shop->id,
)
)
);
Missing );
:D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: bf5a4d4
gsitemap.php
Outdated
@@ -805,7 +794,7 @@ public function createSitemap($id_shop = 0) | |||
if ($this->cron) { | |||
die(); | |||
} | |||
header('Location: ./index.php?tab=AdminModules&configure=gsitemap&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module='.$this->tab.'&module_name=gsitemap&validation'); | |||
Tools::redirectAdmin('index.php?tab=AdminModules&configure=gsitemap&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module='.$this->tab.'&module_name=gsitemap&validation'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use getAdminLink()
as explained before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rewrite the code snippets to use getAdminLink(), I am afraid to mess something up. I can't translate the code from the preview example.
@Quetzacoalt91 @eternoendless Need a waiting for QA maybe? Wdyt? |
Indeed, but wait for the other review to be completed. |
I still need to do some work on this @PierreRambaud :-) |
I have another exception when I configure the module |
Sorry! I see the issue. I fix it when I get to my PC in 20 min. |
@marionf fixed now |
Thank you @mreker 👍 |
@marionf you can close all other PR's too. :-) |
Thanks @mreker (again ;)) |
You are welcome @PierreRambaud :-) Those can be closed: https://github.com/PrestaShop/gsitemap/issues/30, https://github.com/PrestaShop/gsitemap/issues/24, https://github.com/PrestaShop/gsitemap/issues/16 :-) |
Changelog:
|
Please see this PR: #60 |
Why did you remove manufacturer and suppliers from sitemap? |
Fixed all reported bugs.
Tested to work on multistore and multilanguage, with https:// and http://
This change is