Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODX3 — OnResourceSort doesn't work #15657

Closed
SnowCreative opened this issue Apr 8, 2021 · 7 comments · Fixed by #15809
Closed

MODX3 — OnResourceSort doesn't work #15657

SnowCreative opened this issue Apr 8, 2021 · 7 comments · Fixed by #15809
Labels
bug The issue in the code or project, which should be addressed. urgent The issue requires attention and has higher priority over others.
Milestone

Comments

@SnowCreative
Copy link
Contributor

Bug report

Summary

OnResourceSort doesn't seem to fire.

Step to reproduce

Create a plugin that does anything as a result of OnResourceSort firing.

Observed behavior

Nothing happens.

Environment

MODX 3 Alpha 3 2021-04-06

@SnowCreative SnowCreative added the bug The issue in the code or project, which should be addressed. label Apr 8, 2021
@rthrash
Copy link
Member

rthrash commented Apr 8, 2021

This issue has been mentioned on MODX Community. There might be relevant details there:

https://community.modx.com/t/modx-3-coding-question-onresourcesort-not-working/3879/5

@Mark-H
Copy link
Collaborator

Mark-H commented Apr 8, 2021

Had a brief look at the code, but did not see a reason for that to not run unless it fails to actually change the sort. I'm assuming you do see sorting changes still applied after a refresh?

@SnowCreative
Copy link
Contributor Author

SnowCreative commented Apr 8, 2021

Yes, I manually sort in the tree and confirm the menuindex change in the database.

As a test, I made a plugin with this code:

$modx->log(modX::LOG_LEVEL_ERROR, 'Testing the log');

and select OnResourceSort for the system event. Works in 2.8.1, doesn't work in 3.0 alpha.

@SnowCreative
Copy link
Contributor Author

SnowCreative commented Apr 8, 2021

On the other hand, OnResourceBeforeSort DOES trigger the code.

@JoshuaLuckers
Copy link
Contributor

I can confirm this issue.

Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in /Users/joshua/Projects/modx-3x/core/src/Revolution/modElement.php on line 280
--
1 | 0.0124 | 369600 | {main}( ) | .../server.php:0
2 | 0.1290 | 405736 | require( '/Users/joshua/Projects/modx-3x/connectors/index.php' ) | .../server.php:131
3 | 0.1983 | 1268432 | MODX\Revolution\modConnectorRequest->handleRequest( ??? ) | .../index.php:79
4 | 0.1985 | 1268968 | MODX\Revolution\modConnectorRequest->prepareResponse( ??? ) | .../modConnectorRequest.php:77
5 | 0.1988 | 1270232 | MODX\Revolution\modConnectorResponse->outputContent( ??? ) | .../modConnectorRequest.php:89
6 | 0.1991 | 1270424 | MODX\Revolution\modX->runProcessor( ???, ???, ??? ) | .../modConnectorResponse.php:151
7 | 0.1993 | 1274688 | MODX\Revolution\Processors\Resource\Sort->run( ) | .../modX.php:1773
8 | 0.2016 | 1315736 | MODX\Revolution\Processors\Resource\Sort->process( ) | .../Processor.php:189
9 | 0.3795 | 1497080 | MODX\Revolution\Processors\Resource\Sort->fireAfterSort( ) | .../Sort.php:88
10 | 5.1601 | 1511696 | MODX\Revolution\modX->invokeEvent( ???, ??? ) | .../Sort.php:152
11 | 5.1680 | 1515848 | MODX\Revolution\mysql\modPlugin->process( ???, ??? ) | .../modX.php:1708
12 | 5.1680 | 1515848 | MODX\Revolution\mysql\modPlugin->process( ???, ??? ) | .../modScript.php:75
13 | 5.1691 | 1516224 | MODX\Revolution\mysql\modPlugin->getTag( ) | .../modElement.php:352
14 | 27.5515 | 1535032 | serialize ( ??? ) | .../modElement.php:280

$value is an array with modDocument objects. Calling serialize on this object throws an Serialization of 'Closure' is not allowed exception.

@JoshuaLuckers JoshuaLuckers changed the title MODX3 — OnResourceSort doesn't seem to be working MODX3 — OnResourceSort doesn't work Aug 28, 2021
@JoshuaLuckers JoshuaLuckers added this to the v3.0.0-beta1 milestone Aug 28, 2021
@JoshuaLuckers JoshuaLuckers added the urgent The issue requires attention and has higher priority over others. label Aug 28, 2021
@JoshuaLuckers
Copy link
Contributor

JoshuaLuckers commented Aug 28, 2021

Related issue: #15172

@SnowCreative
Copy link
Contributor Author

Just tested this on the latest alpha 3 release (Oct 26 2021), and it now works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed. urgent The issue requires attention and has higher priority over others.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants