-
Notifications
You must be signed in to change notification settings - Fork 3
Cakephp 5 upgrade #327
Open
Ioannis
wants to merge
5
commits into
COmanage:develop
Choose a base branch
from
Ioannis:cakephp-5-upgrade
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Cakephp 5 upgrade #327
+175,487
−134,232
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4511779
to
d5209e3
Compare
d5209e3
to
850e0d5
Compare
CakePHP 4 → 5 Upgrade Developer Guideline Scope
References
Repository-specific hotspots (found using IDE scan)
Checklist and code patterns to change
$query = $table->find()->order(['EnrollmentFlowSteps.ordr' => 'ASC']);
$query = $table->find()->orderBy(['EnrollmentFlowSteps.ordr' => 'ASC']);
$entity = $Table->get($id, ['contain' => $contain, 'fields' => $fields]);
$entity = $Table->get($id, contain: $contain, fields: $fields);
public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
{
if ($this->needsSkip($entity)) {
return false; // or return true / return $response
}
}
public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
{
if ($this->needsSkip($entity)) {
$event->setResult(false); // or set desired value
$event->stopPropagation(); // optional: only if you intend to stop other listeners
return; // explicitly return void
}
}
$rs = $this->paginate($query);
while ($rs->valid()) {
$o = $rs->current();
$rs->next();
}
$rs = $this->paginate($query);
while ($rs->items()->valid()) {
$o = $rs->items()->current();
$rs->items()->next();
}
class CousController extends StandardController {
// somewhere: $this->SomeTable = $this->fetchTable('Some');
}
#[\AllowDynamicProperties]
class CousController extends StandardController {
// or declare public properties explicitly
}
Search-and-Replace plan (do not apply to vendor/):
Examples from this repo (before → after)
->order(['EnrollmentFlowSteps.ordr' => 'ASC'])
→ ->orderBy(['EnrollmentFlowSteps.ordr' => 'ASC'])
->order(['EnrollmentFlowSteps.ordr'])
→ ->orderBy(['EnrollmentFlowSteps.ordr'])
->order(['Names.family', 'Names.given', 'Names.middle'])
→ ->orderBy(['Names.family', 'Names.given', 'Names.middle'])
->order(['name' => 'ASC'], true)
→ ->orderBy(['name' => 'ASC'], true)
$linkObj = $linkTable->get($link->value, ['contain' => $contain]);
→ $linkObj = $linkTable->get($link->value, contain: $contain);
while($rs->valid()) { $o = $rs->current(); /* … */ }
→ while($rs->items()->valid()) { $o = $rs->items()->current(); /* … */ }
if ($controller->calculatePermission()) {
// return true; (deprecated)
$event->setResult(true);
return;
}
#[\AllowDynamicProperties]
class CousController extends StandardController { } |
Bumped to |
Sign in
to join this conversation on GitHub.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important changes:
example:
example:
$event->setResult()
instead or$event->stopPropogation()
to just stop the event propagation.example:
example:
example:
example