Skip to content

Commit

Permalink
Merge branch '5.x' into 5.next
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jul 1, 2024
2 parents b8cd2ae + d3d710e commit 2dccf8f
Show file tree
Hide file tree
Showing 143 changed files with 627 additions and 389 deletions.
2 changes: 1 addition & 1 deletion config/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
epub_tocdepth = 2

rst_epilog = """
.. |phpversion| replace:: **8.2**
.. |phpversion| replace:: **8.3**
.. |minphpversion| replace:: 8.1
"""

Expand Down
1 change: 1 addition & 0 deletions en/console-commands/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ command line::
$parser->addArgument('name', [
'help' => 'What is your name',
]);

return $parser;
}

Expand Down
2 changes: 1 addition & 1 deletion en/contributing/cakephp-coding-conventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Try to avoid unnecessary nesting by bailing early::
{
...
if (!$success) {
throw new RuntimeException(...);
throw new RuntimeException(/* ... */);
}

...
Expand Down
1 change: 1 addition & 0 deletions en/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ You can redirect using :term:`routing array` values::
Or using a relative or absolute URL::

return $this->redirect('/orders/confirm');

return $this->redirect('http://www.example.com');

Or to the referer page::
Expand Down
2 changes: 2 additions & 0 deletions en/controllers/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ in your controller, you could access it like so::
{
if ($this->Post->delete($this->request->getData('Post.id')) {
$this->Flash->success('Post deleted.');

return $this->redirect(['action' => 'index']);
}
}
Expand Down Expand Up @@ -317,6 +318,7 @@ To redirect from within a component callback method you can use the following::
public function beforeFilter(EventInterface $event)
{
$event->stopPropagation();

return $this->getController()->redirect('/');
}

Expand Down
3 changes: 3 additions & 0 deletions en/core-libraries/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ has been created. To keep your Orders model clean you could use events::
'order' => $order
]);
$this->getEventManager()->dispatch($event);

return true;
}

return false;
}
}
Expand Down Expand Up @@ -456,6 +458,7 @@ directly or returning the value in the callback itself::
{
// ...
$alteredData = $event->getData('order') + $moreData;

return $alteredData;
}

Expand Down
16 changes: 8 additions & 8 deletions en/core-libraries/httpclient.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Doing POST and PUT requests is equally simple::
]);

// Other methods as well.
$http->delete(...);
$http->head(...);
$http->patch(...);
$http->delete(/* ... */);
$http->head(/* ... */);
$http->patch(/* ... */);

If you have created a PSR-7 request object you can send it using
``sendRequest()``::
Expand Down Expand Up @@ -570,11 +570,11 @@ is making::

There are methods to mock the most commonly used HTTP methods::

$this->mockClientGet(...);
$this->mockClientPatch(...);
$this->mockClientPost(...);
$this->mockClientPut(...);
$this->mockClientDelete(...);
$this->mockClientGet(/* ... */);
$this->mockClientPatch(/* ... */);
$this->mockClientPost(/* ... */);
$this->mockClientPut(/* ... */);
$this->mockClientDelete(/* ... */);

.. php:method:: newClientResponse(int $code = 200, array $headers = [], string $body = '')
Expand Down
2 changes: 2 additions & 0 deletions en/core-libraries/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ After installing Monolog using composer, configure the logger using the
Log::setConfig('default', function () {
$log = new Logger('app');
$log->pushHandler(new StreamHandler('path/to/your/combined.log'));

return $log;
});

Expand All @@ -531,6 +532,7 @@ Use similar methods if you want to configure a different logger for your console
Log::setConfig('default', function () {
$log = new Logger('cli');
$log->pushHandler(new StreamHandler('path/to/your/combined-cli.log'));

return $log;
});

Expand Down
1 change: 1 addition & 0 deletions en/core-libraries/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ conditions only::
if (isset($context['data']['action'])) {
return $context['data']['action'] === 'subscribe';
}

return false;
});
$validator->requirePresence('email');
Expand Down
15 changes: 14 additions & 1 deletion en/development/application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ global event listeners::
// Call the parent to `require_once` config/bootstrap.php
parent::bootstrap();

// CakePHP has the ability to fallback to using the `Cake\ORM\Table`
// class to represent your database tables when a related class is
// not created for that table. But using this "auto-tables" feature
// can make debugging more difficult in some scenarios. So we disable
// this feature except for the CLI environment (since the classes
// would not be present when using the `bake` code generation tool).
if (PHP_SAPI !== 'cli') {
FactoryLocator::add(
'Table',
(new TableLocator())->allowFallbackClass(false)
);
}

