Skip to content

Conversation

@noec764
Copy link
Contributor

@noec764 noec764 commented Nov 20, 2025

Linked to 36341
Sometimes jQuery('#thirdpartyid').val() is undefined because the input is described in takepos/invoice.php.
But it needs to be defined before, to prevent wrong price to be fetched in case of multilevel prices.

@the-dolibear-bot-for-v18 the-dolibear-bot-for-v18 bot added the Issue for v18 maintenance Team PR is in a maintenance branch with several approvers. Waiting approval of all of them. label Nov 20, 2025

// Only show products for sale (tosell=1)
let socid = jQuery('#thirdpartyid').val();
if ((socid === undefined || socid === "") && parseInt("<?= $socid ?>") > 0) {
Copy link
Member

@eldy eldy Nov 20, 2025

Choose a reason for hiding this comment

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

Use of <?= is forbidden
Must use <?php echo for better compatibility and security

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 corrected it, but why is it forbidden ? According to the PHP documentation, both uses are exactly the same since PHP 5.4.

Copy link
Member

@eldy eldy Nov 21, 2025

Choose a reason for hiding this comment

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

I corrected it, but why is it forbidden ? According to the PHP documentation, both uses are exactly the same since PHP 5.4.

Several reason mentionned into wiki:
PHP code section must start with '''<?php''' (the "smart tags" <? or <?=, also known as the "short tags", depend on php configuration option '''short_open_tag''' even if this is no more true after php5.4. The use of <? can still have conflict with XML syntax. The smartags may not be supported by all IDE. Also, the use of <?= make easier for a hacker to make PHP injection. To fight this, some Dolibarr components, like the website PHP editor, accepts only full php tags to detect, parse and filter PHP. Finaly, using the same tag everywhere make also easier to make code scanning or impact analysis when we are sure of the tags that is used, and the best solution, to be sure of which tag is used, is to use one, only one and the same tag everywhere.

@eldy eldy added the PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do) label Nov 20, 2025
@noec764 noec764 requested a review from eldy November 21, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue for v18 maintenance Team PR is in a maintenance branch with several approvers. Waiting approval of all of them. PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants