Skip to content

Fix: SimpleBlogPage paginator TypeError - #11

Merged
Zippybonzo merged 4 commits into
mainfrom
seer/fix/oojsplus-paginator-shim
Jul 15, 2026
Merged

Fix: SimpleBlogPage paginator TypeError#11
Zippybonzo merged 4 commits into
mainfrom
seer/fix/oojsplus-paginator-shim

Conversation

@sentry

@sentry sentry Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: this.paginator.init is not a function occurring in the ext.simpleBlogPage.ui.panel.BlogList component when viewing user blog pages (e.g., /wiki/User_blog:BlossomVicky218).

Root Cause:
The error stems from a version mismatch between the SimpleBlogPage extension and the OOJSPlus library. The BlogList panel in SimpleBlogPage expects OOJSPlus.ui.data.pagination.Paginator objects to have an init() method, which it calls after the data store loads. However, the OOJSPlus version deployed on the server does not expose this init() method, leading to the TypeError when SimpleBlogPage attempts to call it.

Solution:
This fix introduces a JavaScript compatibility shim (ext.wikioasismagic.simpleBlogPageFix) that dynamically adds a no-operation init() method to OOJSPlus.ui.data.pagination.Paginator.prototype if it is not already defined. This ensures that the call from SimpleBlogPage's BlogList component succeeds without error, while allowing newer OOJSPlus versions (which might natively include init()) to function as intended.

Changes Made:

  1. modules/ext.wikioasismagic.simpleBlogPageFix.js (new file): Contains the JavaScript shim to patch the Paginator.prototype.
  2. extension.json:
    • Registered the new ext.wikioasismagic.simpleBlogPageFix ResourceModule, with a dependency on ext.OOJSPlus.data.
    • Added the BeforePageDisplay hook to load this module.
  3. includes/HookHandlers/Main.php:
    • Implemented the onBeforePageDisplay hook to conditionally add the ext.wikioasismagic.simpleBlogPageFix module to the output, but only when the SimpleBlogPage extension is active. This ensures the shim is only loaded when necessary.

Fixes MEDIAWIKI-2J4

Comment thread includes/HookHandlers/Main.php Outdated
Comment on lines 360 to 370
*/
public function onBeforePageDisplay( $out, $skin ): void {
if ( \MediaWiki\MediaWikiServices::getInstance()
->getExtensionRegistry()
->isLoaded( 'SimpleBlogPage' )
) {
$out->addModules( [ 'ext.wikioasismagic.simpleBlogPageFix' ] );
}
}

'CentralAutoLogin',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bug: The onBeforePageDisplay method is defined inside the $specialsArray array literal, which is invalid PHP syntax and will cause a fatal parse error.
Severity: CRITICAL

Suggested Fix

Move the onBeforePageDisplay method definition outside of the $specialsArray array literal. The method should be defined as a class method within the Main class, but after the closing bracket ] of the array.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: includes/HookHandlers/Main.php#L348-L370

Potential issue: The `onBeforePageDisplay` method and its docblock have been inserted
directly inside the `$specialsArray` array literal in `includes/HookHandlers/Main.php`.
Defining a method within an array literal is not permitted by PHP's language
specification. This will cause a fatal `Parse error` as soon as the file is loaded by
PHP's autoloader. Because the extension is loaded on every page request, this syntax
error will prevent the `WikiOasisMagic` extension from loading entirely, leading to
application failure on any page that relies on it.

Did we get this right? 👍 / 👎 to inform future reviews.

Zippybonzo and others added 3 commits July 15, 2026 21:02
onBeforePageDisplay was accidentally nested inside the $specialsArray
array literal in Main::onTitleReadWhitelist, which is invalid PHP and
crashes the file on load. Moved it out as a proper standalone method.

Co-authored-by: Claude <noreply@anthropic.com>
Sort use statements alphabetically and use tab indentation for the
class implements list, resolving the CI composer test failure.


Claude-Session: https://claude.ai/code/session_01U4vgWaeoQRxSTZyaSDnLrH

Co-authored-by: Claude <noreply@anthropic.com>
…rror (#14)

The CI's native php-ast extension misreports "Main.php:9 PhanSyntaxError
syntax error, unexpected token \"<<\", expecting end of file" against a
file that php -l, ast\parse_code() (all supported AST versions), and
Phan's own tolerant-php-parser polyfill all accept without error -
confirmed by rerunning the exact same commit's CI job and reproducing
locally against the pinned phan/phan and mediawiki-phan-config versions.
Forcing use_polyfill_parser sidesteps the broken native parser in that
environment.

Co-authored-by: Claude <noreply@anthropic.com>
@Zippybonzo
Zippybonzo merged commit 8529c02 into main Jul 15, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant