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!
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>
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.
Apologies.
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>
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
That is why there is the trim="true" attribute for <add>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:
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.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>
RTFM

No bug
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
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?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.
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.
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.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?
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
No, there is only one space after the comma, see attached file which I am working on for one of my opencart-based projects.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.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
FYI, your closing tag is wrong in the .xml fileJNeuhoff wrote:No, there is only one space after the comma, see attached file which I am working on for one of my opencart-based projects.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.
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]);
"$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
Code: Select all
<search position="after"><![CDATA[
'ups_status',
]]></search>
Code: Select all
\n'ups_status',\n
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"
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
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
Users browsing this forum: Bing [Bot] and 2 guests