Skip to content
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

Merged
merged 39 commits into from
Oct 17, 2018
Merged

Fix all reported bugs #53

merged 39 commits into from
Oct 17, 2018

Conversation

MathiasReker
Copy link
Contributor

@MathiasReker MathiasReker commented Aug 8, 2018

Fixed all reported bugs.

Tested to work on multistore and multilanguage, with https:// and http://


This change is Reviewable

Copy link
Member

@eternoendless eternoendless left a 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"
}
Copy link
Member

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

Copy link
Contributor Author

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>
Copy link
Member

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>

Copy link
Contributor Author

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>
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

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 🤔 ?

Copy link
Contributor Author

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

* @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
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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();
Copy link
Contributor

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() ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not change anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I ? :-)

Copy link
Contributor

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'}");
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@PierreRambaud
Copy link
Contributor

Thanks a lot again! Awesome work!

gsitemap.php Outdated
$this->name = 'gsitemap';
$this->tab = 'seo';
$this->version = '4.0.0';
$this->author = 'Prestashop';
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ofc. 👍

@Quetzacoalt91
Copy link
Member

@LouiseBonnard can you please have a look at the domains used in this PR?

@LouiseBonnard
Copy link

@Quetzacoalt91, I can see no domain used here, nor strings to check. Is it?

@Quetzacoalt91
Copy link
Member

They are in the file gsitemap.php, for instance: https://github.com/PrestaShop/gsitemap/pull/53/files#diff-3133bb1114a2b4792863d1d6ec46d8d6R51

@@ -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()) {

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor Author

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 http:// will be missing in the sitemap
The use of function header() is forbidden; use Tools::redirect() instead
Fix alert color-success

Allow to activate checkbox by clicking on text

Fix sitemap links when friendly url is set to off
@MathiasReker
Copy link
Contributor Author

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. :-)

I also fixed bugs from validator: report

Copy link
Member

@Quetzacoalt91 Quetzacoalt91 left a 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

Copy link
Member

@eternoendless eternoendless left a 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!

include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
/* Check to security tocken */
if ('cli' != Tools::isPHPCLI()) {
Copy link
Member

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()) {

Copy link
Contributor Author

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(),
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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,
    )
  )

Copy link
Contributor Author

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?

Copy link
Contributor

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 =)

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comma after $this->tab. Please see screenshot:

screenshot

I tried without ; too. What am I doing wrong?

Copy link
Contributor

@PierreRambaud PierreRambaud Aug 13, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry 🤣

Copy link
Contributor Author

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');
Copy link
Member

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.

Copy link
Contributor Author

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.

@PierreRambaud
Copy link
Contributor

@Quetzacoalt91 @eternoendless Need a waiting for QA maybe? Wdyt?

@Quetzacoalt91
Copy link
Member

Indeed, but wait for the other review to be completed.

@MathiasReker
Copy link
Contributor Author

I still need to do some work on this @PierreRambaud :-)

@MathiasReker
Copy link
Contributor Author

test

Now there are only one kind of cs issue left: Line exceeds 120 characters. I fixed a lot of those issues, but if I fix the rest, the code will be harder to read.

@marionf
Copy link
Contributor

marionf commented Oct 17, 2018

@mreker

I have another exception when I configure the module

capture d ecran_442

@MathiasReker
Copy link
Contributor Author

Sorry! I see the issue. I fix it when I get to my PC in 20 min.

@MathiasReker
Copy link
Contributor Author

@marionf fixed now

@marionf
Copy link
Contributor

marionf commented Oct 17, 2018

Thank you @mreker 👍

@MathiasReker
Copy link
Contributor Author

@marionf you can close all other PR's too. :-)

@PierreRambaud PierreRambaud merged commit d9d06d0 into PrestaShop:dev Oct 17, 2018
@PierreRambaud
Copy link
Contributor

Thanks @mreker (again ;))

@MathiasReker
Copy link
Contributor Author

@MathiasReker
Copy link
Contributor Author

MathiasReker commented Oct 17, 2018

Changelog:

Bump minimum compatibility to 1.7

Bump PHP require to 5.6.0

Use new translation system (PS 1.7)

Fix issue with generating sitemaps for languages

Fix code standard to meet PSR-2

Fix double generation of CMS link

Fix errors when generating sitemap on multistore

Allow running cron job from command line

Fixed issue with duplicated CMS links in sitemap file on multistore

Remove UTF8 control characters from XML sitemap

Fix issue with meta link generations

Fix errors in Google Search Console

Fix format error: https://www.sitemaps.org/protocol.html

Fix problems with SSL

Fix wrong link generation

Allow generate sitemaps without friendly URLs

Fix multi language issues

Update docs: Fixed links

Update header

Fix button to check fields

Make check boxes clickable from text

Fix check of security token

Add caption on categories

Fix errors and warnings from PrestaShop validator

Fix typos

Fix issues with https:// on images

Remove links to supplier and manufactures

@MathiasReker
Copy link
Contributor Author

Please see this PR: #60

@sanctusmob
Copy link

Why did you remove manufacturer and suppliers from sitemap?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants