Search code examples
phpopencartstrposvqmod

vqmod throws strpos() empty needle error


vQmod throws the following error when parsing an XML file:

Warning: strpos(): Empty needle in /home/public_html/vqmod/vqmod.php on line 455

Here's the XML itself:

<operation>
    <search position="before">
        <?php echo $footer; ?>
    </search>
    <add><![CDATA[
        <?php phpinfo(); ?>
    ]]></add>
</operation>

XML file looks ok, all paths are correct.

Didn't find anything relevant on the internet so posting my solution here (see below).


Solution

  • The issue is caused by the <?php ?> tags inside of the search node.

    Those should be escaped with <![CDATA[ ]]>:

    <operation>
        <search position="before"><![CDATA[
            <?php echo $footer; ?>
        ]]></search>
        <add><![CDATA[
            <?php phpinfo(); ?>
        ]]></add>
    </operation>
    

    Hope this saves someone else several minutes of time.