// Load MyPlugin
$this->addPlugin('MyPlugin');
}
Expand All @@ -74,4 +87,4 @@ each test method.

.. meta::
:title lang=en: CakePHP Application
:keywords lang=en: http, middleware, psr-7, events, plugins, application, baseapplication
:keywords lang=en: http, middleware, psr-7, events, plugins, application, baseapplication,auto tables,auto-tables,generic table,class
32 changes: 1 addition & 31 deletions en/development/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -564,36 +564,6 @@ The built in configuration engines are:

By default your application will use ``PhpConfig``.

Disabling Generic Tables
========================

While utilizing generic table classes - also called auto-tables - when quickly
creating new applications and baking models is useful, generic table class can
make debugging more difficult in some scenarios.

You can check if any query was emitted from a generic table class via DebugKit
via the SQL panel in DebugKit. If you're still having trouble diagnosing an
issue that could be caused by auto-tables, you can throw an exception when
CakePHP implicitly uses a generic ``Cake\ORM\Table`` instead of your concrete
class like so::

// In your bootstrap.php
use Cake\Event\EventManager;
use Cake\Http\Exception\InternalErrorException;

$isCakeBakeShellRunning = (PHP_SAPI === 'cli' && isset($argv[1]) && $argv[1] === 'bake');
if (!$isCakeBakeShellRunning) {
EventManager::instance()->on('Model.initialize', function($event) {
$subject = $event->getSubject();
if (get_class($subject) === 'Cake\ORM\Table') {
$msg = sprintf(
'Missing table class or incorrect alias when registering table class for database table %s.',
$subject->getTable());
throw new InternalErrorException($msg);
}
});
}

.. meta::
:title lang=en: Configuration
:keywords lang=en: finished configuration,legacy database,database configuration,value pairs,default connection,optional configuration,example database,php class,configuration database,default database,configuration steps,index database,configuration details,class database,host localhost,inflections,key value,database connection,piece of cake,basic web,auto tables,auto-tables,generic table,class
:keywords lang=en: finished configuration,legacy database,database configuration,value pairs,default connection,optional configuration,example database,php class,configuration database,default database,configuration steps,index database,configuration details,class database,host localhost,inflections,key value,database connection,piece of cake,basic web
6 changes: 4 additions & 2 deletions en/development/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ the ``*.`` wildcard to match any subdomain::

// This route only matches on http://*.example.com
$routes->connect(
'/images/old-log.png',
'/images/old-logo.png',
['controller' => 'Images', 'action' => 'oldLogo']
)->setHost('*.example.com');
});
Expand All @@ -851,7 +851,7 @@ parameter when generating URLs::

// If you have this route
$routes->connect(
'/images/old-log.png',
'/images/old-logo.png',
['controller' => 'Images', 'action' => 'oldLogo']
)->setHost('images.example.com');

Expand Down Expand Up @@ -1683,6 +1683,7 @@ URL filters allow you to implement features like persistent parameters::
if ($request->getParam('lang') && !isset($params['lang'])) {
$params['lang'] = $request->getParam('lang');
}

return $params;
});

Expand All @@ -1701,6 +1702,7 @@ example)::
$params['language'] = $params[0];
unset($params[0]);
}

return $params;
});

Expand Down
3 changes: 3 additions & 0 deletions en/development/sessions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,20 +297,23 @@ something like::
if ($result) {
return $result;
}

return parent::read($id);
}

// Write data into the session.
public function write($id, $data): bool
{
Cache::write($id, $data, $this->cacheKey);

return parent::write($id, $data);
}

// Destroy a session.
public function destroy($id): bool
{
Cache::delete($id, $this->cacheKey);

return parent::destroy($id);
}

Expand Down
3 changes: 3 additions & 0 deletions en/development/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Our helper looks like::
public function bar($value)
{
$width = round($value / 100, 2) * 100;

return sprintf(
'<div class="progress-container">
<div class="progress-bar" style="width: %s%%"></div>
Expand Down Expand Up @@ -1810,8 +1811,10 @@ Expanding on the Orders example, say we have the following tables::
'order' => $order
]);
$this->getEventManager()->dispatch($event);

return true;
}

return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions en/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The model objects can be thought of as "Friend", "User", "Comment", or

