Post by uksitebuilder » Tue Jun 14, 2011 5:18 am

there were a couple of skip errors but only on vqmod default scripts

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by JAY6390 » Tue Jun 14, 2011 5:33 am

And what were the errors . . .

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by uksitebuilder » Tue Jun 14, 2011 5:37 am

Code: Select all

2011-06-13 20:56:53.9483870 - SOURCEFILE:  htdocs/opencart/system/engine/controller.php
2011-06-13 20:56:53.9483940 - MODFILE:     htdocs/opencart/vqmod/xml/vqmod_opencart.xml
2011-06-13 20:56:53.9484000 - TEMPFILE:    htdocs/opencart/vqmod/vqcache/vq-system_engine_controller.php
2011-06-13 20:56:53.9487860 -   OPERATION...
2011-06-13 20:56:53.9487950 -     ERROR:      
2011-06-13 20:56:53.9488010 -     SEARCH:     if (file_exists($file)) {
2011-06-13 20:56:53.9488070 -       POSITION: before
2011-06-13 20:56:53.9488130 -       OFFSET:   
2011-06-13 20:56:53.9488180 -       INDEX:    
2011-06-13 20:56:53.9488240 -       REGEX:    
2011-06-13 20:56:53.9488300 -     ADD:        global $vqmod; $file = $vqmod->modCheck($file);
2011-06-13 20:56:53.9490100 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9490680 -   OPERATION...
2011-06-13 20:56:53.9490750 -     ERROR:      skip
2011-06-13 20:56:53.9490810 -     SEARCH:     if (file_exists(DIR_TEMPLATE . $this->template)) {
2011-06-13 20:56:53.9490870 -       POSITION: replace
2011-06-13 20:56:53.9490920 -       OFFSET:   
2011-06-13 20:56:53.9490980 -       INDEX:    
2011-06-13 20:56:53.9491040 -       REGEX:    
2011-06-13 20:56:53.9491090 -     ADD:        
		global $vqmod;
		$file = $vqmod->modCheck(DIR_TEMPLATE . $this->template);
		if (file_exists($file)) {
		
2011-06-13 20:56:53.9492600 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9493170 -   OPERATION...
2011-06-13 20:56:53.9493240 -     ERROR:      skip
2011-06-13 20:56:53.9493300 -     SEARCH:     exit('Error: Could not load template ' . DIR_TEMPLATE . $this->template . '!');
2011-06-13 20:56:53.9493360 -       POSITION: replace
2011-06-13 20:56:53.9493410 -       OFFSET:   
2011-06-13 20:56:53.9493470 -       INDEX:    
2011-06-13 20:56:53.9493530 -       REGEX:    
2011-06-13 20:56:53.9493580 -     ADD:        exit('Error: Could not load template ' . $file . '!');
2011-06-13 20:56:53.9495040 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9495590 -   OPERATION...
2011-06-13 20:56:53.9495660 -     ERROR:      skip
2011-06-13 20:56:53.9495720 -     SEARCH:     require(DIR_TEMPLATE . $this->template);
2011-06-13 20:56:53.9495780 -       POSITION: replace
2011-06-13 20:56:53.9495830 -       OFFSET:   
2011-06-13 20:56:53.9495890 -       INDEX:    
2011-06-13 20:56:53.9495950 -       REGEX:    
2011-06-13 20:56:53.9496000 -     ADD:        require($file);
2011-06-13 20:56:53.9497500 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9498690 - TEMPFILE UPDATED WITH MODIFIED CODE
2011-06-13 20:56:53.9499090 - SUBSTITUTION COMPLETE!


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by uksitebuilder » Tue Jun 14, 2011 5:39 am

not errors now I look at it, more commands to skip any errors.

I just rtied a really simple xml file and even removed the two that were working in case for some reason there was a limit on the number of xml files

but the following simply created a duplicate of the original too.

Code: Select all

<modification>
	<id>Header Change</id>
	<version>1.0</version>
	<vqmver>1.1.0</vqmver>
	<author>uksb</author>
	<file name="catalog\view\theme\default\template\common\header.tpl">
		<operation>
			<search position="replace"><![CDATA[
<link href="<?php echo $icon; ?>" rel="icon" />
			]]></search>
			<add trim="true"><![CDATA[
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $icon; ?>" />
			]]></add>
		</operation>
	</file>
</modification>

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by uksitebuilder » Tue Jun 14, 2011 5:51 am

I think I have figured it out - haven't tested yet, but seems I was copying the file path's from BeyondCompare and instead of forward slashes BC uses backslashes in the file path.

Coincidence, I think not. Will test and advise if it is now working.

Strange though that duplicates of the original files were being created in the cache.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by uksitebuilder » Tue Jun 14, 2011 5:58 am

Just tested and it is working now. seems it was the backslashes after all!

Apologies.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by JNeuhoff » Tue Jun 14, 2011 8:50 pm

There is a little bug in VQmod 1.1.0. The replace function adds an additional trailing space character to the replacement, as in the following example:

Code: Select all

	<file name="admin/model/catalog/information.php">
		<operation>
			<search position="replace"><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET ]]></search>
			<add><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET meta_description = '".$data['meta_description']."', meta_keywords = '".$data['meta_keywords']."', ]]></add>
		</operation>
	</file>
