dolibarr/dev
Frédéric FRANCE a0b0e44278
NEW Link manage extrafields and phpunit test for the class (#39514)
* NEW: Add extrafields support to Link class

Link now declares isextrafieldmanaged and wires fetch_optionals()/
insertExtraFields()/deleteExtraFields() into fetch(), fetchAll(),
create(), update() and delete(), matching the llx_links_extrafields
table added previously.

* FIX: Several bugs in Link class review

- create(): wrong duplicate-record error message (copy-pasted from
  Societe, referenced undefined $this->name) replaced by the generic
  ErrorDuplicateField, consistent with update().
- create()/update(): missing "NoURL" translation key replaced by the
  standard ErrorFieldRequired pattern.
- fetch(): guard against running an unfiltered query (no rowid, no
  hashforshare) that could silently return an arbitrary link; a caller
  in actions_linkedfiles.inc.php could hit this when 'linkid' was
  missing from the request.
- actions_linkedfiles.inc.php: check fetch() result with `> 0` instead
  of a truthy test, since -1 (error) is truthy in PHP.
- delete(): add User type hint (consistent with create()/update()) and
  a $notrigger parameter to optionally skip the LINK_DELETE trigger.
- update(): fix copy-pasted docblock ("third party" -> "link").

* NEW: Add PHPUnit test for Link class

Covers create/fetch/update/fetchAll/count/delete, plus regression
tests for the two bugs fixed in the previous commit: create() rejects
an empty url, and fetch() rejects a call with neither rowid nor
hashforshare instead of returning an arbitrary record.

* FIX Phan false positive on $object in actions_linkedfiles.inc.php

Phan's ambient type inference for the loosely-typed global $object in
this shared include file was picking up CommonSocialNetworks (an
unrelated trait, not even a class), reported as undeclared
->id/->entity/->addThumbs()/->delThumbs() in a real CI Phan run on
this branch, once this file was analyzed on its own via the
changed-files file-list (this file has no prior baseline entry, so it
was apparently never previously exercised in isolation like this).

Force $object's type explicitly to CommonObject via the same
@phan-var-force string-literal idiom this file already uses for
$upload_dir/$upload_dirold/$confirm/$forceFullTextIndexation -
CommonObject genuinely declares addThumbs()/delThumbs(), which
resolves those two errors outright. $id/$entity remain reported as
PhanUndeclaredProperty (CommonObject itself does not declare them,
only its concrete subclasses do at runtime) - baseline-suppress that
for this file the same way it is already suppressed for the sibling
shared-include files actions_addupdatedelete.inc.php,
actions_massactions.inc.php and actions_sendmails.inc.php, which have
the exact same $object typing situation.
2026-08-19 02:18:46 +02:00
..
build PHPStan > Update baseline (#39571) 2026-08-17 21:29:05 +02:00
examples fix: dev/examples/zapier/package.json to reduce vulnerabilities (#37071) 2026-02-04 14:48:57 +01:00
initdata exit code must be >= 0 (#35311) 2025-09-12 02:29:23 +02:00
initdemo Clean dump file 2026-06-04 23:28:05 +02:00
resources Doc 2026-05-28 19:48:52 +02:00
setup Qual: Update LanguageOfCommentsSniff to avoid PHP7 incompatibility (#39032) 2026-07-01 16:44:17 +02:00
skeletons Clean files 2026-01-07 19:01:54 +01:00
tools NEW Link manage extrafields and phpunit test for the class (#39514) 2026-08-19 02:18:46 +02:00
translation Fix showunused option in sanity_check_trans_missing_unused.sh 2026-06-27 16:51:54 +02:00
.gitignore Add Rector (automatic refactoring) 2023-10-08 20:25:46 +02:00
dolibarr_changes.txt Automated merge from 23.0 to develop 2026-07-15 02:06:09 +02:00
lockedfiles.txt Test check on checksum 2026-06-04 22:57:30 +02:00
pullmerge.sh Merge branch '24.0' of git@github.com:Dolibarr/dolibarr.git into 24.0 2026-08-13 17:41:57 +02:00
README

README (English)
--------------------------------

This directory contains sub-directories to provide tools or documentation for developers.

Note: All files in this directory are in the source repository only and are not provided with a standard release. They are useless to make Dolibarr working.

You may find a more complete documentation on Dolibarr on the wiki:

https://wiki.dolibarr.org/

and on

https://doxygen.dolibarr.org/