use Cake\ORM\Locator\LocatorAwareTrait;

$users = $this->getTableLocator()->get('Users');
$users = $this->fetchTable('Users');
$resultset = $users->find()->all();
foreach ($resultset as $row) {
echo $row->username;
Expand All @@ -52,7 +52,7 @@ something like::

use Cake\ORM\Locator\LocatorAwareTrait;

$users = $this->getTableLocator()->get('Users');
$users = $this->fetchTable('Users');
$user = $users->newEntity(['email' => '[email protected]']);
$users->save($user);

Expand All @@ -67,7 +67,7 @@ For example, the view could use model data to render an HTML view template conta
or a XML formatted result for others to consume::

// In a view template file, we'll render an 'element' for each user.
<?php foreach ($users as $user): ?>
<?php foreach ($resultset as $user): ?>
<li class="user">
<?= $this->element('user_info', ['user' => $user]) ?>
</li>
Expand Down
37 changes: 15 additions & 22 deletions en/intro/where-to-get-help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ practical examples for function and data member usage for a class. ::

tests/TestCase/

The IRC Channel
===============
Slack
=====

**IRC Channels on irc.freenode.net:**
`CakePHP Slack Support Channel <https://cakesf.slack.com/messages/german/>`_

- `#cakephp <irc://irc.freenode.net/cakephp>`_ -- General Discussion
- `#cakephp-docs <irc://irc.freenode.net/cakephp-docs>`_ -- Documentation
- `#cakephp-bakery <irc://irc.freenode.net/cakephp-bakery>`_ -- Bakery
- `#cakephp-fr <irc://irc.freenode.net/cakephp-fr>`_ -- French Canal.

If you're stumped, give us a holler in the CakePHP IRC channel.
Someone from the `development team <https://cakephp.org/team>`_
is usually there, especially during the daylight hours for North and South
America users. We'd love to hear from you, whether you need some help, want to
If you're stumped, give us a holler in the CakePHP Slack support channel.
We'd love to hear from you, whether you need some help, want to
find users in your area, or would like to donate your brand new sports car.

Discord
=======

`CakePHP Discord <https://discord.com/invite/k4trEMPebj>`_

You can also join us on Discord.

.. _cakephp-official-communities:

Official CakePHP Forum
Expand Down Expand Up @@ -94,19 +94,14 @@ Danish
French
------

- `French CakePHP Community <https://cakephp-fr.org>`_
- `French CakePHP Slack Channel <https://cakesf.slack.com/messages/french/>`_

German
------

- `German CakePHP Slack Channel <https://cakesf.slack.com/messages/german/>`_
- `German CakePHP Facebook Group <https://www.facebook.com/groups/146324018754907/>`_

Iranian
-------

- `Iranian CakePHP Community <https://cakephp.ir>`_

Dutch
-----

Expand All @@ -121,16 +116,14 @@ Japanese
Portuguese
----------

- `Portuguese CakePHP Google Group <https://groups.google.com/group/cakephp-pt>`_
- `Portuguese CakePHP Slack Channel <https://cakesf.slack.com/messages/portuguese/>`_

Spanish
-------

- `Spanish CakePHP Slack Channel <https://cakesf.slack.com/messages/spanish/>`_
- `Spanish CakePHP IRC Channel <irc://irc.freenode.net/cakephp-es>`_
- `Spanish CakePHP Google Group <https://groups.google.com/group/cakephp-esp>`_

.. meta::
:title lang=en: Where to Get Help
:description lang=en: Where to get help with CakePHP: The official CakePHP website, The Cookbook, The Bakery, The API, in the test cases, the IRC channel, The CakePHP Google Group or CakePHP Questions.
:description lang=en: Where to get help with CakePHP: The official CakePHP website, The Cookbook, The Bakery, The API, in the test cases, Slack, Discord, CakePHP Questions.
:keywords lang=en: cakephp,cakephp help,help with cakephp,where to get help,cakephp irc,cakephp questions,cakephp api,cakephp test cases,open source projects,channel irc,code reference,irc channel,developer tools,test case,bakery
1 change: 1 addition & 0 deletions en/orm/behaviors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ To prevent the save from continuing, simply stop event propagation in your callb
if (...) {
$event->stopPropagation();
$event->setResult(false);

return;
}
$this->slug($entity);
Expand Down
Loading

0 comments on commit 2dccf8f

Please sign in to comment.