While it doesn't hurt in above given example, there could be cases where it becomes relevant to have a precice replacement string, as specified in the replacement operation.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Tue Jun 14, 2011 9:41 pm

JNeuhoff wrote:There is a little bug in VQmod 1.1.0. The replace function adds an additional trailing space character to the replacement, as in the following example:

Code: Select all

	<file name="admin/model/catalog/information.php">
		<operation>
			<search position="replace"><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET ]]></search>
			<add><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET meta_description = '".$data['meta_description']."', meta_keywords = '".$data['meta_keywords']."', ]]></add>
		</operation>
	</file>
While it doesn't hurt in above given example, there could be cases where it becomes relevant to have a precice replacement string, as specified in the replacement operation.
That is why there is the trim="true" attribute for <add>
RTFM ;)
No bug

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Tue Jun 14, 2011 10:15 pm

Works with <add trim="true"> though it kind of defeats the purpose of using <![CDATA[ which is supposed to leave the string unchanged.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Tue Jun 14, 2011 10:16 pm

JNeuhoff wrote:Works with <add trim="true"> though it kind of defeats the purpouse of using <![CDATA[ which is supposed to leave the string unchanged.
touche, tho in your example above there IS a space after the comma and before the ]]. If you remove that space does it still add the space?

Thinking about it now, the replace command simply uses "str_replace" so there is no way it could add additional spaces on its own. the trim attribute is usually only needed for before or after positioning as it creates a new line which may include an extra carriage return if another line before it was already a blank line.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Tue Jun 14, 2011 11:43 pm

Qphoria wrote: touche, tho in your example above there IS a space after the comma and before the ]]. If you remove that space does it still add the space?
yes, the space after the comma is there on purpose. If I remove that space, it still adds one after the replacement which it shouldn't. If I keep the space, it ends up with 2 spaces after the replacement instead of the original single one.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Tue Jun 14, 2011 11:58 pm

Is it possible that there is an extra space in the original file itself? I know there are a lot of places that have extra tabs and spaces at the end of the in the core. As I said above, the replace command uses the php function "str_replace" so I dont see any way for an extra space to occur.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Wed Jun 15, 2011 12:10 am

Qphoria wrote:Is it possible that there is an extra space in the original file itself? I know there are a lot of places that have extra tabs and spaces at the end of the in the core. As I said above, the replace command uses the php function "str_replace" so I dont see any way for an extra space to occur.
No, there is only one space after the comma, see attached file which I am working on for one of my opencart-based projects.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Wed Jun 15, 2011 12:21 am

JNeuhoff wrote:
Qphoria wrote:Is it possible that there is an extra space in the original file itself? I know there are a lot of places that have extra tabs and spaces at the end of the in the core. As I said above, the replace command uses the php function "str_replace" so I dont see any way for an extra space to occur.
No, there is only one space after the comma, see attached file which I am working on for one of my opencart-based projects.
FYI, your closing tag is wrong in the .xml file

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Wed Jun 15, 2011 12:28 am

Sorry, yes, it should have been </modification>.

Howver, the problem is still there with the additional blank.

I looked at your vqmod.php file. By the time it reaches the line at

Code: Select all

                        	$filedata[$linenum] = str_replace($search, $add, $filedata[$linenum]);
the blank character is already chopped off. $search contains

"$this->db->query("INSERT INTO " . DB_PREFIX . "information SET"

instead of

"$this->db->query("INSERT INTO " . DB_PREFIX . "information SET "

while the variable $add is correct. I think the $search is wrong because it is set like this in vqmod.php:

Code: Select all

$search 	= trim($operation->getElementsByTagName('search')->item(0)->nodeValue);

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Wed Jun 15, 2011 1:25 am

yea i saw this too.. because I ALWAYS trim $search.. the reason I always trim search is to offset the way people format their tags... for readability sake I always use:

Code: Select all

<search position="after"><![CDATA[
'ups_status',
]]></search>
Keeping the code separate from the tags. If i didn't trim then it would be searching for

Code: Select all

\n'ups_status',\n
Technically tho you are right that cdata should be the exact string.. but i made it lax.

That said, it would be detrimental for existing mods to have to go back and fix their xml files to follow the strict rules of cdata. Instead it will just have to be lax and keep in mind that you shouldn't try to match trailing spaces. Perhaps I can add an attribute for the search trim="false"

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Wed Jun 15, 2011 2:09 am

You could instead remove leading and trailing whitespaces like \n and \r only, e.g.

Code: Select all

$search = trim($operation->getElementsByTagName('search')->item(0)->nodeValue,"\n\r");

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by JAY6390 » Wed Jun 15, 2011 2:20 am

Qphoria wrote:Perhaps I can add an attribute for the search trim="false"
That to me sounds like the ideal solution

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by JNeuhoff » Wed Jun 15, 2011 2:34 am

Let's make it a vqmod version 1.1.1 then:



Code: Select all

final class VQMod {
	private $vqversion = '1.1.1';						// Current version for logging
	......

					.....
					if ($version < $this->vqversion) {
						$search = trim($operation->getElementsByTagName('search')->item(0)->nodeValue);
					} else {
						$search = trim($operation->getElementsByTagName('search')->item(0)->nodeValue,"\n\r");
					}
					.....

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Wed Jun 15, 2011 3:40 am

Yea that is true.. I could just do newlines and leave spaces. Both ideas seem good to support older and newer scripts

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: Bing [Bot] and 2 guests